My objective is to play a certain “wav” file depending upon which combination of midi keys a user presses.
I was able to get a basic sample generation working using the Jucedemo as a template, but only for a small amount of files and single keyboard presses by using the below snippet, but it doesn’t seem scalable. Also, it feels like I am restricted by the key-to-wave mapping within the SamplerSound class. As such, I do not think I am heading in the right direction.
[code] AudioFormatReader* audioReader = audioFormatManager.createReaderFor (File(String(“C:\Audio\test1.wav”)));
AudioFormatReader* audioReader2 = audioFormatManager.createReaderFor (File(String(“C:\Audio\test2.wav”)));
BitArray allNotes; allNotes.setRange (77, 1, true); synth.addSound (new SamplerSound (T("test1"), *audioReader,allNotes,77,0.1,0.1,10.0)); allNotes.setRange (79, 1, true); synth.addSound (new SamplerSound (T("test2"), *audioReader,allNotes,79,0.1,0.1,10.0));[/code]
For performance reasons, my idea is to read the various “wav” files and load them into memory during a class construction. Then, when the midi keys are being processed, I will identify the midi keys pressed, find the appropriate memory location, and use it to generate the sound. My wav files are approximately 500K in size. I have a total number of ~1,000 files.
- Is my idea of pre-loading the wavs a good approach considering the number of files and sizes involved?
- What classes would be most efficient to use for this? (to read the wav, to store the wav’s data, to generate the sound)
I have read and re-read the documentation and forum several times over and I now suffer from Juce library fatigue.