Kyma Forum
  Tips & Techniques
  Scripts

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

next newest topic | next oldest topic
Author Topic:   Scripts
HectorBenard
Member
posted 10 September 2004 08:48         Edit/Delete Message   Reply w/Quote
I've been looking at the use of parameter variables and scripts in kyma. As an exercise I tried to implement a multi-tap delay line that would ask for an array of delay times (and max delay value), and this worked fine:

?arrayOfTimes do: [ :i |
del start: 0 s
anInput: (inputs at: 1)
delay: (i / ?maxDelay)]

As a next step I tried to add a panner so that the output of each delay sound would get a specific panning value, and here's where I ran into trouble. I've gone over the documentation a few times and I just can't figure out how to do it. There doesn't seem to be anything about making scripts to reproduce a structure with more than one step of processing (as in a delay with a green variable for DelayScale, then a panner with a green variable for Pan, and making several copies of that structure with a do: loop, so that each copy will have its own parameter values). I couldn't find any useful examples in the Kyma Sound Library either. But surely there must be a way to do this in Kyma.

I guess the question is how to reference each copy of the delay sound so that you can feed it into an instance of another sounds (such as a panner). Does anybody have any suggestions, or examples of this type of process that you could share? Thanks.


IP: Logged

SSC
Administrator
posted 10 September 2004 10:02         Edit/Delete Message   Reply w/Quote
"As a next step I tried to add a panner so that the output of each delay sound would get a specific panning value."

The easiest approach would be to modify the Sound you called del. In the Sound editor, drag a Pan module to the right of the del Sound. Set its Pan parameter to a green variable (say ?pan). Then you could modify your script to read something like:

?arrayOfTimes do: [ :i |
panner start: 0 s
anInput: (inputs at: 1)
delay: (i / ?maxDelay)
pan: i / (?arrayOfTimes last)]


"I guess the question is how to reference each copy of the delay sound so that you can feed it into an instance of another sound..."

If instead you add Pan to the Script's inputs and set Pan's input to the Variable module (renamed to 'input'), you could write:

?arrayOfTimes do: [ :i |
pan start: 0 s input: (del anInput: (inputs at: 1) delay: (i / ?maxDelay))]

Note that I used a Variable Sound named "input" and you used a Variable Sound named "anInput", but the effect is the same.

[This message has been edited by SSC (edited 10 September 2004).]

IP: Logged

HectorBenard
Member
posted 11 September 2004 13:08         Edit/Delete Message   Reply w/Quote
Thanks for your help! I have a few more questions. I guess the first one would be if there is an up to date book that you would recommend for learning smalltalk (I've heard that most of the ones mentioned in the manual are rather outdated, but is that true when it comes to the smalltalk "dialect" kyma uses?). While I can figure out all of this out on my own...

?arrayOfTimes do: [ :i |
panner start: 0 s
anInput: (inputs at: 1)
delay: (i / ?maxDelay)
pan: i / (?arrayOfTimes last)]

What does the "last" message sent to ?arrayOfTimes mean, and why is it necessary? And what would be the easiest way to add an array of panning values similar to the ?arrayOfTimes variable? I tried something like this:

?arrayOfTimes do: [ :i |
| nbr |
nbr := (?arrayOfPans at: 1) .
panner start: 0 s
anInput: (inputs at: 1)
delay: (i / ?maxDelay)
panning: c
nbr := nbr + 1)]

But obviously the syntax (to begin with) isn't right. If I move the last statement to go before the panner, it gives me an error message saying that the message #clipTo01 sent to an instance of Array wasn't understood.

I also tried using a count to reference the ?arrayOfPans. In SuperCollider the first argument for the do loop is always item (as seems to be the case here too), and the second argument is count. But it doesn''t seem to work that way here (it complains that the block expects 2 arguments when I just declare another argument and then use it). How can I know the default arguments for the do: method? Or how do I assign it to be a count? (excuse my sloppy terminology)

I know how to do this sort of things in SuperCollider, but it seems to me that if I could learn how to do them just as easily in Kyma I could do so much more with them, because of all the other features that Kyma has. I'd be curious to know if many people are using Kyma like this, and if so, I'd really appreciate it if someone could share some code for learning purposes. There really isn't that much code available in the sound library and manual. Thanks.

Hector

IP: Logged

SSC
Administrator
posted 12 September 2004 12:17         Edit/Delete Message   Reply w/Quote
The #last message is not required. You could instead use:

(?arrayOfTimes at: ?arrayOfTimes size)

To have an array of panning values requires rearranging the loop to use an index rather than each value in the array. For example, you could do something like

