~ubuntu-branches/ubuntu/oneiric/muse/oneiric

« back to all changes in this revision

Viewing changes to muse/mixer/astrip.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2010-11-17 21:43:38 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101117214338-1hvfl7oo2dsqnvrb
Tags: 1.1-0ubuntu1
* New upstream release (LP: #668631)
* Switch to dpkg-source 3.0 (quilt) format
* Switch to dh7 short form
* debian/rules:
  - added --enable-dssi and --enable-osc to conf flags for dssi support
  - added -ljackserver to LDFLAGS to fix a FTBFS because of --as-needed
* debian/control:
  - added build build dependency on liblo-dev and dssi-dev for dssi support
  - bump Standards-version to 3.9.1. No changes required.
* debian/muse.desktop, debian/muse.xpm: dropped as desktop file and icon is
  now shipped upstream.
* fix-desktop-categories.patch: fix Categories tag in upstream desktop file
* 10_es_locale_fix.dpatch: refreshed and converted to quilt as
  fix_es_locale.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <qcombobox.h>
18
18
#include <qtooltip.h>
19
19
#include <qtimer.h>
20
 
#include <qpopupmenu.h>
 
20
//#include <qpopupmenu.h>
21
21
#include <qcursor.h>
22
 
#include <qmenudata.h>
23
22
#include <qpainter.h>
 
23
#include <qstring.h>
 
24
#include <qpoint.h>
 
25
#include <qevent.h>
 
26
#include <qwidget.h>
24
27
 
 
28
#include "app.h"
25
29
#include "globals.h"
26
30
#include "audio.h"
27
31
#include "driver/audiodev.h"
33
37
#include "astrip.h"
34
38
#include "track.h"
35
39
#include "synth.h"
36
 
#include "route.h"
 
40
//#include "route.h"
37
41
#include "doublelabel.h"
38
42
#include "rack.h"
39
43
#include "node.h"
42
46
#include "gconfig.h"
43
47
#include "ttoolbutton.h"
44
48
#include "menutitleitem.h"
 
49
#include "popupmenu.h"
45
50
 
46
51
/*
47
52
//---------------------------------------------------------
122
127
 
123
128
void AudioStrip::configChanged()    
124
129
125
 
  // Added by Tim. p3.3.6
126
 
  //printf("AudioStrip::configChanged\n");
127
 
      
128
130
  songChanged(SC_CONFIG); 
129
131
}
130
132
 
135
137
void AudioStrip::songChanged(int val)
136
138
      {
137
139
      // Is it simply a midi controller value adjustment? Forget it.
138
 
      if(val == SC_MIDI_CONTROLLER)
 
140
      if (val == SC_MIDI_CONTROLLER)
139
141
        return;
140
142
    
141
143
      AudioTrack* src = (AudioTrack*)track;
143
145
      // Do channels before config...
144
146
      if (val & SC_CHANNELS)
145
147
        updateChannels();
 
148
      
 
149
      // p3.3.47
 
150
      // Update the routing popup menu if anything relevant changed.
 
151
      if (val & (SC_ROUTE | SC_CHANNELS | SC_CONFIG))
 
152
      { 
 
153
        //updateRouteMenus();
 
154
        muse->updateRouteMenus(track, this);      // p3.3.50 Use this handy shared routine.
 
155
      }
 
156
      
146
157
      // Catch when label font, or configuration min slider and meter values change.
147
158
      if (val & SC_CONFIG)
148
159
      {
249
260
      double vol = ((AudioTrack*)track)->volume();
250
261
        if (vol != volume) 
251
262
        {
252
 
            // Added by Tim. p3.3.6
253
263
            //printf("AudioStrip::updateVolume setting slider and label\n");
254
264
          
255
265
            slider->blockSignals(true);
272
282
      double v = ((AudioTrack*)track)->pan();
273
283
        if (v != panVal) 
274
284
        {
275
 
            // Added by Tim. p3.3.6
276
285
            //printf("AudioStrip::updatePan setting slider and label\n");
277
286
            
278
287
            pan->blockSignals(true);
553
562
      {
554
563
      AudioTrack* t = (AudioTrack*)track;
555
564
      int c = t->channels();
556
 
      // Added by Tim. p3.3.6
557
565
      //printf("AudioStrip::updateChannels track channels:%d current channels:%d\n", c, channel);
558
566
      
559
567
      if (c > channel) {
678
686
AudioStrip::AudioStrip(QWidget* parent, AudioTrack* at)
679
687
   : Strip(parent, at)
680
688
      {
681
 
      iR            = 0;
682
 
      oR            = 0;
 
689
      //iR            = 0;
 
690
      //oR            = 0;
 
691
      
683
692
      off           = 0;
684
693
      
685
694
      volume        = -1.0;
874
883
      connect(solo, SIGNAL(toggled(bool)), SLOT(soloToggled(bool)));
875
884
      if (type == Track::AUDIO_OUTPUT) {
876
885
            QToolTip::add(record, tr("record downmix"));
877
 
            QToolTip::add(solo, tr("solo mode (monitor)"));
 
886
            //QToolTip::add(solo, tr("solo mode (monitor)"));
 
887
            QToolTip::add(solo, tr("solo mode"));
878
888
            }
879
889
      else {
880
 
            QToolTip::add(solo, tr("pre fader listening"));
 
890
            //QToolTip::add(solo, tr("pre fader listening"));
 
891
            QToolTip::add(solo, tr("solo mode"));
881
892
            }
882
893
 
883
894
      off  = new TransparentToolButton(this);
960
971
      }
961
972
 
962
973
//---------------------------------------------------------
 
974
//   addMenuItem
 
975
//---------------------------------------------------------
 
976
 
 
977
static int addMenuItem(AudioTrack* track, Track* route_track, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
 
978
{
 
979
  // totalInChannels is only used by syntis.
 
980
  //int channels = (!isOutput || route_track->type() != Track::AUDIO_SOFTSYNTH) ? ((AudioTrack*)route_track)->totalOutChannels() : ((AudioTrack*)route_track)->totalInChannels();
 
981
  //int channels = (!isOutput || track->type() != Track::AUDIO_SOFTSYNTH) ? ((AudioTrack*)track)->totalOutChannels() : ((AudioTrack*)track)->totalInChannels();
 
982
  int toch = ((AudioTrack*)track)->totalOutChannels();
 
983
  // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user.
 
984
  if(track->channels() == 1)
 
985
    toch = 1;
 
986
  
 
987
  // totalInChannels is only used by syntis.
 
988
  ///int chans = (isOutput || track->type() != Track::AUDIO_SOFTSYNTH) ? toch : ((AudioTrack*)track)->totalInChannels();
 
989
  
 
990
  // Don't add the last stray mono route if the track is stereo.
 
991
  //if(route_track->channels() > 1 && (channel+1 == chans))
 
992
  //  return id;
 
993
    
 
994
  RouteList* rl = isOutput ? track->outRoutes() : track->inRoutes();
 
995
  
 
996
  QString s(route_track->name());
 
997
  //int trackchans = track->channels();
 
998
  //QString ns;
 
999
  
 
1000
  //if(track->channels() > 1 && (channel+1 < channels))
 
1001
  //if(track->channels() > 1)
 
1002
  //if(route_track->type() == Track::AUDIO_SOFTSYNTH && channels > 2 && track->channels() > 1)
 
1003
  ///if(track->type() == Track::AUDIO_SOFTSYNTH && chans > 2 && route_track->channels() > 1)
 
1004
  ///  s += QString(" < [%1,%2]").arg(channel+1).arg(channel+2);
 
1005
  
 
1006
  //int it = lb->insertItem(s);
 
1007
  lb->insertItem(s, id);
 
1008
  
 
1009
  int ach = channel;
 
1010
  int bch = -1;
 
1011
  
 
1012
  Route r(route_track, isOutput ? ach : bch, channels);
 
1013
  //Route r(route_track, channel);
 
1014
  
 
1015
  r.remoteChannel = isOutput ? bch : ach;
 
1016
  
 
1017
  mm.insert( pRouteMenuMap(id, r) );
 
1018
  
 
1019
  for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) 
 
1020
  {
 
1021
    //if (ir->type == 0 && ir->track == track) {
 
1022
    //if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->channels == channels) 
 
1023
    //if(ir->type == Route::TRACK_ROUTE && ir->track == track && 
 
1024
    //   (channel != -1 && ir->channel == channel) && (channels != -1 && ir->channels == channels)) 
 
1025
    //if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->channel == channel) 
 
1026
    //printf("addMenuItem: ir->type:%d ir->track:%s track:%s ir->channel:%d channel:%d ir->channels:%d channels:%d\n",
 
1027
    //       ir->type, ir->track->name().latin1(), track->name().latin1(), ir->channel, channel, ir->channels, channels);
 
1028
    //if(ir->type == Route::TRACK_ROUTE && ir->track == route_track && ir->channel == channel && ir->remoteChannel == r.remoteChannel) 
 
1029
    //if(*ir == r)
 
1030
    //if(ir->type == Route::TRACK_ROUTE && ir->track == route_track && ir->channel == channel && ir->channels == channels && ir->remoteChannel == r.remoteChannel) 
 
1031
    
 
1032
    if(ir->type == Route::TRACK_ROUTE && ir->track == route_track && ir->remoteChannel == r.remoteChannel)
 
1033
    {
 
1034
      int tcompch = r.channel;
 
1035
      if(tcompch == -1)
 
1036
        tcompch = 0;
 
1037
      int tcompchs = r.channels;
 
1038
      if(tcompchs == -1)
 
1039
        tcompchs = isOutput ? track->channels() : route_track->channels();
 
1040
      
 
1041
      int compch = ir->channel;
 
1042
      if(compch == -1)
 
1043
        compch = 0;
 
1044
      int compchs = ir->channels;
 
1045
      if(compchs == -1)
 
1046
        compchs = isOutput ? track->channels() : ir->track->channels();
 
1047
      
 
1048
      //if(ir->type == Route::TRACK_ROUTE && ir->track == route_track && ir->channel == r.channel && ir->channels == r.channels && ir->remoteChannel == r.remoteChannel) 
 
1049
      if(compch == tcompch && compchs == tcompchs) 
 
1050
      {
 
1051
        //lb->setItemChecked(it, true);
 
1052
        lb->setItemChecked(id, true);
 
1053
        break;
 
1054
      }
 
1055
    }  
 
1056
  }
 
1057
  return ++id;      
 
1058
}
 
1059
 
 
1060
//---------------------------------------------------------
963
1061
//   addAuxPorts
964
1062
//---------------------------------------------------------
965
1063
 
966
 
static void addAuxPorts(AudioTrack* t, QPopupMenu* lb, RouteList* r)
 
1064
static int addAuxPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
967
1065
      {
968
1066
      AuxList* al = song->auxs();
969
1067
      for (iAudioAux i = al->begin(); i != al->end(); ++i) {
970
1068
            Track* track = *i;
971
1069
            if (t == track)
972
1070
                  continue;
 
1071
            //id = addMenuItem(parent, t, track, lb, id, mm, channel, channels, isOutput);
 
1072
            id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput);
 
1073
            
 
1074
            /*
973
1075
            QString s(track->name());
974
 
            int it = lb->insertItem(s);
 
1076
            //int it = lb->insertItem(s);
 
1077
            lb->insertItem(s, id);
975
1078
            for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
976
 
                  if (ir->type == 0 && ir->track == track) {
977
 
                        lb->setItemChecked(it, true);
 
1079
                  //if (ir->type == 0 && ir->track == track) {
 
1080
                  if (ir->type == 0 && ir->track == track && ir->channels == channels) {
 
1081
                        //lb->setItemChecked(it, true);
 
1082
                        lb->setItemChecked(id, true);
978
1083
                        break;
979
1084
                        }
980
1085
                  }
 
1086
            ++id;      
 
1087
            */      
 
1088
            
981
1089
            }
 
