Skip to content

Instantly share code, notes, and snippets.

@DaveChambers
Forked from jatinchowdhury18/AudioLoading.cpp
Created September 27, 2023 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaveChambers/d383289000241590eaf9e81de48279bc to your computer and use it in GitHub Desktop.
Save DaveChambers/d383289000241590eaf9e81de48279bc 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