OpenScofo API
Reference for the main OpenScofo C++ class.
Info
This page is generated automatically from the OpenScofo source code. Do not edit it manually.
Construction
OpenScofo
Initialize OpenScofo processing pipeline.
Parameters
| Parameter | Type | Description |
|---|---|---|
Sr | float | Sampling rate (Hz) |
WindowSize | float | |
HopSize | float | Hop size (samples) |
Note
Initializes Forward model, MIR extractor, and score handler.
Note
Configures global spdlog logger (overwrites default).
Configuration
SetConfiguration
Apply configuration settings to the system.
Parameters
| Parameter | Type | Description |
|---|---|---|
Config | Configuration & | Configuration object |
Note
Updates internal modules according to provided configuration.
GetSr
Get current sampling rate.
Returns
Sampling rate in Hz
GetFFTSize
Get FFT window size.
Returns
FFT size in samples
GetHopSize
Get hop size used for frame processing.
Returns
Hop size in samples
GetConfiguration
Retrieve current system configuration.
Returns
Copy of the current configuration object
Note
Returned by value (snapshot, not a live reference).
Score Following
LoadScore
Load and initialize a score from file.
Parameters
| Parameter | Type | Description |
|---|---|---|
ScorePath | fs::path | Path to score file |
Returns
true if loading and initialization succeeded, false otherwise
Note
Resets internal state and reinitializes processing pipeline.
Note
May load and validate an ONNX model if present in the score.
ScoreIsLoaded
Check if a score is currently loaded.
Returns
true if score data is available, false otherwise
SetCurrentEvent
Set active score event and reset decoding state.
Parameters
| Parameter | Type | Description |
|---|---|---|
Event | int | Event index in the loaded score (0 = reset) |
Note
Resets forward model state, buffers, and descriptors.
Note
Updates current score position based on event mapping if valid.
SetCurrentSection
Select a score section and reset decoding at its first state.
Parameters
| Parameter | Type | Description |
|---|---|---|
Section | const std::string & | Section identifier without quotes |
Returns
true when the section exists, false otherwise
GetCurrentBPM
Get estimated current tempo.
Returns
Current BPM estimate from the forward model.
GetCurrentScorePosition
Get current position in the score (following Antescofo, Rest does not count for this).
Returns
Score position index computed by the forward model.
GetCurrentStateIndex
Get current state index from the forward model.
Returns
Index of the active internal state.
GetCurrentEventActions
Get actions associated with the current score event.
Returns
Event action list (empty if no score is loaded).
Note
Delegates to the forward model when a score is active.
GetAudioStateChangeActions
Audio Processing
ProcessBlock
Process an incoming audio block.
Parameters
| Parameter | Type | Description |
|---|---|---|
AudioBuffer | const T * | Input audio buffer |
n | size_t | Number of samples in buffer |
Returns
true if processing succeeded
Note
Maintains internal circular buffer state.
Note
Triggers analysis every hop size.
Note
Updates descriptors and score position depending on mode.
GetBlockDuration
Get processing block duration in seconds.
Returns
Block duration in seconds (derived from hop size and sampling rate)
GetCurrentBufferIndex
Get current processing buffer index.
Returns
Current index within the analysis buffer (forward model state)
Audio Descriptors
SetRequestedDescriptors
Parameters
| Parameter | Type | Description |
|---|---|---|
Descriptors | std::vector< Descriptors > |
RequestDescriptor
Parameters
| Parameter | Type | Description |
|---|---|---|
Descriptor | Descriptors |
ActivateAllDescriptors
GetPitchProb
Compute pitch probability for a given frequency.
Parameters
| Parameter | Type | Description |
|---|---|---|
Freq | double | Frequency in Hz |
Returns
Probability score from forward model
Note
Uses current description frame as input to the model.
GetPitchTemplate
Generate pitch template for a given frequency.
Parameters
| Parameter | Type | Description |
|---|---|---|
Freq | double | Target frequency in Hz |
Returns
Pitch template vector computed by the forward model
GetDescription
Get current audio description frame.
Returns
Copy of the current descriptor structure
Note
Returns by value (snapshot, not live reference).
GetDescriptorsEnum
Convert string identifier to descriptor enum.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | const char * | Descriptor name (e.g. "mfcc", "chroma") |
Returns
Corresponding Descriptors enum value, or INVALID on failure
Note
Logs an error if the string is not recognized.
GetDescriptionId
Convert descriptor enum to string identifier.
Parameters
| Parameter | Type | Description |
|---|---|---|
d | Descriptors | Descriptor enum value |
Returns
Human-readable identifier string (e.g. "mfcc", "chroma")
GetDescriptionFloat
Extract scalar descriptor value from a Description.
Parameters
| Parameter | Type | Description |
|---|---|---|
Desc | Description & | Audio description container |
d | Descriptors | Descriptor type |
Returns
Scalar value for the requested descriptor, or -1.0 on error / invalid type
Note
Logs an error if the descriptor is vector-valued or invalid.
GetDescriptionArray
Access vector-valued descriptor data.
Parameters
| Parameter | Type | Description |
|---|---|---|
Desc | Description & | Audio description container |
d | Descriptors | Descriptor type (must be vector-valued) |
Returns
Reference to internal descriptor array
Note
Logs an error before throwing for invalid descriptor types.
ONNX
LoadONNXModel
Load an ONNX model for descriptor inference.
Parameters
| Parameter | Type | Description |
|---|---|---|
Model | fs::path | Path to .onnx model file |
Descriptors | std::vector< Descriptors > | List of descriptors expected by the model |
Note
Only .onnx models are supported.
Note
Delegates initialization to the MIR module.
Warning
Invalid file extension or incompatible descriptors will result in an error log.
Lua
GetLuaCode
Return Lua code string defined in global events using LUA {}.
Returns
Lua script as a string
Logging and Errors
ClearErrors
Reset internal error state.
Note
Clears m_HasErrors unless a critical error was previously set.
Warning
If a critical error occurred, the state is not reset and recovery is not possible without reinitializing the instance.
SetErrorCallback
void OpenScofo::OpenScofo::SetErrorCallback(std::function< void(const spdlog::details::log_msg &, void *data)> cb, void *data=nullptr)
Set callback for log/error messages.
Parameters
| Parameter | Type | Description |
|---|---|---|
cb | std::function< void(const spdlog::details::log_msg &, void *data)> | Callback invoked on each log message |
data | void * | User-defined pointer passed to the callback |
Note
The callback is triggered by the internal logging sink.
Note
Updates the internal error flag (m_HasErrors) automatically.
Note
Log level is set to debug (debug builds) or info (release builds).
Warning
Overwrites any previously registered callback.
SetLogLevel
Set logging verbosity level.
Parameters
| Parameter | Type | Description |
|---|---|---|
level | spdlog::level::level_enum | spdlog log level |
Note
Affects the global default spdlog logger.
Other
GetStates
Access internal score state machine.
Returns
Reference to forward model states container.
Note
Exposes internal mutable state (no copy is made).