1090
      return id;      
982
1091
      }
983
1092
 
984
1093
//---------------------------------------------------------
985
1094
//   addInPorts
986
1095
//---------------------------------------------------------
987
1096
 
988
 
static void addInPorts(AudioTrack* t, QPopupMenu* lb, RouteList* r)
 
1097
static int addInPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
989
1098
      {
990
1099
      InputList* al = song->inputs();
991
1100
      for (iAudioInput i = al->begin(); i != al->end(); ++i) {
992
1101
            Track* track = *i;
993
1102
            if (t == track)
994
1103
                  continue;
 
1104
            //id = addMenuItem(parent, t, track, lb, id, mm, channel, channels, isOutput);
 
1105
            id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput);
 
1106
            
 
1107
            /*
995
1108
            QString s(track->name());
996
 
            int it = lb->insertItem(s);
 
1109
            //int it = lb->insertItem(s);
 
1110
            lb->insertItem(s, id);
997
1111
            for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
998
 
                  if (ir->type == 0 && ir->track == track) {
999
 
                        lb->setItemChecked(it, true);
 
1112
                  //if (ir->type == 0 && ir->track == track) {
 
1113
                  if (ir->type == 0 && ir->track == track && ir->channels == channels) {
 
1114
                        //lb->setItemChecked(it, true);
 
1115
                        lb->setItemChecked(id, true);
1000
1116
                        break;
1001
1117
                        }
1002
1118
                  }
 
1119
            ++id;      
 
1120
            */
 
1121
            
1003
1122
            }
 
1123
      return id;      
1004
1124
      }
1005
1125
 
1006
1126
//---------------------------------------------------------
1007
1127
//   addOutPorts
1008
1128
//---------------------------------------------------------
1009
1129
 
1010
 
static void addOutPorts(AudioTrack* t, QPopupMenu* lb, RouteList* r)
 
1130
static int addOutPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
1011
1131
      {
1012
1132
      OutputList* al = song->outputs();
1013
1133
      for (iAudioOutput i = al->begin(); i != al->end(); ++i) {
1014
1134
            Track* track = *i;
1015
1135
            if (t == track)
1016
1136
                  continue;
 
1137
            //id = addMenuItem(parent, t, track, lb, id, mm, channel, channels, isOutput);
 
1138
            id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput);
 
1139
            
 
1140
            /*
1017
1141
            QString s(track->name());
1018
 
            int it = lb->insertItem(s);
 
1142
            //int it = lb->insertItem(s);
 
1143
            lb->insertItem(s, id);
1019
1144
            for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
1020
 
                  if (ir->type == 0 && ir->track == track) {
1021
 
                        lb->setItemChecked(it, true);
 
1145
                  //if (ir->type == 0 && ir->track == track) {
 
1146
                  if (ir->type == 0 && ir->track == track && ir->channels == channels) {
 
1147
                        //lb->setItemChecked(it, true);
 
1148
                        lb->setItemChecked(id, true);
1022
1149
                        break;
1023
1150
                        }
1024
1151
                  }
 
1152
            ++id;      
 
1153
            */
 
1154
            
1025
1155
            }
 
1156
      return id;      
1026
1157
      }
1027
1158
 
1028
1159
//---------------------------------------------------------
1029
1160
//   addGroupPorts
1030
1161
//---------------------------------------------------------
1031
1162
 
1032
 
static void addGroupPorts(AudioTrack* t, QPopupMenu* lb, RouteList* r)
 
1163
static int addGroupPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
1033
1164
      {
1034
1165
      GroupList* al = song->groups();
1035
1166
      for (iAudioGroup i = al->begin(); i != al->end(); ++i) {
1036
1167
            Track* track = *i;
1037
1168
            if (t == track)
1038
1169
                  continue;
 
1170
            //id = addMenuItem(parent, t, track, lb, id, mm, channel, channels, isOutput);
 
1171
            id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput);
 
1172
            
 
1173
            /*
1039
1174
            QString s(track->name());
1040
 
            int it = lb->insertItem(s);
 
1175
            //int it = lb->insertItem(s);
 
1176
            lb->insertItem(s, id);
1041
1177
            for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
1042
 
                  if (ir->type == 0 && ir->track == track) {
1043
 
                        lb->setItemChecked(it, true);
 
1178
                  //if (ir->type == 0 && ir->track == track) {
 
1179
                  if (ir->type == 0 && ir->track == track && ir->channels == channels) {
 
1180
                        //lb->setItemChecked(it, true);
 
1181
                        lb->setItemChecked(id, true);
1044
1182
                        break;
1045
1183
                        }
1046
1184
                  }
 
1185
            ++id;      
 
1186
            */
 
1187
            
1047
1188
            }
 
1189
      return id;      
1048
1190
      }
1049
1191
 
1050
1192
//---------------------------------------------------------
1051
1193
//   addWavePorts
1052
1194
//---------------------------------------------------------
1053
1195
 
1054
 
static void addWavePorts(AudioTrack* t, QPopupMenu* lb, RouteList* r)
 
1196
static int addWavePorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
1055
1197
      {
1056
1198
      WaveTrackList* al = song->waves();
1057
1199
      for (iWaveTrack i = al->begin(); i != al->end(); ++i) {
1058
1200
            Track* track = *i;
1059
1201
            if (t == track)
1060
1202
                  continue;
 
1203
            //id = addMenuItem(parent, t, track, lb, id, mm, channel, channels, isOutput);
 
1204
            id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput);
 
1205
            
 
1206
            /*
1061
1207
            QString s(track->name());
1062
 
            int it = lb->insertItem(s);
 
1208
            //int it = lb->insertItem(s);
 
1209
            lb->insertItem(s, id);
1063
1210
            for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
1064
 
                  if (ir->type == 0 && ir->track == track) {
1065
 
                        lb->setItemChecked(it, true);
 
1211
                  //if (ir->type == 0 && ir->track == track) {
 
1212
                  if (ir->type == 0 && ir->track == track && ir->channels == channels) {
 
1213
                        //lb->setItemChecked(it, true);
 
1214
                        lb->setItemChecked(id, true);
1066
1215
                        break;
1067
1216
                        }
1068
1217
                  }
 
1218
            ++id;      
 
1219
            */
 
1220
            
1069
1221
            }
 
1222
      return id;      
1070
1223
      }
1071
1224
 
1072
1225
//---------------------------------------------------------
1073
1226
//   addSyntiPorts
1074
1227
//---------------------------------------------------------
1075
1228
 
1076
 
static void addSyntiPorts(AudioTrack* t, QPopupMenu* lb, RouteList* r)
1077
 
      {
1078
 
      SynthIList* al = song->syntis();
1079
 
      for (iSynthI i = al->begin(); i != al->end(); ++i) {
1080
 
            Track* track = *i;
1081
 
            if (t == track)
1082
 
                  continue;
1083
 
            QString s(track->name());
1084
 
            int it = lb->insertItem(s);
1085
 
            for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
1086
 
                  if (ir->type == 0 && ir->track == track) {
1087
 
                        lb->setItemChecked(it, true);
1088
 
                        break;
1089
 
                        }
1090
 
                  }
1091
 
            }
1092
 
      }
1093
 
 
 
1229
static int addSyntiPorts(AudioTrack* t, PopupMenu* lb, int id, 
 
1230
                         RouteMenuMap& mm, int channel, int channels, bool isOutput)
 
