diff options
Diffstat (limited to 'muse2/muse/mixer/astrip.cpp')
-rw-r--r-- | muse2/muse/mixer/astrip.cpp | 1058 |
1 files changed, 6 insertions, 1052 deletions
diff --git a/muse2/muse/mixer/astrip.cpp b/muse2/muse/mixer/astrip.cpp index c1e92e59..5644e6eb 100644 --- a/muse2/muse/mixer/astrip.cpp +++ b/muse2/muse/mixer/astrip.cpp @@ -48,33 +48,8 @@ #include "gconfig.h" #include "ttoolbutton.h" #include "menutitleitem.h" -#include "popupmenu.h" - -//--------------------------------------------------------- -// MenuTitleItem -//--------------------------------------------------------- - -MenuTitleItem::MenuTitleItem(const QString& ss, QWidget* parent) - : QWidgetAction(parent) - { - s = ss; - // Don't allow to click on it. - setEnabled(false); - // Just to be safe, set to -1 instead of default 0. - setData(-1); - } - -QWidget* MenuTitleItem::createWidget(QWidget *parent) -{ - QLabel* l = new QLabel(s, parent); - l->setAlignment(Qt::AlignCenter); - l->setAutoFillBackground(true); - //QPalette palette; - //palette.setColor(label->backgroundRole(), c); - //l->setPalette(palette); - l->setBackgroundRole(QPalette::Dark); - return l; -} +//#include "popupmenu.h" +#include "routepopup.h" /* //--------------------------------------------------------- @@ -145,14 +120,6 @@ void AudioStrip::songChanged(int val) if (val & SC_CHANNELS) updateChannels(); - // p3.3.47 - // Update the routing popup menu if anything relevant changed. - if (val & (SC_ROUTE | SC_CHANNELS | SC_CONFIG)) - { - //updateRouteMenus(); - muse->updateRouteMenus(track, this); // p3.3.50 Use this handy shared routine. - } - // Catch when label font, or configuration min slider and meter values change. if (val & SC_CONFIG) { @@ -215,7 +182,6 @@ void AudioStrip::songChanged(int val) if (val & SC_TRACK_MODIFIED) { setLabelText(); - // Added by Tim. p3.3.9 setLabelFont(); } @@ -1007,898 +973,14 @@ AudioStrip::AudioStrip(QWidget* parent, AudioTrack* at) } //--------------------------------------------------------- -// addMenuItem -//--------------------------------------------------------- - -static int addMenuItem(AudioTrack* track, Track* route_track, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput) -{ - // totalInChannels is only used by syntis. - int toch = ((AudioTrack*)track)->totalOutChannels(); - // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user. - if(track->channels() == 1) - toch = 1; - - // Don't add the last stray mono route if the track is stereo. - //if(route_track->channels() > 1 && (channel+1 == chans)) - // return id; - - RouteList* rl = isOutput ? track->outRoutes() : track->inRoutes(); - - QAction* act; - - QString s(route_track->name()); - - act = lb->addAction(s); - act->setData(id); - act->setCheckable(true); - - int ach = channel; - int bch = -1; - - Route r(route_track, isOutput ? ach : bch, channels); - - r.remoteChannel = isOutput ? bch : ach; - - mm.insert( pRouteMenuMap(id, r) ); - - for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) - { - if(ir->type == Route::TRACK_ROUTE && ir->track == route_track && ir->remoteChannel == r.remoteChannel) - { - int tcompch = r.channel; - if(tcompch == -1) - tcompch = 0; - int tcompchs = r.channels; - if(tcompchs == -1) - tcompchs = isOutput ? track->channels() : route_track->channels(); - - int compch = ir->channel; - if(compch == -1) - compch = 0; - int compchs = ir->channels; - if(compchs == -1) - compchs = isOutput ? track->channels() : ir->track->channels(); - - if(compch == tcompch && compchs == tcompchs) - { - act->setChecked(true); - break; - } - } - } - return ++id; -} - -//--------------------------------------------------------- -// addAuxPorts -//--------------------------------------------------------- - -static int addAuxPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput) - { - AuxList* al = song->auxs(); - for (iAudioAux i = al->begin(); i != al->end(); ++i) { - Track* track = *i; - if (t == track) - continue; - id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput); - } - return id; - } - -//--------------------------------------------------------- -// addInPorts -//--------------------------------------------------------- - -static int addInPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput) - { - InputList* al = song->inputs(); - for (iAudioInput i = al->begin(); i != al->end(); ++i) { - Track* track = *i; - if (t == track) - continue; - id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput); - } - return id; - } - -//--------------------------------------------------------- -// addOutPorts -//--------------------------------------------------------- - -static int addOutPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput) - { - OutputList* al = song->outputs(); - for (iAudioOutput i = al->begin(); i != al->end(); ++i) { - Track* track = *i; - if (t == track) - continue; - id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput); - } - return id; - } - -//--------------------------------------------------------- -// addGroupPorts -//--------------------------------------------------------- - -static int addGroupPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput) - { - GroupList* al = song->groups(); - for (iAudioGroup i = al->begin(); i != al->end(); ++i) { - Track* track = *i; - if (t == track) - continue; - id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput); - } - return id; - } - -//--------------------------------------------------------- -// addWavePorts -//--------------------------------------------------------- - -static int addWavePorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput) - { - WaveTrackList* al = song->waves(); - for (iWaveTrack i = al->begin(); i != al->end(); ++i) { - Track* track = *i; - if (t == track) - continue; - id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput); - } - return id; - } - -//--------------------------------------------------------- -// addSyntiPorts -//--------------------------------------------------------- - -static int addSyntiPorts(AudioTrack* t, PopupMenu* lb, int id, - RouteMenuMap& mm, int channel, int channels, bool isOutput) -{ - RouteList* rl = isOutput ? t->outRoutes() : t->inRoutes(); - - QAction* act; - - SynthIList* al = song->syntis(); - for (iSynthI i = al->begin(); i != al->end(); ++i) - { - Track* track = *i; - if (t == track) - continue; - int toch = ((AudioTrack*)track)->totalOutChannels(); - // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user. - if(track->channels() == 1) - toch = 1; - - // totalInChannels is only used by syntis. - int chans = (!isOutput || track->type() != Track::AUDIO_SOFTSYNTH) ? toch : ((AudioTrack*)track)->totalInChannels(); - - int tchans = (channels != -1) ? channels: t->channels(); - if(tchans == 2) - { - // Ignore odd numbered left-over mono channel. - //chans = chans & ~1; - //if(chans != 0) - chans -= 1; - } - - if(chans > 0) - { - PopupMenu* chpup = new PopupMenu(lb, true); - chpup->setTitle(track->name()); - for(int ch = 0; ch < chans; ++ch) - { - char buffer[128]; - if(tchans == 2) - snprintf(buffer, 128, "%s %d,%d", chpup->tr("Channel").toLatin1().constData(), ch+1, ch+2); - else - snprintf(buffer, 128, "%s %d", chpup->tr("Channel").toLatin1().constData(), ch+1); - act = chpup->addAction(QString(buffer)); - act->setData(id); - act->setCheckable(true); - - int ach = (channel == -1) ? ch : channel; - int bch = (channel == -1) ? -1 : ch; - - Route rt(track, (t->type() != Track::AUDIO_SOFTSYNTH || isOutput) ? ach : bch, tchans); - //Route rt(track, ch); - //rt.remoteChannel = -1; - rt.remoteChannel = (t->type() != Track::AUDIO_SOFTSYNTH || isOutput) ? bch : ach; - - mm.insert( pRouteMenuMap(id, rt) ); - - for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) - { - if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->remoteChannel == rt.remoteChannel) - { - int tcompch = rt.channel; - if(tcompch == -1) - tcompch = 0; - int tcompchs = rt.channels; - if(tcompchs == -1) - tcompchs = isOutput ? t->channels() : track->channels(); - - int compch = ir->channel; - if(compch == -1) - compch = 0; - int compchs = ir->channels; - if(compchs == -1) - compchs = isOutput ? t->channels() : ir->track->channels(); - - if(compch == tcompch && compchs == tcompchs) - { - act->setChecked(true); - break; - } - } - } - ++id; - } - - lb->addMenu(chpup); - } - } - return id; -} - -//--------------------------------------------------------- -// addMultiChannelOutPorts -//--------------------------------------------------------- - -static int addMultiChannelPorts(AudioTrack* t, PopupMenu* pup, int id, RouteMenuMap& mm, bool isOutput) -{ - int toch = t->totalOutChannels(); - // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user. - if(t->channels() == 1) - toch = 1; - - // Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less. - // totalInChannels is only used by syntis. - int chans = (isOutput || t->type() != Track::AUDIO_SOFTSYNTH) ? toch : t->totalInChannels(); - - if(chans > 1) - pup->addAction(new MenuTitleItem("<Mono>", pup)); - - // - // If it's more than one channel, create a sub-menu. If it's just one channel, don't bother with a sub-menu... - // - - PopupMenu* chpup = pup; - - for(int ch = 0; ch < chans; ++ch) - { - // If more than one channel, create the sub-menu. - if(chans > 1) - chpup = new PopupMenu(pup, true); - - if(isOutput) - { - switch(t->type()) - { - - case Track::AUDIO_INPUT: - //id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput); // Rem p4.0.20 - case Track::WAVE: - case Track::AUDIO_GROUP: - case Track::AUDIO_SOFTSYNTH: - case Track::AUDIO_AUX: // p4.0.20 - id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput); - id = addOutPorts(t, chpup, id, mm, ch, 1, isOutput); - id = addGroupPorts(t, chpup, id, mm, ch, 1, isOutput); - id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput); - //break; // Rem p4.0.20 - //case Track::AUDIO_AUX: // - //id = addOutPorts(t, chpup, id, mm, ch, 1, isOutput); // - break; - default: - break; - } - } - else - { - switch(t->type()) - { - - case Track::AUDIO_OUTPUT: - id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput); - id = addInPorts(t, chpup, id, mm, ch, 1, isOutput); - id = addGroupPorts(t, chpup, id, mm, ch, 1, isOutput); - id = addAuxPorts(t, chpup, id, mm, ch, 1, isOutput); - id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput); - break; - case Track::WAVE: - //id = addInPorts(t, chpup, id, mm, ch, 1, isOutput); // Rem p4.0.20 - //break; - case Track::AUDIO_SOFTSYNTH: - case Track::AUDIO_GROUP: - id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput); - id = addInPorts(t, chpup, id, mm, ch, 1, isOutput); - id = addGroupPorts(t, chpup, id, mm, ch, 1, isOutput); - id = addAuxPorts(t, chpup, id, mm, ch, 1, isOutput); // p4.0.20 - id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput); - break; - default: - break; - } - } - - // If more than one channel, add the created sub-menu. - if(chans > 1) - { - char buffer[128]; - snprintf(buffer, 128, "%s %d", pup->tr("Channel").toLatin1().constData(), ch+1); - chpup->setTitle(QString(buffer)); - pup->addMenu(chpup); - } - } - - // For stereo listing, ignore odd numbered left-over channels. - chans -= 1; - if(chans > 0) - { - // Ignore odd numbered left-over channels. - //int schans = (chans & ~1) - 1; - - pup->addSeparator(); - pup->addAction(new MenuTitleItem("<Stereo>", pup)); - - // - // If it's more than two channels, create a sub-menu. If it's just two channels, don't bother with a sub-menu... - // - - chpup = pup; - if(chans <= 2) - // Just do one iteration. - chans = 1; - - for(int ch = 0; ch < chans; ++ch) - { - // If more than two channels, create the sub-menu. - if(chans > 2) - chpup = new PopupMenu(pup, true); - - if(isOutput) - { - switch(t->type()) - { - case Track::AUDIO_INPUT: - //id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput); // Rem p4.0.20 - case Track::WAVE: - case Track::AUDIO_GROUP: - case Track::AUDIO_SOFTSYNTH: - case Track::AUDIO_AUX: // p4.0.20 - id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput); // p4.0.20 - id = addOutPorts(t, chpup, id, mm, ch, 2, isOutput); - id = addGroupPorts(t, chpup, id, mm, ch, 2, isOutput); - id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput); - break; - //case Track::AUDIO_AUX: // Rem p4.0.20 - // id = addOutPorts(t, chpup, id, mm, ch, 2, isOutput); - // break; - default: - break; - } - } - else - { - switch(t->type()) - { - case Track::AUDIO_OUTPUT: - id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput); - id = addInPorts(t, chpup, id, mm, ch, 2, isOutput); - id = addGroupPorts(t, chpup, id, mm, ch, 2, isOutput); - id = addAuxPorts(t, chpup, id, mm, ch, 2, isOutput); - id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput); - break; - case Track::WAVE: - //id = addInPorts(t, chpup, id, mm, ch, 2, isOutput); // Rem p4.0.20 - //break; - case Track::AUDIO_SOFTSYNTH: - case Track::AUDIO_GROUP: - id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput); - id = addInPorts(t, chpup, id, mm, ch, 2, isOutput); - id = addGroupPorts(t, chpup, id, mm, ch, 2, isOutput); - id = addAuxPorts(t, chpup, id, mm, ch, 2, isOutput); // p4.0.20 - id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput); - break; - default: - break; - } - } - - // If more than two channels, add the created sub-menu. - if(chans > 2) - { - char buffer[128]; - snprintf(buffer, 128, "%s %d,%d", pup->tr("Channel").toLatin1().constData(), ch+1, ch+2); - chpup->setTitle(QString(buffer)); - pup->addMenu(chpup); - } - } - } - - return id; -} - -//--------------------------------------------------------- -// nonSyntiTrackAddSyntis -//--------------------------------------------------------- - -static int nonSyntiTrackAddSyntis(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, bool isOutput) -{ - RouteList* rl = isOutput ? t->outRoutes() : t->inRoutes(); - - QAction* act; - SynthIList* al = song->syntis(); - for (iSynthI i = al->begin(); i != al->end(); ++i) - { - Track* track = *i; - if (t == track) - continue; - - int toch = ((AudioTrack*)track)->totalOutChannels(); - // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user. - if(track->channels() == 1) - toch = 1; - - // totalInChannels is only used by syntis. - int chans = (!isOutput || track->type() != Track::AUDIO_SOFTSYNTH) ? toch : ((AudioTrack*)track)->totalInChannels(); - - //int schans = synti->channels(); - //if(schans < chans) - // chans = schans; -// int tchans = (channels != -1) ? channels: t->channels(); -// if(tchans == 2) -// { - // Ignore odd numbered left-over mono channel. - //chans = chans & ~1; - //if(chans != 0) -// chans -= 1; -// } - //int tchans = (channels != -1) ? channels: t->channels(); - - if(chans > 0) - { - PopupMenu* chpup = new PopupMenu(lb, true); - chpup->setTitle(track->name()); - if(chans > 1) - chpup->addAction(new MenuTitleItem("<Mono>", chpup)); - - for(int ch = 0; ch < chans; ++ch) - { - char buffer[128]; - snprintf(buffer, 128, "%s %d", chpup->tr("Channel").toLatin1().constData(), ch+1); - act = chpup->addAction(QString(buffer)); - act->setData(id); - act->setCheckable(true); - - int ach = ch; - int bch = -1; - - Route rt(track, isOutput ? bch : ach, 1); - - rt.remoteChannel = isOutput ? ach : bch; - - mm.insert( pRouteMenuMap(id, rt) ); - - for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) - { - if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->remoteChannel == rt.remoteChannel) - { - int tcompch = rt.channel; - if(tcompch == -1) - tcompch = 0; - int tcompchs = rt.channels; - if(tcompchs == -1) - tcompchs = isOutput ? t->channels() : track->channels(); - - int compch = ir->channel; - if(compch == -1) - compch = 0; - int compchs = ir->channels; - if(compchs == -1) - compchs = isOutput ? t->channels() : ir->track->channels(); - - if(compch == tcompch && compchs == tcompchs) - { - act->setChecked(true); - break; - } - } - } - ++id; - } - - chans -= 1; - if(chans > 0) - { - // Ignore odd numbered left-over channels. - //int schans = (chans & ~1) - 1; - - chpup->addSeparator(); - chpup->addAction(new MenuTitleItem("<Stereo>", chpup)); - - for(int ch = 0; ch < chans; ++ch) - { - char buffer[128]; - snprintf(buffer, 128, "%s %d,%d", chpup->tr("Channel").toLatin1().constData(), ch+1, ch+2); - act = chpup->addAction(QString(buffer)); - act->setData(id); - act->setCheckable(true); - - int ach = ch; - int bch = -1; - - Route rt(track, isOutput ? bch : ach, 2); - - rt.remoteChannel = isOutput ? ach : bch; - - mm.insert( pRouteMenuMap(id, rt) ); - - for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) - { - if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->remoteChannel == rt.remoteChannel) - { - int tcompch = rt.channel; - if(tcompch == -1) - tcompch = 0; - int tcompchs = rt.channels; - if(tcompchs == -1) - tcompchs = isOutput ? t->channels() : track->channels(); - - int compch = ir->channel; - if(compch == -1) - compch = 0; - int compchs = ir->channels; - if(compchs == -1) - compchs = isOutput ? t->channels() : ir->track->channels(); - - if(compch == tcompch && compchs == tcompchs) - { - act->setChecked(true); - break; - } - } - } - ++id; - } - } - - lb->addMenu(chpup); - } - } - return id; -} - -//--------------------------------------------------------- -// addMidiPorts -//--------------------------------------------------------- - -static int addMidiPorts(AudioTrack* t, PopupMenu* pup, int id, RouteMenuMap& mm, bool isOutput) -{ - QAction* act; - for(int i = 0; i < MIDI_PORTS; ++i) - { - MidiPort* mp = &midiPorts[i]; - MidiDevice* md = mp->device(); - - // This is desirable, but could lead to 'hidden' routes unless we add more support - // such as removing the existing routes when user changes flags. - // So for now, just list all valid ports whether read or write. - if(!md) - continue; - //if(!(md->rwFlags() & (isOutput ? 1 : 2))) - // continue; - - // p4.0.17 Do not list synth devices! - if(md->isSynti()) - continue; - - RouteList* rl = isOutput ? t->outRoutes() : t->inRoutes(); - - PopupMenu* subp = new PopupMenu(pup, true); - subp->setTitle(md->name()); - - int chanmask = 0; - // To reduce number of routes required, from one per channel to just one containing a channel mask. - // Look for the first route to this midi port. There should always be only a single route for each midi port, now. - for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) - { - if(ir->type == Route::MIDI_PORT_ROUTE && ir->midiPort == i) - { - // We have a route to the midi port. Grab the channel mask. - chanmask = ir->channel; - break; - } - } - - for(int ch = 0; ch < MIDI_CHANNELS; ++ch) - { - act = subp->addAction(QString("Channel %1").arg(ch+1)); - act->setCheckable(true); - act->setData(id); - - int chbit = 1 << ch; - Route srcRoute(i, chbit); // In accordance with new channel mask, use the bit position. - - mm.insert( pRouteMenuMap(id, srcRoute) ); - - if(chanmask & chbit) // Is the channel already set? Show item check mark. - act->setChecked(true); - - ++id; - } - - //gid = MIDI_PORTS * MIDI_CHANNELS + i; // Make sure each 'toggle' item gets a unique id. - act = subp->addAction(QString("Toggle all")); - //act->setCheckable(true); - act->setData(id); - Route togRoute(i, (1 << MIDI_CHANNELS) - 1); // Set all channel bits. - mm.insert( pRouteMenuMap(id, togRoute) ); - ++id; - - pup->addMenu(subp); - } - return id; -} - -//--------------------------------------------------------- -// routingPopupMenuActivated -//--------------------------------------------------------- - -void AudioStrip::routingPopupMenuActivated(QAction* act) -{ - if(!track || gRoutingPopupMenuMaster != this || track->isMidiTrack()) - return; - - PopupMenu* pup = muse->getRoutingPopupMenu(); - - if(pup->actions().isEmpty()) - return; - - AudioTrack* t = (AudioTrack*)track; - RouteList* rl = gIsOutRoutingPopupMenu ? t->outRoutes() : t->inRoutes(); - - int n = act->data().toInt(); - if (n == -1) - return; - - iRouteMenuMap imm = gRoutingMenuMap.find(n); - if(imm == gRoutingMenuMap.end()) - return; - - if(gIsOutRoutingPopupMenu) - { - Route srcRoute(t, imm->second.channel, imm->second.channels); - srcRoute.remoteChannel = imm->second.remoteChannel; - - Route &dstRoute = imm->second; - - // check if route src->dst exists: - iRoute irl = rl->begin(); - for (; irl != rl->end(); ++irl) { - if (*irl == dstRoute) - break; - } - if (irl != rl->end()) { - // disconnect if route exists - audio->msgRemoveRoute(srcRoute, dstRoute); - } - else { - // connect if route does not exist - audio->msgAddRoute(srcRoute, dstRoute); - } - audio->msgUpdateSoloStates(); - song->update(SC_ROUTE); - } - else - { - Route &srcRoute = imm->second; - - // Support Midi Port to Audio Input routes. p4.0.14 Tim. - if(track->type() == Track::AUDIO_INPUT && srcRoute.type == Route::MIDI_PORT_ROUTE) - { - int chbit = srcRoute.channel; - Route dstRoute(t, chbit); - int mdidx = srcRoute.midiPort; - int chmask = 0; - iRoute iir = rl->begin(); - for (; iir != rl->end(); ++iir) - { - if(iir->type == Route::MIDI_PORT_ROUTE && iir->midiPort == mdidx) // Is there already a route to this port? - { - chmask = iir->channel; // Grab the channel mask. - break; - } - } - - if ((chmask & chbit) == chbit) // Is the channel's bit(s) set? - { - //printf("astrip: removing src route ch:%d dst route ch:%d\n", srcRoute.channel, dstRoute.channel); - audio->msgRemoveRoute(srcRoute, dstRoute); - } - else - { - //printf("astrip: adding src route ch:%d dst route ch:%d\n", srcRoute.channel, dstRoute.channel); - audio->msgAddRoute(srcRoute, dstRoute); - } - - audio->msgUpdateSoloStates(); - song->update(SC_ROUTE); - return; - } - - Route dstRoute(t, imm->second.channel, imm->second.channels); - dstRoute.remoteChannel = imm->second.remoteChannel; - - iRoute irl = rl->begin(); - for (; irl != rl->end(); ++irl) { - if (*irl == srcRoute) - break; - } - if (irl != rl->end()) { - // disconnect - audio->msgRemoveRoute(srcRoute, dstRoute); - } - else { - // connect - audio->msgAddRoute(srcRoute, dstRoute); - } - audio->msgUpdateSoloStates(); - song->update(SC_ROUTE); - } -} - -//--------------------------------------------------------- // iRoutePressed //--------------------------------------------------------- void AudioStrip::iRoutePressed() { - //if(track->isMidiTrack() || (track->type() == Track::AUDIO_AUX) || (track->type() == Track::AUDIO_SOFTSYNTH)) - if(!track || track->isMidiTrack() || track->type() == Track::AUDIO_AUX) - { - gRoutingPopupMenuMaster = 0; - return; - } - - QPoint ppt = QCursor::pos(); - - PopupMenu* pup = muse->getRoutingPopupMenu(); - pup->disconnect(); - - AudioTrack* t = (AudioTrack*)track; - RouteList* irl = t->inRoutes(); - - QAction* act = 0; - int gid = 0; - //int id = 0; - - pup->clear(); - gRoutingMenuMap.clear(); - gid = 0; - - switch(track->type()) - { - case Track::AUDIO_INPUT: - { - for(int i = 0; i < channel; ++i) - { - char buffer[128]; - snprintf(buffer, 128, "%s %d", tr("Channel").toLatin1().constData(), i+1); - MenuTitleItem* titel = new MenuTitleItem(QString(buffer), pup); - pup->addAction(titel); - - if(!checkAudioDevice()) - { - gRoutingPopupMenuMaster = 0; - pup->clear(); - gRoutingMenuMap.clear(); - iR->setDown(false); - return; - } - std::list<QString> ol = audioDevice->outputPorts(); - for(std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip) - { - //id = gid * 16 + i; // IDs removed p4.0.14 Tim. - act = pup->addAction(*ip); - //act->setData(id); - act->setData(gid); - act->setCheckable(true); - - Route dst(*ip, true, i, Route::JACK_ROUTE); - //gRoutingMenuMap.insert( pRouteMenuMap(id, dst) ); - gRoutingMenuMap.insert( pRouteMenuMap(gid, dst) ); - ++gid; - for(iRoute ir = irl->begin(); ir != irl->end(); ++ir) - { - if(*ir == dst) - { - act->setChecked(true); - break; - } - } - } - if(i+1 != channel) - pup->addSeparator(); - } - - // p4.0.14 - // - // Display using separate menus for midi ports and audio outputs: - // - pup->addSeparator(); - pup->addAction(new MenuTitleItem(tr("Soloing chain"), pup)); - PopupMenu* subp = new PopupMenu(pup, true); - subp->setTitle(tr("Audio sends")); - pup->addMenu(subp); - gid = addOutPorts(t, subp, gid, gRoutingMenuMap, -1, -1, false); - subp = new PopupMenu(pup, true); - subp->setTitle(tr("Midi port sends")); - pup->addMenu(subp); - addMidiPorts(t, subp, gid, gRoutingMenuMap, false); - // - // Display all in the same menu: - // - //pup->addAction(new MenuTitleItem(tr("Audio sends"), pup)); - //gid = addOutPorts(t, pup, gid, gRoutingMenuMap, -1, -1, false); - //pup->addSeparator(); - //pup->addAction(new MenuTitleItem(tr("Midi sends"), pup)); - //addMidiPorts(t, pup, gid, gRoutingMenuMap, false); - } - break; - //case Track::AUDIO_OUTPUT: - //case Track::WAVE: - //case Track::AUDIO_GROUP: - - case Track::AUDIO_OUTPUT: - gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, false); - gid = addInPorts( t, pup, gid, gRoutingMenuMap, -1, -1, false); - gid = addGroupPorts(t, pup, gid, gRoutingMenuMap, -1, -1, false); - gid = addAuxPorts( t, pup, gid, gRoutingMenuMap, -1, -1, false); - gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, false); - break; - case Track::WAVE: - gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, false); // p4.0.20 - gid = addInPorts( t, pup, gid, gRoutingMenuMap, -1, -1, false); - gid = addGroupPorts(t, pup, gid, gRoutingMenuMap, -1, -1, false); // - gid = addAuxPorts( t, pup, gid, gRoutingMenuMap, -1, -1, false); // - gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, false); // - break; - case Track::AUDIO_GROUP: - gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, false); - gid = addInPorts( t, pup, gid, gRoutingMenuMap, -1, -1, false); - gid = addGroupPorts(t, pup, gid, gRoutingMenuMap, -1, -1, false); - gid = addAuxPorts( t, pup, gid, gRoutingMenuMap, -1, -1, false); // p4.0.20 - gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, false); - break; - - case Track::AUDIO_SOFTSYNTH: - gid = addMultiChannelPorts(t, pup, gid, gRoutingMenuMap, false); - break; - default: - gRoutingPopupMenuMaster = 0; - pup->clear(); - gRoutingMenuMap.clear(); - iR->setDown(false); - return; - } - - if(pup->actions().isEmpty()) - { - gRoutingPopupMenuMaster = 0; - gRoutingMenuMap.clear(); - iR->setDown(false); - return; - } - - gIsOutRoutingPopupMenu = false; - gRoutingPopupMenuMaster = this; - connect(pup, SIGNAL(triggered(QAction*)), SLOT(routingPopupMenuActivated(QAction*))); - connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide())); - pup->popup(ppt); + RoutePopupMenu* pup = muse->getRoutingPopupMenu(); iR->setDown(false); + pup->exec(QCursor::pos(), track, false); } //--------------------------------------------------------- @@ -1907,136 +989,8 @@ void AudioStrip::iRoutePressed() void AudioStrip::oRoutePressed() { - if(!track || track->isMidiTrack()) - { - gRoutingPopupMenuMaster = 0; - return; - } - - QPoint ppt = QCursor::pos(); - - PopupMenu* pup = muse->getRoutingPopupMenu(); - pup->disconnect(); - - AudioTrack* t = (AudioTrack*)track; - RouteList* orl = t->outRoutes(); - - QAction* act = 0; - int gid = 0; - //int id = 0; - - pup->clear(); - gRoutingMenuMap.clear(); - gid = 0; - - switch(track->type()) - { - case Track::AUDIO_OUTPUT: - { - for(int i = 0; i < channel; ++i) - { - char buffer[128]; - snprintf(buffer, 128, "%s %d", tr("Channel").toLatin1().constData(), i+1); - MenuTitleItem* titel = new MenuTitleItem(QString(buffer), pup); - pup->addAction(titel); - - if(!checkAudioDevice()) - { - gRoutingPopupMenuMaster = 0; - pup->clear(); - gRoutingMenuMap.clear(); - oR->setDown(false); - return; - } - std::list<QString> ol = audioDevice->inputPorts(); - for(std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip) - { - //id = gid * 16 + i; // IDs removed p4.0.14 Tim. - act = pup->addAction(*ip); - //act->setData(id); - act->setData(gid); - act->setCheckable(true); - - Route dst(*ip, true, i, Route::JACK_ROUTE); - //gRoutingMenuMap.insert( pRouteMenuMap(id, dst) ); - gRoutingMenuMap.insert( pRouteMenuMap(gid, dst) ); - ++gid; - for(iRoute ir = orl->begin(); ir != orl->end(); ++ir) - { - if(*ir == dst) - { - act->setChecked(true); - break; - } - } - } - if(i+1 != channel) - pup->addSeparator(); - } - - // p4.0.14 - // - // Display using separate menu for audio inputs: - // - pup->addSeparator(); - pup->addAction(new MenuTitleItem(tr("Soloing chain"), pup)); - PopupMenu* subp = new PopupMenu(pup, true); - subp->setTitle(tr("Audio returns")); - pup->addMenu(subp); - gid = addInPorts(t, subp, gid, gRoutingMenuMap, -1, -1, true); - // - // Display all in the same menu: - // - //pup->addSeparator(); - //MenuTitleItem* title = new MenuTitleItem(tr("Audio returns"), pup); - //pup->addAction(title); - //gid = addInPorts(t, pup, gid, gRoutingMenuMap, -1, -1, true); - } - break; - //case Track::AUDIO_INPUT: - //case Track::WAVE: - //case Track::AUDIO_GROUP: - - case Track::AUDIO_SOFTSYNTH: - gid = addMultiChannelPorts(t, pup, gid, gRoutingMenuMap, true); - break; - - case Track::AUDIO_INPUT: - //gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, true); // Rem p4.0.20 - case Track::WAVE: - case Track::AUDIO_GROUP: - case Track::AUDIO_AUX: - //case Track::AUDIO_SOFTSYNTH: - gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, true); // p4.0.20 - gid = addOutPorts( t, pup, gid, gRoutingMenuMap, -1, -1, true); - gid = addGroupPorts( t, pup, gid, gRoutingMenuMap, -1, -1, true); - gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, true); - break; - //case Track::AUDIO_AUX: - // gid = addOutPorts( t, pup, gid, gRoutingMenuMap, -1, -1, true); - //break; - - default: - gRoutingPopupMenuMaster = 0; - pup->clear(); - gRoutingMenuMap.clear(); - oR->setDown(false); - return; - } - - if(pup->actions().isEmpty()) - { - gRoutingPopupMenuMaster = 0; - gRoutingMenuMap.clear(); - oR->setDown(false); - return; - } - - gIsOutRoutingPopupMenu = true; - gRoutingPopupMenuMaster = this; - connect(pup, SIGNAL(triggered(QAction*)), SLOT(routingPopupMenuActivated(QAction*))); - connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide())); - pup->popup(ppt); + RoutePopupMenu* pup = muse->getRoutingPopupMenu(); oR->setDown(false); + pup->exec(QCursor::pos(), track, true); } |