Beginner user-Minim questions
in
Core Library Questions
•
2 years ago
Hi everyone. I was hoping to get some help with my code please. I'm a fairly new user to processing and don't just want the answer straight forward; i would like this to be a learning process as much as an answer to the question. Ive been trying to mash up some bits of code ive found online and in the libraries. Here's the gist of what i'm trying to do. A user speaks into a microphone. This audio is fed into processing and the audio is converted and output on a screen in another room as sound waves. This part I have down pretty well (I still haven't figured out how to assign a color range to the sound waves yet...). The second part of the equation here is that the sound input will then be played in a third room as a live (or as close to it as possible) feed. I would like the audio output into room #3 to be distorted so as to maintain the anonymity of the original user, in room #1. If anyone could help me figure out how to do this second part of taking the live audio in, distorting it, then playing it elsewhere 'live' that would be incredible. Here is what i've got so far.
Thanks a million.
Evan
Columbia GSAPP
- import ddf.minim.*;
- Minim minim;
- AudioInput in;
- AudioRecorder recorder;
- int x = 30;
- PFont fontA;
- void setup()
- {
- size(1000, 800, P2D);
- textMode(SCREEN);
- minim = new Minim(this);
- minim.debugOn();
- // get a stereo line-in: sample buffer length of 2048
- // default sample rate is 44100, default bit depth is 16
- in = minim.getLineIn(Minim.STEREO, 1000);
- // create a recorder that will record from the input to the filename specified, using buffered recording
- // buffered recording means that all captured audio will be written into a sample buffer
- // then when save() is called, the contents of the buffer will actually be written to a file
- // the file will be located in the sketch's root folder.
- recorder = minim.createRecorder(in, "01.wav", true);
- // textFont(createFont("SanSerif", 12));
- // Load the font. Fonts must be placed within the data
- // directory of your sketch. Use Tools > Create Font
- // to create a distributable bitmap font.
- // For vector fonts, use the createFont() function.
- fontA = loadFont("Ziggurat-HTF-Black-32.vlw");
- // Set the font and its size (in units of pixels)
- textFont(fontA, 30);
- }
- void draw()
- {
- background(0);
- stroke(255,0,0);
- // Use fill() to change the value or color of the text
- // fill(0);
- text("Evan Bauer_M.Fornabai_Sp.2009", 10, 650);
- // draw the waveforms
- // the values returned by left.get() and right.get() will be between -1 and 1,
- // so we need to scale them up to see the waveform
- for(int i = 0; i < in.bufferSize() - 1; i++)
- {
- line(i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*200);
- line(i, 150 + in.right.get(i)*50, i+1, 150 + in.left.get(i+1)*200);
- line(i, 250 + in.right.get(i)*50, i+1, 250 + in.left.get(i+1)*200);
- line(i, 350 + in.right.get(i)*50, i+1, 350 + in.left.get(i+1)*200);
- line(i, 450 + in.right.get(i)*50, i+1, 450 + in.left.get(i+1)*200);
- line(i, 550 + in.right.get(i)*50, i+1, 550 + in.left.get(i+1)*200);
- line(i, 650 + in.right.get(i)*50, i+1, 650 + in.left.get(i+1)*200);
- line(i, 750 + in.right.get(i)*50, i+1, 750 + in.left.get(i+1)*200);
- }
- if ( recorder.isRecording() )
- {
- text("Not Recording...", 5, 50);
- }
- else
- {
- text("Recording...", 5, 50);
- }
- }
- void keyReleased()
- {
- if ( key == 'r' )
- {
- // to indicate that you want to start or stop capturing audio data, you must call
- // beginRecord() and endRecord() on the AudioRecorder object. You can start and stop
- // as many times as you like, the audio data will be appended to the end of the buffer
- // (in the case of buffered recording) or to the end of the file (in the case of streamed recording).
- if ( recorder.isRecording() )
- {
- recorder.endRecord();
- }
- else
- {
- recorder.beginRecord();
- }
- }
- if ( key == 's' )
- {
- // we've filled the file out buffer,
- // now write it to the file we specified in createRecorder
- // in the case of buffered recording, if the buffer is large,
- // this will appear to freeze the sketch for sometime
- // in the case of streamed recording,
- // it will not freeze as the data is already in the file and all that is being done
- // is closing the file.
- // the method returns the recorded audio as an AudioRecording,
- // see the example AudioRecorder >> RecordAndPlayback for more about that
- recorder.save();
- println("Done saving.");
- }
- }
- void stop()
- {
- // always close Minim audio classes when you are done with them
- in.close();
- minim.stop();
- super.stop();
- }
1