SFZ

This forum section was originally created while we were discussing a new, additional engine and sampler format designed from scratch. In the meantime this resulted in our new SFZ2 engine, which is already implemented to a large extent. However this is still the right place for ideas, feature requests, drafts and plans for new engine / format concepts and ideas. We now have 3 sampler engines (Gig, SFZ2, SoundFont 2). Why not having more?
User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: SFZ

Post by dahnielson » 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:

Code: Select all

std::ifstream SfzStream("instrument.sfz");
sfz::File pFile = sfz::File(SfzStream);
Get the constructed instrument:

Code: Select all

sfz::Instrument* pInstrument = pFile->GetInstrument();
The client then iterate through the regions and call either...

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);
Returning bool to check if the region was triggered. Or...

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); 
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:

Code: Select all

sfz::Articulation* pArticulation = pRegion->GetArticulation(bend, bpm, chanaft, polyaft, cc);
GetArticulation() is called every time the state changes. The articulation contain all performance parameters.

Work in progress...
Last edited by dahnielson on Wed Feb 18, 2009 9:53 pm, edited 15 times in total.
Anders Dahnielson

Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux

User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: SFZ

Post by dahnielson » Fri Feb 20, 2009 6:10 pm

FYI, I've pushed an updated implementation to my public github repository. But I haven't tried to compile it yet. It's still a work in progress.
Anders Dahnielson

Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux

User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: SFZ

Post by dahnielson » Fri Feb 20, 2009 11:23 pm

And now it even compiles!
Anders Dahnielson

Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux

User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: SFZ

Post by dahnielson » Sat Feb 21, 2009 1:24 pm

I'm amazed at the shear number of typos/errors in the SFZ format specification in Simon Cann's "Cakewalk Synthesizers" as well. Didn't anyone proof it?

My spec on Google Doc is now becoming more accurate than the official version... :roll:
Anders Dahnielson

Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux

dakylla
User
Posts: 51
Joined: Wed Jan 14, 2009 11:08 am

Re: SFZ

Post by dakylla » Wed Mar 04, 2009 5:58 pm

hi dahnielson,

