Question on CC values

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

Moderators: eric_telemaque, davidv

michaelwayneharwood
Posts: 14
Joined: Fri Nov 27, 2015 12:04 pm

Question on CC values

Postby michaelwayneharwood » Tue Dec 01, 2015 11:03 am

I am wondering if it is possible to code a sample to randomly play based on a CC value. What I envision is setting a CC to represent the percentage chance that a given sample will play, and then use that as the input for a "hirand".

michaelwayneharwood
Posts: 14
Joined: Fri Nov 27, 2015 12:04 pm

Re: Question on CC values

Postby michaelwayneharwood » Tue Dec 01, 2015 2:54 pm

To add a bit of clarification... I would like to add an option for a user to be able to control how often a particular sound is applied during playback. Release samples are a good example of this. Being able to control how often string movement noise is played based on a percentage adds significantly to the realism of the instrument being played.

michaelwayneharwood
Posts: 14
Joined: Fri Nov 27, 2015 12:04 pm

Re: Question on CC values

Postby michaelwayneharwood » Wed Dec 02, 2015 11:27 am

I played around with this a bit last night and was able to code a system that will work. For the curious here is what I came up with, though I believe there must be a more elegant way to structure this, and I need to do more testing to make sure that the percentages average out appropriately.

Assume CC100 is a control used to vary the frequency of a particular sample being played, and that the options for frequency in the following code is as follows:

    0% (CC value of 0)
    20% (CC value of 1)
    40% (CC value of 2)
    60% (CC value of 3)
    80% (CC value of 4)
    100% (CC value of 5)
This could easily be expanded to any frequency necessary.

Code: Select all

// 20% chance of sample being played
<group>
locc100=1 hicc100=1
lowrand=0 hirand=.2
<region> sample=*saw

// 40% chance of sample being played
<group>
locc100=2 hicc100=2
lowrand=0 hirand=.4
<region> sample=*saw

// 60% chance of sample being played
<group>
locc100=3 hicc100=3
lowrand=0 hirand=.6
<region> sample=*saw

// 80% chance of sample being played
<group>
locc100=4 hicc100=4
lowrand=0 hirand=.8
<region> sample=*saw

// 100% chance of sample being played
<group>
locc100=5 hicc100=5
<region> sample=*saw

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

Re: Question on CC values

Postby pljones » Wed Dec 02, 2015 1:34 pm

That will give between one and five layers - i.e. it doesn't switch between layers, you'll get all matching layers playing.

eric_telemaque
Posts: 215
Joined: Tue Jan 31, 2012 1:10 pm

Re: Question on CC values

Postby eric_telemaque » Wed Dec 02, 2015 1:39 pm

Hi,

Great workaround, I'd say! I've been scratching my head on this one looking for more convoluted solutions. (but it's lorand, not lowrand :wink: )

pljones wrote:That will give between one and five layers - i.e. it doesn't switch between layers, you'll get all matching layers playing.


That's what I thought at first, but with exclusive loccN and hiccN, only one region will ever play (or not) at any time.
Éric Patenaude,
Plogue Art et Technologie Inc. Montreal.
http://www.plogue.com

michaelwayneharwood
Posts: 14
Joined: Fri Nov 27, 2015 12:04 pm

Re: Question on CC values

Postby michaelwayneharwood » Wed Dec 02, 2015 3:36 pm

but it's lorand, not lowrand


Whoops! I am at work and coded the example from memory. Great catch!

with exclusive loccN and hiccN, only one region will ever play (or not) at any time.


My understanding is that all opcodes are treated with a logical "AND", so all parameters must agree for the region to play. The <group> parameters will hold until the next <group> section overrides them for the next block of regions. The group that has a "locc100=1 hicc100=1" should only be activated when the CC100 value is 1.

I plan on implementing round-robins, so to be able to make the code easier to read and troubleshoot, as well as reduce the possibility of typos, I think creating a separate SFZ file for the round-robin regions and using the #include directive something like this is wise:

Main SFZ:

Code: Select all

// 20% chance of sample being played
<group>
locc100=1 hicc100=1
lowrand=0 hirand=.2
#include=rr.sfz

// 40% chance of sample being played
<group>
locc100=2 hicc100=2
lowrand=0 hirand=.4
#include=rr.sfz

// 60% chance of sample being played
<group>
locc100=3 hicc100=3
lowrand=0 hirand=.6
#include=rr.sfz

// 80% chance of sample being played
<group>
locc100=4 hicc100=4
lowrand=0 hirand=.8
#include=rr.sfz

// 100% chance of sample being played
<group>
locc100=5 hicc100=5
#include=rr.sfz


Round Robin Regions SFZ:

Code: Select all

seq_length=5
<region> sample=rr1.wav seq_position=1
<region> sample=rr2.wav seq_position=2
<region> sample=rr3.wav seq_position=3
<region> sample=rr4.wav seq_position=4
<region> sample=rr5.wav seq_position=5


Obviously this is just a crude example to prove out the efficacy of the method, but it has enough potential to move forward with. ;)

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