1 to: ?arrayOfTimes size do: [ :i | | t pan |
t := ?arrayOfTimes at: i.
pan := ?arrayOfPans at: i.
panner start: 0 s anInput: (inputs at: 1) delay: (t / ?maxDelay) panning: pan]

For learning about the use of Smalltalk in Kyma, the best place to start is by reading the Kyma X Revealed! chapters on Smalltalk and Capytalk, starting on page 215, and referring to the Capytalk and Smalltalk references on page 369 and page 375. Kyma X Revealed! is installed with Kyma X in the Documentation folder of the Kyma folder. (Also, it is available as a physical book.)

[This message has been edited by SSC (edited 12 September 2004).]

IP: Logged

HectorBenard
Member
posted 12 September 2004 15:03         Edit/Delete Message   Reply w/Quote
That makes sense! I'll try it first thing tomorrow.

As for learning smalltalk, I've been studying the Kyma X revealed! chapters on smalltalk and capytalk (as well as the quick reference appendices). What I meant is if there is anything else that you would recommend to go into more detail. There is the squeak stuff and so on, but I'm really only interested in using smalltalk inside kyma. SuperCollider has a lot of simmilarities with smalltalk (since it comes from it), and I think that's part of what's throwing me off (that is, what is NOT so simmilar). I guess what I would need is something to calrify all the little differences in syntax and so on, as well as reference to the classes and methods. I guess for now I'll keep studying the kyma manual and have a look at some of the old smalltalk books on the web. Then maybe I'll bug you with some more questions in a while.

Thanks for all your help!

Hector

IP: Logged

HectorBenard
Member
posted 12 September 2004 15:45         Edit/Delete Message   Reply w/Quote
For example, the "last" message sent to an array, I couldn't find it anywhere in the quick reference appendix. I know it is a pretty common message in many different langauges, but if I didn't know it existed in smalltalk how could I have found out about it?

IP: Logged

SSC
Administrator
posted 13 September 2004 11:07         Edit/Delete Message   Reply w/Quote
If you require more detail than is in Kyma X Revealed, you can try a standard Smalltalk book or Squeak (some links to Smalltalk references can be found in the LEARN section of tweaky): http://www.symbolicsound.com/cgi-bin/bin/view/Learn/Smalltalk

If you find a book on Smalltalk that you like, concentrate on the sections describing arithmetic and collections. Those will be the most immediately useful inside Kyma.

IP: Logged

HectorBenard
Member
posted 13 September 2004 11:50         Edit/Delete Message   Reply w/Quote
Yes, I've already downloaded a couple of smalltalk books from the twiki link last night. I'll have a look at them. Thanks!

I tried running the code that you sent me yesterday, but it gives me an error message: "the message #clipTo01, sent to (1 0 0.5) <which is the array of pans I entered>, an instance of class Array, was not understood."

Any idea why that would be? Here's the sound in which I'm using it (the rightmost sound is just an annotation):

pan arrays (add original)
. add original (dir, Multi-tap script)
. . dir (source)
. . . source
. . Multi-tap script (source, panner)
. . . source
. . . panner (del)
. . . . del (anInput)
. . . . . anInput

Thanks for your help!

Hector

IP: Logged

SSC
Administrator
posted 13 September 2004 12:09         Edit/Delete Message   Reply w/Quote
Can you please attach the Sound to an email so we can have a look at it? Somehow it looks like you might be passing an Array to the ?pan variable, rather than a single element of the Array.

IP: Logged

SSC
Administrator
posted 14 September 2004 11:36         Edit/Delete Message   Reply w/Quote
Thanks for sending the Sound. The problem was that you had used
?panArray
in the Pan field of the Sound called 'panner'. So the parameter was being set to an Array instead of to a single number from that Array. You probably intended to use
?panning
as the green variable, since your Script reads:
panner start: 0 s
anInput: (inputs at: 1)
delay: (t / ?maxDelay)
panning: pan

IP: Logged

HectorBenard
Member
posted 14 September 2004 12:18         Edit/Delete Message   Reply w/Quote
Of course! :P No wonder I couldn't find any mistakes in the script itself. Sorry about that. Thanks a lot for your help.

H

IP: Logged

HectorBenard
Member
posted 16 September 2004 08:19         Edit/Delete Message   Reply w/Quote

template.kym

 
Say now I wanted to make a class out of that sound. I would have to replace the source input for a variable, right? (otherwise the new class has no input and just uses the original sound) However, when I do this and try to play the sound or do a 'New class from example' I get asked for values for all the variables, including those I already declared in the script (such as ?anInput and ?delay). Am I doing something wrong? I have uploaded a copy of the sound.

Thanks!

H.

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