1231
{
 
1232
      RouteList* rl = isOutput ? t->outRoutes() : t->inRoutes();
 
1233
      
 
1234
      SynthIList* al = song->syntis();
 
1235
      for (iSynthI i = al->begin(); i != al->end(); ++i) 
 
1236
      {
 
1237
            Track* track = *i;
 
1238
            if (t == track)
 
1239
                  continue;
 
1240
            //id = addMenuItem(parent, track, lb, r, id, mm, channel, channels);
 
1241
            
 
1242
            /*
 
1243
            QString s(track->name());
 
1244
            //int it = lb->insertItem(s);
 
1245
            lb->insertItem(s, id);
 
1246
            for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
 
1247
                  //if (ir->type == 0 && ir->track == track) {
 
1248
                  if (ir->type == 0 && ir->track == track && ir->channels == channels) {
 
1249
                        //lb->setItemChecked(it, true);
 
1250
                        lb->setItemChecked(id, true);
 
1251
                        break;
 
1252
                        }
 
1253
                  }
 
1254
            ++id;      
 
1255
            */
 
1256
            
 
1257
            //SynthI* synti = (SynthI*)track;
 
1258
            
 
1259
            int toch = ((AudioTrack*)track)->totalOutChannels();
 
1260
            // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user.
 
1261
            if(track->channels() == 1)
 
1262
              toch = 1;
 
1263
            
 
1264
            //int chans = synti->totalOutChannels();
 
1265
            //int chans = (!isOutput || track->type() != Track::AUDIO_SOFTSYNTH) ? ((AudioTrack*)track)->totalOutChannels() : ((AudioTrack*)track)->totalInChannels();
 
1266
            // totalInChannels is only used by syntis.
 
1267
            int chans = (!isOutput || track->type() != Track::AUDIO_SOFTSYNTH) ? toch : ((AudioTrack*)track)->totalInChannels();
 
1268
            
 
1269
            //int schans = synti->channels();
 
1270
            //if(schans < chans)
 
1271
            //  chans = schans;
 
1272
            int tchans = (channels != -1) ? channels: t->channels();
 
1273
            if(tchans == 2)
 
1274
            {
 
1275
              // Ignore odd numbered left-over mono channel.
 
1276
              //chans = chans & ~1;
 
1277
              //if(chans != 0)
 
1278
                chans -= 1;
 
1279
            }
 
1280
            
 
1281
            if(chans > 0)
 
1282
            {
 
1283
              //QPopupMenu* chpup = new QPopupMenu(parent);
 
1284
              //PopupMenu* chpup = new PopupMenu(parent);
 
1285
              //PopupMenu* chpup = new PopupMenu(lb->parent());
 
1286
              PopupMenu* chpup = new PopupMenu();
 
1287
              //strip->connect(chpup, SIGNAL(activated(int)), strip, SLOT(routingPopupMenuActivated(int)));
 
1288
              lb->connect(chpup, SIGNAL(activated(int)), lb, SIGNAL(activated(int)));
 
1289
              chpup->setCheckable(true);
 
1290
              for(int ch = 0; ch < chans; ++ch)
 
1291
              {
 
1292
                char buffer[128];
 
1293
                if(tchans == 2)
 
1294
                  snprintf(buffer, 128, "%s %d,%d", chpup->tr("Channel").latin1(), ch+1, ch+2);
 
1295
                else  
 
1296
                  snprintf(buffer, 128, "%s %d", chpup->tr("Channel").latin1(), ch+1);
 
1297
                chpup->insertItem(QString(buffer), id);
 
1298
                
 
1299
                int ach = (channel == -1) ? ch : channel;
 
1300
                int bch = (channel == -1) ? -1 : ch;
 
1301
                
 
1302
                Route rt(track, (t->type() != Track::AUDIO_SOFTSYNTH || isOutput) ? ach : bch, tchans);
 
1303
                //Route rt(track, ch);
 
1304
                //rt.remoteChannel = -1;
 
1305
                rt.remoteChannel = (t->type() != Track::AUDIO_SOFTSYNTH || isOutput) ? bch : ach;
 
1306
                
 
1307
                mm.insert( pRouteMenuMap(id, rt) );
 
1308
                
 
1309
                for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) 
 
1310
                {
 
1311
                  //if (ir->type == 0 && ir->track == track) {
 
1312
                  //if(ir->type == 0 && ir->track == track && ir->channels == channels) 
 
1313
                  //if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->channel == channel && 
 
1314
                  //   ir->channels == channels && ir->remoteChannel == r.remoteChannel) 
 
1315
                  //if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->channel == ch && 
 
1316
                  //   ir->remoteChannel == rt.remoteChannel) 
 
1317
                  //if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->channel == rt.channel && 
 
1318
                  //   ir->channels == rt.channels && ir->remoteChannel == rt.remoteChannel) 
 
1319
                  
 
1320
                  if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->remoteChannel == rt.remoteChannel)
 
1321
                  {
 
1322
                    int tcompch = rt.channel;
 
1323
                    if(tcompch == -1)
 
1324
                      tcompch = 0;
 
1325
                    int tcompchs = rt.channels;
 
1326
                    if(tcompchs == -1)
 
1327
                      tcompchs = isOutput ? t->channels() : track->channels();
 
1328
                    
 
1329
                    int compch = ir->channel;
 
1330
                    if(compch == -1)
 
1331
                      compch = 0;
 
1332
                    int compchs = ir->channels;
 
1333
                    if(compchs == -1)
 
1334
                      compchs = isOutput ? t->channels() : ir->track->channels();
 
1335
                    
 
1336
                    if(compch == tcompch && compchs == tcompchs) 
 
1337
                    {
 
1338
                      chpup->setItemChecked(id, true);
 
1339
                      break;
 
1340
                    }
 
1341
                  }
 
1342
                }  
 
1343
                ++id;
 
1344
              }
 
1345
            
 
1346
              lb->insertItem(track->name(), chpup);
 
1347
            }
 
1348
      }
 
1349
      return id;      
 
1350
}
 
1351
 
 
1352
//---------------------------------------------------------
 
1353
//   addMultiChannelOutPorts
 
1354
//---------------------------------------------------------
 
1355
 
 
1356
static int addMultiChannelPorts(AudioTrack* t, PopupMenu* pup, int id, RouteMenuMap& mm, bool isOutput)
 
1357
{
 
1358
  int toch = t->totalOutChannels();
 
1359
  // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user.
 
1360
  if(t->channels() == 1)
 
1361
    toch = 1;
 
1362
  
 
1363
  // Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less. 
 
1364
  //int chans = t->totalOutChannels();  
 
1365
  // totalInChannels is only used by syntis.
 
1366
  //int chans = isOutput ? t->totalOutChannels() : t->totalInChannels();
 
1367
  //int chans = (isOutput || t->type() != Track::AUDIO_SOFTSYNTH) ? t->totalOutChannels() : t->totalInChannels();
 
1368
  int chans = (isOutput || t->type() != Track::AUDIO_SOFTSYNTH) ? toch : t->totalInChannels();
 
1369
 
 
1370
  // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user.
 
1371
  //if(t->channels() == 1)
 
1372
  //  chans = 1;
 
1373
  
 
1374
  if(chans > 1)
 
1375
  {
 
1376
    pup->insertItem(new MenuTitleItem("<Mono>"));
 
1377
    //pup->insertSeparator();
 
1378
  }
 
1379
  
 
1380
  //
 
1381
  // If it's more than one channel, create a sub-menu. If it's just one channel, don't bother with a sub-menu...
 
1382
  //
 
1383
 
 
1384
  //QPopupMenu* chpup = pup;
 
1385
  PopupMenu* chpup = pup;
 
1386
  
 
1387
  for(int ch = 0; ch < chans; ++ch)
 
1388
  {
 
1389
    // If more than one channel, create the sub-menu.
 
1390
    if(chans > 1)
 
1391
    {
 
1392
      //chpup = new QPopupMenu(parent);
 
1393
      //chpup = new PopupMenu(parent);
 
1394
      //chpup = new PopupMenu(pup->parent());
 
1395
      chpup = new PopupMenu();
 
1396
      //connect(chpup, SIGNAL(activated(int)), strip, SLOT(oRouteMenuActivated(int)));
 
1397
      //strip->connect(chpup, SIGNAL(activated(int)), strip, SLOT(routingPopupMenuActivated(int)));
 
1398
      pup->connect(chpup, SIGNAL(activated(int)), pup, SIGNAL(activated(int)));
 
1399
      chpup->setCheckable(true);
 
1400
    }
 
1401
    
 
1402
    if(isOutput)
 
1403
    {
 
1404
      switch(t->type()) 
 
1405
      {
 
1406
        
 
1407
        case Track::AUDIO_INPUT:
 
1408
              //id = addWavePorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1409
              id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput);
 
1410
        case Track::WAVE:
 
1411
        case Track::AUDIO_GROUP:
 
1412
        case Track::AUDIO_SOFTSYNTH:
 
1413
              //id = addOutPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1414
              //id = addGroupPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1415
              id = addOutPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1416
              id = addGroupPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1417
              //id = addSyntiPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1418
              //id = addSyntiPorts(strip, parent, t, chpup, id, mm, ch, 1, isOutput);
 
1419
              id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1420
              break;
 
1421
        case Track::AUDIO_AUX:
 
1422
              //id = addOutPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1423
              id = addOutPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1424
              break;
 
1425
        default:
 
1426
              break;
 
1427
        
 
1428
        /*
 
1429
        case Track::AUDIO_INPUT:
 
1430
               id = addWavePorts(parent, t, chpup, id, mm, ch, isOutput);
 
1431
        case Track::WAVE:
 
1432
        case Track::AUDIO_GROUP:
 
1433
        case Track::AUDIO_SOFTSYNTH:
 
1434
              id = addOutPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1435
              id = addGroupPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1436
              id = addSyntiPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1437
              break;
 
1438
        case Track::AUDIO_AUX:
 
1439
              id = addOutPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1440
              break;
 
1441
        default:
 
1442
              break;
 
1443
        */      
 
1444
      }
 
1445
    }
 
1446
    else
 
1447
    {
 
1448
      switch(t->type()) 
 
1449
      {
 
1450
        
 
1451
        case Track::AUDIO_OUTPUT:
 
1452
              //id = addWavePorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1453
              //id = addInPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1454
              //id = addGroupPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1455
              //id = addAuxPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1456
              id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput);
 
1457
              id = addInPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1458
              id = addGroupPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1459
              id = addAuxPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1460
              //id = addSyntiPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1461
              //id = addSyntiPorts(strip, parent, t, chpup, id, mm, ch, 1, isOutput);
 
1462
              id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1463
              break;
 
1464
        case Track::WAVE:
 
1465
              //id = addInPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1466
              id = addInPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1467
              break;
 
1468
        case Track::AUDIO_SOFTSYNTH:
 
1469
        case Track::AUDIO_GROUP:
 
1470
              //id = addWavePorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1471
              //id = addInPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1472
              //id = addGroupPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1473
              id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput);
 
1474
              id = addInPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1475
              id = addGroupPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1476
              //id = addSyntiPorts(parent, t, chpup, id, mm, ch, 1, isOutput);
 
1477
              //id = addSyntiPorts(strip, parent, t, chpup, id, mm, ch, 1, isOutput);
 
1478
              id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput);
 
1479
              break;
 
1480
        default:
 
1481
              break;
 
1482
        
 
1483
        /*
 
1484
        case Track::AUDIO_OUTPUT:
 
1485
              id = addWavePorts(parent, t, chpup, id, mm, ch, isOutput);
 
1486
              id = addInPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1487
              id = addGroupPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1488
              id = addAuxPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1489
              id = addSyntiPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1490
              break;
 
1491
        case Track::WAVE:
 
1492
              id = addInPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1493
              break;
 
1494
        case Track::AUDIO_SOFTSYNTH:
 
1495
        case Track::AUDIO_GROUP:
 
1496
              id = addWavePorts(parent, t, chpup, id, mm, ch, isOutput);
 
1497
              id = addInPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1498
              id = addGroupPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1499
              id = addSyntiPorts(parent, t, chpup, id, mm, ch, isOutput);
 
1500
              break;
 
1501
        default:
 
1502
              break;
 
1503
       */       
 
1504
      }
 
1505
    }
 
1506
      
 
1507
    // If more than one channel, add the created sub-menu.
 
1508
    if(chans > 1)
 
1509
    {
 
1510
      char buffer[128];
 
1511
      snprintf(buffer, 128, "%s %d", pup->tr("Channel").latin1(), ch+1);
 
1512
      pup->insertItem(QString(buffer), chpup);
 
1513
    }  
 
