Skip to content

Instantly share code, notes, and snippets.

@fesor
Last active August 29, 2015 14:03
Show Gist options
  • Save fesor/9cb75622a6f32bb7c3cd to your computer and use it in GitHub Desktop.
Save fesor/9cb75622a6f32bb7c3cd to your computer and use it in GitHub Desktop.
Audio encoding/decoding
import audio;
auto soundDecoder = new Decoder(new BufferedFile("./mywave.mp3"));
// Decoder should implements opApply method;
// http://dlang.org/statement.html#opApply
foreach(ulong frameNumber, FrameInfo frame; soundDecoder) {
// so something usefull, FFT for example
doStuff(frame.data);
}
// or
soundDecoder.rewind();
FrameInfo frame = soundDecoder.getFrame();
// or
soundDecoder.rewind();
FrameInfo[] frames = soundDecoder.getAllFrames();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment