Skip to content

Python

Loading Releases

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: bool indicating 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:

  • mfcc
  • chroma
  • onset
  • silence_prob
  • spectral_magniture
  • normalized_spectral_magniture
  • loudness
  • spectral_flux
  • spectral_flatness
  • harmonicity
  • db
  • rms
  • power

State

Attributes:

  • position
  • type
  • markov
  • forward
  • bpm_expected
  • bpm_observed
  • onset_expected
  • onset_observed
  • phase_expected
  • phase_observed
  • ioi_phi_n
  • ioi_hat_phi_n
  • audio_states
  • duration
  • line

AudioState

Attributes:

  • frequency
  • index

EventType

Enum values:

  • EventType.REST
  • EventType.NOTE
  • EventType.CHORD
  • EventType.TRILL
  • EventType.MULTI