First time here? Check out the FAQ!
x

Capytalk to Scale the output of Controller

+1 vote
373 views

I would like to scale the output of this controller.

For example, instead of 0, 1 - I would like it to generate 8000 - 13000 for !Frequency

and 0.2 - 1.0 for !Amp.

Thanks!http://kyma.symbolicsound.com/qa/?qa=blob&qa_blobid=716716362563027251

asked Dec 19, 2020 in Capytalk & Smalltalk by anne-la-berge (Adept) (2,170 points)

1 Answer

+1 vote
 
Best answer

Hi Anne,

Do you want to scale the frequency linearly between 8000 and 13000 Hz or logarithmically?

For linear interpolation you could take your random number which is between 0, 1 and scale it using interpolateFrom:to: eg:

{| t |
t := (1 s randExp).
(t s random abs smooth: t s) interpolateFrom: 8000 to: 13000}

If you want it logarithmic you could use note numbers instead of Hz. So something like:

{| t |
t := (1 s randExp).
((t s random abs smooth: t s) interpolateFrom: 8000 hz nn to: 13000 hz nn) nn hz}

Here I'm converting from 8000 hz to the nn equivalent (which is about 120) and interpolating between that and the nn equivalent of 13000 hz. Then at the end I'm converting from nn back to hz.  This would give a more "musical" distribution I think because the numbers would be more uniformly spread across the octave instead of being more perceptually up the high end, if you see what I mean. 

 You could then make another SoundToGlobalController for !Amp and use interpolateFrom:to: with 0.2 and 1.

 

answered Dec 19, 2020 by alan-jackson (Virtuoso) (15,840 points)
selected Dec 19, 2020 by anne-la-berge
Thanks Alan!
I was looking for the interpolateFrom command.
...