Re: Question on CC values

Postby pljones » Wed Dec 02, 2015 4:22 pm

Aiiee, yeah, I missed that! :oops: Yes, so the random number would select up to five layers but, depending on the CC value, only (zero or) one will be selected. (CC100 of 0 or over 5 will mean no region selected.)

Ideally, all range defining opcodes would have versions could be modulated by CC value, EG and LFO inputs for some lovely modular programming madness :).

eric_telemaque
Posts: 215
Joined: Tue Jan 31, 2012 1:10 pm

Re: Question on CC values

Postby eric_telemaque » Wed Dec 02, 2015 4:32 pm

michaelwayneharwood wrote:I plan on implementing round-robins, so to be able to make the code easier to read and troubleshoot, as well as reduce the possibility of typos, I think creating a separate SFZ file for the round-robin regions and using the #include directive something like this is wise:

Main SFZ:

Code: Select all

// 20% chance of sample being played
<group>
locc100=1 hicc100=1
lowrand=0 hirand=.2
#include=rr.sfz

// 40% chance of sample being played
<group>
locc100=2 hicc100=2
lowrand=0 hirand=.4
#include=rr.sfz

// 60% chance of sample being played
<group>
locc100=3 hicc100=3
lowrand=0 hirand=.6
#include=rr.sfz

// 80% chance of sample being played
<group>
locc100=4 hicc100=4
lowrand=0 hirand=.8
#include=rr.sfz

// 100% chance of sample being played
<group>
locc100=5 hicc100=5
#include=rr.sfz


Round Robin Regions SFZ:

Code: Select all

seq_length=5
<region> sample=rr1.wav seq_position=1
<region> sample=rr2.wav seq_position=2
<region> sample=rr3.wav seq_position=3
<region> sample=rr4.wav seq_position=4
<region> sample=rr5.wav seq_position=5


Obviously this is just a crude example to prove out the efficacy of the method, but it has enough potential to move forward with. ;)



That will totally work. Most users would prefer repeatability, which is definitely not the case here! But I get your point perfectly. I like that!
Éric Patenaude,
Plogue Art et Technologie Inc. Montreal.
http://www.plogue.com

eric_telemaque
Posts: 215
Joined: Tue Jan 31, 2012 1:10 pm

Re: Question on CC values

Postby eric_telemaque » Wed Dec 02, 2015 4:36 pm

pljones wrote:Aiiee, yeah, I missed that! :oops: Yes, so the random number would select up to five layers but, depending on the CC value, only (zero or) one will be selected. (CC100 of 0 or over 5 will mean no region selected.)


yeah, I tweaked the example a bit for my own testing purposes. CC1 gets the nod for quick proof-of-concepts with my controller :

Code: Select all

// 20% chance of sample being played
<group>
locc1=1 hicc1=25
lorand=0 hirand=.2
<region> sample=*saw

// 40% chance of sample being played
<group>
locc1=26 hicc1=50
lorand=0 hirand=.4
<region> sample=*saw

// 60% chance of sample being played
<group>
locc1=51 hicc1=75
lorand=0 hirand=.6
<region> sample=*saw

// 80% chance of sample being played
<group>
locc1=76 hicc1=100
lorand=0 hirand=.8
<region> sample=*saw

// 100% chance of sample being played
<group>
locc1=101 hicc1=127
<region> sample=*saw
Éric Patenaude,
Plogue Art et Technologie Inc. Montreal.
http://www.plogue.com

michaelwayneharwood
Posts: 14
Joined: Fri Nov 27, 2015 12:04 pm

Re: Question on CC values

Postby michaelwayneharwood » Wed Dec 02, 2015 5:13 pm

Thanks so much for the verification and attention guys! I have only been playing with SFZ for a week or two, but I am finding that I should be able to pull off almost everything I want to do with a little thought. I am surprised that more attention is not being paid to this format - it has all of the basic building blocks needed to create robust and feature rich sample libraries, and there are options for copy protection if a commercial developer desires them.

The only down side I can see if that there is not easily available, and full, opcode documentation available on the net with complete examples. I have a copy of the book by Simon Cann on order, and I found an archived version of the Cakewalk DevXchange article (complete with a .zip file of SFZ examples) using Archive.org's WayBack Machine (http://www.cakewalk.com/DevXchange/article.aspx?aid=108), but I have had to spend a significant number of hours hunting down the information.

http://sfzformat.com exists, and it appears that Eric has done some work on it, but it needs a lot of fleshing out. Only so many hours in the day, right?

In any case I really appreciate all the help, and you can expect more questions as I explore.


Return to “SFZ Programming”

Who is online

Users browsing this forum: No registered users and 1 guest