ddf / Minim

A Java audio library, designed to be used with Processing.
http://code.compartmental.net/tools/minim
GNU Lesser General Public License v3.0
668 stars 136 forks source link

Problem with Wavetable Methods #85

Closed luisarandas closed 5 years ago

luisarandas commented 5 years ago

Hello and good afternoon all! I am creating and plotting 3 wavetable methods, their 3 oscillators and 3 visualisations. I am using also ControlP5 for buttons and to trigger functions. The problem here is when I trigger a button and say oscillator_one -> make a sine and oscillator_two -> make a sine I think they are the same one. Here I send my code:

setting up Oscil WAVE_ONE; Oscil WAVE_TWO; Oscil WAVE_THREE; Wavetable WAVETABLE_GEN_ONE; Wavetable WAVETABLE_GEN_TWO; Wavetable WAVETABLE_GEN_THREE; PGraphics WAVETABLE_GRAPHICS_ONE; PGraphics WAVETABLE_GRAPHICS_TWO; PGraphics WAVETABLE_GRAPHICS_THREE;

setup function WAVETABLE_GEN_ONE = Waves.randomNHarms(16); WAVETABLE_GEN_TWO = Waves.randomNHarms(8); WAVETABLE_GEN_THREE = Waves.randomNHarms(13); WAVE_ONE = new Oscil( 440, 0.5f, WAVETABLE_GEN_ONE ); WAVE_TWO = new Oscil( 620, 0.5f, WAVETABLE_GEN_TWO ); WAVE_THREE = new Oscil( 845, 0.5f, WAVETABLE_GEN_THREE );

OUT_WAVE = createGraphics(500,120); WAVETABLE_GRAPHICS_ONE = createGraphics(500,120); WAVETABLE_GRAPHICS_TWO = createGraphics(500,120); WAVETABLE_GRAPHICS_THREE = createGraphics(500,120);

But the main problem comes in the function that is being called when I press a button

void controlEvent(ControlEvent theEvent) { if (theEvent.isFrom(CP5.getController("SINE_ONE"))) { WAVETABLE_GEN_ONE = Waves.SINE; WAVE_ONE.setWaveform(Waves.SINE); }

SINE_ONE is a button that makes the first wavetable being a sine If I make this in another button like SINE_TWO and make exactly the same method the waves are the same and not different ones

void controlEvent(ControlEvent theEvent) { if (theEvent.isFrom(CP5.getController("SINE_TWO"))) { WAVETABLE_GEN_TWO = Waves.SINE; WAVE_TWO.setWaveform(Waves.SINE); }

I notice this when I call the function mousePressed() and make a warp (like the examples) if more than one oscillator have the same wave like SINE or SQUARE they behave the same and not independently Perhaps make a WAVETABLE_GEN_ONE = new Waves.SINE? Best, Luis