Kyma Forum
  Kyma Support
  scripting help

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   scripting help
Phi Curtis
Member
posted 25 May 2008 19:53         Edit/Delete Message   Reply w/Quote

Rhythmsgeneratedbybpmexpression.kym

 
Hi,

I've hit a wall and am hoping for help.

In the attached file I have a sound where a rhythm is being generated with the aid of the following array:

#(1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9)

In other words, every number in the array has to be repeated by the number of times that the number is. If you try the expression you can see why an array like this is necessary:

(!StartTime bpm: !BPM dutyCycle: 0.01) triggerEvery:
(((!StartTime bpm: !BPM) countTriggersMod: 45) of: #(1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9) ).

First off, can anyone think of a better way to do what I'm trying to do? Basically I want to be able to program rhythms that are driven by a 1 bpm: !BPM expression (maybe a solution could be worked out with an AnalogSequencer, but I'm trying to avoid using a sequencer).

Anyway, since it's kind of cumbersome to write out arrays like that (especially if it gets long and with big numbers), I was hoping to write a script that would generate an array if given the numbers for the desired rhythmic values (In the present example, I would just give it 1, 2, 3, 4, 5 ,6 ,7, 8 ,9). But I'm afraid my rather poor scripting chops aren't getting me very close - I know it would probably involve using a collect: expression with some kind of loop...

Lastly, although the sound does a nice job of generating the desired rhythm in clicks, the intention is to use the rhythm as a gate for an envelope-driven sound, and for that I need the click to stay on for a user-definable percentage of the time between clicks (basically to have a duty cycle, but one going across many of the underlying triggers that are generating the rhythm).

I hope this makes sense (I think you probably have to check out the attachment to get what I'm after).

thanks for any help!

Phil

IP: Logged

SSC
Administrator
posted 30 May 2008 10:30         Edit/Delete Message   Reply w/Quote
Hi Phil,

One way to generate the array pattern you describe would be to add each element to a collection that element number of times. One construct for doing this might be to use
timesRepeat:
inside a loop, for example:

code:

| coll |

coll := OrderedCollection new.
1 to: 9 do: [ :i | i timesRepeat: [coll addLast: i]].

(!StartTime bpm: !BPM dutyCycle: !Duty) triggerEvery:
(((!StartTime bpm: !BPM) countTriggersMod: 45) of: coll)


By making the dutyCycle hot (!Duty), you can make the gate stay on for a variable percentage of the cycle.

IP: Logged

Phi Curtis
Member
posted 31 May 2008 01:37         Edit/Delete Message   Reply w/Quote
Hi SSC,

Thanks - that gets me part of the way there. What I am looking for is something a little more generalized, so that I can redefine the members of the collection to whatever I want, and then have it constructed for me. My example with the numbers 1-9 in order was just so that it would be able to listen to the result and see if it was right.

So I imagine that if I want to construct the array #{3 3 3 5 5 5 5 5 2 2 7 7 7 7 7 7 7 4 4 4 4) - to pick a completely arbitrary example, I would start with something like this:

code:

| coll index0 index1 index2 index3 index4 totalOfIndexes |
coll := OrderedCollection new.
index0 := 3.
index1 := 5.
index2 := 2.
index3 := 7.
index4 := 4.
totalOfIndexes := index0 + index1 + index2 + index3 + index4.

And then I'm stuck. I imagine I'd have to somehow define the members of the collection "coll" by using add: messages but I'm not sure just how to do this.

Would it be something like this?

code:
(((coll add: index0) add: index1) add: index2)


etc? But do I put this in the section defining the "coll" variable, or somehow in the subsequent code?

You see that I'm also defining a variable called totalOfIndexes as the sum of all of the indexes. This is because the total times needed for the countTriggersMod in my original code isn't set, but dependant on what is chosen for the values of index0, index1, etc. So when it gets to that part, it would be "countTriggersMod: totalOfIndexes."

Thanks again for your help.

best,
Phil

IP: Logged

SSC
Administrator
posted 31 May 2008 09:02         Edit/Delete Message   Reply w/Quote
You can use the elements of the array as values in the loop, for example:

code:

| coll |
coll := OrderedCollection new.
#(3 5 2 7 4) do: [ :i | i timesRepeat: [coll addLast: i]].


IP: Logged

Phi Curtis
Member
posted 31 May 2008 12:39         Edit/Delete Message   Reply w/Quote
That's it - I can see now where I should start reviewing in the Kyma X Revealed book...

thanks again!
Phil

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply

Contact Us | Symbolic Sound Home

This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.


Ultimate Bulletin Board 5.45c