Search in sources :

Example 1 with RecordToSample

use of net.beadsproject.beads.ugens.RecordToSample in project narchy by automenta.

the class AudioContext method record.

/**
 * Tells the AudioContext to record all output for the given millisecond
 * duration, kill the AudioContext, and save the recording to the given file
 * path. This is a convenient way to make quick recordings, but may not suit
 * every circumstance.
 *
 * @param timeMS   the time in milliseconds to record for.
 * @param filename the filename to save the recording to.
 * @throws IOException Signals that an I/O exception has occurred.
 * @see RecordToSample recorder
 * @see Sample sample
 */
public void record(double timeMS, String filename) throws Exception {
    Sample s = new Sample(timeMS, audioFormat.outputs, audioFormat.sampleRate);
    RecordToSample r;
    try {
        r = new RecordToSample(this, s);
        r.in(out);
        out.dependsOn(r);
        r.start();
        r.after(new AudioContextStopTrigger(this));
    } catch (Exception e) {
    /* won't happen */
    }
    while (isRunning()) {
    }
    s.write(filename);
}
Also used : AudioContextStopTrigger(net.beadsproject.beads.events.AudioContextStopTrigger) Sample(net.beadsproject.beads.data.Sample) RecordToSample(net.beadsproject.beads.ugens.RecordToSample) RecordToSample(net.beadsproject.beads.ugens.RecordToSample) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 Sample (net.beadsproject.beads.data.Sample)1 AudioContextStopTrigger (net.beadsproject.beads.events.AudioContextStopTrigger)1 RecordToSample (net.beadsproject.beads.ugens.RecordToSample)1