Forcing SinOsc objects into phase in Processing.sound

So if you have a user able to turn on or turn off a SinOsc channel with a button, depending on when the button is pressed the tones will be more or less out of phase with each other, leading to different sounds being produced. With 3 or more oscillators at once you usually get some horrible buzzing unless you’re prepared to turn the sound off and on again until you get things close to being in phase by chance.

I’ve been playing around with SinOsc.add() but I can’t find any good documentation on what it does precisely. I’m not even sure it’s to do with phase to be honest, the reference just says “offset the output”. I’ve been using something like “(millis()%1000)/1000” to get the delay from the previous one second marker and feeding that into each oscillator, but it isn’t working at all, it doesn’t seem to make any difference.

Can someone point me in a better direction?

there could be a way using the CLUSTER

Java Examples / Libraries /Sound / Oscillators / SineCluster

  • you setup several of them
  • but set amp = 0
  • when you need one
    • set freq = x
    • set amp = y

they all play together already from setup,
so you just LET’s GET LOUD