1514
  } 
 
1515
       
 
1516
  // For stereo listing, ignore odd numbered left-over channels.
 
1517
  chans -= 1;
 
1518
  if(chans > 0)
 
1519
  {
 
1520
    // Ignore odd numbered left-over channels.
 
1521
    //int schans = (chans & ~1) - 1;
 
1522
    
 
1523
    pup->insertSeparator();
 
1524
    pup->insertItem(new MenuTitleItem("<Stereo>"));
 
1525
    //pup->insertSeparator();
 
1526
  
 
1527
    //
 
1528
    // If it's more than two channels, create a sub-menu. If it's just two channels, don't bother with a sub-menu...
 
1529
    //
 
1530
    
 
1531
    //QPopupMenu* chpup = pup;
 
1532
    chpup = pup;
 
1533
    if(chans <= 2)
 
1534
      // Just do one iteration.
 
1535
      chans = 1;
 
1536
    
 
1537
    //for(int ch = 0; ch < schans; ++ch)
 
1538
    for(int ch = 0; ch < chans; ++ch)
 
1539
    {
 
1540
      // If more than two channels, create the sub-menu.
 
1541
      if(chans > 2)
 
1542
      {
 
1543
        //chpup = new QPopupMenu(parent);
 
1544
        //chpup = new PopupMenu(parent);
 
1545
        //chpup = new PopupMenu(pup->parent());
 
1546
        chpup = new PopupMenu();
 
1547
        //strip->connect(chpup, SIGNAL(activated(int)), strip, SLOT(routingPopupMenuActivated(int)));
 
1548
        pup->connect(chpup, SIGNAL(activated(int)), pup, SIGNAL(activated(int)));
 
1549
        chpup->setCheckable(true);
 
1550
      }
 
1551
      
 
1552
      if(isOutput)
 
1553
      {
 
1554
        switch(t->type()) 
 
1555
        {
 
1556
          case Track::AUDIO_INPUT:
 
1557
                //id = addWavePorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1558
                id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput);
 
1559
          case Track::WAVE:
 
1560
          case Track::AUDIO_GROUP:
 
1561
          case Track::AUDIO_SOFTSYNTH:
 
1562
                //id = addOutPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1563
                //id = addGroupPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1564
                id = addOutPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1565
                id = addGroupPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1566
                //id = addSyntiPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1567
                //id = addSyntiPorts(strip, parent, t, chpup, id, mm, ch, 2, isOutput);
 
1568
                id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1569
                break;
 
1570
          case Track::AUDIO_AUX:
 
1571
                //id = addOutPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1572
                id = addOutPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1573
                break;
 
1574
          default:
 
1575
                break;
 
1576
        }
 
1577
      }    
 
1578
      else
 
1579
      {
 
1580
        switch(t->type()) 
 
1581
        {
 
1582
          case Track::AUDIO_OUTPUT:
 
1583
                //id = addWavePorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1584
                //id = addInPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1585
                //id = addGroupPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1586
                //id = addAuxPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1587
                id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput);
 
1588
                id = addInPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1589
                id = addGroupPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1590
                id = addAuxPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1591
                //id = addSyntiPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1592
                //id = addSyntiPorts(strip, parent, t, chpup, id, mm, ch, 2, isOutput);
 
1593
                id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1594
                break;
 
1595
          case Track::WAVE:
 
1596
                //id = addInPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1597
                id = addInPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1598
                break;
 
1599
          case Track::AUDIO_SOFTSYNTH:
 
1600
          case Track::AUDIO_GROUP:
 
1601
                //id = addWavePorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1602
                //id = addInPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1603
                //id = addGroupPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1604
                id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput);
 
1605
                id = addInPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1606
                id = addGroupPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1607
                //id = addSyntiPorts(parent, t, chpup, id, mm, ch, 2, isOutput);
 
1608
                //id = addSyntiPorts(strip, parent, t, chpup, id, mm, ch, 2, isOutput);
 
1609
                id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput);
 
1610
                break;
 
1611
          default:
 
1612
                break;
 
1613
        }
 
1614
      }
 
1615
      
 
1616
      // If more than two channels, add the created sub-menu.
 
1617
      if(chans > 2)
 
1618
      {
 
1619
        char buffer[128];
 
1620
        snprintf(buffer, 128, "%s %d,%d", pup->tr("Channel").latin1(), ch+1, ch+2);
 
1621
        pup->insertItem(QString(buffer), chpup);
 
1622
      }  
 
1623
    } 
 
1624
  }
 
1625
  
 
1626
  return id;
 
1627
}
 
1628
 
 
1629
//---------------------------------------------------------
 
1630
//   nonSyntiTrackAddSyntis
 
1631
//---------------------------------------------------------
 
1632
 
 
1633
static int nonSyntiTrackAddSyntis(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, bool isOutput)
 
1634
{
 
1635
      RouteList* rl = isOutput ? t->outRoutes() : t->inRoutes();
 
1636
      
 
1637
      SynthIList* al = song->syntis();
 
1638
      for (iSynthI i = al->begin(); i != al->end(); ++i) 
 
1639
      {
 
1640
            Track* track = *i;
 
1641
            if (t == track)
 
1642
                  continue;
 
1643
            //id = addMenuItem(parent, track, lb, r, id, mm, channel, channels);
 
1644
            
 
1645
            /*
 
1646
            QString s(track->name());
 
1647
            //int it = lb->insertItem(s);
 
1648
            lb->insertItem(s, id);
 
1649
            for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
 
1650
                  //if (ir->type == 0 && ir->track == track) {
 
1651
                  if (ir->type == 0 && ir->track == track && ir->channels == channels) {
 
1652
                        //lb->setItemChecked(it, true);
 
1653
                        lb->setItemChecked(id, true);
 
1654
                        break;
 
1655
                        }
 
1656
                  }
 
1657
            ++id;      
 
1658
            */
 
1659
            
 
1660
            //SynthI* synti = (SynthI*)track;
 
1661
            
 
1662
            int toch = ((AudioTrack*)track)->totalOutChannels();
 
1663
            // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user.
 
1664
            if(track->channels() == 1)
 
1665
              toch = 1;
 
1666
            
 
1667
            //int chans = synti->totalOutChannels();
 
1668
            //int chans = (!isOutput || track->type() != Track::AUDIO_SOFTSYNTH) ? ((AudioTrack*)track)->totalOutChannels() : ((AudioTrack*)track)->totalInChannels();
 
1669
            // totalInChannels is only used by syntis.
 
1670
            int chans = (!isOutput || track->type() != Track::AUDIO_SOFTSYNTH) ? toch : ((AudioTrack*)track)->totalInChannels();
 
1671
            
 
1672
            //int schans = synti->channels();
 
1673
            //if(schans < chans)
 
1674
            //  chans = schans;
 
1675
//            int tchans = (channels != -1) ? channels: t->channels();
 
1676
//            if(tchans == 2)
 
1677
//            {
 
1678
              // Ignore odd numbered left-over mono channel.
 
1679
              //chans = chans & ~1;
 
1680
              //if(chans != 0)
 
1681
//                chans -= 1;
 
1682
//            }
 
1683
            //int tchans = (channels != -1) ? channels: t->channels();
 
1684
            
 
1685
            if(chans > 0)
 
1686
            {
 
1687
              //QPopupMenu* chpup = new QPopupMenu(parent);
 
1688
              //PopupMenu* chpup = new PopupMenu(parent);
 
1689
              //PopupMenu* chpup = new PopupMenu(lb->parent());
 
1690
              PopupMenu* chpup = new PopupMenu();
 
1691
              //strip->connect(chpup, SIGNAL(activated(int)), strip, SLOT(routingPopupMenuActivated(int)));
 
1692
              lb->connect(chpup, SIGNAL(activated(int)), lb, SIGNAL(activated(int)));
 
1693
              chpup->setCheckable(true);
 
1694
              
 
1695
              if(chans > 1)
 
1696
              {
 
1697
                chpup->insertItem(new MenuTitleItem("<Mono>"));
 
1698
                //pup->insertSeparator();
 
1699
              }
 
1700
              
 
1701
              for(int ch = 0; ch < chans; ++ch)
 
1702
              {
 
1703
                char buffer[128];
 
1704
                //if(tchans == 2)
 
1705
                //  snprintf(buffer, 128, "%s %d,%d", chpup->tr("Channel").latin1(), ch+1, ch+2);
 
1706
                //else  
 
1707
                  snprintf(buffer, 128, "%s %d", chpup->tr("Channel").latin1(), ch+1);
 
1708
                chpup->insertItem(QString(buffer), id);
 
1709
                
 
1710
                //int ach = (channel == -1) ? ch : channel;
 
1711
                //int bch = (channel == -1) ? -1 : ch;
 
1712
                int ach = ch;
 
1713
                int bch = -1;
 
1714
                
 
1715
                //Route rt(track, (t->type() != Track::AUDIO_SOFTSYNTH || isOutput) ? ach : bch, tchans);
 
1716
                Route rt(track, isOutput ? bch : ach, 1);
 
1717
                //Route rt(track, ch);
 
1718
                
 
1719
                //rt.remoteChannel = -1;
 
1720
                //rt.remoteChannel = (t->type() != Track::AUDIO_SOFTSYNTH || isOutput) ? bch : ach;
 
1721
                rt.remoteChannel = isOutput ? ach : bch;
 
1722
                
 
1723
                mm.insert( pRouteMenuMap(id, rt) );
 
1724
                
 
1725
                for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) 
 
1726
                {
 
1727
                  //if (ir->type == 0 && ir->track == track) {
 
1728
                  //if(ir->type == 0 && ir->track == track && ir->channels == channels) 
 
1729
                  //if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->channel == channel && 
 
1730
                  //   ir->channels == channels && ir->remoteChannel == r.remoteChannel) 
 
1731
                  //if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->channel == ch && 
 
1732
                  //   ir->remoteChannel == rt.remoteChannel) 
 
1733
                  //if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->channel == rt.channel && 
 
1734
                  //   ir->channels == rt.channels && ir->remoteChannel == rt.remoteChannel) 
 
1735
                  
 
1736
                  if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->remoteChannel == rt.remoteChannel)
 
1737
                  {
 
1738
                    int tcompch = rt.channel;
 
1739
                    if(tcompch == -1)
 
1740
                      tcompch = 0;
 
1741
                    int tcompchs = rt.channels;
 
1742
                    if(tcompchs == -1)
 
1743
                      tcompchs = isOutput ? t->channels() : track->channels();
 
1744
                    
 
1745
                    int compch = ir->channel;
 
1746
                    if(compch == -1)
 
1747
                      compch = 0;
 
1748
                    int compchs = ir->channels;
 
1749
                    if(compchs == -1)
 
1750
                      compchs = isOutput ? t->channels() : ir->track->channels();
 
1751
                    
 
1752
                    if(compch == tcompch && compchs == tcompchs) 
 
1753
                    {
 
1754
                      chpup->setItemChecked(id, true);
 
1755
                      break;
 
1756
                    }
 
1757
                  }
 
1758
                }
 
1759
                ++id;
 
1760
              }
 
1761
            
 
1762
              chans -= 1;
 
1763
              if(chans > 0)
 
1764
              {
 
1765
                // Ignore odd numbered left-over channels.
 
1766
                //int schans = (chans & ~1) - 1;
 
1767
                
 
1768
                chpup->insertSeparator();
 
1769
                chpup->insertItem(new MenuTitleItem("<Stereo>"));
 
1770
                //pup->insertSeparator();
 
1771
              
 
1772
                for(int ch = 0; ch < chans; ++ch)
 
1773
                {
 
1774
                  char buffer[128];
 
1775
                  //if(tchans == 2)
 
1776
                    snprintf(buffer, 128, "%s %d,%d", chpup->tr("Channel").latin1(), ch+1, ch+2);
 
1777
                  //else  
 
1778
                  //  snprintf(buffer, 128, "%s %d", chpup->tr("Channel").latin1(), ch+1);
 
1779
                  chpup->insertItem(QString(buffer), id);
 
1780
                  
 
1781
                  //int ach = (channel == -1) ? ch : channel;
 
1782
                  //int bch = (channel == -1) ? -1 : ch;
 
1783
                  int ach = ch;
 
1784
                  int bch = -1;
 
1785
                  
 
1786
                  //Route rt(track, (t->type() != Track::AUDIO_SOFTSYNTH || isOutput) ? ach : bch, tchans);
 
1787
                  Route rt(track, isOutput ? bch : ach, 2);
 
1788
                  //Route rt(track, ch);
 
1789
                  
 
1790
                  //rt.remoteChannel = -1;
 
1791
                  //rt.remoteChannel = (t->type() != Track::AUDIO_SOFTSYNTH || isOutput) ? bch : ach;
 
1792
                  rt.remoteChannel = isOutput ? ach : bch;
 
1793
                  
 
1794
                  mm.insert( pRouteMenuMap(id, rt) );
 
1795
                  
 
1796
                  for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) 
 
1797
                  {
 
1798
                    //if (ir->type == 0 && ir->track == track) {
 
1799
                    //if(ir->type == 0 && ir->track == track && ir->channels == channels) 
 
1800
                    //if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->channel == channel && 
 
1801
                    //   ir->channels == channels && ir->remoteChannel == r.remoteChannel) 
 
1802
                    //if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->channel == ch && 
 
1803
                    //   ir->remoteChannel == rt.remoteChannel) 
 
1804
                    //if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->channel == rt.channel && 
 
1805
                    //  ir->channels == rt.channels && ir->remoteChannel == rt.remoteChannel) 
 
1806
                    
 
1807
                    
 
1808
                    if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->remoteChannel == rt.remoteChannel)
 
1809
                    {
 
1810
                      int tcompch = rt.channel;
 
1811
                      if(tcompch == -1)
 
1812
                        tcompch = 0;
 
1813
                      int tcompchs = rt.channels;
 
1814
                      if(tcompchs == -1)
 
1815
                        tcompchs = isOutput ? t->channels() : track->channels();
 
1816
                      
 
1817
                      int compch = ir->channel;
 
1818
                      if(compch == -1)
 
1819
                        compch = 0;
 
1820
                      int compchs = ir->channels;
 
1821
                      if(compchs == -1)
 
1822
                        compchs = isOutput ? t->channels() : ir->track->channels();
 
1823
                      
 
1824
                      if(compch == tcompch && compchs == tcompchs) 
 
1825
                      {
 
1826
                        chpup->setItemChecked(id, true);
 
1827
                        break;
 
1828
                      }
 
1829
                    }  
 
1830
                  }
 
1831
                  ++id;
 
1832
                }
 
