I think I've found a good fix for the midi record / lookahead issue. I've
attached the patch. Comments?
I plan to do more testing before applying the patch... but for now I'm going to
bed. :-)
Peace,
Gabriel
diff --git a/libs/hydrogen/src/hydrogen.cpp b/libs/hydrogen/src/hydrogen.cpp
index 1bd3ff1..c1fa566 100644
--- a/libs/hydrogen/src/hydrogen.cpp
+++ b/libs/hydrogen/src/hydrogen.cpp
@@ -161,6 +161,7 @@ float m_fFXPeak_R[MAX_FX];
int m_nPatternStartTick = -1;
int m_nPatternTickPosition = 0;
+int m_nLookaheadFrames = 0;
// used in findPatternInTick
int m_nSongSizeInTicks = 0;
@@ -1050,6 +1051,7 @@ inline int audioEngine_updateNoteQueue( unsigned nFrames )
// lookahead. lookahead should be equal or greater than the
// nLeadLagFactor + nMaxTimeHumanize.
int lookahead = nLeadLagFactor + nMaxTimeHumanize + 1;
+ m_nLookaheadFrames = lookahead;
if ( framepos == 0
|| ( m_audioEngineState == STATE_PLAYING
&& m_pSong->get_mode() == Song::SONG_MODE
@@ -1826,7 +1828,24 @@ void Hydrogen::addRealtimeNote( int instrument,
return;
}
+ Pattern* currentPattern = NULL;
+ PatternList *pPatternList = m_pSong->get_pattern_list();
+ if ( ( m_nSelectedPatternNumber != -1 )
+ && ( m_nSelectedPatternNumber < ( int )pPatternList->get_size() ) ) {
+ currentPattern = pPatternList->get( m_nSelectedPatternNumber );
+ }
+
+ // Get current column and compensate for "lookahead"
unsigned int column = getTickPosition();
+ unsigned int lookaheadTicks = m_nLookaheadFrames
+ / m_pAudioDriver->m_transport.m_nTickSize;
+ if ( column >= lookaheadTicks ) {
+ column -= lookaheadTicks;
+ } else {
+ lookaheadTicks %= currentPattern->get_lenght();
+ column = (column + currentPattern->get_lenght() - lookaheadTicks)
+ % currentPattern->get_lenght();
+ }
realcolumn = getRealtimeTickPosition();
@@ -1841,13 +1860,6 @@ void Hydrogen::addRealtimeNote( int instrument,
unsigned position = column;
- Pattern* currentPattern = NULL;
- PatternList *pPatternList = m_pSong->get_pattern_list();
- if ( ( m_nSelectedPatternNumber != -1 )
- && ( m_nSelectedPatternNumber < ( int )pPatternList->get_size() ) ) {
- currentPattern = pPatternList->get( m_nSelectedPatternNumber );
- }
-
Instrument *instrRef = 0;
if ( song ) {
instrRef = song->get_instrument_list()->get( instrument );
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Hydrogen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel