k y m a • t w e a k y — the kyma collective || view the current website || February 2015 Archive

/ WebHome / How.ConstrainControlRandom


How Section

How do I...
Add a question...


All Sections


Login / Register 
Change password
Forgot password?

Symbolic Sound

Kyma Forum
Eighth Nerve

TWiki Links

TWiki Formatting FAQ
What is TWiki?
%SESSION_ENDIF% twiki.org

Question (or Task)

I'm looking for some way to control the behavior of a random panning feature (other than manually panning each event ... boring!!!) But so far I've been unsuccessful.

What I'm looking for is the equivalent of the [change] object in Max. I want each !Keydown triggered event to come from an obviously different pan placement than the previous one. Initital attempts to limit the random output so that the different pan locations are consistently obvious [example: !KeyDown nextRandom * 4 of: #(0.9 0.75 0.25 0.1)] produce FAR too many instances where the pan position does not change from one to the next.

I think what I need a way of discarding the output of a limited nextRandom in the event that it's the same as the previous one ... and then quickly generating another ... and another ... and another if necessary ... until it's different.

Surely there is a way to do this... yes?!?!

-- MarkPhillips - 28 Oct 2003


How about taking a different approach to achieving the same end:

  1. Create a repeating circular pan
  2. Sample and hold it at random time intervals

For example, a circular pan that repeats every three seconds would be

(1 repeatingRamp: 3 s) for the Panner Sound or

(1 repeatingFullRamp: 3 s) for the Timeline

To generate a random number from a uniform distribution at random time intervals you could use 1 s randExp random. You could test whether this random number exceeds a threshold and trigger the sample and hold on the following test case:

(1 s randExp random gt: 0)

Put them all together and you get

(1 s randExp random gt: 0) sampleAndHold: (1 repeatingRamp: 3 s)

-- CarlaScaletti - 28 Oct 2003

Another approach would be to pre-determine your random numbers and use countTriggersMod: to step through them in order:

(!KeyDown countTriggersMod: 15) of: {
   | last r this |
   last := 0.
   r := Random newForKymaWithSeed: 12.
   (1 to: 16) collect: [ :i |
      [((this := r next) - last) abs < 0.1] whileTrue.
      last := this]}

In this code, the expression inside the curly braces generates a list of 16 random numbers between 0 and 1 that are at least 0.1 different from one to the next.

You could change the 16 (in the two places) to a different number to generate a different quantity of numbers, and you could change the 0.1 to increase or decrease the minimum change between consecutive numbers.

-- KurtHebel - 28 Oct 2003

Interesting ... I really like this last one. Curiously, it's functionally very similar (but much more elegant and math/computer saavy) than what I came up with on my own before this elegant bit of code appeared on the web. I used a countTriggersMod: and just typed in a bunch of numbers that I thought would work OK ... and indeed it does. :-) This is still a lot better than individually panning each event. Doesn't take very many numbers, actually. I don't think most listeners are that sensitive to patterns of pan placement (especially if independant of any other parameter) as we are to patterns of pitch and/or rhythms.

I think this little bit of code would be very useful to lots of users and in many different contexts ... I'd like to suggest that it (or something like it) should be readily available in the prototypes somehow/somewhere. It would be really cool to have a module where your variables could be "hot" so you could tweak values interactively while experimenting and exploring outcomes.

-- MarkPhillips - 28 Oct 2003

Pendng SSC from doing it, you could easly add this to the expression library yourself. open up one of the expression text files to see the format. this example fits in with the array expressions nicely.

-- BenPhenix - 12 Nov 2003

Question: How do I make random numbers be really random?
Keywords: Constrain Control Random

© 2003-2014 by the contributing authors. / You are TWikiGuest