1833
              }
 
1834
              
 
1835
              lb->insertItem(track->name(), chpup);
 
1836
            }
 
1837
      }
 
1838
      return id;      
 
1839
}
 
1840
 
 
1841
//---------------------------------------------------------
 
1842
//   iRoutePressed
 
1843
//---------------------------------------------------------
 
1844
 
 
1845
void AudioStrip::iRoutePressed()
 
1846
      {
 
1847
      //if(track->isMidiTrack() || (track->type() == Track::AUDIO_AUX) || (track->type() == Track::AUDIO_SOFTSYNTH))
 
1848
      if(!track || track->isMidiTrack() || track->type() == Track::AUDIO_AUX)
 
1849
      {
 
1850
        //_isRoutingPopupMenuMaster = false;
 
1851
        gRoutingPopupMenuMaster = 0;
 
1852
        return;
 
1853
      }
 
1854
        
 
1855
      QPoint ppt = QCursor::pos();
 
1856
      
 
1857
      //QPopupMenu* pup = new QPopupMenu(iR);
 
1858
      //PopupMenu* pup = new PopupMenu(iR);
 
1859
      //pup->setCheckable(true);
 
1860
      
 
1861
      PopupMenu* pup = muse->getRoutingPopupMenu();
 
1862
      pup->disconnect();
 
1863
      
 
1864
      AudioTrack* t = (AudioTrack*)track;
 
1865
      RouteList* irl = t->inRoutes();
 
1866
 
 
1867
      int gid = 0;
 
1868
      //int n;
 
1869
      ///RouteMenuMap mm;
 
1870
      
 
1871
  // Routes can't be re-read until the message sent from msgAddRoute1() 
 
1872
  //  has had time to be sent and actually affected the routes.
 
1873
  ///_redisplay:
 
1874
      
 
1875
      //QPopupMenu* pup = new QPopupMenu(iR);
 
1876
      //RouteList* irl = t->inRoutes();
 
1877
      
 
1878
      pup->clear();
 
1879
      gRoutingMenuMap.clear();
 
1880
      gid = 0;
 
1881
      
 
1882
      switch(track->type()) 
 
1883
      {
 
1884
        case Track::AUDIO_INPUT:
 
1885
        {
 
1886
          pup->setCheckable(true);
 
1887
          //int gid = 0;
 
1888
          for(int i = 0; i < channel; ++i) 
 
1889
          {
 
1890
            char buffer[128];
 
1891
            snprintf(buffer, 128, "%s %d", tr("Channel").latin1(), i+1);
 
1892
            MenuTitleItem* titel = new MenuTitleItem(QString(buffer));
 
1893
            pup->insertItem(titel);
 
1894
  
 
1895
            if(!checkAudioDevice())
 
1896
            { 
 
1897
              ///delete pup;
 
1898
              gRoutingPopupMenuMaster = 0;
 
1899
              pup->clear();
 
1900
              gRoutingMenuMap.clear();
 
1901
              iR->setDown(false);     
 
1902
              return;
 
1903
            }
 
1904
            std::list<QString> ol = audioDevice->outputPorts();
 
1905
            for(std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip) 
 
1906
            {
 
1907
              int id = pup->insertItem(*ip, (gid * 16) + i);
 
1908
              //Route dst(*ip, true, i);
 
1909
              Route dst(*ip, true, i, Route::JACK_ROUTE);
 
1910
              gRoutingMenuMap.insert( pRouteMenuMap(id, dst) );
 
1911
              ++gid;
 
1912
              for(iRoute ir = irl->begin(); ir != irl->end(); ++ir) 
 
1913
              {
 
1914
                if(*ir == dst) 
 
1915
                {
 
1916
                  pup->setItemChecked(id, true);
 
1917
                  break;
 
1918
                }
 
1919
              }
 
1920
            }
 
1921
            if(i+1 != channel)
 
1922
              pup->insertSeparator();
 
1923
          }
 
1924
        }
 
1925
        break;
 
1926
        //case Track::AUDIO_OUTPUT:
 
1927
        //case Track::WAVE:
 
1928
        //case Track::AUDIO_GROUP:
 
1929
        
 
1930
        case Track::AUDIO_OUTPUT:
 
1931
              //gid = addWavePorts( iR, t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1932
              //gid = addInPorts(   iR, t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1933
              //gid = addGroupPorts(iR, t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1934
              //gid = addAuxPorts(  iR, t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1935
              gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1936
              gid = addInPorts(   t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1937
              gid = addGroupPorts(t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1938
              gid = addAuxPorts(  t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1939
              //gid = addSyntiPorts(iR, t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1940
              //gid = nonSyntiTrackAddSyntis(iR, t, pup, gid, gRoutingMenuMap, false);
 
1941
              //gid = nonSyntiTrackAddSyntis(this, iR, t, pup, gid, gRoutingMenuMap, false);
 
1942
              gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, false);
 
1943
              break;
 
1944
        case Track::WAVE:
 
1945
              //gid = addInPorts(   iR, t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1946
              gid = addInPorts(   t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1947
              break;
 
1948
        case Track::AUDIO_GROUP:
 
1949
              //gid = addWavePorts( iR, t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1950
              //gid = addInPorts(   iR, t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1951
              //gid = addGroupPorts(iR, t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1952
              gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1953
              gid = addInPorts(   t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1954
              gid = addGroupPorts(t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1955
              //gid = addSyntiPorts(iR, t, pup, gid, gRoutingMenuMap, -1, -1, false);
 
1956
              //gid = nonSyntiTrackAddSyntis(iR, t, pup, gid, gRoutingMenuMap, false);
 
1957
              //gid = nonSyntiTrackAddSyntis(this, iR, t, pup, gid, gRoutingMenuMap, false);
 
1958
              gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, false);
 
1959
              break;
 
1960
        
 
1961
        case Track::AUDIO_SOFTSYNTH:
 
1962
              //gid = addMultiChannelPorts(iR, t, pup, gid, gRoutingMenuMap, false);
 
1963
              //gid = addMultiChannelPorts(this, iR, t, pup, gid, gRoutingMenuMap, false);
 
1964
              gid = addMultiChannelPorts(t, pup, gid, gRoutingMenuMap, false);
 
1965
              break;
 
1966
        default:
 
1967
              ///delete pup;
 
1968
              gRoutingPopupMenuMaster = 0;
 
1969
              pup->clear();
 
1970
              gRoutingMenuMap.clear();
 
1971
              iR->setDown(false);     
 
1972
              return;
 
1973
      }  
 
1974
      
 
1975
      if(pup->count() == 0)
 
1976
      {
 
1977
        ///delete pup;
 
1978
        gRoutingPopupMenuMaster = 0;
 
1979
        gRoutingMenuMap.clear();
 
1980
        iR->setDown(false);     
 
1981
        return;
 
1982
      }
 
1983
      
 
1984
      gIsOutRoutingPopupMenu = false;
 
1985
      gRoutingPopupMenuMaster = this;
 
1986
      connect(pup, SIGNAL(activated(int)), SLOT(routingPopupMenuActivated(int)));
 
1987
      connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide()));
 
1988
      pup->popup(ppt, 0);
 
1989
      iR->setDown(false);     
 
1990
      return;
 
1991
      
 
1992
      
 
1993
      
 
1994
      /*
 
1995
      //int n = pup->exec(QCursor::pos());
 
1996
      // For some reason, after the first display, it won't redisplay at the same point if the menu is too high. 
 
1997
      n = pup->exec(ppt, 0);
 
1998
      if(n != -1) 
 
1999
      {
 
2000
            QString s(pup->text(n));
 
2001
            
 
2002
            if(track->type() == Track::AUDIO_INPUT)
 
2003
            {
 
2004
              ///delete pup;
 
2005
              int chan = n & 0xf;
 
2006
              
 
2007
              Route srcRoute(s, false, -1, Route::JACK_ROUTE);
 
2008
              Route dstRoute(t, chan);
 
2009
              
 
2010
              srcRoute.channel = chan;
 
2011
              
 
2012
              iRoute iir = irl->begin();
 
2013
              for(; iir != irl->end(); ++iir) 
 
2014
              {
 
2015
                if(*iir == srcRoute)
 
2016
                  break;
 
2017
              }
 
2018
              if(iir != irl->end()) 
 
2019
                // disconnect
 
2020
                audio->msgRemoveRoute(srcRoute, dstRoute);
 
2021
              else 
 
2022
                // connect
 
2023
                audio->msgAddRoute(srcRoute, dstRoute);
 
2024
              
 
2025
              audio->msgUpdateSoloStates();
 
2026
              song->update(SC_ROUTE);
 
2027
              iR->setDown(false);     // pup->exec() catches mouse release event
 
2028
              return;
 
2029
              
 
2030
              // p3.3.46
 
2031
              ///goto _redisplay;
 
2032
            }
 
2033
            
 
2034
            iRouteMenuMap imm = mm.find(n);
 
2035
            if(imm == mm.end())
 
2036
            {  
 
2037
              delete pup;
 
2038
              iR->setDown(false);     // pup->exec() catches mouse release event
 
2039
              return;
 
2040
            }  
 
2041
            
 
2042
            //int chan = n >> 16;
 
2043
            //int chans = (chan >> 15) + 1; // Bit 31 MSB: Mono or stereo.
 
2044
            //chan &= 0xffff;
 
2045
            //int chan = imm->second.channel;
 
2046
            //int chans = imm->second.channels; 
 
2047
            
 
2048
            //Route srcRoute(s, false, -1);
 
2049
            //Route srcRoute(s, false, -1, Route::TRACK_ROUTE);
 
2050
            Route &srcRoute = imm->second;
 
2051
            
 
2052
            //Route dstRoute(t, -1);
 
2053
            //Route dstRoute(t, chan, chans);
 
2054
            Route dstRoute(t, imm->second.channel, imm->second.channels);
 
2055
            //Route dstRoute(t, imm->second.channel);
 
2056
            dstRoute.remoteChannel = imm->second.remoteChannel;
 
2057
 
 
2058
            iRoute iir = irl->begin();
 
2059
            for (; iir != irl->end(); ++iir) {
 
2060
                  if (*iir == srcRoute)
 
2061
                        break;
 
2062
                  }
 
2063
            if (iir != irl->end()) {
 
2064
                  // disconnect
 
2065
                  audio->msgRemoveRoute(srcRoute, dstRoute);
 
2066
                  }
 
2067
            else {
 
2068
                  // connect
 
2069
                  audio->msgAddRoute(srcRoute, dstRoute);
 
2070
                  }
 
2071
            audio->msgUpdateSoloStates();
 
2072
            song->update(SC_ROUTE);
 
2073
            
 
2074
            // p3.3.46
 
2075
            //iR->setDown(false);     // pup->exec() catches mouse release event
 
2076
            ///goto _redisplay;
 
2077
            
 
2078
            }
 
2079
            
 
2080
      delete pup;
 
2081
      iR->setDown(false);     // pup->exec() catches mouse release event
 
2082
      */
 
2083
      
 
2084
      }
 
2085
 
 
2086
#if 0
 
2087
//---------------------------------------------------------
 
2088
//   updateRouteMenus
 
2089
//---------------------------------------------------------
 
2090
 
 
2091
void AudioStrip::updateRouteMenus()
 
2092
{
 
2093
      //if(!_isRoutingPopupMenuMaster || track->isMidiTrack() || (track->type() == Track::AUDIO_AUX))
 
2094
      if(!track || gRoutingPopupMenuMaster != this || track->isMidiTrack())
 
2095
        return;
 
2096
        
 
2097
      ///QPopupMenu* pup = new QPopupMenu(oR);
 
2098
      // p3.3.47
 
2099
      //if(!orpup)
 
2100
      //  return;
 
2101
      
 
2102
      //QPopupMenu* pup = muse->getORoutesPopup();
 
2103
      PopupMenu* pup = muse->getRoutingPopupMenu();
 
2104
      
 
2105
      if(pup->count() == 0)
 
2106
        return;
 
2107
        
 
2108
      //pup->setCheckable(true);
 
2109
      AudioTrack* t = (AudioTrack*)track;
 
2110
      RouteList* rl = gIsOutRoutingPopupMenu ? t->outRoutes() : t->inRoutes();
 
2111
 
 
2112
      //int gid = 0;
 
2113
      //int n;
 
2114
      ///RouteMenuMap mm;
 
2115
      
 
2116
      //QPoint ppt = QCursor::pos();
 
2117
      
 
2118
      
 
2119
      /*
 
2120
      iRoute iorl = orl->begin();
 
2121
      for(; iorl != orl->end(); ++iorl) 
 
2122
      {
 
2123
        iRouteMenuMap imm = ormm->begin();
 
2124
        for(; imm != ormm->end(); ++imm) 
 
2125
        {
 
2126
          if(*iorl == imm->second)
 
2127
          {
 
2128
            orpup->setItemChecked(imm->first, true);
 
2129
            break;
 
2130
          }
 
2131
        }
 
2132
        //if(imm == ormm->end()) 
 
2133
        //{
 
2134
        //}
 
2135
        
 
2136
      }
 
2137
      //if (iorl == orl->end()) 
 
2138
      //{
 
2139
      //}
 
2140
      */     
 
2141
           
 
2142
      iRouteMenuMap imm = gRoutingMenuMap.begin();
 
2143
      for(; imm != gRoutingMenuMap.end(); ++imm) 
 
2144
      {
 
2145
        bool found = false;
 
2146
        iRoute irl = rl->begin();
 
2147
        for(; irl != rl->end(); ++irl) 
 
2148
        {
 
2149
          if(*irl == imm->second)
 
2150
          {
 
2151
            found = true;
 
2152
            break;
 
2153
          }
 
2154
        }
 
2155
        pup->setItemChecked(imm->first, found);
 
2156
      }
 
2157
      
 
2158
      return;
 
2159
}
 
2160
#endif
 
2161
 
 
2162
//---------------------------------------------------------
 
2163
//   routingPopupMenuActivated
 
2164
//---------------------------------------------------------
 
2165
 
 
2166
void AudioStrip::routingPopupMenuActivated(int n)
 
2167
{
 
2168
      if(!track || gRoutingPopupMenuMaster != this || track->isMidiTrack())
 
2169
        return;
 
2170
      
 
2171
      PopupMenu* pup = muse->getRoutingPopupMenu();
 
2172
      
 
2173
      //printf("AudioStrip::routingPopupMenuActivated n:%d count:%d\n", n, pup->count());
 
2174
      
 
2175
      if(pup->count() == 0)
 
2176
        return;
 
2177
        
 
2178
      AudioTrack* t = (AudioTrack*)track;
 
2179
      RouteList* rl = gIsOutRoutingPopupMenu ? t->outRoutes() : t->inRoutes();
 
2180
      
 
2181
      //QPoint ppt = QCursor::pos();
 
2182
      
 
2183
      // p3.3.47
 
2184
      if (n == -1) 
 
2185
      {
 
2186
        //printf("AudioStrip::routingPopupMenuActivated n = -1\n");
 
2187
        ///delete pup;
 
2188
        return;
 
2189
      }
 
2190
      else
 
2191
      //if(n == 0)
 
2192
      //{
 
2193
        //printf("AudioStrip::routingPopupMenuActivated n = 0 = tearOffHandle\n");
 
2194
        //oR->setDown(false);     
 
2195
      //  return;
 
2196
      //}
 
2197
      //else
 
2198
      {
 
2199
          if(gIsOutRoutingPopupMenu)
 
2200
          {  
 
2201
            QString s(pup->text(n));
 
2202
            
 
2203
            //printf("AudioStrip::routingPopupMenuActivated text:%s\n", s.latin1());
 
2204
            
 
2205
            if(track->type() == Track::AUDIO_OUTPUT)
 
2206
            {
 
2207
              ///delete orpup;
 
2208
              
 
2209
              int chan = n & 0xf;
 
2210
              
 
2211
              //Route srcRoute(t, -1);
 
2212
              //Route srcRoute(t, chan, chans);
 
2213
              //Route srcRoute(t, chan, 1);
 
2214
              Route srcRoute(t, chan);
 
2215
              
 
2216
              //Route dstRoute(s, true, -1);
 
2217
              Route dstRoute(s, true, -1, Route::JACK_ROUTE);
 
2218
              //Route dstRoute(s, true, 0, Route::JACK_ROUTE);
 
2219
  
 
2220
              //srcRoute.channel = dstRoute.channel = chan;
 
2221
              dstRoute.channel = chan;
 
2222
              //dstRoute.channels = 1;
 
2223
  
 
2224
              // check if route src->dst exists:
 
2225
              iRoute irl = rl->begin();
 
2226
              for (; irl != rl->end(); ++irl) {
 
2227
                    if (*irl == dstRoute)
 
2228
                          break;
 
2229
                    }
 
2230
              if (irl != rl->end()) {
 
2231
                    // disconnect if route exists
 
2232
                    audio->msgRemoveRoute(srcRoute, dstRoute);
 
2233
                    }
 
2234
              else {
 
2235
                    // connect if route does not exist
 
2236
                    audio->msgAddRoute(srcRoute, dstRoute);
 
2237
                    }
 
2238
              audio->msgUpdateSoloStates();
 
2239
              song->update(SC_ROUTE);
 
2240
              
 
2241
              // p3.3.47
 
2242
              //pup->popup(ppt, 0);
 
2243
              
 
2244
              //oR->setDown(false);   
 
2245
              return;
 
2246
              
 
2247
              // p3.3.46
 
2248
              ///goto _redisplay;
 
2249
            }
 
2250
            
 
2251
            iRouteMenuMap imm = gRoutingMenuMap.find(n);
 
2252
            if(imm == gRoutingMenuMap.end())
 
2253
            {  
 
2254
              ///delete orpup;
 
2255
              //oR->setDown(false);     // orpup->exec() catches mouse release event
 
2256
              return;
 
2257
            }  
 
2258
            
 
2259
            //int chan = n >> 16;
 
2260
            //int chans = (chan >> 15) + 1; // Bit 31 MSB: Mono or stereo.
 
2261
            //chan &= 0xffff;
 
2262
            //int chan = imm->second.channel;
 
2263
            //int chans = imm->second.channels; 
 
2264
            
 
2265
            //Route srcRoute(t, -1);
 
2266
            //srcRoute.remoteChannel = chan;
 
2267
            //Route srcRoute(t, chan, chans);
 
2268
            Route srcRoute(t, imm->second.channel, imm->second.channels);
 
2269
            //Route srcRoute(t, imm->second.channel);
 
2270
            srcRoute.remoteChannel = imm->second.remoteChannel;
 
2271
            
 
2272
            //Route dstRoute(s, true, -1);
 
2273
            //Route dstRoute(s, true, -1, Route::TRACK_ROUTE);
 
2274
            Route &dstRoute = imm->second;
 
2275
 
 
2276
            // check if route src->dst exists:
 
2277
            iRoute irl = rl->begin();
 
2278
            for (; irl != rl->end(); ++irl) {
 
2279
                  if (*irl == dstRoute)
 
2280
                        break;
 
2281
                  }
 
2282
            if (irl != rl->end()) {
 
2283
                  // disconnect if route exists
 
2284
                  audio->msgRemoveRoute(srcRoute, dstRoute);
 
2285
                  }
 
2286
            else {
 
2287
                  // connect if route does not exist
 
2288
                  audio->msgAddRoute(srcRoute, dstRoute);
 
2289
                  }
 
2290
            audio->msgUpdateSoloStates();
 
2291
            song->update(SC_ROUTE);
 
2292
              
 
2293
            // p3.3.46
 
2294
            //oR->setDown(false);     
 
2295
            ///goto _redisplay;
 
2296
            
 
2297
            // p3.3.47
 
2298
            //pup->popup(ppt, 0);
 
2299
          }  
 
2300
          else
 
2301
          {
 
2302
            QString s(pup->text(n));
 
2303
            
 
2304
            if(track->type() == Track::AUDIO_INPUT)
 
2305
            {
 
2306
              ///delete pup;
 
2307
              int chan = n & 0xf;
 
2308
              
 
2309
              Route srcRoute(s, false, -1, Route::JACK_ROUTE);
 
2310
              Route dstRoute(t, chan);
 
2311
              
 
2312
              srcRoute.channel = chan;
 
2313
              
 
2314
              iRoute irl = rl->begin();
 
2315
              for(; irl != rl->end(); ++irl) 
 
2316
              {
 
2317
                if(*irl == srcRoute)
 
2318
                  break;
 
2319
              }
 
2320
              if(irl != rl->end()) 
 
2321
                // disconnect
 
2322
                audio->msgRemoveRoute(srcRoute, dstRoute);
 
2323
              else 
 
2324
                // connect
 
2325
                audio->msgAddRoute(srcRoute, dstRoute);
 
2326
              
 
2327
              audio->msgUpdateSoloStates();
 
2328
              song->update(SC_ROUTE);
 
2329
              //iR->setDown(false);     // pup->exec() catches mouse release event
 
2330
              return;
 
2331
              
 
2332
              // p3.3.46
 
2333
              ///goto _redisplay;
 
2334
            }
 
2335
            
 
2336
            iRouteMenuMap imm = gRoutingMenuMap.find(n);
 
2337
            if(imm == gRoutingMenuMap.end())
 
2338
            {  
 
2339
              //delete pup;
 
2340
              //iR->setDown(false);     // pup->exec() catches mouse release event
 
2341
              return;
 
2342
            }  
 
2343
            
 
2344
            //int chan = n >> 16;
 
2345
            //int chans = (chan >> 15) + 1; // Bit 31 MSB: Mono or stereo.
 
2346
            //chan &= 0xffff;
 
2347
            //int chan = imm->second.channel;
 
2348
            //int chans = imm->second.channels; 
 
2349
            
 
2350
            //Route srcRoute(s, false, -1);
 
2351
            //Route srcRoute(s, false, -1, Route::TRACK_ROUTE);
 
2352
            Route &srcRoute = imm->second;
 
2353
            
 
2354
            //Route dstRoute(t, -1);
 
2355
            //Route dstRoute(t, chan, chans);
 
2356
            Route dstRoute(t, imm->second.channel, imm->second.channels);
 
2357
            //Route dstRoute(t, imm->second.channel);
 
2358
            dstRoute.remoteChannel = imm->second.remoteChannel;
 
2359
 
 
2360
            iRoute irl = rl->begin();
 
2361
            for (; irl != rl->end(); ++irl) {
 
2362
                  if (*irl == srcRoute)
 
2363
                        break;
 
2364
                  }
 
2365
            if (irl != rl->end()) {
 
2366
                  // disconnect
 
2367
                  audio->msgRemoveRoute(srcRoute, dstRoute);
 
2368
                  }
 
2369
            else {
 
2370
                  // connect
 
2371
                  audio->msgAddRoute(srcRoute, dstRoute);
 
2372
                  }
 
2373
            audio->msgUpdateSoloStates();
 
2374
            song->update(SC_ROUTE);
 
2375
            
 
2376
            // p3.3.46
 
2377
            //iR->setDown(false);     
 
2378
            ///goto _redisplay;
 
2379
            
 
2380
          }
 
2381
              
 
2382
      }
 
2383
            
 
2384
      ///delete pup;
 
2385
      //oR->setDown(false);     
 
2386
}
 
2387
 
 
2388
//---------------------------------------------------------
 
2389
//   oRoutePressed
 
2390
//---------------------------------------------------------
 
2391
 
 
2392
void AudioStrip::oRoutePressed()
 
2393
{
 
2394
      if(!track || track->isMidiTrack())
 
2395
      {
 
2396
        gRoutingPopupMenuMaster = 0;
 
2397
        return;
 
2398
      }
 
2399
        
 
2400
      QPoint ppt = QCursor::pos();
 
2401
      
 
2402
      ///QPopupMenu* pup = new QPopupMenu(oR);
 
2403
      
 
2404
      PopupMenu* pup = muse->getRoutingPopupMenu();
 
2405
      pup->disconnect();
 
2406
      
 
2407
      //pup->setCheckable(true);
 
2408
      AudioTrack* t = (AudioTrack*)track;
 
2409
      RouteList* orl = t->outRoutes();
 
2410
 
 
2411
      int gid = 0;
 
2412
      //int n;
 
2413
      ///RouteMenuMap mm;
 
2414
      
 
2415
  // Routes can't be re-read until the message sent from msgAddRoute1() 
 
2416
  //  has had time to be sent and actually affected the routes.
 
2417
///  _redisplay:
 
2418
      
 
2419
      //QPopupMenu* pup = new QPopupMenu(oR);
 
2420
      //RouteList* orl = t->outRoutes();
 
2421
      
 
2422
      pup->clear();
 
2423
      gRoutingMenuMap.clear();
 
2424
      gid = 0;
 
2425
      
 
2426
      // p3.3.47
 
2427
      //orpup->insertTearOffHandle(gid);
 
2428
      //gid++;
 
2429
      
 
2430
      switch(track->type()) 
 
2431
      {
 
2432
        case Track::AUDIO_OUTPUT:
 
2433
        {
 
2434
          pup->setCheckable(true);
 
2435
          //int gid = 0;
 
2436
          for(int i = 0; i < channel; ++i) 
 
2437
          {
 
2438
            char buffer[128];
 
2439
            snprintf(buffer, 128, "%s %d", tr("Channel").latin1(), i+1);
 
2440
            MenuTitleItem* titel = new MenuTitleItem(QString(buffer));
 
2441
            pup->insertItem(titel);
 
2442
  
 
2443
            if(!checkAudioDevice())
 
2444
            { 
 
2445
              ///delete pup;
 
2446
              gRoutingPopupMenuMaster = 0;
 
2447
              pup->clear();
 
2448
              gRoutingMenuMap.clear();
 
2449
              oR->setDown(false);     
 
2450
              return;
 
2451
            }
 
2452
            std::list<QString> ol = audioDevice->inputPorts();
 
2453
            for(std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip) 
 
2454
            {
 
2455
              int id = pup->insertItem(*ip, (gid * 16) + i);
 
2456
              //Route dst(*ip, true, i);
 
2457
              Route dst(*ip, true, i, Route::JACK_ROUTE);
 
2458
              gRoutingMenuMap.insert( pRouteMenuMap(id, dst) );
 
2459
              ++gid;
 
2460
              for(iRoute ir = orl->begin(); ir != orl->end(); ++ir) 
 
2461
              {
 
2462
                if(*ir == dst) 
 
2463
                {
 
2464
                  pup->setItemChecked(id, true);
 
2465
                  break;
 
2466
                }
 
2467
              }
 
2468
            }
 
2469
            if(i+1 != channel)
 
2470
              pup->insertSeparator();
 
2471
          }      
 
2472
        }
 
2473
        break;
 
2474
        //case Track::AUDIO_INPUT:
 
2475
        //case Track::WAVE:
 
2476
        //case Track::AUDIO_GROUP:
 
2477
 
 
2478
        case Track::AUDIO_SOFTSYNTH:
 
2479
              //addOutPorts(t, pup, orl);
 
2480
              //addGroupPorts(t, pup, orl);
 
2481
              //gid = addMultiChannelPorts(oR, t, pup, gid, gRoutingMenuMap, true);
 
2482
              //gid = addMultiChannelPorts(this, oR, t, pup, gid, gRoutingMenuMap, true);
 
2483
              gid = addMultiChannelPorts(t, pup, gid, gRoutingMenuMap, true);
 
2484
        break;
 
2485
        
 
2486
        case Track::AUDIO_INPUT:
 
2487
              //gid = addWavePorts(        oR, t, pup, gid, gRoutingMenuMap, -1, -1, true);
 
2488
              gid = addWavePorts(        t, pup, gid, gRoutingMenuMap, -1, -1, true);
 
2489
        case Track::WAVE:
 
2490
        case Track::AUDIO_GROUP:
 
2491
        case Track::AUDIO_AUX:
 
2492
        //case Track::AUDIO_SOFTSYNTH:
 
2493
              //gid = addOutPorts(         oR, t, pup, gid, gRoutingMenuMap, -1, -1, true);
 
2494
              //gid = addGroupPorts(       oR, t, pup, gid, gRoutingMenuMap, -1, -1, true);
 
2495
              gid = addOutPorts(         t, pup, gid, gRoutingMenuMap, -1, -1, true);
 
2496
              gid = addGroupPorts(       t, pup, gid, gRoutingMenuMap, -1, -1, true);
 
2497
              //gid = addSyntiPorts(       oR, t, pup, gid, gRoutingMenuMap, -1, -1, true);
 
2498
              //gid = nonSyntiTrackAddSyntis(oR, t, pup, gid, gRoutingMenuMap, true);
 
2499
              //gid = nonSyntiTrackAddSyntis(this, oR, t, pup, gid, gRoutingMenuMap, true);
 
2500
              gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, true);
 
2501
        break;
 
2502
        //case Track::AUDIO_AUX:
 
2503
              //gid = addOutPorts(         oR, t, pup, gid, gRoutingMenuMap, -1, -1, true);
 
2504
        //      gid = addOutPorts(         t, pup, gid, gRoutingMenuMap, -1, -1, true);
 
2505
        //break;
 
2506
        
 
2507
        default:
 
2508
              ///delete pup;
 
2509
              gRoutingPopupMenuMaster = 0;
 
2510
              pup->clear();
 
2511
              gRoutingMenuMap.clear();
 
2512
              oR->setDown(false);     
 
2513
              return;
 
2514
      }
 
2515
      
 
2516
      if(pup->count() == 0)
 
2517
      {
 
2518
        ///delete pup;
 
2519
        gRoutingPopupMenuMaster = 0;
 
2520
        gRoutingMenuMap.clear();
 
2521
        oR->setDown(false);     
 
2522
        return;
 
2523
      }
 
2524
      
 
2525
      //int n = pup->exec(QCursor::pos());
 
2526
      ///n = pup->exec(ppt);
 
2527
      gIsOutRoutingPopupMenu = true;
 
2528
      gRoutingPopupMenuMaster = this;
 
2529
      connect(pup, SIGNAL(activated(int)), SLOT(routingPopupMenuActivated(int)));
 
2530
      connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide()));
 