how are things progressing ?
what about coding the library in vala (http://live.gnome.org/Vala) ?
it's really an easy language compared to bare C, or even C++.
maybe that would drag more developers into the effort, me being the first :D

see ya

User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: SFZ

Post by dahnielson » Wed Mar 04, 2009 8:26 pm

Not at all at the moment. I'm in crunchmode preparing for an examination on the antiquity and middle ages on Friday. But will probably ramp things up after that.

No point introducing another language. Would be a solution to a non-problem. The libsfz is just a minor part to write, albeit a tedious one, the major part will be the new LS engine.
Anders Dahnielson

Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux

User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: SFZ

Post by dahnielson » Fri Apr 03, 2009 11:22 pm

I've been idle for a month. But I'll probably at least spend some of my weekend on the libsfz (despite the fact that I've got another examination, this time the early modern period, on Tuesday). Something I'd planned anyway but that I now are even more eager to do after having a nice chat with David Viens from Plogue about the future of SFZ.
Anders Dahnielson

Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux

User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: SFZ

Post by dahnielson » Mon Apr 06, 2009 3:16 pm

Status update

I finally start to see the end of the definition file parsing bit of libsfz and hope to be concentrating on the articulation API bit soonish rather than lateish.

For the record, I asked about a clarification of the SFZ2 spec yesterday:
Anders Dahnielson wrote: I have still got problems wrapping my head around the opcodes that selects destinations for EGs ("FlexEG") and LFOs in SFZ2. I.e. the EG destinations listed on p.396 (starting with egN_freq_lfo) and LFO destinations listed on p.398 (starting with lfoN_freq_lfo) in Cakewalk Synthesizers.

From my reading of the specification; those "routing" opcodes don't appear to have an equal sign and a value. If they have: what do the value represent?

Is it a percentage of how much they affect the destination?

I'm sorry if I'm a bit confused. My confusion may stem from the lack of examples of their use and the specifications lack of clarity on this particular point. Would appreciate any help to clarify it.
And today I got this excellent answer:
David Viens wrote: All modulators in SFZ2 speak in "destination units" so it varies across destinations.

Code: Select all

eg01_pitch_oncc1=1200 
Means "eg01's normalized output will be multiplied by 1200 and added to whatever unit pitch needs". We know that pitch is is cents, so you do the maths.

A harder example is this

Code: Select all

lfo01_freq=1 //base lfo01 freq is 1hz
lfo01_pitch=200 //lfo01's [-1;1] outputs is multiplying by 200 cents to destination
// resulting in [-200;200] wobling
eg01_freq_lfo01=10 //lfo01's native value is pitch, so EG01 adds up to 10 Hz to the targets "1" for a [1;11] range.
I hope that clears a few things
Anders Dahnielson

Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux

User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: SFZ

Post by dahnielson » Thu Apr 09, 2009 7:02 am

David Viens wrote:
Anders Dahnielson wrote:1) The meaning of opcodes found in the filter and modulator tables ending with: *_smoothccN, *_stepccN, *_curveccN?
Smooth is a low pass filter on speed of parameter changes and its in ms. Example from one of my SFZs from Microsoft Songsmith (you can download that for free btw - not sure it runs in wine though)

Code: Select all

amplitude_oncc7=100 amplitude_smoothcc7=50 amplitude_curvecc7=7
This will smooth cc7's effect on amplitude over 50 ms (staircasing protection), and uses curve number 7 defined later in the file as table of values for each CC.

You've heard of <curve> right?
Anders Dahnielson wrote:2) The meaning of egN_pan_curve and egN_pan_curveccX opcodes?
Ditto,

Code: Select all

pan_oncc10=100 pan_curvecc10=1
My curve #1 in ARIA is bipolar.

Dimension predefined its 6 first curves internally. Rule of thumb, you want SFZ 2.0 files to be compatible across engines, start with curve #7.
Anders Dahnielson wrote:3) Do you think there's a reason 'position' as a modulator destination was omitted? Or is it just a typo in the spec?
ARIA doesnt yet support position and width, we use normal pan for stereo samples, but we have two layers of pans internally - one being outside of SFZ generation - so that does kind of the same result.

BTW, I do consider the following as Dimension specific too:

decim
bitred
noiselevel
noisestep
noisetone
drive

They are "Expression Engine" specific features, and i dont even think that they are all in Drop Zone, or Rapture.
Anders Dahnielson

Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux

User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: SFZ

Post by dahnielson » Thu Apr 09, 2009 7:10 am

David Viens wrote:
Anders Dahnielson wrote:Yeah. I'm going to go through my chart and start to strike out stuff that's either Cakewalk specific or that I don't intend to support to begin with or at all.
Good, no shame in it, theres plenty of stuff i dont yet support from Dimension Pro. :)
Anders Dahnielson wrote:My first step has just been to get a complete overall picture of the format.
Sure thing.
Anders Dahnielson wrote:In the longtime I'm also interested in extending and figure out how/if physical modeling, spectral modeling synthesis and various convolution applications can fit into it.
Well, of course, I'm doing such a thing for my in-dev VSTi.

The trick is to use

Code: Select all

sample=*{enter your generator name}
Both ARIA and Dimension natively support sample=*sine sample=*noise etc

But my stuff allows for sample=*com.Plogue.GeneratorX, where com.Plogue.GeneratorX is a special ARIA generator class built using the private ARIA SDK (external dynamic library).

I can do any form of synthesis I like in there, AND other plugins in <effect> and use the rest of the engine for everything else, so really you only have ONE major flexible synth engine to reuse, and i believe SFZ is flexible enough that way.
Anders Dahnielson

Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux

Post Reply