Re: SFZ
Posted: Wed Feb 18, 2009 11:29 am
I'm still trying to figure out the API for libsfz to handle the two tables of opcodes posted in the Google Doc link above. You can find the repository for my code here:
http://github.com/dahnielson/libsfz/tree/master
The only thing that I'm happy with is the parsing of opcodes in the SFZ definition file (the File class). One big flaw in my first attempt was the lack of statelessness. I'm also making it a read-only implementation, as SFZ definition files can easily be authored in a text editor or generated by a simple script for batch processing.
My idea for the API so far...
Parse the SFZ definition file:
Get the constructed instrument:
The client then iterate through the regions and call either...
Returning bool to check if the region was triggered. Or...
To find out if the region was triggered by the event. It's the clients responsibility to implement any non-linear lookup. Each region has a unique ID so that the client can keep track of the state for each region.
Get an articulation for the current state:
GetArticulation() is called every time the state changes. The articulation contain all performance parameters.
Work in progress...
http://github.com/dahnielson/libsfz/tree/master
The only thing that I'm happy with is the parsing of opcodes in the SFZ definition file (the File class). One big flaw in my first attempt was the lack of statelessness. I'm also making it a read-only implementation, as SFZ definition files can easily be authored in a text editor or generated by a simple script for batch processing.
My idea for the API so far...
Parse the SFZ definition file:
Code: Select all
std::ifstream SfzStream("instrument.sfz");
sfz::File pFile = sfz::File(SfzStream);
Code: Select all
sfz::Instrument* pInstrument = pFile->GetInstrument();
Code: Select all
pRegion->OnKey(chan, key, vel, bend, bpm, chanaft, polyaft, prog, rand, trig, cc, timer, seq, sw, last_sw_key, prev_sw_key);
Code: Select all
pRegion->OnControl(chan, cont, val, bend, bpm, chanaft, polyaft, prog, rand, trig, cc, timer, seq, sw, last_sw_key, prev_sw_key);
Get an articulation for the current state:
Code: Select all
sfz::Articulation* pArticulation = pRegion->GetArticulation(bend, bpm, chanaft, polyaft, cc);
Work in progress...