Kyma Forum
  Tips & Techniques
  smalltalk index array in pitch field analog seq

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

next newest topic | next oldest topic
Author Topic:   smalltalk index array in pitch field analog seq
rafe
Member
posted 09 December 2008 03:41         Edit/Delete Message   Reply w/Quote
hello

this code works in my evaluation window but when i paste it into the pitches feild of an analogue sequencer kyma won't let me move to another sound in the editor.

my intent is to expand on this base program to attempt to add a hot value for seed and to use the input keynumber as a center value for a window into a larger collection stored in mode.

{ | r mode keypit|

keypit := 'keypitch' asHotValue.
mode := #(40 42 43 45 47 48 51 52 54).
r := Random newForKymaWithSeed: 7.
( 1 to: 15) collect: [ :i | (( keypit := mode at: ((r next * 8) rounded +1))nn )] }

i am not clear what the problem is with the following code either but this always evaluates with the error message error during literal evaluation after i get a dialogue window informing me that the variable keypitch is not used. is this causing an issue because its a reserved word?

DIDN'T WORK
Error during literal evaluation ->{ | r mode keypitch|

mode:= #(40 42 43 45 47 48 51 52 54).
r:= Random newForKymaWithSeed: 7.
keypitch := 'keypitch' asHotValue.
( 1 to: 15) collect: [ :i | (( keypitch := mode indexAt: ((r next * 8) rounded +1))nn )] }

thanks

rafe

IP: Logged

SSC
Administrator
posted 09 December 2008 08:12         Edit/Delete Message   Reply w/Quote
I think you are getting the message about keypit never being used because you assign a value to keypit here:

keypit := mode at: ((r next * 8) rounded +1))nn

but there are no further references to it after that. If you want keypit to be a center value, you could try adding the random value to it instead, for example:

(keypit * (mode at: ((r next * 8) rounded +1))) nn

IP: Logged

rafe
Member
posted 10 December 2008 03:42         Edit/Delete Message   Reply w/Quote
quote:
Originally posted by SSC:
I think you are getting the message about keypit never being used because you assign a value to keypit here:

keypit := mode at: ((r next * 8) rounded +1))nn

but there are no further references to it after that. If you want keypit to be a center value, you could try adding the random value to it instead, for example:

(keypit * (mode at: ((r next * 8) rounded +1))) nn


i used your final expression, modified, to get the basic structure to work in the sound. ->

