diff --git a/ChangeLog b/ChangeLog index 2190203e4..a614c175b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-12-03 Tobias Doerffel + + * plugins/midi_import/midi_import.cpp: + load Patman-plugin instead of TripleOsc and try to load patch + according to program-change-events + 2007-11-12 Tobias Doerffel * configure.in: diff --git a/plugins/midi_import/midi_import.cpp b/plugins/midi_import/midi_import.cpp index f393d3e1c..df46906df 100644 --- a/plugins/midi_import/midi_import.cpp +++ b/plugins/midi_import/midi_import.cpp @@ -29,6 +29,7 @@ #include "pattern.h" #include "automation_pattern.h" #include "level_object.h" +#include "instrument.h" #include "debug.h" @@ -41,6 +42,7 @@ #else +#include #include #include #include @@ -292,8 +294,10 @@ invalid_format: assert( it != NULL ); #endif // TODO: setup program, channel etc. - it->loadInstrument( "tripleoscillator" ); + instrument * it_inst = it->loadInstrument( "patman" ); it->toggledInstrumentTrackButton( FALSE ); + bool sample_loaded = FALSE; + // TODO: track_name.trimmed().isEmpty() (Qt4) if( !track_name.isEmpty() ) { @@ -351,19 +355,22 @@ invalid_format: } break; -/* case MIDI_META_EVENT: + case PROGRAM_CHANGE: { - switch( ev.m_data.m_param[0] ) + const QString num = QString::number( ev.key() ); + const QString filter = QString().fill( '0', 3 - num.length() ) + num + "*.pat"; + const QString dir = "/usr/share/midi/" + "freepats/Tone_000/"; + const QStringList files = QDir( dir ). + entryList( filter ); + if( !files.empty() && !sample_loaded ) { - case MIDI_SET_TEMPO: - { - break; - } - default: - break; + it_inst->setParameter( "samplefile", + dir+files.front() ); + sample_loaded = TRUE; } break; - }*/ + } default: /* printf( "Unhandled event: %#x\n",