Relation between CC value and N in <parameter>_onccXX=N

Discussion on the SFZ implementation and opcodes available in the ARIA engine.

Moderators: eric_telemaque, davidv

Archer6621
Posts: 4
Joined: Wed Nov 26, 2014 10:09 am

Relation between CC value and N in <parameter>_onccXX=N

Postby Archer6621 » Fri Nov 10, 2017 11:19 pm

Hi,

I was a bit annoyed by the fact that Sforzando doesn't allow control/manipulation over ADSR envelope by default, so I decided to create a Python script that adds these automagically to the sfz files for a given range, via CC controls. Say I do this for a CC release control (will use this example throughout the post), setting it lower than 64 would make the release shorter than the original and setting the control higher than 64 would make the release longer (or at least, this is the goal).

So I thought I had figured out what happens under the hood. The assumption was that 0% (or 0) on the control meant that it did not influence the release given that there's a "ampeg_release_oncc72=N" opcode in the same region, while 100% (or 128) meant that it would multiply the original release value by "N" in the "ampeg_release_oncc72=N" opcode. So the range is then [0.25, 4], with formula 0.25 + 0.25 * p * (N-1), with p between 0 and 1 (representing the percentage of the control).

Example:
the original release is 2.0
scaling factor N is 16

To vary the release around 2.0, take 2.0/8 = 0.250 as lower bound (so ampeg_release=0.250), and use ampeg_release_oncc72=16, meaning that at 100%, 0.250 + 15 * 0.250 = 4 would be the actual release value.

However, this did not seem the case. When setting the control at 50%, the release was much longer than 2.0. In fact, I had to put it around 10-15 % in order to obtain a value that resembled the 2.0 release. I had to do this by listening though, since I don't know this value (and there's no easy way to obtain it, unless Sforzando has some cool debug feature for it). Now I'm not sure if this is whether I made a stupid mistake and will find out later, but posting anyway since the deviation from what I expected was pretty high..

TL;DR
How does Sforzando apply the N value given to e.g. ampeg_release_oncc72=N to the original release in relation to the CC value at the time (either via controls or MIDI messages)? Is it linear? A curve? What is the formula?

Hope my story/problem is a bit clear, wrote this late at night while scratching my head at the problem lol.

pljones
Posts: 100
Joined: Wed Oct 15, 2014 2:05 pm

Re: Relation between CC value and N in <parameter>_onccXX=N

Postby pljones » Sat Nov 11, 2017 3:41 am

You've not made it clear how you're triggering and controlling playback of your samples, so it's hard to answer what I think you think you're asking directly.

So, first some background.

A sample is an audio file, just like a track on a CD - you push play, listen to it, it's done. "Play" in this sense is a "Note On" MIDI event. By default, however, unlike a CD player, you need to keep holding play - if a "Note Off" MIDI event arrives, playback just stops. (Also, unlike a CD player, when the track gets to the end, it stops playback.)

For a "Note Off" to trigger EG release processing two things are needed
- an envelope, defined using the appropriate opcodes
- "off_mode=normal" opcode to turn on use of the release phase

At this point, when playback gets stopped before the "end of the track", the envelope release phase is entered. Still, playback stops at the end of the sample if it gets there first. So if you've played 2 seconds of a 3 second sample and have a 2 second release, you'll only have output for 1 second after the Note Off takes you into the release phase.

Now... That's the simple sample case. Maybe you have a sample with loop points? First off, you need to decide whether the sample is set up to play best with "loop_mode=loop_sustain" or "loop_mode=continuous". What happens on the release trigger depends on which you pick. The envelope release phase remains crucial but with "loop_sustain", you could find the sample is longer or shorter than the release phase, depending on where the loop end marker is.

I'm getting this from my SFZ 1.0 mapping page -- don't blame Sforzando for any of this, it's in the original spec.
http://www.drealm.info/sfz/plj-sfz.xhtml

http://www.drealm.info/sfz/plj-sfz.xhtml#eg for the specific answer:
"The time taken to fall from the sustain level to zero after release" -- it's an absolute quantity from 0 to 100 (mapped up from the 0 to 127 values by dividing by 127 and multiplying by 100, or some other method unspecified, in SFZ 1.0).

