better tempo-handling and note-alignment

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@490 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2007-07-17 15:47:38 +00:00
parent 29b3f944e5
commit 27e0df82c3
4 changed files with 31 additions and 5 deletions

View File

@@ -1,3 +1,11 @@
2007-07-17 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* include/midi.h:
* plugins/midi_import/midi_import.h:
* plugins/midi_import/midi_import.cpp:
- initial incomplete handling for tempo-events
- properly aligned imported notes
2007-07-16 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* src/core/mixer.cpp:

View File

@@ -58,7 +58,8 @@ enum midiEventTypes
MIDI_ACTIVE_SENSING = 0xFE,
MIDI_SYSTEM_RESET = 0xFF,
// meta event - for midi files only
MIDI_META_EVENT = 0xFF
MIDI_META_EVENT = 0xFF,
MIDI_TEMPO = 0xFF51
} ;

View File

@@ -72,7 +72,10 @@ plugin::descriptor midiimport_plugin_descriptor =
midiImport::midiImport( const QString & _file ) :
importFilter( _file, &midiimport_plugin_descriptor )
importFilter( _file, &midiimport_plugin_descriptor ),
m_events(),
m_smpteTiming( FALSE ),
m_tempo( 120 )
{
}
@@ -270,8 +273,8 @@ invalid_format:
NOTES_PER_OCTAVE * OCTAVES &&
keys[ev.key()][0] >= 0 )
{
note n( midiTime( ( tick - keys[ev.key()][0] ) / 10 ),
midiTime( keys[ev.key()][0] / 10 ),
note n( midiTime( ( tick - keys[ev.key()][0] ) * 16 / m_tempo ),
midiTime( keys[ev.key()][0] * 16 / m_tempo ),
(tones)( ev.key() % NOTES_PER_OCTAVE ),
(octaves)( ev.key() / NOTES_PER_OCTAVE ),
keys[ev.key()][1] * 100 / 128 );
@@ -280,6 +283,10 @@ invalid_format:
}
break;
case MIDI_TEMPO:
break;
default:
/* printf( "Unhandled event: %#x\n",
ev.m_type );*/
@@ -485,6 +492,15 @@ bool FASTCALL midiImport::readTrack( int _track_end )
}
else
{
int tempo = readByte() << 16;
tempo |= readByte() << 8;
tempo |= readByte();
tempo = ( 60*1000*1000 ) / tempo;
m_events.push_back( qMakePair( tick,
midiEvent( MIDI_TEMPO,
0,
tempo,
0 ) ) );
/* event = new_event(track, 0);
event->type = SND_SEQ_EVENT_TEMPO;
event->port = port;
@@ -493,7 +509,7 @@ bool FASTCALL midiImport::readTrack( int _track_end )
event->data.tempo |= read_byte() << 8;
event->data.tempo |= read_byte();
skip( len -3 );*/
skip( len );
skip( len-3 );
}
break;

View File

@@ -134,6 +134,7 @@ private:
typedef vvector<QPair<int, midiEvent> > eventVector;
eventVector m_events;
bool m_smpteTiming;
int m_tempo;
} ;