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

« back to all changes in this revision

Viewing changes to muse/audiotrack.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:
22
22
// By T356. For caching jack in/out routing names BEFORE file save. 
23
23
// Jack often shuts down during file save, causing the routes to be lost in the file.
24
24
// cacheJackRouteNames() is ONLY called from MusE::save() in app.cpp
 
25
// Update: Not required any more because the real problem was Jack RT priority, which has been fixed.
 
26
/*
25
27
typedef std::multimap <const int, QString> jackRouteNameMap;
26
28
std::map <const AudioTrack*, jackRouteNameMap > jackRouteNameCache;
27
29
typedef std::multimap <const int, QString>::const_iterator ciJackRouteNameMap;
54
56
      }                            
55
57
    }
56
58
}
 
59
*/
 
60
 
57
61
//---------------------------------------------------------
58
62
//   AudioTrack
59
63
//---------------------------------------------------------
60
64
 
61
65
AudioTrack::AudioTrack(TrackType t)
 
66
//AudioTrack::AudioTrack(TrackType t, int num_out_bufs)
62
67
   : Track(t)
63
68
      {
 
69
      //_totalOutChannels = num_out_bufs; // Is either parameter-default MAX_CHANNELS, or custom value passed (used by syntis).
64
70
      _processed = false;
65
71
      _haveData = false;
66
72
      _sendMetronome = false;
68
74
      _efxPipe  = new Pipeline();
69
75
      _recFile  = 0;
70
76
      _channels = 0;
71
 
      _automationType = AUTO_READ;
 
77
      _automationType = AUTO_OFF;
72
78
      //setChannels(1);
73
79
      setChannels(2);
74
 
      addController(new CtrlList(AC_VOLUME));
75
 
      addController(new CtrlList(AC_PAN));
76
 
      addController(new CtrlList(AC_MUTE));
 
80
      addController(new CtrlList(AC_VOLUME,"Volume",0.0,1.0));
 
81
      addController(new CtrlList(AC_PAN, "Pan", -1.0, 1.0));
 
82
      addController(new CtrlList(AC_MUTE,"Mute",0.0,1.0));
77
83
      
78
84
      // Changed by Tim. p3.3.15
79
85
      //outBuffers = new float*[MAX_CHANNELS];
80
86
      //for (int i = 0; i < MAX_CHANNELS; ++i)
81
87
      //      outBuffers[i] = new float[segmentSize];
82
 
      for (int i = 0; i < MAX_CHANNELS; ++i)
83
 
            posix_memalign((void**)(outBuffers + i), 16, sizeof(float) * segmentSize);
 
88
      //for (int i = 0; i < MAX_CHANNELS; ++i)
 
89
      //      posix_memalign((void**)(outBuffers + i), 16, sizeof(float) * segmentSize);
 
90
      
84
91
      // Let's allocate it all in one block, and just point the remaining buffer pointers into the block
85
92
      //  which allows faster one-shot buffer copying.
86
93
      // Nope. Nice but interferes with possibility we don't know if other buffers are contiguous (jack buffers, local stack buffers etc.).
88
95
      //for (int i = 0; i < MAX_CHANNELS; ++i)
89
96
      //  *(outBuffers + i) = sizeof(float) * segmentSize * i;
90
97
            
 
98
      // p3.3.38
 
99
      // Easy way, less desirable... Start out with enough for MAX_CHANNELS. Then multi-channel syntis can re-allocate, 
 
100
      //  via a call to (a modified!) setChannels().
 
101
      // Hard way, more desirable... Creating a synti instance passes the total channels to this constructor, overriding MAX_CHANNELS.
 
102
      _totalOutChannels = MAX_CHANNELS;
 
103
      outBuffers = new float*[_totalOutChannels];
 
104
      for (int i = 0; i < _totalOutChannels; ++i)
 
105
            posix_memalign((void**)&outBuffers[i], 16, sizeof(float) * segmentSize);
 
106
      
 
107
      // This is only set by multi-channel syntis...
 
108
      _totalInChannels = 0;
 
109
      
91
110
      bufferPos = MAXINT;
92
111
      
93
112
      setVolume(1.0);
98
117
AudioTrack::AudioTrack(const AudioTrack& t, bool cloneParts)
99
118
  : Track(t, cloneParts)
100
119
      {
 
120
      _totalOutChannels = t._totalOutChannels; // Is either MAX_CHANNELS, or custom value (used by syntis).
101
121
      _processed      = false;
102
122
      _haveData       = false;
103
123
      _sendMetronome  = t._sendMetronome;
112
132
      //outBuffers = new float*[MAX_CHANNELS];
113
133
      //for (int i = 0; i < MAX_CHANNELS; ++i)
114
134
      //      outBuffers[i] = new float[segmentSize];
115
 
      for (int i = 0; i < MAX_CHANNELS; ++i)
116
 
            posix_memalign((void**)(outBuffers + i), 16, sizeof(float) * segmentSize);
 
135
      //for (int i = 0; i < MAX_CHANNELS; ++i)
 
136
      //      posix_memalign((void**)(outBuffers + i), 16, sizeof(float) * segmentSize);
 
137
      
 
138
      // p3.3.38
 
139
      int chans = _totalOutChannels;
 
140
      // Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less. 
 
141
      if(chans < MAX_CHANNELS)
 
142
        chans = MAX_CHANNELS;
 
143
      outBuffers = new float*[chans];
 
144
      for (int i = 0; i < chans; ++i)
 
145
            posix_memalign((void**)&outBuffers[i], 16, sizeof(float) * segmentSize);
 
146
      
117
147
      bufferPos = MAXINT;
118
148
      _recFile  = t._recFile;
119
149
      }
124
154
      //for (int i = 0; i < MAX_CHANNELS; ++i)
125
155
      //      delete[] outBuffers[i];
126
156
      //delete[] outBuffers;
127
 
      for(int i = 0; i < MAX_CHANNELS; ++i) 
 
157
      
 
158
      // p3.3.15
 
159
      //for(int i = 0; i < MAX_CHANNELS; ++i) 
 
160
      //{
 
161
      //  if(outBuffers[i])
 
162
      //    free(outBuffers[i]);
 
163
      //}
 
164
      
 
165
      // p3.3.38
 
166
      int chans = _totalOutChannels;
 
167
      // Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less. 
 
168
      if(chans < MAX_CHANNELS)
 
169
        chans = MAX_CHANNELS;
 
170
      for(int i = 0; i < chans; ++i) 
128
171
      {
129
172
        if(outBuffers[i])
130
173
          free(outBuffers[i]);
131
174
      }
 
175
      delete[] outBuffers;
 
176
      
132
177
}
133
178
 