If you're using Sforzando exclusively, you may be able to better model the behaviour you're after by using SFZ 2.0. (For example, you can control the curve used to map between the CC# and the envelope time.) Even in SFZ 2.0, attempting to apply more than one control to a single parameter directly will cause unpredictable behaviour - you can't set the release time to two values at the same time. You have more flexibility to be indirect and modify one parameter by another before it's applied to the target, though. For SFZ 2.0, the best reference I'm aware of remains Simon Cann's book "Cakewalk Synthesizers", though it was still out of print last time I checked.

Archer6621
Posts: 4
Joined: Wed Nov 26, 2014 10:09 am

Re: Relation between CC value and N in <parameter>_onccXX=N

Postby Archer6621 » Sat Nov 11, 2017 9:10 am

Thanks for the swift response! My explanation might have been lacking/too generic above, as I'm fully aware of most things you explained in your post. I understand how samples/envelopes etc work as I've been working with them for a long time now, this is not the problem. What is puzzling to me is that the release time (or any parameter really) does not change as I expect it to, and I will elaborate further below.

As far as I understand, the moment you release a key, it will gradually fall off according to some curve (or line if linear) to 0 from the value it was at on the key's release, within a time-span (in seconds right?) defined in the release parameter (as you said). But the release parameter was just given as example though, my issue holds for all parameters.

I checked the spec links you've given me before, but they don't help, because they don't contain any information about how <param>_onccXX=N (e.g. something like ampeg_release_onCC72=2.0) modifies the parameter.



Let me just share the sfz file I was experimenting on, it is from Paul B.'s VPO library: https://pastebin.com/z8EAqmxs

This is the modified version after I added controls under the assumptions I made in the first post: https://pastebin.com/UuxpbZt4

In short, it has two regions that had a ampeg_release=2.0 opcode, in both regions this was replaced by:

Code: Select all

ampeg_release_oncc72=16.0
ampeg_release=0.250


And at the bottom added:

Code: Select all

<control>
label_cc72=Amp EG Release set_cc72=64


I assumed (with the explanation in the first post) that this would result in the value being unmodified, as the control is initially set on 50% (=64), so I expected the release time to be 2.0 in that case, but it appeared to be much longer, and this is my problem. I don't understand how the CC value maps to the release value, as there's no way for me to actually obtain that total release value at 50%, I can only hear that it is wrong.

The way I test this is by simply triggering (and quickly letting go of) notes with Sforzando in Ableton Live 9 Suite with the sfz file above and the corresponding samples (the whole kit is here: http://virtualplaying.com/). When swapping between the version I modified and the original, I notice that the modified version suddenly has a much longer release, against my expectation.

My goal is to preserve the original value of some parameter for an sfz file, while allowing the user to shorten/lengthen it with the corresponding controls. Since controls only modify the values in one direction (e.g. positive value increases the original release value, negative value decreases it), I have to modifiy the original release time to be smaller to allow the user to both shorten and increase it compared to the original, such that at 50% control it just sounds like the original again. The larger goal is to completely automate this so that people made reliably add desired controls to existing sfz definitions without impacting the original values via a simple little Python script that can very easily be run via a batch/bash file. I personally really need this for my own music projects, but I thought others would also find it to come in handy.

So far the script I made works fine at doing this, but setting the control on 50% and changing the original release value as I did does not preserve the original value, instead it makes it too long.


TL;DR:
I have some sfz file, and I modified it to contain controls to shorten/lengthen parameters in it under some assumptions I made, but those assumptions are wrong because I don't understand how the CC value maps to the original value of the parameters (does it multiply? add? what happens?). With this link missing, and no way to retrieve the actual release time after the CC values modify it (e.g. at 50%), I don't know how to find the relation/mapping between the CC value and the parameter.

Or even more briefly: I simply don't understand how a CC control maps to its parameter, what it does to the parameter when set above 0% that is. I am convinced that at 0% it does nothing to the parameter, but that is all.


I will check out this reference you mentioned, maybe I can find a PDF of it or something. I will also do a bit more research myself today to see what I can find.

Archer6621
Posts: 4
Joined: Wed Nov 26, 2014 10:09 am

Re: Relation between CC value and N in <parameter>_onccXX=N

Postby Archer6621 » Sat Nov 11, 2017 9:42 am

I think I found it: It actually adds the onCC value times the percentage to the original, instead of scaling it... so if release is 0.1, control is 50% and onCC is 8, the new release becomes 0.1 + 0.5 * 8 = 4.1 seconds.

This kinda explains why it become much longer than anticipated. I found out by simply using a stopwatch and doing some measurements... :D

EDIT: After applying it, it seems to work fine for release. I will share this script shortly along with instructions on how to automatically add controls for all .sfz files! After I refactored it a little bit.

pljones
Posts: 100
Joined: Wed Oct 15, 2014 2:05 pm

Re: Relation between CC value and N in <parameter>_onccXX=N

Postby pljones » Sat Nov 11, 2017 1:10 pm

Yes, that's it -- now I understand what you originally said (you did actually say it - it just didn't get into my head :D ).

ampeg_release_oncc72=16.0
ampeg_release=0.250

Means (assuming linear curve) - start at 0.25 and add 16.0 * (CC72 value / 127.0).


Return to “SFZ Programming”

Who is online

Users browsing this forum: No registered users and 1 guest