Kyma Forum
  Kyma Support
  Please help me with the script

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

next newest topic | next oldest topic
Author Topic:   Please help me with the script
Phi Curtis
Member
posted 11 July 2006 20:33         Edit/Delete Message   Reply w/Quote

Scriptingproblem.kym

 
Hi,

I'd like to create a script that wires together a sound like the sound called "Switch4" in the enclosed sound file. "Switch4" is a simple sound that allows the user to switch between 4 different inputs. The reason I want it to be implemented in a script is so that the user can specify the actual number of inputs he/she wants.

The accomanying sound is my best attempt so far. The problem is in creating the Arrays that should go in the gains. I would like to test :r in the collect: loop against i: in the larger, enclosing do: loop, but when I attempt to reference i I am told that i is an undeclared variable.

//

For those reading along at home and not looking at the sound, here's the script:
| default |

default := 60 nn hz.

1 to: ?nbrInputs do: [:i |
switch start: 0 s
anInput: (soundInput scale: (default * (i / ?nbrInputs)))
switcher: (1 to: ?nbrInputs) collect: [ :r | r].
].

//

My thought was that, in comparing r against i, if r=i, then that item in the array should be set to 1. If r=i evaluates to false, then the item would be set to 0.

It is my impression that I need curly brackets around the collect: loop, but every time I try to put them there I am not allowed to exit the box. I am told that for expressions containing hot values or variables, I need to use vmin:, vmax: varIfTrue: etc. I can't seem to find an expression using these that works and allows me to attempt a compile. When I don't have the curly brackets, whatever I try to do in the loop seems to be ignored.

thanks,
Phil

IP: Logged

SSC
Administrator
posted 13 July 2006 14:18         Edit/Delete Message   Reply w/Quote
I think it's a case of the dreaded missing parentheses

The argument to switcher is an expression that has a colon and the rest of the expression after that colon was interpreted as another parameter value. Here it is with parantheses installed:

| default |

default := 60 nn hz.

1 to: ?nbrInputs do: [:i |

switch start: 0 s
anInput: (soundInput scale: (default * (i / ?nbrInputs)))
switcher: ((1 to: ?nbrInputs) collect: [ :r | (r = i) ifTrue: [1] ifFalse: [0]])].

(sorry the forum doesn't preserve tabs)


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