134
179
//---------------------------------------------------------
166
211
//---------------------------------------------------------
167
212
 
168
213
void AudioTrack::addPlugin(PluginI* plugin, int idx)
 
214
{
 
215
  if (plugin == 0) 
 
216
  {
 
217
    PluginI* oldPlugin = (*_efxPipe)[idx];
 
218
    if (oldPlugin) 
 
219
    {
 
220
      oldPlugin->setID(-1);
 
221
      oldPlugin->setTrack(0);
 
222
      
 
223
      int controller = oldPlugin->parameters();
 
224
      for (int i = 0; i < controller; ++i) 
169
225
      {
170
 
      if (plugin == 0) {
171
 
            PluginI* oldPlugin = (*_efxPipe)[idx];
172
 
            if (oldPlugin) {
173
 
                  
174
 
                  oldPlugin->setID(-1);
175
 
                  oldPlugin->setTrack(0);
176
 
                  
177
 
                  int controller = oldPlugin->parameters();
178
 
                  for (int i = 0; i < controller; ++i) {
179
 
                        int id = genACnum(idx, i);
180
 
                        removeController(id);
181
 
                        }
182
 
                  }
183
 
            }
184
 
      efxPipe()->insert(plugin, idx);
185
 
      if (plugin) {
186
 
            plugin->setID(idx);
187
 
            plugin->setTrack(this);
188
 
                  
189
 
            int controller = plugin->parameters();
190
 
            for (int i = 0; i < controller; ++i) {
191
 
                  int id = genACnum(idx, i);
192
 
                  const char* name = plugin->paramName(i);
193
 
                  float min, max;
194
 
                  plugin->range(i, &min, &max);
195
 
                  CtrlValueType t = plugin->valueType();
196
 
                  CtrlList* cl = new CtrlList(id);
197
 
                  cl->setRange(min, max);
198
 
                  cl->setName(QString(name));
199
 
                  cl->setValueType(t);
200
 
                  LADSPA_PortRangeHint range = plugin->range(i);
201
 
                  if(LADSPA_IS_HINT_TOGGLED(range.HintDescriptor))
202
 
                    cl->setMode(CtrlList::DISCRETE);
203
 
                  else  
204
 
                    cl->setMode(CtrlList::INTERPOLATE);
205
 
                  cl->setCurVal(plugin->param(i));
206
 
                  addController(cl);
207
 
                  }
208
 
            }
 
226
        int id = genACnum(idx, i);
 
227
        removeController(id);
209
228
      }
 
229
    }
 
230
  }
 
231
  efxPipe()->insert(plugin, idx);
 
232
  if (plugin) 
 
233
  {
 
234
    plugin->setID(idx);
 
235
    plugin->setTrack(this);
 
236
          
 
237
    int controller = plugin->parameters();
 
238
    for (int i = 0; i < controller; ++i) 
 
239
    {
 
240
      int id = genACnum(idx, i);
 
241
      const char* name = plugin->paramName(i);
 
242
      float min, max;
 
243
      plugin->range(i, &min, &max);
 
244
      CtrlValueType t = plugin->valueType();
 
245
      CtrlList* cl = new CtrlList(id);
 
246
      cl->setRange(min, max);
 
247
      cl->setName(QString(name));
 
248
      cl->setValueType(t);
 
249
      LADSPA_PortRangeHint range = plugin->range(i);
 
250
      if(LADSPA_IS_HINT_TOGGLED(range.HintDescriptor))
 
251
        cl->setMode(CtrlList::DISCRETE);
 
252
      else  
 
253
        cl->setMode(CtrlList::INTERPOLATE);
 
254
      cl->setCurVal(plugin->param(i));
 
255
      addController(cl);
 
256
    }
 
257
  }
 
258
}
210
259
 
211
260
//---------------------------------------------------------
212
261
//   addAuxSend
879
928
 
880
929
bool AudioTrack::readProperties(Xml& xml, const QString& tag)
881
930
      {
882
 
      if (tag == "plugin") {
 
931
      if (tag == "plugin") 
 
932
      {
883
933
            int rackpos;
884
934
            for(rackpos = 0; rackpos < PipelineDepth; ++rackpos) 
885
935
            {
886
936
              if(!(*_efxPipe)[rackpos]) 
887
 
                              break;
888
 
                              }
 
937
                break;
 
938
            }
889
939
            if(rackpos < PipelineDepth)
890
940
            {
891
941
              PluginI* pi = new PluginI();
895
945
                delete pi;
896
946
              else 
897
947
                (*_efxPipe)[rackpos] = pi;
898
 
                        }
 
948
            }
899
949
            else
900
950
              printf("can't load plugin - plugin rack is already full\n");
901
 
            }
 
951
      }
902
952
      else if (tag == "auxSend")
903
953
            readAuxSend(xml);
904
954
      else if (tag == "prefader")
965
1015
      }
966
1016
 
967
1017
//---------------------------------------------------------
 
1018
//   showPendingPluginNativeGuis
 
1019
//   This is needed because OSC needs all tracks with plugins to be already
 
1020
//    added to their track lists so it can find them and show their native guis.
 
1021
//---------------------------------------------------------
 
1022
 
 
1023
void AudioTrack::showPendingPluginNativeGuis()
 
1024
{
 
1025
  for(int idx = 0; idx < PipelineDepth; ++idx)
 
1026
  {
 
1027
    PluginI* p = (*_efxPipe)[idx];
 
1028
    if(!p)
 
1029
      continue;
 
1030
    
 
1031
    if(p->isShowNativeGuiPending())
 
1032
      p->showNativeGui(true);
 
1033
  }      
 
1034
}
 
1035
 
 
1036
//---------------------------------------------------------
968
1037
//   mapRackPluginsToControllers
969
1038
//---------------------------------------------------------
970
1039
 
1109
1178
    */
1110
1179
}
1111
1180
 
 
1181
/*
1112
1182
//---------------------------------------------------------
1113
1183
//   writeRouting
1114
1184
//---------------------------------------------------------
1115
1185
 
1116
1186
void AudioTrack::writeRouting(int level, Xml& xml) const
1117
 
      {
 
1187
{
1118
1188
      QString n;
1119
1189
      if (type() == Track::AUDIO_INPUT) {
1120
1190
                ciJackRouteNameCache circ = jackRouteNameCache.find(this);
1168
1238
            }
1169
1239
        }  
1170
1240
      }  
1171
 
    }
 
1241
}
 
1242
*/       
 
1243
       
1172
1244
//---------------------------------------------------------
1173
1245
//   AudioInput
1174
1246
//---------------------------------------------------------