2531
      pup->popup(ppt, 0);
 
2532
      oR->setDown(false);     
 
2533
      return;
 
2534
      
 
2535
      
 
2536
      /*
 
2537
      // p3.3.47
 
2538
      if(n == 0)
 
2539
      {
 
2540
        printf("AudioStrip::oRoutePressed n = 0 = tearOffHandle\n");
 
2541
        oR->setDown(false);     // orpup->exec() catches mouse release event
 
2542
        return;
 
2543
      }
 
2544
      else
 
2545
              
 
2546
      if (n != -1) {
 
2547
            QString s(orpup->text(n));
 
2548
            
 
2549
            if(track->type() == Track::AUDIO_OUTPUT)
 
2550
            {
 
2551
              delete orpup;
 
2552
              
 
2553
              int chan = n & 0xf;
 
2554
              
 
2555
              //Route srcRoute(t, -1);
 
2556
              //Route srcRoute(t, chan, chans);
 
2557
              //Route srcRoute(t, chan, 1);
 
2558
              Route srcRoute(t, chan);
 
2559
              
 
2560
              //Route dstRoute(s, true, -1);
 
2561
              Route dstRoute(s, true, -1, Route::JACK_ROUTE);
 
2562
              //Route dstRoute(s, true, 0, Route::JACK_ROUTE);
 
2563
  
 
2564
              //srcRoute.channel = dstRoute.channel = chan;
 
2565
              dstRoute.channel = chan;
 
2566
              //dstRoute.channels = 1;
 
2567
  
 
2568
              // check if route src->dst exists:
 
2569
              iRoute iorl = orl->begin();
 
2570
              for (; iorl != orl->end(); ++iorl) {
 
2571
                    if (*iorl == dstRoute)
 
2572
                          break;
 
2573
                    }
 
2574
              if (iorl != orl->end()) {
 
2575
                    // disconnect if route exists
 
2576
                    audio->msgRemoveRoute(srcRoute, dstRoute);
 
2577
                    }
 
2578
              else {
 
2579
                    // connect if route does not exist
 
2580
                    audio->msgAddRoute(srcRoute, dstRoute);
 
2581
                    }
 
2582
              audio->msgUpdateSoloStates();
 
2583
              song->update(SC_ROUTE);
 
2584
              
 
2585
              oR->setDown(false);     // orpup->exec() catches mouse release event
 
2586
              return;
 
2587
              
 
2588
              // p3.3.46
 
2589
              ///goto _redisplay;
 
2590
            }
 
2591
            
 
2592
            iRouteMenuMap imm = ormm.find(n);
 
2593
            if(imm == ormm.end())
 
2594
            {  
 
2595
              delete orpup;
 
2596
              oR->setDown(false);     // orpup->exec() catches mouse release event
 
2597
              return;
 
2598
            }  
 
2599
            
 
2600
            //int chan = n >> 16;
 
2601
            //int chans = (chan >> 15) + 1; // Bit 31 MSB: Mono or stereo.
 
2602
            //chan &= 0xffff;
 
2603
            //int chan = imm->second.channel;
 
2604
            //int chans = imm->second.channels; 
 
2605
            
 
2606
            //Route srcRoute(t, -1);
 
2607
            //srcRoute.remoteChannel = chan;
 
2608
            //Route srcRoute(t, chan, chans);
 
2609
            Route srcRoute(t, imm->second.channel, imm->second.channels);
 
2610
            //Route srcRoute(t, imm->second.channel);
 
2611
            srcRoute.remoteChannel = imm->second.remoteChannel;
 
2612
            
 
2613
            //Route dstRoute(s, true, -1);
 
2614
            //Route dstRoute(s, true, -1, Route::TRACK_ROUTE);
 
2615
            Route &dstRoute = imm->second;
 
2616
 
 
2617
            // check if route src->dst exists:
 
2618
            iRoute iorl = orl->begin();
 
2619
            for (; iorl != orl->end(); ++iorl) {
 
2620
                  if (*iorl == dstRoute)
 
2621
                        break;
 
2622
                  }
 
2623
            if (iorl != orl->end()) {
 
2624
                  // disconnect if route exists
 
2625
                  audio->msgRemoveRoute(srcRoute, dstRoute);
 
2626
                  }
 
2627
            else {
 
2628
                  // connect if route does not exist
 
2629
                  audio->msgAddRoute(srcRoute, dstRoute);
 
2630
                  }
 
2631
            audio->msgUpdateSoloStates();
 
2632
            song->update(SC_ROUTE);
 
2633
              
 
2634
            // p3.3.46
 
2635
            //oR->setDown(false);     // orpup->exec() catches mouse release event
 
2636
            ///goto _redisplay;
 
2637
            
 
2638
            }
 
2639
            
 
2640
      delete orpup;
 
2641
      oR->setDown(false);     // pup->exec() catches mouse release event
 
2642
      */
 
