Skip to content

Commit

Permalink
fixed the RecordAndPlayback example which was hopelessly broken and d…
Browse files Browse the repository at this point in the history
…id not even compile.
  • Loading branch information
ddf committed Apr 25, 2012
1 parent fb0a6bb commit ea4ec44
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions examples/Advanced/RecordAndPlayback/RecordAndPlayback.pde
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
*/

import ddf.minim.*;
import ddf.minim.ugens.*;

Minim minim;

// for recording
AudioInput in;
AudioRecorder recorder;
AudioPlayer player;

// for playing back
AudioOutput out;
FilePlayer player;

void setup()
{
Expand All @@ -28,6 +34,9 @@ void setup()
// the file will be located in the sketch's data folder.
recorder = minim.createRecorder(in, "myrecording.wav", true);

// get an output we can playback the recording on
out = minim.getLineOut( Minim.STEREO );

textFont(createFont("Arial", 12));
}

Expand Down Expand Up @@ -80,13 +89,15 @@ void keyReleased()
// 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.
// save returns the recorded audio in an AudioRecording,
// which we can then play with an AudioPlayer
// save returns the recorded audio in an AudioRecordingStream,
// which we can then play with a FilePlayer
if ( player != null )
{
player.unpatch( out );
player.close();
}
player = recorder.save();
player = new FilePlayer( recorder.save() );
player.patch( out );
player.play();
}
}

0 comments on commit ea4ec44

Please sign in to comment.