From b89794b67daf50bea881a2f3a7549e85af52bb4f Mon Sep 17 00:00:00 2001 From: "Tim E. Real" Date: Mon, 25 Jan 2010 02:17:52 +0000 Subject: See ChangeLog --- muse/ChangeLog | 1 + muse/muse/app.cpp | 2 +- muse/muse/conf.cpp | 5 + muse/muse/driver/jack.cpp | 24 ++- muse/muse/gconfig.cpp | 1 + muse/muse/gconfig.h | 1 + muse/muse/importmidi.cpp | 122 ++++++++------- muse/muse/shortcuts.cpp | 2 +- muse/muse/widgets/configmidifilebase.ui | 256 ++++++++++++++++++++------------ muse/muse/widgets/gensetbase.ui | 2 +- muse/muse/widgets/musewidgetsplug.cpp | 1 + 11 files changed, 261 insertions(+), 156 deletions(-) diff --git a/muse/ChangeLog b/muse/ChangeLog index 8fcf6fd1..78c0b47b 100644 --- a/muse/ChangeLog +++ b/muse/ChangeLog @@ -1,6 +1,7 @@ 24.01.2010 * Added: Midi sync: Added 'Jack timebase master' checkbox, removed requirement of MusE being tempo map master. (T356) * Added: While on external sync and Jack timebase master, reports correct MusE BBT info to Jack. (Tempo not correct yet). (T356) + * Added: Midi import option: Whether to split imported tracks into multiple parts. (T356) 23.01.2010 * Fixed: External midi sync in: MusE transport not rewinding upon reception of start. (T356) * Added: Midi sync: MusE now transmits and receives some MMC commands, and displays some MTC and SMTPE info. (T356) diff --git a/muse/muse/app.cpp b/muse/muse/app.cpp index 4fdcf825..b5f75b43 100644 --- a/muse/muse/app.cpp +++ b/muse/muse/app.cpp @@ -1246,7 +1246,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow(0, "mainwindow") menu_ids[CMD_CONFIG_MIDISYNC] = menuSettings->insertItem( QIconSet(*settings_midisyncIcon), tr("Midi Sync"), this, SLOT(configMidiSync()), 0); menu_ids[CMD_MIDI_FILE_CONFIG] = menuSettings->insertItem( - QIconSet(*settings_midifileexportIcon), tr("Midi File Export"), this, SLOT(configMidiFile()), 0); + QIconSet(*settings_midifileexportIcon), tr("Midi File Import/Export"), this, SLOT(configMidiFile()), 0); menuSettings->insertSeparator(); menu_ids[CMD_APPEARANCE_SETTINGS] = menuSettings->insertItem( QIconSet(*settings_appearance_settingsIcon), tr("Appearance settings"), this, SLOT(configAppearance()), 0); diff --git a/muse/muse/conf.cpp b/muse/muse/conf.cpp index 7096edfb..33a1a965 100644 --- a/muse/muse/conf.cpp +++ b/muse/muse/conf.cpp @@ -571,6 +571,8 @@ void readConfiguration(Xml& xml, bool readOnlySequencer) config.exp2ByteTimeSigs = xml.parseInt(); else if (tag == "expOptimNoteOffs") config.expOptimNoteOffs = xml.parseInt(); + else if (tag == "importMidiSplitParts") + config.importMidiSplitParts = xml.parseInt(); else if (tag == "midiInputDevice") midiInputPorts = xml.parseInt(); else if (tag == "midiInputChannel") @@ -1007,6 +1009,7 @@ void MusE::writeGlobalConfiguration(int level, Xml& xml) const xml.intTag(level, "smfFormat", config.smfFormat); xml.intTag(level, "exp2ByteTimeSigs", config.exp2ByteTimeSigs); xml.intTag(level, "expOptimNoteOffs", config.expOptimNoteOffs); + xml.intTag(level, "importMidiSplitParts", config.importMidiSplitParts); xml.intTag(level, "startMode", config.startMode); xml.strTag(level, "startSong", config.startSong); @@ -1311,6 +1314,7 @@ void MidiFileConfig::updateValues() copyrightEdit->setText(config.copyright); optNoteOffs->setChecked(config.expOptimNoteOffs); twoByteTimeSigs->setChecked(config.exp2ByteTimeSigs); + splitPartsCheckBox->setChecked(config.importMidiSplitParts); } //--------------------------------------------------------- @@ -1329,6 +1333,7 @@ void MidiFileConfig::okClicked() config.copyright = copyrightEdit->text(); config.expOptimNoteOffs = optNoteOffs->isChecked(); config.exp2ByteTimeSigs = twoByteTimeSigs->isChecked(); + config.importMidiSplitParts = splitPartsCheckBox->isChecked(); muse->changeConfig(true); // write config file close(); diff --git a/muse/muse/driver/jack.cpp b/muse/muse/driver/jack.cpp index 67146cca..6bbb57d9 100644 --- a/muse/muse/driver/jack.cpp +++ b/muse/muse/driver/jack.cpp @@ -196,12 +196,30 @@ static void timebase_callback(jack_transport_state_t /* state */, pos->bar++; pos->beat++; pos->bar_start_tick = Pos(pos->bar, 0, 0).tick(); + // // dummy: // - pos->beats_per_bar = 4; - pos->beat_type = 4; - pos->ticks_per_beat = 384; + + // p3.3.26 + //pos->beats_per_bar = 4; + //pos->beat_type = 4; + //pos->ticks_per_beat = 384; + // + /* // From example client transport.c : + float time_beats_per_bar = 4.0; + float time_beat_type = 0.25; // Huh? Inverted? From docs: "Time signature 'denominator'" + double time_ticks_per_beat = 1920.0; // Huh? Ticks per beat should be 24 etc. not 384 or 1920 etc. Otherwise it would be called 'frames_per_beat'. + double time_beats_per_minute = 120.0; + */ + // + int z, n; + sigmap.timesig(p.tick(), z, n); + pos->beats_per_bar = z; + pos->beat_type = n; + //pos->ticks_per_beat = config.division; + pos->ticks_per_beat = 24; + int tempo = tempomap.tempo(p.tick()); pos->beats_per_minute = (60000000.0 / tempo) * tempomap.globalTempo()/100.0; } diff --git a/muse/muse/gconfig.cpp b/muse/muse/gconfig.cpp index db019ff6..8072e656 100644 --- a/muse/muse/gconfig.cpp +++ b/muse/muse/gconfig.cpp @@ -88,6 +88,7 @@ GlobalConfigValues config = { 1, // smf export file format false, // midi export file 2 byte timesigs instead of 4 true, // optimize midi export file note offs + true, // Split imported tracks into multiple parts. 1, // startMode QString(""), // start song path 384, // gui division diff --git a/muse/muse/gconfig.h b/muse/muse/gconfig.h index 94789bd6..5d4d98a8 100644 --- a/muse/muse/gconfig.h +++ b/muse/muse/gconfig.h @@ -85,6 +85,7 @@ struct GlobalConfigValues { int smfFormat; // smf export file type bool exp2ByteTimeSigs; // Export 2 byte time sigs instead of 4 bytes bool expOptimNoteOffs; // Save space by replacing note offs with note on velocity 0 + bool importMidiSplitParts; // Split imported tracks into multiple parts. int startMode; // 0 - start with last song // 1 - start with default template diff --git a/muse/muse/importmidi.cpp b/muse/muse/importmidi.cpp index a50497a6..2c8bfb24 100644 --- a/muse/muse/importmidi.cpp +++ b/muse/muse/importmidi.cpp @@ -27,6 +27,7 @@ #include "drummap.h" #include "xml.h" #include "audio.h" +#include "gconfig.h" //--------------------------------------------------------- // importMidi @@ -288,61 +289,76 @@ void MusE::processTrack(MidiTrack* track) lastTick = epos; } - int len = song->roundUpBar(lastTick+1); - int bar2, beat; - unsigned tick; - sigmap.tickValues(len, &bar2, &beat, &tick); - QString partname = track->name(); + int len = song->roundUpBar(lastTick+1); - int lastOff = 0; - int st = -1; // start tick current part - int x1 = 0; // start tick current measure - int x2 = 0; // end tick current measure - - for (int bar = 0; bar < bar2; ++bar, x1 = x2) { - x2 = sigmap.bar2tick(bar+1, 0, 0); - if (lastOff > x2) { - // this measure is busy! - continue; - } - iEvent i1 = tevents->lower_bound(x1); - iEvent i2 = tevents->lower_bound(x2); - - if (i1 == i2) { // empty? - if (st != -1) { - MidiPart* part = new MidiPart(track); - part->setTick(st); - part->setLenTick(x1-st); -// printf("new part %d len: %d\n", st, x1-st); - part->setName(partname); - pl->add(part); - st = -1; - } - } - else { - if (st == -1) - st = x1; // begin new part - //HACK: - //lastOff: - for (iEvent i = i1; i != i2; ++i) { - Event event = i->second; - if (event.type() == Note) { - int off = event.tick() + event.lenTick(); - if (off > lastOff) - lastOff = off; - } - } - } - } - if (st != -1) { - MidiPart* part = new MidiPart(track); - part->setTick(st); -// printf("new part %d len: %d\n", st, x2-st); - part->setLenTick(x2-st); - part->setName(partname); - pl->add(part); - } + // p3.3.27 + if(config.importMidiSplitParts) + { + + int bar2, beat; + unsigned tick; + sigmap.tickValues(len, &bar2, &beat, &tick); + + int lastOff = 0; + int st = -1; // start tick current part + int x1 = 0; // start tick current measure + int x2 = 0; // end tick current measure + + for (int bar = 0; bar < bar2; ++bar, x1 = x2) { + x2 = sigmap.bar2tick(bar+1, 0, 0); + if (lastOff > x2) { + // this measure is busy! + continue; + } + iEvent i1 = tevents->lower_bound(x1); + iEvent i2 = tevents->lower_bound(x2); + + if (i1 == i2) { // empty? + if (st != -1) { + MidiPart* part = new MidiPart(track); + part->setTick(st); + part->setLenTick(x1-st); + // printf("new part %d len: %d\n", st, x1-st); + part->setName(partname); + pl->add(part); + st = -1; + } + } + else { + if (st == -1) + st = x1; // begin new part + //HACK: + //lastOff: + for (iEvent i = i1; i != i2; ++i) { + Event event = i->second; + if (event.type() == Note) { + int off = event.tick() + event.lenTick(); + if (off > lastOff) + lastOff = off; + } + } + } + } + if (st != -1) { + MidiPart* part = new MidiPart(track); + part->setTick(st); + // printf("new part %d len: %d\n", st, x2-st); + part->setLenTick(x2-st); + part->setName(partname); + pl->add(part); + } + } + else + { + // Just one long part... + MidiPart* part = new MidiPart(track); + //part->setTick(st); + part->setTick(0); + part->setLenTick(len); + part->setName(partname); + pl->add(part); + } //------------------------------------------------------------- // assign events to parts diff --git a/muse/muse/shortcuts.cpp b/muse/muse/shortcuts.cpp index 29dbbce8..057fef49 100644 --- a/muse/muse/shortcuts.cpp +++ b/muse/muse/shortcuts.cpp @@ -94,7 +94,7 @@ void initShortCuts() defShrt(SHRT_CONFIG_SHORTCUTS, 0, "Settings: Configure shortcuts", ARRANG_SHRT, "configure_shortcuts"); defShrt(SHRT_CONFIG_METRONOME, 0, "Settings: Configure metronome", ARRANG_SHRT, "configure_metronome"); defShrt(SHRT_CONFIG_MIDISYNC, 0, "Settings: Midi sync configuration", ARRANG_SHRT, "configure_midi_sync"); - defShrt(SHRT_MIDI_FILE_CONFIG, 0, "Settings: Midi file export configuration", ARRANG_SHRT, "configure_midi_file"); + defShrt(SHRT_MIDI_FILE_CONFIG, 0, "Settings: Midi file import/export configuration", ARRANG_SHRT, "configure_midi_file"); defShrt(SHRT_APPEARANCE_SETTINGS, 0, "Settings: Appearance settings", ARRANG_SHRT, "configure_appearance_settings"); defShrt(SHRT_CONFIG_MIDI_PORTS, 0, "Settings: Midi ports / Soft Synth", ARRANG_SHRT, "configure_midi_ports"); defShrt(SHRT_CONFIG_AUDIO_PORTS, 0, "Settings: Audio subsystem configuration", ARRANG_SHRT, "configure_audio_ports"); diff --git a/muse/muse/widgets/configmidifilebase.ui b/muse/muse/widgets/configmidifilebase.ui index dfdfffa4..4ba53d7e 100644 --- a/muse/muse/widgets/configmidifilebase.ui +++ b/muse/muse/widgets/configmidifilebase.ui @@ -8,21 +8,174 @@ 0 0 - 449 - 282 + 548 + 353 - MusE: Config Midi File Export + MusE: Config Midi File Import/Export true - + unnamed - + + + midiImportGroupBox + + + + 5 + 1 + 0 + 0 + + + + Import: + + + + unnamed + + + + splitPartsCheckBox + + + Split tracks into &parts + + + Alt+P + + + Split tracks into parts, or one single part + + + + + + + midiExportGroupBox + + + + 5 + 7 + 0 + 0 + + + + Export: + + + + unnamed + + + + copyrightEdit + + + + + + 96 + + + + + 192 + + + + + 384 + + + + divisionCombo + + + + + extendedFormat + + + true + + + Enable extended smf format (currently not implemented) + + + + + twoByteTimeSigs + + + Use &2-byte time signatures instead of standard 4 + + + Alt+2 + + + + + textLabel2 + + + Copyright: + + + + + textLabel3 + + + Format: + + + + + textLabel1 + + + Division: + + + + + optNoteOffs + + + Save space by replacing note-offs with &zero velocity note-ons + + + Alt+Z + + + + + + 0 (single track) + + + + + 1 (multiple tracks) + + + + formatCombo + + + + + Layout1 @@ -86,98 +239,7 @@ - - - - 0 (single track) - - - - - 1 (multiple tracks) - - - - formatCombo - - - - - textLabel3 - - - Format: - - - - - - 96 - - - - - 192 - - - - - 384 - - - - divisionCombo - - - - - textLabel1 - - - Division: - - - - - textLabel2 - - - Copyright: - - - - - copyrightEdit - - - - - extendedFormat - - - true - - - Enable extended smf format (currently not implemented) - - - - - twoByteTimeSigs - - - Use &2-byte time signatures instead of standard 4 - - - - - optNoteOffs - - - Save space by replacing note-offs with &zero velocity note-ons - - - + diff --git a/muse/muse/widgets/gensetbase.ui b/muse/muse/widgets/gensetbase.ui index 85873922..cd6f2888 100644 --- a/muse/muse/widgets/gensetbase.ui +++ b/muse/muse/widgets/gensetbase.ui @@ -1,4 +1,4 @@ - + GlobalSettingsDialogBase diff --git a/muse/muse/widgets/musewidgetsplug.cpp b/muse/muse/widgets/musewidgetsplug.cpp index 59d1e826..a32707e5 100644 --- a/muse/muse/widgets/musewidgetsplug.cpp +++ b/muse/muse/widgets/musewidgetsplug.cpp @@ -115,6 +115,7 @@ GlobalConfigValues config = { 1, // smf export file format false, // midi export file 2 byte timesigs instead of 4 true, // optimize midi export file note offs + true, // Split imported tracks into multiple parts. 1, // startMode QString(""), // start song path 384, // gui division -- cgit v1.2.3