2643
}
 
2644
 
 
2645
/*
1094
2646
//---------------------------------------------------------
1095
2647
//   iRoutePressed
1096
2648
//---------------------------------------------------------
1122
2674
                        std::list<QString> ol = audioDevice->outputPorts();
1123
2675
                        for (std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip) {
1124
2676
                              int id = pup->insertItem(*ip, (gid * 16) + i);
1125
 
                              Route dst(*ip, true, i);
 
2677
                              //Route dst(*ip, true, i);
 
2678
                              Route dst(*ip, true, i, Route::JACK_ROUTE);
1126
2679
                              ++gid;
1127
2680
                              for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) {
1128
2681
                                    if (*ir == dst) {
1136
2689
                        }
1137
2690
                  }
1138
2691
                  break;
1139
 
                  break;
1140
2692
            case Track::AUDIO_OUTPUT:
1141
2693
                  addWavePorts(t, pup, irl);
1142
2694
                  addInPorts(t, pup, irl);
1157
2709
      int n = pup->exec(QCursor::pos());
1158
2710
      if (n != -1) {
1159
2711
            QString s(pup->text(n));
1160
 
            Route srcRoute(s, false, -1);
 
2712
            
 
2713
            //Route srcRoute(s, false, -1);
 
2714
            Route srcRoute(s, false, -1, (track->type() == Track::AUDIO_INPUT) ? Route::JACK_ROUTE : Route::TRACK_ROUTE);
1161
2715
            Route dstRoute(t, -1);
1162
2716
 
1163
2717
            if (track->type() == Track::AUDIO_INPUT)
1181
2735
      delete pup;
1182
2736
      iR->setDown(false);     // pup->exec() catches mouse release event
1183
2737
      }
 
2738
*/
1184
2739
 
 
2740
/*
1185
2741
//---------------------------------------------------------
1186
2742
//   oRoutePressed
1187
2743
//---------------------------------------------------------
1211
2767
                        std::list<QString> ol = audioDevice->inputPorts();
1212
2768
                        for (std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip) {
1213
2769
                              int id = pup->insertItem(*ip, (gid * 16) + i);
1214
 
                              Route dst(*ip, true, i);
 
2770
                              //Route dst(*ip, true, i);
 
2771
                              Route dst(*ip, true, i, Route::JACK_ROUTE);
1215
2772
                              ++gid;
1216
2773
                              for (iRoute ir = orl->begin(); ir != orl->end(); ++ir) {
1217
2774
                                    if (*ir == dst) {
1241
2798
      if (n != -1) {
1242
2799
            QString s(pup->text(n));
1243
2800
            Route srcRoute(t, -1);
1244
 
            Route dstRoute(s, true, -1);
 
2801
            //Route dstRoute(s, true, -1);
 
2802
            Route dstRoute(s, true, -1, (track->type() == Track::AUDIO_OUTPUT) ? Route::JACK_ROUTE : Route::TRACK_ROUTE);
1245
2803
 
1246
2804
            if (track->type() == Track::AUDIO_OUTPUT)
1247
2805
                  srcRoute.channel = dstRoute.channel = n & 0xf;
1266
2824
      delete pup;
1267
2825
      oR->setDown(false);     // pup->exec() catches mouse release event
1268
2826
      }
1269
 
 
 
2827
*/