We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I took some codes off the internet for an oscilloscope, but I'm having trouble making copies of it and moving it around. I want to create duplicates of the oscilloscope and scatter them all over the screen. I'm also trying to manipulate the shape of the waveforms that are created by the audio input. How do I do these? Please point me into the right direction. Thank you all in advance!
John
Answers
What problems do you have? In regards to the audio input, did you have a look at the examples that come with P5's libs?
It is easier if you post your code btw.
Kf
This is the code. Right now it's just a single oscilloscope. I want to duplicate it and be able to position them anywhere I want on the screen.
import ddf.minim.analysis.*; import ddf.minim.*; import ddf.minim.signals.*;
Minim minim; AudioInput in;
float gain = 200; int tbase = 1024; float[] myBuffer;
void setup() { size(1280, 800, P3D);
minim = new Minim(this); in = minim.getLineIn(Minim.MONO,2048);
myBuffer = new float[in.bufferSize()]; }
void draw() { background(0); stroke(255); // draw the output waveforms, so there's something to look at // first grab a stationary copy for (int i = 50; i < in.bufferSize(); ++i) { myBuffer[i] = in.left.get(i); } // find trigger point as largest +ve slope in first 1/4 of buffer int offset = 50; float maxdx = 50; for(int i = 50; i < myBuffer.length/4; ++i) { float dx = myBuffer[i+1] - myBuffer[i]; if (dx > maxdx) { offset = i; maxdx = dx; } } // plot out that waveform int mylen = min(tbase, myBuffer.length-offset); for(int i = 0; i < mylen - 1; i++) { float x1 = map(i+1, 0, tbase, 0, width); float x2 = map(i, 0, tbase, 0, width); line(x1, 100 - myBuffer[i+offset]gain, x2, 100 - myBuffer[i+1+offset]gain); } }
void stop() { // always close Minim audio classes when you finish with them in.close(); minim.stop();
super.stop(); }
Edit post, select code and hit ctrl+o to properly format your code.
Kf
This modifications are based on a recent post.
https://forum.processing.org/two/discussion/comment/77986/#Comment_77986
I hope this helps,
Kf
Thank you, Kf! I figured it out after playing with the code for a while, your modified version of the code is also helpful! thanks again!
John