Skip to content

Instantly share code, notes, and snippets.

@zymawy
Forked from jatinchowdhury18/AudioLoading.cpp
Created January 10, 2023 20:25
Show Gist options
  • Save zymawy/6aaa5d186019bb36ca93da51cfbb8f2b to your computer and use it in GitHub Desktop.
Save zymawy/6aaa5d186019bb36ca93da51cfbb8f2b to your computer and use it in GitHub Desktop.
Loading audio files from BinaryData (JUCE/C++)
// loading audio file "guitar.wav"
AudioFormatManager formatManager;
formatManager.registerBasicFormats();
// normal way
File audioFile ("/path/to/guitar.wav");
FileInputStream* input = audioFile.createInputStream();
AudioFormatReader* reader = formatManager.createReaderFor (input);
// from the reader we can load into an audio buffer, etc...
// From BinaryData
MemoryInputStream* input = new MemoryInputStream (BinaryData::guitar_wav, BinaryData::guitar_wavSize, false);
AudioFormatReader* reader = formatManager.createReaderFor (input);
// Don't forget to clean up pointers...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment