diff --git a/data/locale/en.ts b/data/locale/en.ts
index 43083bf0385..2b05adab4d0 100644
--- a/data/locale/en.ts
+++ b/data/locale/en.ts
@@ -227,9 +227,6 @@ If you're interested in translating LMMS in another language or want to imp
-
-
- AudioJack::setupWidget
@@ -2248,9 +2245,6 @@ You can remove and move FX channels in the context menu, which is accessed by ri
-
-
- FxMixerView::FxChannelView
@@ -5805,6 +5799,13 @@ Reason: "%2"
+
+ QGuiApplication
+
+
+
+
+
QWidget
@@ -6721,11 +6722,12 @@ Please make sure you have read-permission to the file and the directory containi
-
-
- TrackContainer::TrackContainer
-
+
+
+
+
+
@@ -7744,7 +7746,7 @@ Please make sure you have read-permission to the file and the directory containi
commonReader
-
+
diff --git a/include/SmfMidiChannel.h b/include/SmfMidiChannel.h
index e4e5abbd9a7..721748ea5e0 100644
--- a/include/SmfMidiChannel.h
+++ b/include/SmfMidiChannel.h
@@ -52,6 +52,7 @@ class SmfMidiChannel
SmfMidiChannel * create( TrackContainer* tc, QString tn );
void addNote( Note & n );
+ void setName(QString tn );
};
diff --git a/plugins/SmfImport/CMakeLists.txt b/plugins/SmfImport/CMakeLists.txt
index c161b1deb27..a0394fa7001 100644
--- a/plugins/SmfImport/CMakeLists.txt
+++ b/plugins/SmfImport/CMakeLists.txt
@@ -1,18 +1,19 @@
# Importer for SMF-like file format, such as .mid, .ove, .wrk
-INCLUDE(BuildPlugin)
-
# check for drumstick-file
PKG_CHECK_MODULES(DRUMSTICK_FILE REQUIRED drumstick-file>=0.5.0)
IF(NOT DRUMSTICK_FILE_FOUND)
- MESSAGE(FATAL_ERROR "LMMS requires libdrumstick-file and drumstick-dev >= 0.5.0 - please install, remove CMakeCache.txt and try again!")
-ENDIF(NOT DRUMSTICK_FILE_FUND)
+ MESSAGE(FATAL_ERROR "LMMS requires libdrumstick-file and drumstick-dev >= 0.5.0 - please install, remove CMakeCache.txt and try again!")
+ENDIF(NOT DRUMSTICK_FILE_FOUND)
-IF(LMMS_BUILD_APPLE)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
-ENDIF(LMMS_BUILD_APPLE)
+INCLUDE(BuildPlugin)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -ldrumstick-file -Wno-reorder")
+LINK_DIRECTORIES(${DRUMSTICK_FILE_LIBDIR})
+INCLUDE_DIRECTORIES(${DRUMSTICK_FILE_INCLUDEDIR})
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
BUILD_PLUGIN(smfimport SmfImport.cpp commonReader.cpp midiReader.cpp oveReader.cpp wrkReader.cpp
MOCFILES SmfImport.h commonReader.h midiReader.h oveReader.h wrkReader.h )
+
+TARGET_LINK_LIBRARIES(smfimport ${DRUMSTICK_LIBRARIES})
diff --git a/plugins/SmfImport/SmfImport.cpp b/plugins/SmfImport/SmfImport.cpp
index 04e5ff0b43b..9b83e9008de 100644
--- a/plugins/SmfImport/SmfImport.cpp
+++ b/plugins/SmfImport/SmfImport.cpp
@@ -50,26 +50,26 @@
extern "C"
{
-Plugin::Descriptor PLUGIN_EXPORT smfimport_plugin_descriptor =
-{
- STRINGIFY( PLUGIN_NAME ),
- "SMF Import",
- QT_TRANSLATE_NOOP( "pluginBrowser",
- "Filter for importing MIDI-like files into LMMS" ),
- "Tony Chyi ",
- 0x0100,
- Plugin::ImportFilter,
- NULL,
- NULL,
- NULL
-} ;
+ Plugin::Descriptor PLUGIN_EXPORT smfimport_plugin_descriptor =
+ {
+ STRINGIFY( PLUGIN_NAME ),
+ "SMF Import",
+ QT_TRANSLATE_NOOP( "pluginBrowser",
+ "Filter for importing MIDI-like files into LMMS" ),
+ "Tony Chyi ",
+ 0x0100,
+ Plugin::ImportFilter,
+ NULL,
+ NULL,
+ NULL
+ } ;
}
-SmfImport::SmfImport(const QString &_file):
- ImportFilter(_file, &smfimport_plugin_descriptor)
+SmfImport::SmfImport( const QString &_file ):
+ ImportFilter( _file, &smfimport_plugin_descriptor )
{
}
@@ -79,37 +79,40 @@ SmfImport::~SmfImport()
closeFile();
}
-bool SmfImport::tryImport(TrackContainer *tc)
+bool SmfImport::tryImport( TrackContainer *tc )
{
#ifdef LMMS_HAVE_FLUIDSYNTH
+
if( gui != NULL && ConfigManager::inst()->defaultSoundfont().isEmpty() )
{
QMessageBox::information( gui->mainWindow(),
- tr( "Setup incomplete" ),
- tr( "You do not have set up a default soundfont in "
- "the settings dialog (Edit->Settings). "
- "Therefore no sound will be played back after "
- "importing this MIDI file. You should download "
- "a General MIDI soundfont, specify it in "
- "settings dialog and try again." ) );
+ tr( "Setup incomplete" ),
+ tr( "You do not have set up a default soundfont in "
+ "the settings dialog (Edit->Settings). "
+ "Therefore no sound will be played back after "
+ "importing this MIDI file. You should download "
+ "a General MIDI soundfont, specify it in "
+ "settings dialog and try again." ) );
}
+
#else
+
if( gui )
{
QMessageBox::information( gui->mainWindow(),
- tr( "Setup incomplete" ),
- tr( "You did not compile LMMS with support for "
- "SoundFont2 player, which is used to add default "
- "sound to imported MIDI files. "
- "Therefore no sound will be played back after "
- "importing this MIDI file." ) );
+ tr( "Setup incomplete" ),
+ tr( "You did not compile LMMS with support for "
+ "SoundFont2 player, which is used to add default "
+ "sound to imported MIDI files. "
+ "Therefore no sound will be played back after "
+ "importing this MIDI file." ) );
}
+
return false;
#endif
- return true;
- if( openFile() == false )
+ if( !openFile() )
{
return false;
}
@@ -119,47 +122,47 @@ bool SmfImport::tryImport(TrackContainer *tc)
switch( readID() )
{
case makeID( 'M', 'T', 'h', 'd' ):
- printf( "SmfImport::tryImport(): found MThd\n");
+ printf( "SmfImport::tryImport(): found MThd\n" );
return readSMF( tc );
case makeID( 'R', 'I', 'F', 'F' ):
- printf( "SmfImport::tryImport(): found RIFF\n");
+ printf( "SmfImport::tryImport(): found RIFF\n" );
return readRIFF( tc );
case makeID( 'O', 'V', 'S', 'C' ):
- printf("SmfImport::tryImport(): found OVSC\n");
+ printf( "SmfImport::tryImport(): found OVSC\n" );
return readOve( tc );
- case makeID( 'C', 'A', 'K', 'E'):
- printf("SmfImport::tryImport(): found CAKEWALK\n");
+ case makeID( 'C', 'A', 'K', 'E' ):
+ printf( "SmfImport::tryImport(): found CAKEWALK\n" );
return readWrk( tc );
default:
printf( "MidiImport::tryImport(): not a Standard MIDI "
- "file\n" );
+ "file\n" );
return false;
}
}
-bool SmfImport::readWrk(TrackContainer *tc)
+bool SmfImport::readWrk( TrackContainer *tc )
{
- wrkReader mr(tc);
- mr.read(filename);
+ wrkReader mr( tc );
+ mr.read( filename );
return true;
}
-bool SmfImport::readOve( TrackContainer *tc)
+bool SmfImport::readOve( TrackContainer *tc )
{
- oveReader mr(tc);
- mr.read(filename);
+ oveReader mr( tc );
+ mr.read( filename );
return true;
}
-bool SmfImport::readSMF( TrackContainer *tc)
+bool SmfImport::readSMF( TrackContainer *tc )
{
- midiReader mr(tc);
- mr.read(filename);
+ midiReader mr( tc );
+ mr.read( filename );
return true;
}
@@ -172,8 +175,8 @@ bool SmfImport::readRIFF( TrackContainer* tc )
if( readID() != makeID( 'R', 'M', 'I', 'D' ) )
{
invalid_format:
- qWarning( "MidiImport::readRIFF(): invalid file format" );
- return false;
+ qWarning( "MidiImport::readRIFF(): invalid file format" );
+ return false;
}
// search for "data" chunk
@@ -181,20 +184,24 @@ bool SmfImport::readRIFF( TrackContainer* tc )
{
const int id = readID();
const int len = read32LE();
+
if( file().atEnd() )
{
data_not_found:
- qWarning( "MidiImport::readRIFF(): data chunk not found" );
- return false;
+ qWarning( "MidiImport::readRIFF(): data chunk not found" );
+ return false;
}
+
if( id == makeID( 'd', 'a', 't', 'a' ) )
{
- break;
+ break;
}
+
if( len < 0 )
{
- goto data_not_found;
+ goto data_not_found;
}
+
skip( ( len + 1 ) & ~1 );
}
@@ -203,6 +210,7 @@ bool SmfImport::readRIFF( TrackContainer* tc )
{
goto invalid_format;
}
+
return readSMF( tc );
}
@@ -216,11 +224,11 @@ extern "C"
{
// necessary for getting instance out of shared lib
-Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data )
-{
- return new SmfImport( QString::fromUtf8(
- static_cast( _data ) ) );
-}
+ Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data )
+ {
+ return new SmfImport( QString::fromUtf8(
+ static_cast( _data ) ) );
+ }
}
diff --git a/plugins/SmfImport/SmfImport.h b/plugins/SmfImport/SmfImport.h
index 8b080e13d20..9e0145f5abf 100644
--- a/plugins/SmfImport/SmfImport.h
+++ b/plugins/SmfImport/SmfImport.h
@@ -35,38 +35,43 @@
class SmfImport : public ImportFilter
{
- Q_OBJECT
+ Q_OBJECT
public:
- SmfImport(const QString & _file);
+ SmfImport( const QString & _file );
virtual ~SmfImport();
- virtual PluginView * instantiateView(QWidget *)
+ virtual PluginView * instantiateView( QWidget * )
{
return NULL;
}
private:
- virtual bool tryImport(TrackContainer *tc);
+ virtual bool tryImport( TrackContainer *tc );
bool readSMF( TrackContainer* tc );
bool readRIFF( TrackContainer* tc );
- bool readOve( TrackContainer* tc);
- bool readWrk( TrackContainer* tc);
+ bool readOve( TrackContainer* tc );
+ bool readWrk( TrackContainer* tc );
void error();
inline int readInt( int _bytes )
{
int c, value = 0;
+
do
{
c = readByte();
+
if( c == -1 )
{
return( -1 );
}
+
value = ( value << 8 ) | c;
- } while( --_bytes );
+ }
+ while( --_bytes );
+
return( value );
}
inline int read32LE()
@@ -81,26 +86,31 @@ class SmfImport : public ImportFilter
{
int c = readByte();
int value = c & 0x7f;
+
if( c & 0x80 )
{
c = readByte();
value = ( value << 7 ) | ( c & 0x7f );
+
if( c & 0x80 )
{
c = readByte();
value = ( value << 7 ) | ( c & 0x7f );
+
if( c & 0x80 )
{
c = readByte();
value = ( value << 7 ) | c;
+
if( c & 0x80 )
{
return -1;
}
}
}
- }
- return( !file().atEnd() ? value : -1 );
+ }
+
+ return( !file().atEnd() ? value : -1 );
}
inline int readID()
diff --git a/plugins/SmfImport/commonReader.cpp b/plugins/SmfImport/commonReader.cpp
index 7397842ea3d..8e6018b2540 100644
--- a/plugins/SmfImport/commonReader.cpp
+++ b/plugins/SmfImport/commonReader.cpp
@@ -42,7 +42,7 @@
#include "commonReader.h"
-#define CHECK_TRACK track = track==noTrack? chan:track;
+#define CHECK_TRACK track = ( track == noTrack ? chan : track );
#define PITCH_RANGE_RPN_CODE {track, 0}
#define CC_RPN_SEND rpn_data[0] = track; \
rpn_data[1] = value;
@@ -52,34 +52,35 @@
const int note_pitch = channel + 1; \
const int note_vol = note_pitch + 1;
-commonReader::commonReader(TrackContainer *tc, const char *hintText):
- m_tc(tc),
- beatsPerTact(4),
+commonReader::commonReader( TrackContainer *tc, const QString hintText ):
+ m_tc( tc ),
+ beatsPerTact( 4 ),
pitchBendMultiply( defaultPitchRange ),
- pd(TrackContainer::tr(hintText), TrackContainer::tr("Cancel"),
- 0, preTrackSteps, gui->mainWindow())
+ pd( hintText, QGuiApplication::tr( "Cancel" ),
+ 0, preTrackSteps, gui->mainWindow() )
{
+ m_currentTrackName.first = -1;
pd.setWindowTitle( TrackContainer::tr( "Please wait..." ) );
- pd.setWindowModality(Qt::WindowModal);
+ pd.setWindowModality( Qt::WindowModal );
pd.setMinimumDuration( 0 );
- pd.setValue(0);
+ pd.setValue( 0 );
MeterModel & timeSigMM = Engine::getSong()->getTimeSigModel();
timeSigNumeratorPat = AutomationPattern::globalAutomationPattern(
- &timeSigMM.numeratorModel());
+ &timeSigMM.numeratorModel() );
timeSigDenominatorPat = AutomationPattern::globalAutomationPattern(
- &timeSigMM.denominatorModel());
+ &timeSigMM.denominatorModel() );
ticksPerBeat = DefaultTicksPerTact / beatsPerTact;
- if(note_list.size() != 0)
+ if( note_list.size() )
note_list.clear();
- if(rpn_msbs.size() != 0)
+ if( rpn_msbs.size() )
rpn_msbs.clear();
- if(rpn_lsbs.size() != 0)
+ if( rpn_lsbs.size() )
rpn_lsbs.clear();
AutomationPattern * tap = m_tc->tempoAutomationPattern();
@@ -88,11 +89,13 @@ commonReader::commonReader(TrackContainer *tc, const char *hintText):
commonReader::~commonReader()
{
- printf("destory fileReader\n");
+ printf( "destory fileReader\n" );
- for( int c=0; c<256; c++){
- if( !chs[c].hasNotes && chs[c].it ) {
- printf(" Should remove empty track\n");
+ for( int c = 0; c < 256; c++ )
+ {
+ if( !chs[c].hasNotes && chs[c].it )
+ {
+ printf( " Should remove empty track\n" );
// must delete trackView first - but where is it?
//m_tc->removeTrack( chs[c].it );
//chs[c].it->deleteLater();
@@ -101,9 +104,19 @@ commonReader::~commonReader()
}
-void commonReader::CCHandler(long tick, int track, int ctl, int value)
+void commonReader::CCHandler( long tick, int track, int ctl, int value )
{
- QString trackName = QString( tr( "Track" ) + " %1").arg(track+1);
+ QString trackName;
+
+ if( m_currentTrackName.first == m_currentTrack )
+ {
+ trackName = m_currentTrackName.second;
+ }
+ else
+ {
+ trackName = TrackContainer::tr( "Track %1" ).arg( track + 1 );
+ }
+
SmfMidiChannel * ch = chs[track].create( m_tc, trackName );
AutomatableModel * objModel = NULL;
int * rpn_data = new int[2];
@@ -115,77 +128,87 @@ void commonReader::CCHandler(long tick, int track, int ctl, int value)
{
switch( ctl )
{
- case bankEventId:
- if( ch->isSF2 && ch->it_inst )
- {
- objModel = ch->it_inst->childModel( "bank" );
- printf("Tick=%ld: BANK SELECT %d\n", tick, value);
- }
- break;
-
- case 6:
- for(int c=0; c < rpn_msbs.size(); c++)
- {
- rpn_data = rpn_msbs[c];
- if(rpn_data[0] == track && rpn_data[1] == 0)
- {
- flag_rpn_msb = true;
- rpn_msbs.removeAt(c);
- delete rpn_data;
- }
- }
- for(int c=0; c < rpn_lsbs.size(); c++) {
- rpn_data = rpn_lsbs[c];
- if(rpn_data[0] == track && rpn_data[1] == 0)
+ case bankEventId:
+ if( ch->isSF2 && ch->it_inst )
{
- flag_rpn_lsb = true;
- rpn_lsbs.removeAt(c);
- delete rpn_data;
+ objModel = ch->it_inst->childModel( "bank" );
+ printf( "Tick=%ld: BANK SELECT %d\n", tick, value );
}
- }
- if(flag_rpn_lsb && flag_rpn_msb)
- {
- objModel = ch->it->pitchRangeModel();
- pitchBendMultiply = value;
- }
- break;
- case volumeEventId:
- objModel = ch->it->volumeModel();
- value = value * 100 / 127;
- break;
- case panEventId:
- objModel = ch->it->panningModel();
- // value may be nagetive.
- value = value * 100 / 127;
- break;
+ break;
- // RPN LSB
- case 100:
- CC_RPN_SEND
- rpn_lsbs << rpn_data;
- break;
+ case 6:
+ for( int c = 0; c < rpn_msbs.size(); c++ )
+ {
+ rpn_data = rpn_msbs[c];
+
+ if( rpn_data[0] == track && rpn_data[1] == 0 )
+ {
+ flag_rpn_msb = true;
+ rpn_msbs.removeAt( c );
+ delete rpn_data;
+ }
+ }
- // RPN MSB
- case 101:
- CC_RPN_SEND
- rpn_msbs << rpn_data;
- break;
+ for( int c = 0; c < rpn_lsbs.size(); c++ )
+ {
+ rpn_data = rpn_lsbs[c];
+
+ if( rpn_data[0] == track && rpn_data[1] == 0 )
+ {
+ flag_rpn_lsb = true;
+ rpn_lsbs.removeAt( c );
+ delete rpn_data;
+ }
+ }
- case pitchBendEventId:
- objModel = ch->it->pitchModel();
- value = value * 100 / 8192 * pitchBendMultiply;
- break;
+ if( flag_rpn_lsb && flag_rpn_msb )
+ {
+ objModel = ch->it->pitchRangeModel();
+ pitchBendMultiply = value;
+ }
- case programEventId:
- if( ch->isSF2 && ch->it_inst )
- objModel = ch->it_inst->childModel( "patch" );
- break;
- default:
- // TODO: something useful for other CCs
- printf("Tick=%ld: Unused CC %d with value=%d\n",
- tick, ctl, value);
- break;
+ break;
+
+ case volumeEventId:
+ objModel = ch->it->volumeModel();
+ value = value * 100 / 127;
+ break;
+
+ case panEventId:
+ objModel = ch->it->panningModel();
+ // value may be nagetive.
+ value = value * 100 / 127;
+ break;
+
+ // RPN LSB
+ case 100:
+ CC_RPN_SEND
+ rpn_lsbs << rpn_data;
+ break;
+
+ // RPN MSB
+ case 101:
+ CC_RPN_SEND
+ rpn_msbs << rpn_data;
+ break;
+
+ case pitchBendEventId:
+ objModel = ch->it->pitchModel();
+ value = value * 100 / 8192 * pitchBendMultiply;
+ break;
+
+ case programEventId:
+ if( ch->isSF2 && ch->it_inst )
+ objModel = ch->it_inst->childModel( "patch" );
+
+ break;
+
+ default:
+ // TODO: something useful for other CCs
+ printf( "Tick=%ld: Unused CC %d with value=%d\n",
+ tick, ctl, value );
+ break;
}
if( objModel )
@@ -196,73 +219,123 @@ void commonReader::CCHandler(long tick, int track, int ctl, int value)
{
if( ccs[track][ctl].at == NULL )
{
- ccs[track][ctl].create( m_tc, trackName + " > " + objModel->displayName());
+ ccs[track][ctl].create( m_tc, trackName + " > " + objModel->displayName() );
}
- ccs[track][ctl].putValue( tick*tickRate , objModel, value );
+
+ ccs[track][ctl].putValue( tick * tickRate , objModel, value );
}
}
}
}
-void commonReader::programHandler(long tick, int chan, int patch,
- int track)
+void commonReader::programHandler( long tick, int chan, int patch,
+ int track )
{
CHECK_TRACK
-
- QString trackName = QString( tr( "Track" ) + " %1").arg(chan+1);
+ QString trackName = TrackContainer::tr( "Track %1" ).arg( chan + 1 );
SmfMidiChannel * ch = chs[track].create( m_tc, trackName );
if( ch->isSF2 )
{
// AFAIK, 128 should be the standard bank for drums in SF2.
// If not, this has to be made configurable.
- ch->it_inst->childModel( "bank" )->setValue(chan!=9 ? 0 : 128);
- if(tick == 0)
- ch->it_inst->childModel( "patch" )->setValue(patch);
+ ch->it_inst->childModel( "bank" )->setValue( chan != 9 ? 0 : 128 );
+
+ if( tick == 0 )
+ ch->it_inst->childModel( "patch" )->setValue( patch );
else
- CCHandler(tick, track, programEventId, patch);
+ CCHandler( tick, track, programEventId, patch );
}
else
{
const QString num = QString::number( patch );
const QString filter = QString().fill( '0', 3 - num.length() ) + num + "*.pat";
const QString dir = "/usr/share/midi/"
- "freepats/Tone_000/";
+ "freepats/Tone_000/";
const QStringList files = QDir( dir ).
- entryList( QStringList( filter ) );
+ entryList( QStringList( filter ) );
+
if( ch->it_inst && !files.empty() )
{
- ch->it_inst->loadFile( dir+files.front() );
+ ch->it_inst->loadFile( dir + files.front() );
}
}
}
-void commonReader::timeSigHandler(long tick, int num, int den)
+void commonReader::timeSigHandler( long tick, int num, int den )
{
- printf("Another timesig at %f\n", tick * tickRate);
- timeSigNumeratorPat->putValue(tick * tickRate, num);
- timeSigDenominatorPat->putValue(tick * tickRate, den);
- pd.setValue(preTrackSteps);
+ printf( "Another timesig at %f\n", tick * tickRate );
+ timeSigNumeratorPat->putValue( tick * tickRate, num );
+ timeSigDenominatorPat->putValue( tick * tickRate, den );
+ pd.setValue( preTrackSteps );
}
-void commonReader::tempoHandler(long tick, int tempo)
+void commonReader::tempoHandler( long tick, int tempo )
{
AutomationPattern * tap = m_tc->tempoAutomationPattern();
- if( tap ) {
- tap->putValue((double)tick * tickRate, tempo);
+
+ if( tap )
+ {
+ tap->putValue( static_cast( tick ) * tickRate, tempo );
+ }
+}
+
+void commonReader::textHandler( int text_type, const QString &data , int track )
+{
+ switch ( text_type )
+ {
+ case 3:
+
+ // Track Name
+ m_currentTrack = ( track == -10 ? m_currentTrack : track );
+
+ if ( m_currentTrack == noTrack ) // Meta name, i.e. The real title/name of the current song file
+ {
+ return; // Don't know how to handle this in LMMS
+ }
+
+ m_currentTrackName.first = m_currentTrack;
+ m_currentTrackName.second = data;
+
+ if( chs[m_currentTrack].it )
+ {
+ chs[m_currentTrack].setName( data );
+ }
+ else
+ {
+ chs[m_currentTrack].create( m_tc, data );
+ }
+
+ case 5:
+
+ // Lyrics
+ // How to handle lyrics?
+ case 6:
+
+ // MIDI Marker Description
+ // How to handle markers & cue points?
+
+ default:
+ printf( "Unknown Text Event: %d %s", text_type, data.toStdString().c_str() );
}
+
+}
+
+void commonReader::timeBaseHandler( int timebase )
+{
+ tickRate = ticksPerBeat / static_cast( timebase );
}
-void commonReader::timeBaseHandler(int timebase)
+void commonReader::trackStartHandler()
{
- tickRate = ticksPerBeat / (double) timebase;
+ m_currentTrack ++;
}
-// when use this, addNoteEvent() should be called later, or memeory leak.
-void commonReader::insertNoteEvent(long tick, int chan, int pitch,
- int vol, int track)
+// when use this, addNoteEvent() should be called later, otherwise it will cause memeory leak.
+void commonReader::insertNoteEvent( long tick, int chan, int pitch,
+ int vol, int track )
{
NOTE_EVENT_DEFINITION
CHECK_TRACK
@@ -275,52 +348,52 @@ void commonReader::insertNoteEvent(long tick, int chan, int pitch,
note_list << note;
}
-void commonReader::addNoteEvent(long tick, int chan,
- int pitch, int track)
+void commonReader::addNoteEvent( long tick, int chan,
+ int pitch, int track )
{
NOTE_EVENT_DEFINITION
CHECK_TRACK
- for(int c=0; c= note[time])
+ if( note[channel] == track && note[note_pitch] == pitch
+ && tick >= note[time] )
{
int dur = tick - note[time];
- addNoteEvent(note[time], chan, pitch, note[note_vol], dur, track);
- note_list.removeAt(c);
+ addNoteEvent( note[time], chan, pitch, note[note_vol], dur, track );
+ note_list.removeAt( c );
delete note;
break;
}
}
- if(pd.maximum() <= chan+preTrackSteps)
- pd.setMaximum(pd.maximum()+preTrackSteps);
+ if( pd.maximum() <= chan + preTrackSteps )
+ pd.setMaximum( pd.maximum() + preTrackSteps );
- if(pd.value() <= chan+preTrackSteps)
- pd.setValue(chan+preTrackSteps);
+ if( pd.value() <= chan + preTrackSteps )
+ pd.setValue( chan + preTrackSteps );
}
-void commonReader::addNoteEvent(long tick, int chan, int pitch, int vol,
- int dur, int track)
+void commonReader::addNoteEvent( long tick, int chan, int pitch, int vol,
+ int dur, int track )
{
CHECK_TRACK
- QString trackName = QString( tr( "Track" ) + " %1").arg(track+1);
+ QString trackName = TrackContainer::tr( "Track %1" ).arg( track + 1 );
SmfMidiChannel * ch = chs[track].create( m_tc, trackName );
double realDur = dur * tickRate;
- Note n( (realDur < 1 ? 1 : realDur ), (double)tick * tickRate, pitch-12, vol );
+ Note n( ( realDur < 1 ? 1 : realDur ), static_cast( tick ) * tickRate, pitch - 12, vol );
ch->addNote( n );
}
-void commonReader::errorHandler(const QString &errorStr)
+void commonReader::errorHandler( const QString &errorStr )
{
printf( "SmfImport::readFile(): got error %s\n",
- errorStr.toStdString().c_str() );
+ errorStr.toStdString().c_str() );
}
diff --git a/plugins/SmfImport/commonReader.h b/plugins/SmfImport/commonReader.h
index e7363e1422c..d7fdfdcef5e 100644
--- a/plugins/SmfImport/commonReader.h
+++ b/plugins/SmfImport/commonReader.h
@@ -25,6 +25,7 @@
#ifndef COMMON_READER_H
#define COMMON_READER_H
+#include
#include
#include
#include
@@ -55,28 +56,30 @@ class commonReader : public QObject
{
Q_OBJECT
public:
- commonReader(TrackContainer *tc, const char *hintText);
- ~commonReader();
+ commonReader( TrackContainer *tc, const QString hintText );
+ ~commonReader();
protected:
- virtual void errorHandler(const QString &errorStr);
- void CCHandler(long tick, int track, int ctl, int value);
- void programHandler(long tick, int chan, int patch, int track=noTrack);
- void timeSigHandler(long tick, int num, int den);
- void tempoHandler(long tick, int tempo);
- void timeBaseHandler(int timebase);
+ virtual void errorHandler( const QString &errorStr );
+ void CCHandler( long tick, int track, int ctl, int value );
+ void programHandler( long tick, int chan, int patch, int track = noTrack );
+ void timeSigHandler( long tick, int num, int den );
+ void tempoHandler( long tick, int tempo );
+ void textHandler( int text_type, const QString& data , int track = -10 );
+ void timeBaseHandler( int timebase );
+ void trackStartHandler();
- void insertNoteEvent(long tick, int chan, int pitch, int vol, int track=noTrack);
+ void insertNoteEvent( long tick, int chan, int pitch, int vol, int track = noTrack );
- void addNoteEvent(long tick, int chan, int pitch, int track=noTrack);
- void addNoteEvent(long tick, int chan, int pitch, int vol, int dur, int track=noTrack);
+ void addNoteEvent( long tick, int chan, int pitch, int track = noTrack );
+ void addNoteEvent( long tick, int chan, int pitch, int vol, int dur, int track = noTrack );
- QProgressDialog pd;
- TrackContainer *m_tc;
+ QProgressDialog pd;
+ TrackContainer *m_tc;
// 128 CC + Pitch Bend + Program
- SmfMidiCC ccs[256][130];
- SmfMidiChannel chs[256];
+ SmfMidiCC ccs[256][130];
+ SmfMidiChannel chs[256];
AutomationPattern * timeSigNumeratorPat;
AutomationPattern * timeSigDenominatorPat;
@@ -86,12 +89,14 @@ class commonReader : public QObject
double tickRate; // convert ove tick to lmms tick.
int pitchBendMultiply;
+ int m_currentTrack = -2;
+ QPair m_currentTrackName;
- /*
- * record note event.
- * tick, channel, pitch, vol.
- */
- QList note_list;
+ /*
+ * record note event.
+ * tick, channel, pitch, vol.
+ */
+ QList note_list;
/*
* record rpn event.
@@ -100,7 +105,7 @@ class commonReader : public QObject
QList rpn_msbs;
QList rpn_lsbs;
-
+
};
#endif
diff --git a/plugins/SmfImport/midiReader.cpp b/plugins/SmfImport/midiReader.cpp
index 346ee522aef..a7895296c5f 100644
--- a/plugins/SmfImport/midiReader.cpp
+++ b/plugins/SmfImport/midiReader.cpp
@@ -42,48 +42,54 @@
#include "midiReader.h"
midiReader::midiReader( TrackContainer* tc ) :
- commonReader(tc, "Importing MIDI-file..." ),
- m_seq(new drumstick::QSmf)
+ commonReader( tc, commonReader::tr( "Importing %1 file..." ).arg( "MIDI" ) ),
+ m_seq( new drumstick::QSmf )
{
// Connect to slots.
- connect(m_seq, SIGNAL(signalSMFTimeSig(int,int,int,int)),
- this, SLOT(timeSigEvent(int,int,int,int)));
+ connect( m_seq, SIGNAL( signalSMFTimeSig( int, int, int, int ) ),
+ this, SLOT( timeSigEvent( int, int, int, int ) ) );
- connect(m_seq, SIGNAL(signalSMFTempo(int)),
- this, SLOT(tempoEvent(int)));
+ connect( m_seq, SIGNAL( signalSMFTempo( int ) ),
+ this, SLOT( tempoEvent( int ) ) );
- connect(m_seq, SIGNAL(signalSMFError(QString)),
- this, SLOT(errorHandler(QString)));
+ connect( m_seq, SIGNAL( signalSMFText( int, QString ) ),
+ this, SLOT( textEvent( int, QString ) ) );
- connect(m_seq, SIGNAL(signalSMFCtlChange(int,int,int)),
- this, SLOT(ctlChangeEvent(int,int,int)));
+ connect( m_seq, SIGNAL( signalSMFError( QString ) ),
+ this, SLOT( errorHandler( QString ) ) );
- connect(m_seq, SIGNAL(signalSMFPitchBend(int,int)),
- this, SLOT(pitchBendEvent(int,int)));
+ connect( m_seq, SIGNAL( signalSMFCtlChange( int, int, int ) ),
+ this, SLOT( ctlChangeEvent( int, int, int ) ) );
- connect(m_seq, SIGNAL(signalSMFNoteOn(int,int,int)),
- this, SLOT(noteOnEvent(int,int,int)));
+ connect( m_seq, SIGNAL( signalSMFPitchBend( int, int ) ),
+ this, SLOT( pitchBendEvent( int, int ) ) );
- connect(m_seq, SIGNAL(signalSMFNoteOff(int,int,int)),
- this, SLOT(noteOffEvent(int,int,int)));
+ connect( m_seq, SIGNAL( signalSMFNoteOn( int, int, int ) ),
+ this, SLOT( noteOnEvent( int, int, int ) ) );
- connect(m_seq, SIGNAL(signalSMFProgram(int,int)),
- this, SLOT(programEvent(int,int)));
+ connect( m_seq, SIGNAL( signalSMFNoteOff( int, int, int ) ),
+ this, SLOT( noteOffEvent( int, int, int ) ) );
- connect(m_seq, SIGNAL(signalSMFHeader(int,int,int)),
- this, SLOT(headerEvent(int,int,int)));
+ connect( m_seq, SIGNAL( signalSMFProgram( int, int ) ),
+ this, SLOT( programEvent( int, int ) ) );
+
+ connect( m_seq, SIGNAL( signalSMFHeader( int, int, int ) ),
+ this, SLOT( headerEvent( int, int, int ) ) );
+
+ connect( m_seq, SIGNAL( signalSMFTrackStart() ), this,
+ SLOT( startTrackEvent() ) );
}
midiReader::~midiReader()
{
- printf("destroy midiReader\n");
+ printf( "destroy midiReader\n" );
delete m_seq;
}
-void midiReader::read(QString &fileName)
+void midiReader::read( QString &fileName )
{
- m_seq->readFromFile(fileName);
+ m_seq->readFromFile( fileName );
}
// Slots below.
@@ -92,55 +98,69 @@ void midiReader::read(QString &fileName)
// b1: Denominator (exponent in a power of two)
// b2: Number of MIDI clocks per metronome click
// b3: Number of notated 32nd notes per 24 MIDI clocks
-void midiReader::timeSigEvent(int b0, int b1, int b2, int b3)
+void midiReader::timeSigEvent( int b0, int b1, int b2, int b3 )
{
- timeSigHandler(m_seq->getCurrentTime(), b0, 1<getCurrentTime(), b0, 1 << b1 );
}
-void midiReader::tempoEvent(int tempo)
+void midiReader::tempoEvent( int tempo )
{
- tempoHandler(m_seq->getCurrentTime(), 60000000/tempo);
+ tempoHandler( m_seq->getCurrentTime(), 60000000 / tempo );
}
-void midiReader::errorHandler(const QString &errorStr)
+void midiReader::textEvent( int text_type, const QString &data )
+{
+ if ( data.length() )
+ {
+ textHandler( text_type, data );
+ }
+}
+
+void midiReader::startTrackEvent()
+{
+ trackStartHandler();
+}
+
+void midiReader::errorHandler( const QString &errorStr )
{
printf( "MidiImport::readSMF(): got error %s at %ld\n",
- errorStr.toStdString().c_str(), m_seq->getCurrentTime() );
+ errorStr.toStdString().c_str(), m_seq->getCurrentTime() );
}
-void midiReader::ctlChangeEvent(int chan, int ctl, int value)
+void midiReader::ctlChangeEvent( int chan, int ctl, int value )
{
- CCHandler(m_seq->getCurrentTime(), chan, ctl, value);
+ CCHandler( m_seq->getCurrentTime(), chan, ctl, value );
}
-void midiReader::pitchBendEvent(int chan, int value)
+void midiReader::pitchBendEvent( int chan, int value )
{
- CCHandler(m_seq->getCurrentTime(), chan, pitchBendEventId, value);
+ CCHandler( m_seq->getCurrentTime(), chan, pitchBendEventId, value );
}
-void midiReader::noteOnEvent(int chan, int pitch, int vol)
+void midiReader::noteOnEvent( int chan, int pitch, int vol )
{
- if(vol != 0){
- insertNoteEvent(m_seq->getCurrentTime(), chan, pitch, vol);
+ if( vol )
+ {
+ insertNoteEvent( m_seq->getCurrentTime(), chan, pitch, vol );
}
else
{
- addNoteEvent(m_seq->getCurrentTime(), chan, pitch);
+ addNoteEvent( m_seq->getCurrentTime(), chan, pitch );
}
}
-void midiReader::noteOffEvent(int chan, int pitch, int vol)
+void midiReader::noteOffEvent( int chan, int pitch, int vol )
{
- addNoteEvent(m_seq->getCurrentTime(), chan, pitch);
+ addNoteEvent( m_seq->getCurrentTime(), chan, pitch );
}
-void midiReader::headerEvent(int format, int ntrks, int division)
+void midiReader::headerEvent( int format, int ntrks, int division )
{
- timeBaseHandler(division);
+ timeBaseHandler( division );
pd.setMaximum( ntrks + preTrackSteps );
}
-void midiReader::programEvent(int chan, int patch)
+void midiReader::programEvent( int chan, int patch )
{
- programHandler(m_seq->getCurrentTime(), chan, patch);
+ programHandler( m_seq->getCurrentTime(), chan, patch );
}
diff --git a/plugins/SmfImport/midiReader.h b/plugins/SmfImport/midiReader.h
index 8b8fe5769fb..3e015ed7bda 100644
--- a/plugins/SmfImport/midiReader.h
+++ b/plugins/SmfImport/midiReader.h
@@ -32,19 +32,21 @@ class midiReader : public commonReader
{
Q_OBJECT
public:
- midiReader(TrackContainer *tc);
+ midiReader( TrackContainer *tc );
~midiReader();
- void read(QString &fileName);
+ void read( QString &fileName );
public slots:
- void headerEvent(int format, int ntrks, int division);
- void noteOnEvent(int chan, int pitch, int vol);
- void noteOffEvent(int chan, int pitch, int vol);
- void ctlChangeEvent(int chan, int ctl, int value);
- void pitchBendEvent(int chan, int value);
- void programEvent(int chan, int patch);
- void timeSigEvent(int b0, int b1, int b2, int b3);
- void tempoEvent(int tempo);
- void errorHandler(const QString& errorStr);
+ void headerEvent( int format, int ntrks, int division );
+ void noteOnEvent( int chan, int pitch, int vol );
+ void noteOffEvent( int chan, int pitch, int vol );
+ void ctlChangeEvent( int chan, int ctl, int value );
+ void pitchBendEvent( int chan, int value );
+ void programEvent( int chan, int patch );
+ void timeSigEvent( int b0, int b1, int b2, int b3 );
+ void tempoEvent( int tempo );
+ void textEvent( int text_type, const QString& data );
+ void startTrackEvent();
+ void errorHandler( const QString& errorStr );
private:
drumstick::QSmf *m_seq;
};
diff --git a/plugins/SmfImport/oveReader.cpp b/plugins/SmfImport/oveReader.cpp
index 9c844f1a8d8..6b518c90a26 100644
--- a/plugins/SmfImport/oveReader.cpp
+++ b/plugins/SmfImport/oveReader.cpp
@@ -42,130 +42,135 @@
#include "oveReader.h"
oveReader::oveReader( TrackContainer* tc ) :
- commonReader(tc, "Importing Overture file..."),
- m_seq(new drumstick::QOve)
+ commonReader( tc, commonReader::tr( "Importing %1 file..." ).arg( "Overture" ) ),
+ m_seq( new drumstick::QOve )
{
// Connect to slots.
- connect(m_seq, SIGNAL(signalOVEError(QString)),
- this, SLOT(errorHandler(QString)));
+ connect( m_seq, SIGNAL( signalOVEError( QString ) ),
+ this, SLOT( errorHandler( QString ) ) );
- connect(m_seq, SIGNAL(signalOVEHeader(int,int)),
- this, SLOT(fileHeader(int,int)));
+ connect( m_seq, SIGNAL( signalOVEHeader( int, int ) ),
+ this, SLOT( fileHeader( int, int ) ) );
- connect(m_seq, SIGNAL(signalOVENoteOn(int,long,int,int,int)),
- this, SLOT(noteOnEvent(int,long,int,int,int)));
+ connect( m_seq, SIGNAL( signalOVENoteOn( int, long, int, int, int ) ),
+ this, SLOT( noteOnEvent( int, long, int, int, int ) ) );
- connect(m_seq, SIGNAL(signalOVENoteOff(int,long,int,int,int)),
- this, SLOT(noteOffEvent(int,long,int,int,int)));
+ connect( m_seq, SIGNAL( signalOVENoteOff( int, long, int, int, int ) ),
+ this, SLOT( noteOffEvent( int, long, int, int, int ) ) );
- connect(m_seq, SIGNAL(signalOVECtlChange(int,long,int,int,int)),
- this, SLOT(ctlChangeEvent(int,long,int,int,int)));
+ connect( m_seq, SIGNAL( signalOVECtlChange( int, long, int, int, int ) ),
+ this, SLOT( ctlChangeEvent( int, long, int, int, int ) ) );
- connect(m_seq, SIGNAL(signalOVEPitchBend(int,long,int,int)),
- this, SLOT(ctlChangeEvent(int,long,int,int,int)));
+ connect( m_seq, SIGNAL( signalOVEPitchBend( int, long, int, int ) ),
+ this, SLOT( ctlChangeEvent( int, long, int, int, int ) ) );
- connect(m_seq, SIGNAL(signalOVEProgram(int,long,int,int)),
- this, SLOT(programEvent(int,long,int,int)));
+ connect( m_seq, SIGNAL( signalOVEProgram( int, long, int, int ) ),
+ this, SLOT( programEvent( int, long, int, int ) ) );
- connect(m_seq, SIGNAL(signalOVETimeSig(int,long,int,int)),
- this, SLOT(timeSigEvent(int,long,int,int)));
+ connect( m_seq, SIGNAL( signalOVETimeSig( int, long, int, int ) ),
+ this, SLOT( timeSigEvent( int, long, int, int ) ) );
- connect(m_seq, SIGNAL(signalOVETempo(long,int)),
- this, SLOT(tempoEvent(long,int)));
+ connect( m_seq, SIGNAL( signalOVETempo( long, int ) ),
+ this, SLOT( tempoEvent( long, int ) ) );
- connect(m_seq, SIGNAL(signalOVETrackPatch(int,int,int)),
- this, SLOT(trackPatch(int,int,int)));
+ connect( m_seq, SIGNAL( signalOVETrackPatch( int, int, int ) ),
+ this, SLOT( trackPatch( int, int, int ) ) );
- connect(m_seq, SIGNAL(signalOVETrackVol(int,int,int)),
- this, SLOT(trackVol(int,int,int)));
+ connect( m_seq, SIGNAL( signalOVETrackVol( int, int, int ) ),
+ this, SLOT( trackVol( int, int, int ) ) );
- connect(m_seq, SIGNAL(signalOVETrackBank(int,int,int)),
- this, SLOT(trackBank(int,int,int)));
+ connect( m_seq, SIGNAL( signalOVETrackBank( int, int, int ) ),
+ this, SLOT( trackBank( int, int, int ) ) );
+
+ connect( m_seq, SIGNAL( signalOVENewTrack( QString, int, int, int, int, int, bool, bool, bool ) ),
+ this, SLOT( trackStart( QString, int, int, int, int, int, bool, bool, bool ) ) );
}
oveReader::~oveReader()
{
- printf("destroy oveReader\n");
+ printf( "destroy oveReader\n" );
delete m_seq;
}
-void oveReader::read(QString &fileName)
+void oveReader::read( QString &fileName )
{
- m_seq->readFromFile(fileName);
+ m_seq->readFromFile( fileName );
}
// Slots below.
-void oveReader::timeSigEvent(int bar, long tick, int num, int den)
+void oveReader::timeSigEvent( int bar, long tick, int num, int den )
{
- timeSigHandler(tick, num, den);
+ timeSigHandler( tick, num, den );
}
-void oveReader::tempoEvent(long tick, int tempo)
+void oveReader::tempoEvent( long tick, int tempo )
{
- tempoHandler(tick, tempo/100);
+ tempoHandler( tick, tempo / 100 );
}
-void oveReader::errorHandler(const QString &errorStr)
+void oveReader::errorHandler( const QString &errorStr )
{
printf( "MidiImport::readSMF(): got error %s\n",
- errorStr.toStdString().c_str() );
+ errorStr.toStdString().c_str() );
}
-void oveReader::ctlChangeEvent(int track, long tick, int chan, int ctl, int value)
+void oveReader::ctlChangeEvent( int track, long tick, int chan, int ctl, int value )
{
- CCHandler(tick, track, ctl, value);
+ CCHandler( tick, track, ctl, value );
}
-void oveReader::pitchBendEvent(int track, long tick, int chan, int value)
+void oveReader::pitchBendEvent( int track, long tick, int chan, int value )
{
- CCHandler(tick, track, pitchBendEventId, value);
+ CCHandler( tick, track, pitchBendEventId, value );
}
-void oveReader::noteOnEvent(int track, long tick, int chan, int pitch, int vol)
+void oveReader::noteOnEvent( int track, long tick, int chan, int pitch, int vol )
{
- if(vol != 0){
- insertNoteEvent(tick, chan, pitch, vol, track);
+ if( vol )
+ {
+ insertNoteEvent( tick, chan, pitch, vol, track );
}
else
{
- addNoteEvent(tick, chan, pitch, track);
+ addNoteEvent( tick, chan, pitch, track );
}
}
-void oveReader::noteOffEvent(int track, long tick, int chan, int pitch, int vol)
+void oveReader::noteOffEvent( int track, long tick, int chan, int pitch, int vol )
{
- addNoteEvent(tick, chan, pitch, track);
+ addNoteEvent( tick, chan, pitch, track );
}
-/*void oveReader::headerEvent(int format, int ntrks, int division)
+void oveReader::programEvent( int track, long tick, int chan, int patch )
{
- tickRate = ticksPerBeat / (double)division;
- pd.setMaximum( ntrks + preTrackSteps );
-}*/
+ programHandler( tick, chan, patch, track );
+}
-void oveReader::programEvent(int track, long tick, int chan, int patch)
+void oveReader::trackPatch( int track, int chan, int patch )
{
- programHandler(tick, chan, patch, track);
+ programHandler( 0, chan, patch, track );
}
-void oveReader::trackPatch(int track, int chan, int patch){
- programHandler(0, chan, patch, track);
+void oveReader::trackBank( int track, int chan, int bank )
+{
+ CCHandler( 0, track, bankEventId, bank );
}
-void oveReader::trackBank(int track, int chan, int bank)
+void oveReader::trackStart( const QString &name, int track, int channel, int pitch, int velocity, int port, bool selected, bool muted, bool loop )
{
- CCHandler(0, track, bankEventId, bank);
+ trackStartHandler();
+ textHandler( 3, name, track );
}
-void oveReader::trackVol(int track, int chan, int vol)
+void oveReader::trackVol( int track, int chan, int vol )
{
- CCHandler(0, track, volumeEventId, vol);
+ CCHandler( 0, track, volumeEventId, vol );
}
-void oveReader::fileHeader(int quarter, int trackCount)
+void oveReader::fileHeader( int quarter, int trackCount )
{
- timeBaseHandler(quarter);
- pd.setMaximum(trackCount + preTrackSteps);
+ timeBaseHandler( quarter );
+ pd.setMaximum( trackCount + preTrackSteps );
}
diff --git a/plugins/SmfImport/oveReader.h b/plugins/SmfImport/oveReader.h
index 7651e9c1d70..903fa54cf0f 100644
--- a/plugins/SmfImport/oveReader.h
+++ b/plugins/SmfImport/oveReader.h
@@ -31,22 +31,25 @@ class oveReader : public commonReader
{
Q_OBJECT
public:
- oveReader(TrackContainer *tc);
+ oveReader( TrackContainer *tc );
~oveReader();
- void read(QString &fileName);
+ void read( QString &fileName );
public slots:
- void errorHandler(const QString& errorStr);
- void fileHeader(int quarter, int trackCount);
- void noteOnEvent(int track, long tick, int chan, int pitch, int vol);
- void noteOffEvent(int track, long tick, int chan, int pitch, int vol);
- void ctlChangeEvent(int track, long tick, int chan, int ctl, int value);
- void pitchBendEvent(int track, long tick, int chan, int value);
- void programEvent(int track, long tick, int chan, int patch);
- void timeSigEvent(int bar, long tick, int num, int den);
- void tempoEvent(long tick, int tempo);
- void trackPatch(int track, int chan, int patch);
- void trackVol(int track, int chan, int vol);
- void trackBank(int track, int chan, int bank);
+ void errorHandler( const QString& errorStr );
+ void fileHeader( int quarter, int trackCount );
+ void noteOnEvent( int track, long tick, int chan, int pitch, int vol );
+ void noteOffEvent( int track, long tick, int chan, int pitch, int vol );
+ void ctlChangeEvent( int track, long tick, int chan, int ctl, int value );
+ void pitchBendEvent( int track, long tick, int chan, int value );
+ void programEvent( int track, long tick, int chan, int patch );
+ void timeSigEvent( int bar, long tick, int num, int den );
+ void tempoEvent( long tick, int tempo );
+ void trackPatch( int track, int chan, int patch );
+ void trackVol( int track, int chan, int vol );
+ void trackBank( int track, int chan, int bank );
+ void trackStart( const QString& name, int track, int channel, int pitch, int velocity,
+ int port, bool selected, bool muted, bool loop );
+
private:
drumstick::QOve *m_seq;
};
diff --git a/plugins/SmfImport/wrkReader.cpp b/plugins/SmfImport/wrkReader.cpp
index 24b6143906e..68c026e0f50 100644
--- a/plugins/SmfImport/wrkReader.cpp
+++ b/plugins/SmfImport/wrkReader.cpp
@@ -42,97 +42,106 @@
#include "wrkReader.h"
wrkReader::wrkReader( TrackContainer* tc ) :
- commonReader(tc, "Importing Cakewalk file..."),
- m_seq(new drumstick::QWrk)
+ commonReader( tc, commonReader::tr( "Importing %1 file..." ).arg( "Cakewalk" ) ),
+ m_seq( new drumstick::QWrk )
{
// Connect to slots.
- connect(m_seq, SIGNAL(signalWRKError(QString)),
- this, SLOT(errorHandler(QString)));
- connect(m_seq, SIGNAL(signalWRKTimeBase(int)),
- this, SLOT(timeBase(int)));
- connect(m_seq, SIGNAL(signalWRKNote(int,long,int,int,int,int)),
- this, SLOT(noteEvent(int,long,int,int,int,int)));
- connect(m_seq, SIGNAL(signalWRKCtlChange(int,long,int,int,int)),
- this, SLOT(ctlChangeEvent(int,long,int,int,int)));
- connect(m_seq, SIGNAL(signalWRKPitchBend(int,long,int,int)),
- this, SLOT(pitchBendEvent(int,long,int,int)));
- connect(m_seq, SIGNAL(signalWRKProgram(int,long,int,int)),
- this, SLOT(programEvent(int,long,int,int)));
- connect(m_seq, SIGNAL(signalWRKTimeSig(int,int,int)),
- this, SLOT(timeSigEvent(int,int,int)));
- connect(m_seq, SIGNAL(signalWRKTempo(long,int)),
- this, SLOT(tempoEvent(long,int)));
- connect(m_seq, SIGNAL(signalWRKTrackVol(int,int)),
- this, SLOT(trackVol(int,int)));
- connect(m_seq, SIGNAL(signalWRKTrackBank(int,int)),
- this, SLOT(trackBank(int,int)));
+ connect( m_seq, SIGNAL( signalWRKError( QString ) ),
+ this, SLOT( errorHandler( QString ) ) );
+ connect( m_seq, SIGNAL( signalWRKTimeBase( int ) ),
+ this, SLOT( timeBase( int ) ) );
+ connect( m_seq, SIGNAL( signalWRKNote( int, long, int, int, int, int ) ),
+ this, SLOT( noteEvent( int, long, int, int, int, int ) ) );
+ connect( m_seq, SIGNAL( signalWRKCtlChange( int, long, int, int, int ) ),
+ this, SLOT( ctlChangeEvent( int, long, int, int, int ) ) );
+ connect( m_seq, SIGNAL( signalWRKPitchBend( int, long, int, int ) ),
+ this, SLOT( pitchBendEvent( int, long, int, int ) ) );
+ connect( m_seq, SIGNAL( signalWRKProgram( int, long, int, int ) ),
+ this, SLOT( programEvent( int, long, int, int ) ) );
+ connect( m_seq, SIGNAL( signalWRKTimeSig( int, int, int ) ),
+ this, SLOT( timeSigEvent( int, int, int ) ) );
+ connect( m_seq, SIGNAL( signalWRKTempo( long, int ) ),
+ this, SLOT( tempoEvent( long, int ) ) );
+ connect( m_seq, SIGNAL( signalWRKTrackVol( int, int ) ),
+ this, SLOT( trackVol( int, int ) ) );
+ connect( m_seq, SIGNAL( signalWRKTrackBank( int, int ) ),
+ this, SLOT( trackBank( int, int ) ) );
+ connect( m_seq, SIGNAL( signalWRKTrackName( int, const QString ) ),
+ this, SLOT() );
}
wrkReader::~wrkReader()
{
- printf("destroy wrkReader\n");
+ printf( "destroy wrkReader\n" );
delete m_seq;
}
-void wrkReader::read(QString &fileName)
+void wrkReader::read( QString &fileName )
{
- m_seq->readFromFile(fileName);
+ m_seq->readFromFile( fileName );
}
// Slots below.
-void wrkReader::timeSigEvent(int bar, int num, int den)
+void wrkReader::timeSigEvent( int bar, int num, int den )
{
int tick = bar * num * ticksPerBeat;
- timeSigHandler(tick, num, den);
+ timeSigHandler( tick, num, den );
}
-void wrkReader::tempoEvent(long time, int tempo)
+void wrkReader::tempoEvent( long time, int tempo )
{
- tempoHandler(time, tempo/100);
+ tempoHandler( time, tempo / 100 );
}
-void wrkReader::errorHandler(const QString &errorStr)
+void wrkReader::errorHandler( const QString &errorStr )
{
printf( "MidiImport::readSMF(): got error %s\n",
- errorStr.toStdString().c_str() );
+ errorStr.toStdString().c_str() );
}
-void wrkReader::ctlChangeEvent(int track, long tick, int chan, int ctl, int value)
+void wrkReader::ctlChangeEvent( int track, long tick, int chan, int ctl, int value )
{
- CCHandler(tick, track, ctl, value);
+ CCHandler( tick, track, ctl, value );
}
-void wrkReader::pitchBendEvent(int track, long tick, int chan, int value)
+void wrkReader::pitchBendEvent( int track, long tick, int chan, int value )
{
- CCHandler(tick, track, pitchBendEventId, value);
+ CCHandler( tick, track, pitchBendEventId, value );
}
-void wrkReader::noteEvent(int track, long time, int chan, int pitch, int vol, int dur)
+void wrkReader::noteEvent( int track, long time, int chan, int pitch, int vol, int dur )
{
- addNoteEvent(time, chan, pitch, vol, dur, track);
+ addNoteEvent( time, chan, pitch, vol, dur, track );
}
-void wrkReader::programEvent(int track, long tick, int chan, int patch)
+void wrkReader::programEvent( int track, long tick, int chan, int patch )
{
- programHandler(tick, chan, patch, track);
+ programHandler( tick, chan, patch, track );
}
-void wrkReader::trackPatch(int track, int patch){
+void wrkReader::trackPatch( int track, int patch )
+{
//programHandler(0, chan, patch, track);
}
-void wrkReader::trackBank(int track, int bank)
+void wrkReader::trackBank( int track, int bank )
{
//CCHandler(0, track, 0, bank);
}
-void wrkReader::trackVol(int track, int vol)
+void wrkReader::trackName( int track, QString name )
+{
+ trackStartHandler();
+ textHandler( 3, name, track );
+}
+
+void wrkReader::trackVol( int track, int vol )
{
- CCHandler(0, track, volumeEventId, vol);
+ CCHandler( 0, track, volumeEventId, vol );
}
-void wrkReader::timeBase(int quarter)
+void wrkReader::timeBase( int quarter )
{
- timeBaseHandler(quarter);
+ timeBaseHandler( quarter );
}
diff --git a/plugins/SmfImport/wrkReader.h b/plugins/SmfImport/wrkReader.h
index 7d17c88a598..3fe502d92b6 100644
--- a/plugins/SmfImport/wrkReader.h
+++ b/plugins/SmfImport/wrkReader.h
@@ -31,21 +31,22 @@ class wrkReader : public commonReader
{
Q_OBJECT
public:
- wrkReader(TrackContainer *tc);
+ wrkReader( TrackContainer *tc );
~wrkReader();
- void read(QString &fileName);
+ void read( QString &fileName );
public slots:
- void errorHandler(const QString& errorStr);
- void timeBase(int timebase);
- void noteEvent(int track, long time, int chan, int pitch, int vol, int dur);
- void ctlChangeEvent(int track, long time, int chan, int ctl, int value);
- void pitchBendEvent(int track, long time, int chan, int value);
- void programEvent(int track, long time, int chan, int patch);
- void timeSigEvent(int bar, int num, int den);
- void tempoEvent(long time, int tempo);
- void trackPatch(int track, int patch);
- void trackVol(int track, int vol);
- void trackBank(int track, int bank);
+ void errorHandler( const QString& errorStr );
+ void timeBase( int timebase );
+ void noteEvent( int track, long time, int chan, int pitch, int vol, int dur );
+ void ctlChangeEvent( int track, long time, int chan, int ctl, int value );
+ void pitchBendEvent( int track, long time, int chan, int value );
+ void programEvent( int track, long time, int chan, int patch );
+ void timeSigEvent( int bar, int num, int den );
+ void tempoEvent( long time, int tempo );
+ void trackPatch( int track, int patch );
+ void trackVol( int track, int vol );
+ void trackBank( int track, int bank );
+ void trackName( int track, QString name );
private:
drumstick::QWrk *m_seq;
diff --git a/src/core/SmfMidiChannel.cpp b/src/core/SmfMidiChannel.cpp
index 8b891152b8b..6048dc4a126 100644
--- a/src/core/SmfMidiChannel.cpp
+++ b/src/core/SmfMidiChannel.cpp
@@ -87,5 +87,15 @@ void SmfMidiChannel::addNote( Note & n )
hasNotes = true;
lastEnd = n.pos() + n.length();
n.setPos( n.pos( p->startPosition() ) );
- p->addNote( n, false );
+ p->addNote( n, false );
+}
+
+void SmfMidiChannel::setName( QString tn )
+{
+ if ( !tn.length() )
+ {
+ it->setName( QT_TRANSLATE_NOOP("TrackContainer", "Track") );
+ return;
+ }
+ it->setName( tn );
}