( 1 to: 15) collect: [ :i | (( (keypit/keypit) * (mode at: ((r next * 8) rounded +1)))nn hz)
gets me started thanks!!

but i am a bit confused about why assigning a value within a loop isn't considered a valid instruction?


thanks again
rafe


[This message has been edited by rafe (edited 10 December 2008).]

IP: Logged

SSC
Administrator
posted 10 December 2008 10:10         Edit/Delete Message   Reply w/Quote
quote:
( 1 to: 15) collect: [ :i | (( (keypit/keypit) * (mode at: ((r next * 8) rounded +1)))nn hz)
gets me started thanks!!

If you like, you could simplify this expression because (keypit/keypit) will always equal 1.

quote:
but i am a bit confused about why assigning a value within a loop isn't considered a valid instruction?

Nothing invalid about assigning a value to a variable inside a loop. The message was just warning you that the variable was never used after you'd assigned a value to it.

IP: Logged

rafe
Member
posted 10 December 2008 15:55         Edit/Delete Message   Reply w/Quote
I thought it may be simpler to ask if i am on the right track with my logic in tackling this code so i have ' sketched' an outline below that needs syntax work.


just to be clear - what i want to accomplish is: to have a keynumber input to the sound checked to be in key and while the key is held the sound to generate a random stream of nn that are within a window of the keynum (+- 4 mode steps in this case). and i would like to be able to toggle between an number of seed values for the random number generator.


{ | r mode keypit inseedar keydwn arraystep seedfader |
keydwn := 'keydown' asHotValue.
keypit := 'keypitch' asHotValue.
mode := #( 36 37 39 40 42 43 45 47 48 51 52 54 55 57).
inseedar := #( 7 3906 ).
seedfader := 'seedfader' asHotValue.
arraystep := (seedfader rounded)+1). " this is ambiguous- how to step through the array with live control - set seed fader max to # of seeds, grid one in vcs --mod # = number of literals in the array of seeds"


(r := Random newForKymaWithSeed: (inseedar at: arraystep)),
"test for keydown and keypitch in key then output nn's "
keydwn ifTrue:
[mode includes: (keypit hz nn removeUnits)
ifTrue:
[self keypit.
( 1 to: 15) collect: [ :i | ( (mode at: ((mode detect: keypit )+((((r next *2) -1) * 8) rounded +1)))nn hz).]]] }

thanks in advance

rafe

[This message has been edited by rafe (edited 11 December 2008).]

IP: Logged

rafe
Member
posted 12 December 2008 13:32         Edit/Delete Message   Reply w/Quote
why does this code return the error r2 r3 value are not used if the periods are removed on the random statements - or only evaluates the first loop in the series if the periods are in place
{ | r mode keypit r2 r3 |

keypit := 'keypitch' asHotValue.
mode := #(40 42 43 45 47 48 51 52 54).

r := Random newForKymaWithSeed: 4400.
( 1 to: 15) collect: [ :i | (( (keypit/keypit) * (mode at: ((r next * 8) rounded +1)))nn hz)].

r2 := Random newForKymaWithSeed: 7.
( 1 to: 15) collect: [ :i | (( (keypit/keypit) * (mode at: ((r2 next * 8) rounded +1)))nn hz)].

r3 := Random newForKymaWithSeed: 3906.
( 1 to: 15) collect: [ :i | (( (keypit/keypit) * (mode at: ((r3 next * 8) rounded +1)))nn hz)] }

[This message has been edited by rafe (edited 12 December 2008).]

IP: Logged

SSC
Administrator
posted 12 December 2008 15:36         Edit/Delete Message   Reply w/Quote

Rafemodes.kym

 
I think the key is to create one long array. The first 15 pitches are generated from the first random number generator using the first seed, the next 15 are generated by another random number generator starting on a different seed, etc. If you use the following for the Pitches field of the AnalogSequencer:

code:

{ | r mode r2 r3 arr1 arr2 arr3 |
mode := #(0 2 3 5 7 8 11 12 14).
r := Random newForKymaWithSeed: 4400.
arr1 := ( 1 to: 15) collect: [ :i | !KeyPitch + (mode at: ((r next * 8) rounded +1)) nn].
r2 := Random newForKymaWithSeed: 7.
arr2 := ( 1 to: 15) collect: [ :i | !KeyPitch + (mode at: ((r2 next * 8) rounded +1)) nn].
r3 := Random newForKymaWithSeed: 3906.
arr3 := ( 1 to: 15) collect: [ :i | !KeyPitch + (mode at: ((r3 next * 8) rounded +1)) nn].
(arr1, arr2, arr3) }

And then set StartIndex to: !Seed of: #(0 15 30)

And EndIndex to: !Seed of: #(14 29 44)

I think you can then experiment with your three different random sequences generated from three different seeds.


IP: Logged

rafe
Member
posted 12 December 2008 16:35         Edit/Delete Message   Reply w/Quote
i have one simple question

what is the smalltalk message to send to an expression with a hotvalue to have the event expression output its value? Value and Self are illegal messages to send to a hotvalue. i cannot find this in the manual.

this is the specific statement i need to output the values for.

( 1 to: 15) collect: [ :i | (keynum + (mode at: ((r next * 8) rounded +1))nn)]


BTW thanks Carla for the input today but i realized after we finished our conversation that i still have a catch. if i use the intervals set up in an array rather than note numbers then the output will be out of key under certain circumstances- ie all works fine if the keynumber is the tonic but not if it is the 4 th. yes this sollution works and i can modify it to get my desired result . THANKS AGAIN!!!

BUT I would still like to know what the appropriate message is to send to a event expression with a a hot value - helpful for debugging.


regards

rafe

[This message has been edited by rafe (edited 12 December 2008).]

IP: Logged

SSC
Administrator
posted 12 December 2008 20:10         Edit/Delete Message   Reply w/Quote
quote:
BUT I would still like to know what the appropriate message is to send to a event expression with a a hot value - helpful for debugging.

If you put an event expression into a SoundToGlobalController, it will display its value in the VCS for debugging purposes.

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