Hello,
I would like to create a drum pad in JUCE, with 16 different pads each making a distinct sound from .caf files loaded in my app. In my MainComponent (Which extends from AudioAppComponent), I have 16 AudioTransportSources in which I load all my sounds into, and a put each of these AudioTransportSources into one MixerAudioSource. In my getNextAudioBlock(), I implement it by calling mixerAudioSource.getNextAudioBlock(bufferToFill);. My issue is that when I play ANY of the buttons, only the last loaded AudioTransportSource plays, even though I am indexing into the correct AudioTransportSource. Source code below. Also, the soundCreator.setNameAndLoad() function handles loading the correct file into an AudioTransportSource and returns that loaded AudioTransportSource.
void MainComponent::prepareToPlay (int samplesPerBlockExpected, double sampleRate)
{
mixerSource.prepareToPlay(samplesPerBlockExpected, sampleRate);
}
void MainComponent::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
{
bufferToFill.clearActiveBufferRegion();
mixerSource.getNextAudioBlock(bufferToFill);
}
void MainComponent::releaseResources()
{
mixerSource.releaseResources();
}
void MainComponent::fillStartDrumpad()
{
for (int drumpad = 0; drumpad < 48; drumpad++)
{
drumpadSounds[drumpad] = soundCreator.setNameAndLoad(currentProject.getPadConfig()[drumpad], &formatManager);
mixerSource.addInputSource(drumpadSounds[drumpad], true);
}
}