hello again – returning to this thread because I’ve got the audioBuffers working, now I need to figure out how to update the timestamps of my midiBuffer correctly… @daniel I based this off the code you provided, it was super helpful! This is what I have so far in my processBlock:
void AudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
int samplesLeft = buffer.getNumSamples();
int startSample = 0;
while (samplesLeft > 0)
{
const int numSamples = samplesLeft >= MAX_BUFFERSIZE ? MAX_BUFFERSIZE : samplesLeft; // MAX_BUFFERSIZE is just a global macro I've defined
AudioBuffer<float> proxy (buffer.getArrayOfWritePointers(), buffer.getNumChannels(), startSample, numSamples);
processBlockPrivate(proxy, numSamples, midiMessages);
// update midi buffer timestamps:
// for all midiMessages from startSample to the end of the midiBuffer, subtract startSample from their timestamps
{
auto midiIterator = midiMessages.findNextSamplePosition(startSample);
std::for_each (midiIterator,
midiMessages.cend(),
[&] (const MidiMessageMetadata& meta)
{
MidiMessage current = meta.getMessage();
current.setTimeStamp(current.getTimeStamp() - startSample);
});
}
samplesLeft -= numSamples;
startSample += numSamples;
}
};
Is this the correct approach? I’m a little bit confused about whether or not MidiMessage timestamps should correspond exactly to sample numbers…