In a sampler/synth, is it possible to have each midi note play two audio files and determine the volume of each of those audio files? For example, user hits MIDI note C and the sampler would play audiofile1 at 40% and audiofile2 at 60%.
So, with some code such as this:
juce::OwnedArray<juce::Synthesiser> synth;
juce::SynthesiserSound::Ptr sound1 = new juce::SamplerSound ("audiofile1", *formatReader, midiNotes, 0x40, 0.0, 0.0, 5.0);
juce::SynthesiserSound::Ptr sound1 = new juce::SamplerSound ("audiofile2", *formatReader, midiNotes, 0x40, 0.0, 0.0, 5.0);
synth[channel]->addSound(sound1);
What would I do next to get sound2 to be played simultaneously and how can I blend the two audio files?
Thank you in advance.
cpr2323
January 25, 2022, 7:27pm
#2
Two Synth objects into a mixer object… or create your own copy of the Synth class and add a second file, but you will still need to mix them. btw, there is bug in the code you posted. you are reusing sound1
for audiofile2
I haven’t used a mixer object yet. Do you know of any examples or tutorials that would show how to use it to blend synth objects?
cpr2323
January 26, 2022, 1:38am
#4
You can start with the docs: JUCE: MixerAudioSource Class Reference
I’ll post again if I find any example code for you.
cpr2323
January 26, 2022, 1:43am
#5
This post has some code along with it’s question. I don’t know if it will be helpful.
Made a game and are trying to add multiple sound effects, all from binary resource wav files. These multiple sound effects may or may not be playing while another is playing, and sometimes while one specific is playing, it may be instructed to play again (restarted), and optimally if I restart again, any earlier same sound that has not finished should continue playing until end also.
I figure that I eventually should instead be using a polyphonic synthesizer, but for now until I learned a lot m…