Make MIDI timing sample-accurate
- currently only affects Vestige
- no idea whether this can also be used for Zyn and OpulenZ, I'm not sure if Zyn has any kind of mechanism for communicating frame offset to the synth, as for OpulenZ, @softrabbit would know the answer better
- basically, I made it happen by simply adding an extra parameter in the processMidi{In|Out} functions, which is 0 by default, and made the necessary changes in instrumentTrack and nph to utilize it
- I based this against 1.1 because I didn't think it's a very big change, and I don't see much possibility for things going wrong here, since we're basically just using the existing functionality in Vestige (there already was a frame offset being communicated to the remote plugin, just that it was always set to 0). However, if @tobydox thinks this is better to bump up to 1.2, I can rebase it for master...
This commit is contained in:
@@ -107,7 +107,8 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack,
|
||||
// send MidiNoteOn event
|
||||
m_instrumentTrack->processOutEvent(
|
||||
MidiEvent( MidiNoteOn, midiChannel(), midiKey(), midiVelocity( baseVelocity ) ),
|
||||
MidiTime::fromFrames( offset(), engine::framesPerTick() ) );
|
||||
MidiTime::fromFrames( offset(), engine::framesPerTick() ),
|
||||
offset() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,7 +337,8 @@ void NotePlayHandle::noteOff( const f_cnt_t _s )
|
||||
// send MidiNoteOff event
|
||||
m_instrumentTrack->processOutEvent(
|
||||
MidiEvent( MidiNoteOff, midiChannel(), midiKey(), 0 ),
|
||||
MidiTime::fromFrames( m_framesBeforeRelease, engine::framesPerTick() ) );
|
||||
MidiTime::fromFrames( m_framesBeforeRelease, engine::framesPerTick() ),
|
||||
_s );
|
||||
}
|
||||
|
||||
// inform attached components about MIDI finished (used for recording in Piano Roll)
|
||||
|
||||
@@ -73,7 +73,7 @@ void MidiController::updateName()
|
||||
|
||||
|
||||
|
||||
void MidiController::processInEvent( const MidiEvent& event, const MidiTime& time )
|
||||
void MidiController::processInEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset )
|
||||
{
|
||||
unsigned char controllerNum;
|
||||
switch( event.type() )
|
||||
|
||||
@@ -232,7 +232,7 @@ MidiEvent InstrumentTrack::applyMasterKey( const MidiEvent& event )
|
||||
|
||||
|
||||
|
||||
void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& time )
|
||||
void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset )
|
||||
{
|
||||
engine::mixer()->lock();
|
||||
|
||||
@@ -335,7 +335,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti
|
||||
break;
|
||||
}
|
||||
|
||||
if( eventHandled == false && instrument()->handleMidiEvent( event, time ) == false )
|
||||
if( eventHandled == false && instrument()->handleMidiEvent( event, time, offset ) == false )
|
||||
{
|
||||
qWarning( "InstrumentTrack: unhandled MIDI event %d", event.type() );
|
||||
}
|
||||
@@ -346,7 +346,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti
|
||||
|
||||
|
||||
|
||||
void InstrumentTrack::processOutEvent( const MidiEvent& event, const MidiTime& time )
|
||||
void InstrumentTrack::processOutEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset )
|
||||
{
|
||||
// do nothing if we do not have an instrument instance (e.g. when loading settings)
|
||||
if( m_instrument == NULL )
|
||||
@@ -366,10 +366,10 @@ void InstrumentTrack::processOutEvent( const MidiEvent& event, const MidiTime& t
|
||||
{
|
||||
if( m_runningMidiNotes[key] > 0 )
|
||||
{
|
||||
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOff, midiPort()->realOutputChannel(), key, 0 ), time );
|
||||
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOff, midiPort()->realOutputChannel(), key, 0 ), time, offset );
|
||||
}
|
||||
++m_runningMidiNotes[key];
|
||||
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOn, midiPort()->realOutputChannel(), key, event.velocity() ), time );
|
||||
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOn, midiPort()->realOutputChannel(), key, event.velocity() ), time, offset );
|
||||
|
||||
emit newNote();
|
||||
}
|
||||
@@ -381,12 +381,12 @@ void InstrumentTrack::processOutEvent( const MidiEvent& event, const MidiTime& t
|
||||
if( key >= 0 && key < NumKeys && --m_runningMidiNotes[key] <= 0 )
|
||||
{
|
||||
m_runningMidiNotes[key] = qMax( 0, m_runningMidiNotes[key] );
|
||||
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOff, midiPort()->realOutputChannel(), key, 0 ), time );
|
||||
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOff, midiPort()->realOutputChannel(), key, 0 ), time, offset );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
m_instrument->handleMidiEvent( transposedEvent, time );
|
||||
m_instrument->handleMidiEvent( transposedEvent, time, offset );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user