Python
Use pip
pip install OpenScofo
OpenScofo provides Python bindings (via pybind11) for development, validation, and research workflows.
Import and create an object
from OpenScofo import OpenScofo
scofo = OpenScofo(48000, 4096, 1024)
Constructor arguments:
sr(float): sample rate.fft_size(float): FFT/window size.hop(float): hop size.
OpenScofo methods
Score
parse_score(path)
- Input: score file path.
- Output:
bool.
ok = scofo.parse_score("myscore.txt")
Processing
process_block(audio)
- Input: 1D NumPy array (
float64) with one audio block. - Output:
boolindicating processing success.
import librosa
y, _ = librosa.load(path, sr=48000)
fftsize = 4096
hopsize = 1024
pos = 0
while pos + fftsize <= len(y):
segment = y[pos: pos + fftsize]
ok = scofo.process_block(segment)
pos += hopsize
Configuration
set_db_threshold(value)
scofo.set_db_threshold(-80)
set_tuning(value)
scofo.set_tuning(442)
set_current_event(event)
scofo.set_current_event(2)
set_amplitude_decay(value)
Sets the amplitude decay for harmonic weighting.
scofo.set_amplitude_decay(0.7)
set_harmonics(value)
Sets the number of harmonics used to build pitch templates.
scofo.set_harmonics(8)
set_pitch_template_sigma(value)
Sets the sigma used for pitch template generation.
scofo.set_pitch_template_sigma(1.2)
Information
get_live_bpm()
bpm = scofo.get_live_bpm()
get_event_index()
score_index = scofo.get_event_index()
get_states()
states = scofo.get_states()
get_pitch_template(freq)
template = scofo.get_pitch_template(440)
get_cqt_template(freq)
cqt_template = scofo.get_cqt_template(440)
get_block_duration()
seconds = scofo.get_block_duration()
get_audio_description(audio)
y, _ = librosa.load(path, sr=48000)
segment = y[0:4096]
desc = scofo.get_audio_description(segment)
Exposed types
Description
Attributes:
mfccchromaonsetsilence_probspectral_magniturenormalized_spectral_magnitureloudnessspectral_fluxspectral_flatnessharmonicitydbrmspower
State
Attributes:
positiontypemarkovforwardbpm_expectedbpm_observedonset_expectedonset_observedphase_expectedphase_observedioi_phi_nioi_hat_phi_naudio_statesdurationline
AudioState
Attributes:
frequencyindex
EventType
Enum values:
EventType.RESTEventType.NOTEEventType.CHORDEventType.TRILLEventType.MULTI