Kyma Forum
  Tips & Techniques
  scripting

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

next newest topic | next oldest topic
Author Topic:   scripting
Pieter
Member
posted 12 April 2003 02:32         Edit/Delete Message   Reply w/Quote
Hello,
I hope this question is not too basic.

How can I change a variable in a funtcion with another funtion from outside?

r := Random new.
t := 0.
x := 0.05.
a := 3.95.
p := #( 0 2 4 6 7 9 11 12).
200 timesRepeat: [
fr := a*x*(1-x).
self
keyDownAt: t s
duration: 15 s
frequency: 2 c sharp + (p at: ((fr*7 + 1) truncated)) .
t := t + (7 * r next).
x := fr].

Now I would like to change a every 20 repeats and change the octave through another function?
Thanks for help

Best Regards

Pieter

IP: Logged

SSC
Administrator
posted 12 April 2003 12:33         Edit/Delete Message   Reply w/Quote
You may prefer to do this in real time, without having to construct a MIDI script. You can ask for the value of the next iteration of the map of the interval each time you trigger, using the expression:

!KeyDown nextChaotic: !k seed: 0.77 reset: !Inject

In answer to your question on how to change the octave in your script, if you were to use a do: loop instead of timesRepeat: then you would have an index (i) that you could test for the number of repeats. Every 20 times you could change the octave number. You would need another variable to hold the octave (which could take the values -3, -2, -1, 0, 1, 2, 3 as the numbers of octaves above or below the octave of the pitch you read out of the array using fr). For example,

oct := 0.
1 to: 200 do: [:i
fr := a*x*(1-x).
((i mod: 20) = 0) ifTrue: [oct := (fr * 2 - 1 * 3) rounded].
self
keyDownAt: t s
duration: 15 s
frequency: 2 c sharp + (p at: ((fr*7 + 1) truncated)) + (oct * 12 nn).
t := t + (7 * r next).
x := fr].

I didn't actually run the compiler on this, so please just look at it as a suggestion as to how to approach it.

(I think you might find that the nextChaotic:seed:reset: function is a more interactive and tweakable way to do the same thing)

IP: Logged

Fake Person
Member
posted 12 April 2003 12:43         Edit/Delete Message   Reply w/Quote
Alternatively, you could use:

r := Random new.
t := 0.
x := 0.05.
a := 3.95.
p := #( 0 2 4 6 7 9 11 12).
10 timesRepeat: [
20 timesRepeat: [
fr := a*x*(1-x).
self
keyDownAt: t s
duration: 15 s
frequency: 2 c sharp + (p at: ((fr*7 + 1) truncated)) + (12 nn * octave).
t := t + (7 * r next).
x := fr]
"Change octave here."
octave := octave + 1].

IP: Logged

Pieter
Member
posted 12 April 2003 13:28         Edit/Delete Message   Reply w/Quote
Hello Fake,
thank you for your suggestion. But this one I tried also and it doesn't work. It seems you can't do a "timesRepeat" inside another "timesRepeat".
???
Best
Pieter

IP: Logged

Pieter
Member
posted 12 April 2003 13:52         Edit/Delete Message   Reply w/Quote
quote:
Originally posted by SSC:
You may prefer to do this in real time, without having to construct a MIDI script. You can ask for the value of the next iteration of the map of the interval each time you trigger, using the expression:

!KeyDown nextChaotic: !k seed: 0.77 reset: !Inject


Sorry but perhaps I expressed my question the wrong way. In the following function I want to change th variable "a" every 20 repeats. I can do it with another if-function but it would interest me how I can use the expression from above. Please excuse my difficulties with the english language.

| r t x fr a p oct|
r := Random new.
t := 0.
x := 0.05.
a := 3.89.
p := #( 0 2 4 6 8 9 11 12).
oct := 0.
1 to: 200 do: [:i |
fr := a*x*(1-x).
((i mod: 20) = 0) ifTrue: [oct := (fr * 2 + 1) rounded].


IP: Logged

SSC
Administrator
posted 12 April 2003 15:04         Edit/Delete Message   Reply w/Quote
"!KeyDown nextChaotic: !k seed: 0.77 reset: !Inject
------------------------------------------------------------------------
Sorry but perhaps I expressed my question the wrong way. In the following function I want to change th variable "a" every 20 repeats."

The variable a in your script corresponds to the hot value (!k + 3) in the expression I suggested. This is the scalar value (usually called R) that determines whether your iterated function will go into a cycle or whether it will be in a chaotic area. You could change !k every 20th time by:

(1 bpm: !BPM) nextChaotic: ((1 bpm: (!BPM / 20)) nextRandom) reset: !Gate

IP: Logged

Pieter
Member
posted 12 April 2003 23:09         Edit/Delete Message   Reply w/Quote
so much to learn....

thank you for your patience

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