2 * MidiImport.h - support for importing MIDI-files
4 * Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
25 #ifndef _MIDI_IMPORT_H
26 #define _MIDI_IMPORT_H
28 #include <QtCore/QString>
29 #include <QtCore/QPair>
30 #include <QtCore/QVector>
33 #include "ImportFilter.h"
36 class MidiImport
: public ImportFilter
39 MidiImport( const QString
& _file
);
40 virtual ~MidiImport();
42 virtual PluginView
* instantiateView( QWidget
* )
49 virtual bool tryImport( trackContainer
* _tc
);
51 bool readSMF( trackContainer
* _tc
);
52 bool readRIFF( trackContainer
* _tc
);
53 bool readTrack( int _track_end
, QString
& _track_name
);
58 inline int readInt( int _bytes
)
68 value
= ( value
<< 8 ) | c
;
72 inline Sint32
read32LE( void )
74 int value
= readByte();
75 value
|= readByte() << 8;
76 value
|= readByte() << 16;
77 value
|= readByte() << 24;
80 inline int readVar( void )
87 value
= ( value
<< 7 ) | ( c
& 0x7f );
91 value
= ( value
<< 7 ) | ( c
& 0x7f );
95 value
= ( value
<< 7 ) | c
;
103 return( !file().atEnd() ? value
: -1 );
106 inline Sint32
readID( void )
108 return( read32LE() );
110 inline void skip( int _bytes
)
120 typedef QVector
<QPair
<int, midiEvent
> > eventVector
;
121 eventVector m_events
;
122 int m_timingDivision
;