Skip to content

Commit 404b546

Browse files
ruguevaradrowaudio
authored andcommitted
Fix MIDI timestamp handling in FourOscPlugin for sample-accurate timing
The FourOscPlugin had a timing bug where MIDI timestamps (in seconds) were incorrectly cast to integers and treated as sample positions. This caused all MIDI events to be shifted toward the beginning of audio blocks, reducing timing accuracy. Changes: - Convert timestamps from seconds to samples using getSampleRate() - Use roundToInt() for proper rounding instead of truncation Impact: - Fixes sample-accurate MIDI timing for synthesizer voice triggering
1 parent 21bb52d commit 404b546

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/tracktion_engine/plugins/effects/tracktion_FourOscPlugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ void FourOscPlugin::applyToBuffer (const PluginRenderContext& fc)
14871487
{
14881488
for (auto m : *fc.bufferForMidiMessages)
14891489
{
1490-
int midiPos = int (m.getTimeStamp());
1490+
int midiPos = juce::roundToInt (m.getTimeStamp() * getSampleRate());
14911491
if (midiPos >= pos && midiPos < pos + thisBlock)
14921492
midi.addEvent (m, midiPos - pos);
14931493
}

0 commit comments

Comments
 (0)