How to add a wav file in an AudioApplication


#1

Hi, I’m developing an app for v-drums players and I need to play a simple wav file to test the functionalities of the app (OS X).
I’m currently using

File sample = *new File("/users/vdsamples/kick.wav");

But I need to include the file in the app, and then recall as File before passing it at the AudioFormatReader*.

Thanks in advance!


#2

Any particular reason you need to recall the audio file’s File? You could add the audio file as a binary resource using the Projucer (which satisfies But I need to include the file in the app), and load it as such:

AudioFormatManager afm;
afm.registerBasicFormats();
ScopedPointer<AudioFormatReader> reader = afm.createReaderFor (new MemoryInputStream (BinaryData::myaudiofile_wav, BinaryData::myaudiofile_wavSize, false));

Also, I’m not sure what this is File sample = *new File("/users/vdsamples/kick.wav"); except a seriously massive misunderstanding of fundamental C++! Please read up on the heap and stack…

Here are proper stack usage examples:

File sample ("/users/vdsamples/kick.wav");

or

auto sample = File ("/users/vdsamples/kick.wav");

#3

Thank you so much!!
It’s exactly what i needed!

(I’m hot very good in C++, but making JCUE apps let me learn…)