display ellipse for panning sound
in
Programming Questions
•
2 years ago
Hi,
I have included modified code from the 'getsetpan' example provided with processing, this example allows you to move the mouse left and right to pan the sound but there is no object displyed to show you where the pan is. I want to modify this so there is an ellipse displayed on the screen which you click on and drag around the screen to change the pan. i have included the code, can anyone help me with this please?
- import ddf.minim.*;
- import ddf.minim.signals.*;
- Minim minim;
- AudioOutput out;
- Oscillator osc;
- WaveformRenderer waveform;
- void setup()
- {
- size(512, 200);
- minim = new Minim(this);
- out = minim.getLineOut();
- // see the example AudioOutput >> SawWaveSignal for more about this class
- osc = new SawWave(100, 0.2, out.sampleRate());
- // see the example Polyphonic >> addSignal for more about this
- out.addSignal(osc);
- waveform = new WaveformRenderer();
- // see the example Recordable >> addListener for more about this
- out.addListener(waveform);
- textFont(createFont("SanSerif", 12));
- }
- void draw()
- {
- background(0);
- // see waveform.pde for more about this
- ;
- if ( out.hasControl(Controller.PAN) )
- {
- // map the mouse position to the range of the pan
- float val = map(mouseX, 0, width, -1, 1);
- // if a pan control is not available, this will do nothing
- out.setPan(val);
- // if a pan control is not available this will report zero
- ;
- }
- else
- {
- text("The output doesn't have a pan control.", 5, 20);
- }
- }
- void stop()
- {
- // always close Minim audio classes when you are finished with them
- out.close();
- minim.stop();
- super.stop();
- }
1