diff options
author | Werner Schweer <ws.seh.de> | 2006-11-01 15:59:46 +0000 |
---|---|---|
committer | Werner Schweer <ws.seh.de> | 2006-11-01 15:59:46 +0000 |
commit | ee889893c5da28274b26c689146948565b94a715 (patch) | |
tree | 539ff2424da4fa7d9bb36108b3ee973fd43fe8f4 | |
parent | 998b731cb48b16b28be39c7ad1e3027de2eca358 (diff) |
fixes for remove synti + undo/redo
-rw-r--r-- | muse/muse/arranger/trackinfo.cpp | 9 | ||||
-rw-r--r-- | muse/muse/mixer/mstrip.cpp | 5 | ||||
-rw-r--r-- | muse/muse/song.cpp | 74 | ||||
-rw-r--r-- | muse/muse/synth.h | 4 | ||||
-rw-r--r-- | muse/muse/track.cpp | 16 |
5 files changed, 85 insertions, 23 deletions
diff --git a/muse/muse/arranger/trackinfo.cpp b/muse/muse/arranger/trackinfo.cpp index cba5a891..2935b943 100644 --- a/muse/muse/arranger/trackinfo.cpp +++ b/muse/muse/arranger/trackinfo.cpp @@ -657,6 +657,13 @@ void MidiChannelInfo::init(Track* t) curIdx = idx; } instrument->setCurrentIndex(curIdx); + int val = midic->ctrlVal(CTRL_PROGRAM).i; + patch->setText(mi->getPatchName(midic->channelNo(), val)); + // + // instrument type cannot be changed for software + // synthesizer + // + instrument->setEnabled(op->track->type() != Track::AUDIO_SOFTSYNTH); } //--------------------------------------------------------- @@ -703,7 +710,7 @@ void MidiChannelInfo::patchClicked() if (rv != 0) { CVal cval; cval.i = rv->data().toInt(); - song->setControllerVal(midic, CTRL_PROGRAM, cval); + song->setControllerVal(track, CTRL_PROGRAM, cval); } } diff --git a/muse/muse/mixer/mstrip.cpp b/muse/muse/mixer/mstrip.cpp index bb6a0d34..7dae09aa 100644 --- a/muse/muse/mixer/mstrip.cpp +++ b/muse/muse/mixer/mstrip.cpp @@ -39,10 +39,10 @@ static void addSyntiPorts(QMenu* menu, RouteList* r, int channel) { SynthIList* sl = song->syntis(); for (iSynthI i = sl->begin(); i != sl->end(); ++i) { - SynthI* track = *i; + MidiChannel* track = (*i)->channel(channel); QAction* oa = menu->addAction(track->name()); oa->setCheckable(true); - Route dst(track, channel, Route::SYNTIPORT); + Route dst(track, channel, Route::TRACK); oa->setData(QVariant::fromValue(dst)); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { @@ -67,6 +67,7 @@ static void addMidiTracks(QMenu* menu, RouteList* r, int channel) action->setCheckable(true); Route src(track, channel, Route::TRACK); action->setData(QVariant::fromValue(src)); + for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (*ir == src) { action->setChecked(true); diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp index 0875a106..2ae02fee 100644 --- a/muse/muse/song.cpp +++ b/muse/muse/song.cpp @@ -593,7 +593,7 @@ void Song::update(int flags) // // remove unconnected channels // -// printf("update tracks %d %d\n", _tracks.size(), _midiChannel.size()); +// printf("update tracks %d channels: %d\n", _tracks.size(), _midiChannel.size()); bool again; do { again = false; @@ -1417,8 +1417,8 @@ Track* Song::addTrack(QAction* action) MidiSynti* si = new MidiSynti(); QString sName(s->name()); for (k = s->instances(); k < 1000; ++k) { - QString instanceName = ("%1-%2"); - instanceName = instanceName.arg(sName).arg(k); + QString instanceName = (k == 0) ? + sName : instanceName.arg(sName).arg(k); MidiSyntiList* sl = midiSyntis(); iMidiSynti sii; @@ -1450,8 +1450,8 @@ Track* Song::addTrack(QAction* action) SynthI* si = new SynthI(); int i; for (i = s->instances(); i < 1000; ++i) { - QString instanceName = ("%1-%2"); - instanceName = instanceName.arg(s->name()).arg(i); + QString instanceName = (i == 0) ? + s->name() : QString("%1-%2").arg(s->name()).arg(i); SynthIList* sl = syntis(); iSynthI sii; @@ -1746,11 +1746,37 @@ void Song::insertTrack2(Track* track) void Song::removeTrack(Track* track) { startUndo(); + + if (track->type() == Track::AUDIO_SOFTSYNTH) { + for (int i = 0; i < MIDI_CHANNELS; ++i) { + MidiChannel* mc = ((SynthI*)track)->channel(i); + if (!mc->noInRoute()) { + int idx = _tracks.index(mc); + undoOp(UndoOp::DeleteTrack, idx, mc); + removeTrack1(mc); + audio->msgRemoveTrack(mc); + removeTrack3(mc); + } + } + } + else if (track->type() == Track::MIDI_OUT) { + for (int i = 0; i < MIDI_CHANNELS; ++i) { + MidiChannel* mc = ((MidiOutPort*)track)->channel(i); + if (!mc->noInRoute()) { + int idx = _tracks.index(mc); + undoOp(UndoOp::DeleteTrack, idx, mc); + removeTrack1(mc); + audio->msgRemoveTrack(mc); + removeTrack3(mc); + } + } + } int idx = _tracks.index(track); undoOp(UndoOp::DeleteTrack, idx, track); removeTrack1(track); audio->msgRemoveTrack(track); removeTrack3(track); + endUndo(SC_TRACK_REMOVED | SC_ROUTE); } @@ -1761,6 +1787,22 @@ void Song::removeTrack(Track* track) void Song::removeTrack1(Track* track) { +#if 0 + if (track->type() == Track::AUDIO_SOFTSYNTH) { + for (int i = 0; i < MIDI_CHANNELS; ++i) { + MidiChannel* mc = ((SynthI*)track)->channel(i); + if (!mc->noInRoute()) + removeTrack1(mc); + } + } + else if (track->type() == Track::MIDI_OUT) { + for (int i = 0; i < MIDI_CHANNELS; ++i) { + MidiChannel* mc = ((MidiOutPort*)track)->channel(i); + if (!mc->noInRoute()) + removeTrack1(mc); + } + } +#endif track->deactivate(); _tracks.erase(track); } @@ -1780,6 +1822,8 @@ void Song::removeTrack2(Track* track) _midis.erase(track); break; case Track::MIDI_OUT: +// for (int i = 0; i < MIDI_CHANNELS; ++i) +// removeTrack2(((MidiOutPort*)track)->channel(i)); _midiOutPorts.erase(track); break; case Track::MIDI_IN: @@ -1803,6 +1847,8 @@ void Song::removeTrack2(Track* track) case Track::AUDIO_SOFTSYNTH: { SynthI* s = (SynthI*) track; +// for (int i = 0; i < MIDI_CHANNELS; ++i) +// removeTrack2(s->channel(i)); s->deactivate2(); _synthIs.erase(track); } @@ -1814,8 +1860,6 @@ void Song::removeTrack2(Track* track) // remove routes // Route src(track, -1, Route::TRACK); -// if (track->type() == Track::AUDIO_SOFTSYNTH) -// src.type = Route::SYNTIPORT; foreach (const Route r, *(track->inRoutes())) { if (r.type != Route::TRACK && r.type != Route::SYNTIPORT) continue; @@ -1853,7 +1897,23 @@ void Song::removeTrack3(Track* track) if (track->type() == Track::AUDIO_SOFTSYNTH) { SynthI* s = (SynthI*) track; s->deactivate3(); +#if 0 + for (int i = 0; i < MIDI_CHANNELS; ++i) { + MidiChannel* mc = ((SynthI*)track)->channel(i); + if (!mc->noInRoute()) + removeTrack3(mc); + } +#endif } +#if 0 + else if (track->type() == Track::MIDI_OUT) { + for (int i = 0; i < MIDI_CHANNELS; ++i) { + MidiChannel* mc = ((MidiOutPort*)track)->channel(i); + if (!mc->noInRoute()) + removeTrack3(mc); + } + } +#endif emit trackRemoved(track); } diff --git a/muse/muse/synth.h b/muse/muse/synth.h index f657ea41..af45c04d 100644 --- a/muse/muse/synth.h +++ b/muse/muse/synth.h @@ -155,7 +155,7 @@ class SynthI : public AudioTrack, public MidiOut, public MidiInstrument virtual bool isSynti() const { return true; } virtual QString getPatchName(int ch, int prog) { - return _sif->getPatchName(ch, prog); + return _sif ? _sif->getPatchName(ch, prog) : ""; } virtual void populatePatchPopup(QMenu* m, int i) { _sif->populatePatchPopup(m, i); @@ -186,8 +186,6 @@ class SynthI : public AudioTrack, public MidiOut, public MidiInstrument // mess synthesizer instance //--------------------------------------------------------- -static const int PUT_FIFO_SIZE = 64; - class MessSynthIF : public SynthIF { Mess* _mess; diff --git a/muse/muse/track.cpp b/muse/muse/track.cpp index d3e18ee3..aab33bae 100644 --- a/muse/muse/track.cpp +++ b/muse/muse/track.cpp @@ -164,7 +164,6 @@ void Track::setDefaultName() case AUDIO_SOFTSYNTH: // base = QString("Synth"); return; - break; case AUDIO_OUTPUT: case AUDIO_INPUT: case MIDI_OUT: @@ -177,30 +176,27 @@ void Track::setDefaultName() // // create unique name // - base += " "; for (int i = 1; true; ++i) { - QString n; - n.setNum(i); - QString s = base + n; + QString s = QString("%1 $2").arg(base).arg(i); bool found = false; TrackList* tl = song->tracks(); - for (iTrack i = tl->begin(); i != tl->end(); ++i) { - Track* track = *i; + for (iTrack it = tl->begin(); it != tl->end(); ++it) { + Track* track = *it; if (track->name() == s) { found = true; break; } } MidiChannelList* mc = song->midiChannel(); - for (iMidiChannel i = mc->begin(); i != mc->end(); ++i) { - MidiChannel* t = *i; + for (iMidiChannel ic = mc->begin(); ic != mc->end(); ++ic) { + MidiChannel* t = *ic; if (t->name() == s) { found = true; break; } } if (!found) { - setName(s); + setName(i == 1 ? base : s); break; } } |