Give route groups their own colour, settable from the route
[ardour.git] / libs / ardour / audio_track.cc
1 /*
2     Copyright (C) 2002 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <boost/scoped_array.hpp>
21
22 #include "pbd/error.h"
23 #include "pbd/enumwriter.h"
24 #include "pbd/boost_debug.h"
25
26 #include "evoral/Curve.hpp"
27
28 #include "ardour/amp.h"
29 #include "ardour/audio_buffer.h"
30 #include "ardour/audio_diskstream.h"
31 #include "ardour/audio_track.h"
32 #include "ardour/audioplaylist.h"
33 #include "ardour/audioregion.h"
34 #include "ardour/audiosource.h"
35 #include "ardour/buffer_set.h"
36 #include "ardour/io_processor.h"
37 #include "ardour/panner.h"
38 #include "ardour/meter.h"
39 #include "ardour/playlist_factory.h"
40 #include "ardour/plugin_insert.h"
41 #include "ardour/processor.h"
42 #include "ardour/region_factory.h"
43 #include "ardour/route_group_specialized.h"
44 #include "ardour/session.h"
45 #include "ardour/utils.h"
46 #include "ardour/session_playlists.h"
47 #include "ardour/delivery.h"
48 #include "ardour/meter.h"
49 #include "i18n.h"
50
51 using namespace std;
52 using namespace ARDOUR;
53 using namespace PBD;
54
55 AudioTrack::AudioTrack (Session& sess, string name, Route::Flag flag, TrackMode mode)
56         : Track (sess, name, flag, mode)
57 {
58 }
59
60 AudioTrack::~AudioTrack ()
61 {
62 }
63
64 void
65 AudioTrack::use_new_diskstream ()
66 {
67         AudioDiskstream::Flag dflags = AudioDiskstream::Flag (0);
68
69         if (_flags & Hidden) {
70                 dflags = AudioDiskstream::Flag (dflags | AudioDiskstream::Hidden);
71         } else {
72                 dflags = AudioDiskstream::Flag (dflags | AudioDiskstream::Recordable);
73         }
74
75         if (_mode == Destructive) {
76                 dflags = AudioDiskstream::Flag (dflags | AudioDiskstream::Destructive);
77         } else if (_mode == NonLayered){
78                 dflags = AudioDiskstream::Flag(dflags | AudioDiskstream::NonLayered);
79         }
80
81         AudioDiskstream* dsp (new AudioDiskstream (_session, name(), dflags));
82         boost::shared_ptr<AudioDiskstream> ds (dsp);
83
84         ds->do_refill_with_alloc ();
85         ds->set_block_size (_session.get_block_size ());
86
87         set_diskstream (ds);
88 }
89
90 void
91 AudioTrack::set_diskstream (boost::shared_ptr<Diskstream> ds)
92 {
93         Track::set_diskstream (ds);
94
95         _diskstream->set_track (this);
96         _diskstream->set_destructive (_mode == Destructive);
97         _diskstream->set_non_layered (_mode == NonLayered);
98
99         if (audio_diskstream()->deprecated_io_node) {
100
101                 if (!IO::connecting_legal) {
102                         IO::ConnectingLegal.connect_same_thread (*this, boost::bind (&AudioTrack::deprecated_use_diskstream_connections, this));
103                 } else {
104                         deprecated_use_diskstream_connections ();
105                 }
106         }
107
108         _diskstream->set_record_enabled (false);
109         _diskstream->monitor_input (false);
110
111         DiskstreamChanged (); /* EMIT SIGNAL */
112 }
113
114 boost::shared_ptr<AudioDiskstream>
115 AudioTrack::audio_diskstream() const
116 {
117         return boost::dynamic_pointer_cast<AudioDiskstream>(_diskstream);
118 }
119
120 int
121 AudioTrack::set_mode (TrackMode m)
122 {
123         if (m != _mode) {
124
125                 if (_diskstream->set_destructive (m == Destructive)) {
126                         return -1;
127                 }
128
129                 _diskstream->set_non_layered (m == NonLayered);
130                 _mode = m;
131
132                 TrackModeChanged (); /* EMIT SIGNAL */
133         }
134
135         return 0;
136 }
137
138 bool
139 AudioTrack::can_use_mode (TrackMode m, bool& bounce_required)
140 {
141         switch (m) {
142         case NonLayered:
143         case Normal:
144                 bounce_required = false;
145                 return true;
146
147         case Destructive:
148         default:
149                 return _diskstream->can_become_destructive (bounce_required);
150         }
151 }
152
153 int
154 AudioTrack::deprecated_use_diskstream_connections ()
155 {
156         boost::shared_ptr<AudioDiskstream> diskstream = audio_diskstream();
157
158         if (diskstream->deprecated_io_node == 0) {
159                 return 0;
160         }
161
162         const XMLProperty* prop;
163         XMLNode& node (*diskstream->deprecated_io_node);
164
165         /* don't do this more than once. */
166
167         diskstream->deprecated_io_node = 0;
168
169         if ((prop = node.property ("gain")) != 0) {
170                 _amp->set_gain (atof (prop->value().c_str()), this);
171         }
172
173         if ((prop = node.property ("input-connection")) != 0) {
174                 boost::shared_ptr<Bundle> c = _session.bundle_by_name (prop->value());
175
176                 if (c == 0) {
177                         error << string_compose(_("Unknown bundle \"%1\" listed for input of %2"), prop->value(), _name) << endmsg;
178
179                         if ((c = _session.bundle_by_name (_("in 1"))) == 0) {
180                                 error << _("No input bundles available as a replacement")
181                                 << endmsg;
182                                 return -1;
183                         } else {
184                                 info << string_compose (_("Bundle %1 was not available - \"in 1\" used instead"), prop->value())
185                                << endmsg;
186                         }
187                 }
188
189                 _input->connect_ports_to_bundle (c, this);
190
191         } else if ((prop = node.property ("inputs")) != 0) {
192                 if (_input->set_ports (prop->value())) {
193                         error << string_compose(_("improper input channel list in XML node (%1)"), prop->value()) << endmsg;
194                         return -1;
195                 }
196         }
197
198         return 0;
199 }
200
201 int
202 AudioTrack::set_state (const XMLNode& node, int version)
203 {
204         return _set_state (node, version, true);
205 }
206
207 int
208 AudioTrack::_set_state (const XMLNode& node, int version, bool call_base)
209 {
210         const XMLProperty *prop;
211         XMLNodeConstIterator iter;
212         XMLNode *child;
213
214         if (call_base) {
215                 if (Route::_set_state (node, version, call_base)) {
216                         return -1;
217                 }
218         }
219
220         if ((prop = node.property (X_("mode"))) != 0) {
221                 _mode = TrackMode (string_2_enum (prop->value(), _mode));
222         } else {
223                 _mode = Normal;
224         }
225
226         if (version >= 3000) {
227                 if ((child = find_named_node (node, X_("Diskstream"))) != 0) {
228                         boost::shared_ptr<AudioDiskstream> ds (new AudioDiskstream (_session, *child));
229                         ds->do_refill_with_alloc ();
230                         set_diskstream (ds);
231                 }
232         }
233
234         /* set rec-enable control *AFTER* setting up diskstream, because it may want to operate
235            on the diskstream as it sets its own state
236         */
237
238         XMLNodeList nlist;
239         XMLNodeConstIterator niter;
240
241         nlist = node.children();
242         for (niter = nlist.begin(); niter != nlist.end(); ++niter){
243                 child = *niter;
244
245                 if (child->name() == Controllable::xml_node_name && (prop = child->property ("name")) != 0) {
246                         if (prop->value() == X_("recenable")) {
247                                 _rec_enable_control->set_state (*child, version);
248                         }
249                 }
250         }
251
252         pending_state = const_cast<XMLNode*> (&node);
253
254         if (_session.state_of_the_state() & Session::Loading) {
255                 _session.StateReady.connect_same_thread (*this, boost::bind (&AudioTrack::set_state_part_two, this));
256         } else {
257                 set_state_part_two ();
258         }
259
260         return 0;
261 }
262
263 XMLNode&
264 AudioTrack::state (bool full_state)
265 {
266         XMLNode& root (Route::state(full_state));
267         XMLNode* freeze_node;
268         char buf[64];
269
270         if (_freeze_record.playlist) {
271                 XMLNode* inode;
272
273                 freeze_node = new XMLNode (X_("freeze-info"));
274                 freeze_node->add_property ("playlist", _freeze_record.playlist->name());
275                 freeze_node->add_property ("state", enum_2_string (_freeze_record.state));
276
277                 for (vector<FreezeRecordProcessorInfo*>::iterator i = _freeze_record.processor_info.begin(); i != _freeze_record.processor_info.end(); ++i) {
278                         inode = new XMLNode (X_("processor"));
279                         (*i)->id.print (buf, sizeof (buf));
280                         inode->add_property (X_("id"), buf);
281                         inode->add_child_copy ((*i)->state);
282
283                         freeze_node->add_child_nocopy (*inode);
284                 }
285
286                 root.add_child_nocopy (*freeze_node);
287         }
288
289         root.add_property (X_("mode"), enum_2_string (_mode));
290         root.add_child_nocopy (_rec_enable_control->get_state());
291         root.add_child_nocopy (_diskstream->get_state ());
292
293         return root;
294 }
295
296 void
297 AudioTrack::set_state_part_two ()
298 {
299         XMLNode* fnode;
300         XMLProperty* prop;
301         LocaleGuard lg (X_("POSIX"));
302
303         /* This is called after all session state has been restored but before
304            have been made ports and connections are established.
305         */
306
307         if (pending_state == 0) {
308                 return;
309         }
310
311         if ((fnode = find_named_node (*pending_state, X_("freeze-info"))) != 0) {
312
313                 _freeze_record.state = Frozen;
314
315                 for (vector<FreezeRecordProcessorInfo*>::iterator i = _freeze_record.processor_info.begin(); i != _freeze_record.processor_info.end(); ++i) {
316                         delete *i;
317                 }
318                 _freeze_record.processor_info.clear ();
319
320                 if ((prop = fnode->property (X_("playlist"))) != 0) {
321                         boost::shared_ptr<Playlist> pl = _session.playlists->by_name (prop->value());
322                         if (pl) {
323                                 _freeze_record.playlist = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
324                         } else {
325                                 _freeze_record.playlist.reset ();
326                                 _freeze_record.state = NoFreeze;
327                         return;
328                         }
329                 }
330
331                 if ((prop = fnode->property (X_("state"))) != 0) {
332                         _freeze_record.state = FreezeState (string_2_enum (prop->value(), _freeze_record.state));
333                 }
334
335                 XMLNodeConstIterator citer;
336                 XMLNodeList clist = fnode->children();
337
338                 for (citer = clist.begin(); citer != clist.end(); ++citer) {
339                         if ((*citer)->name() != X_("processor")) {
340                                 continue;
341                         }
342
343                         if ((prop = (*citer)->property (X_("id"))) == 0) {
344                                 continue;
345                         }
346
347                         FreezeRecordProcessorInfo* frii = new FreezeRecordProcessorInfo (*((*citer)->children().front()),
348                                                                                    boost::shared_ptr<Processor>());
349                         frii->id = prop->value ();
350                         _freeze_record.processor_info.push_back (frii);
351                 }
352         }
353 }
354
355 int
356 AudioTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick,
357                   bool can_record, bool rec_monitors_input, bool& need_butler)
358 {
359         Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
360         if (!lm.locked()) {
361                 return 0;
362         }
363
364         int dret;
365         Sample* b;
366         Sample* tmpb;
367         framepos_t transport_frame;
368         boost::shared_ptr<AudioDiskstream> diskstream = audio_diskstream();
369
370         automation_snapshot (start_frame, false);
371
372         if (n_outputs().n_total() == 0 && _processors.empty()) {
373                 return 0;
374         }
375
376         if (!_active) {
377                 silence (nframes);
378                 return 0;
379         }
380
381         transport_frame = _session.transport_frame();
382
383         if ((nframes = check_initial_delay (nframes, transport_frame)) == 0) {
384
385                 /* need to do this so that the diskstream sets its
386                    playback distance to zero, thus causing diskstream::commit
387                    to do nothing.
388                 */
389                 return diskstream->process (transport_frame, 0, can_record, rec_monitors_input, need_butler);
390         }
391
392         _silent = false;
393         _amp->apply_gain_automation(false);
394
395         if ((dret = diskstream->process (transport_frame, nframes, can_record, rec_monitors_input, need_butler)) != 0) {
396                 silence (nframes);
397                 return dret;
398         }
399
400         /* special condition applies */
401
402         if (_meter_point == MeterInput) {
403                 _input->process_input (_meter, start_frame, end_frame, nframes);
404         }
405
406         if (diskstream->record_enabled() && !can_record && !_session.config.get_auto_input()) {
407
408                 /* not actually recording, but we want to hear the input material anyway,
409                    at least potentially (depending on monitoring options)
410                  */
411
412                 passthru (start_frame, end_frame, nframes, false);
413
414         } else if ((b = diskstream->playback_buffer(0)) != 0) {
415
416                 /*
417                   XXX is it true that the earlier test on n_outputs()
418                   means that we can avoid checking it again here? i think
419                   so, because changing the i/o configuration of an IO
420                   requires holding the AudioEngine lock, which we hold
421                   while in the process() tree.
422                 */
423
424
425                 /* copy the diskstream data to all output buffers */
426
427                 size_t limit = input_streams ().n_audio();
428                 BufferSet& bufs = _session.get_scratch_buffers ();
429                 const size_t blimit = bufs.count().n_audio();
430
431                 uint32_t n;
432                 uint32_t i;
433
434                 if (limit > blimit) {
435
436                         /* example case: auditioner configured for stereo output,
437                            but loaded with an 8 channel file. there are only
438                            2 passthrough buffers, but n_process_buffers() will
439                            return 8.
440
441                            arbitrary decision: map all channels in the diskstream
442                            to the outputs available.
443                         */
444
445                         float scaling = limit/blimit;
446
447                         for (i = 0, n = 1; i < blimit; ++i, ++n) {
448
449                                 /* first time through just copy a channel into
450                                    the output buffer.
451                                 */
452
453                                 Sample* bb = bufs.get_audio (i).data();
454
455                                 for (pframes_t xx = 0; xx < nframes; ++xx) {
456                                         bb[xx] = b[xx] * scaling;
457                                 }
458
459                                 if (n < diskstream->n_channels().n_audio()) {
460                                         tmpb = diskstream->playback_buffer(n);
461                                         if (tmpb!=0) {
462                                                 b = tmpb;
463                                         }
464                                 }
465                         }
466
467                         for (;i < limit; ++i, ++n) {
468
469                                 /* for all remaining channels, sum with existing
470                                    data in the output buffers
471                                 */
472
473                                 bufs.get_audio (i%blimit).accumulate_with_gain_from (b, nframes, 0, scaling);
474
475                                 if (n < diskstream->n_channels().n_audio()) {
476                                         tmpb = diskstream->playback_buffer(n);
477                                         if (tmpb!=0) {
478                                                 b = tmpb;
479                                         }
480                                 }
481
482                         }
483
484                         limit = blimit;
485
486                 } else {
487                         for (i = 0, n = 1; i < limit; ++i, ++n) {
488                                 memcpy (bufs.get_audio (i).data(), b, sizeof (Sample) * nframes);
489                                 if (n < diskstream->n_channels().n_audio()) {
490                                         tmpb = diskstream->playback_buffer(n);
491                                         if (tmpb!=0) {
492                                                 b = tmpb;
493                                         }
494                                 }
495                         }
496
497                         /* try to leave any MIDI buffers alone */
498
499                         ChanCount chn;
500                         chn.set_audio (limit);
501                         chn.set_midi (_input->n_ports().n_midi());
502                         bufs.set_count (chn);
503                 }
504
505                 /* final argument: don't waste time with automation if we're recording or we've just stopped (yes it can happen) */
506
507                 process_output_buffers (
508                         bufs, start_frame, end_frame, nframes,
509                         (!_session.get_record_enabled() || !Config->get_do_not_record_plugins()),
510                         declick,
511                         (!diskstream->record_enabled() && _session.transport_rolling()));
512
513         } else {
514                 /* problem with the diskstream; just be quiet for a bit */
515                 silence (nframes);
516         }
517
518         return 0;
519 }
520
521 int
522 AudioTrack::export_stuff (BufferSet& buffers, framepos_t start, framecnt_t nframes, bool enable_processing)
523 {
524         boost::scoped_array<gain_t> gain_buffer (new gain_t[nframes]);
525         boost::scoped_array<Sample> mix_buffer (new Sample[nframes]);
526         boost::shared_ptr<AudioDiskstream> diskstream = audio_diskstream();
527
528         Glib::RWLock::ReaderLock rlock (_processor_lock);
529
530         boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist>(diskstream->playlist());
531
532         assert(apl);
533         assert(buffers.count().n_audio() >= 1);
534         assert ((framecnt_t) buffers.get_audio(0).capacity() >= nframes);
535
536         if (apl->read (buffers.get_audio(0).data(), mix_buffer.get(), gain_buffer.get(), start, nframes) != nframes) {
537                 return -1;
538         }
539
540         uint32_t n=1;
541         Sample* b = buffers.get_audio(0).data();
542         BufferSet::audio_iterator bi = buffers.audio_begin();
543         ++bi;
544         for ( ; bi != buffers.audio_end(); ++bi, ++n) {
545                 if (n < diskstream->n_channels().n_audio()) {
546                         if (apl->read (bi->data(), mix_buffer.get(), gain_buffer.get(), start, nframes, n) != nframes) {
547                                 return -1;
548                         }
549                         b = bi->data();
550                 } else {
551                         /* duplicate last across remaining buffers */
552                         memcpy (bi->data(), b, sizeof (Sample) * nframes);
553                 }
554         }
555
556         // If no processing is required, there's no need to go any further.
557         if (!enable_processing) {
558                 return 0;
559         }
560
561         /* note: only run processors during export. other layers in the machinery
562            will already have checked that there are no external port processors.
563            Also, don't run deliveries that write to real output ports, and don't
564            run meters.
565         */
566
567         for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
568                 boost::shared_ptr<Processor> processor = boost::dynamic_pointer_cast<Processor> (*i);
569                 boost::shared_ptr<Delivery> delivery = boost::dynamic_pointer_cast<Delivery> (*i);
570                 boost::shared_ptr<PeakMeter> meter = boost::dynamic_pointer_cast<PeakMeter> (*i);
571
572                 if (processor && (!delivery || !Delivery::role_requires_output_ports (delivery->role())) && !meter) {
573                         processor->run (buffers, start, start+nframes, nframes, true);
574                 }
575         }
576
577         return 0;
578 }
579
580 boost::shared_ptr<Region>
581 AudioTrack::bounce (InterThreadInfo& itt)
582 {
583         vector<boost::shared_ptr<Source> > srcs;
584         return _session.write_one_track (*this, _session.current_start_frame(), _session.current_end_frame(), false, srcs, itt);
585 }
586
587 boost::shared_ptr<Region>
588 AudioTrack::bounce_range (framepos_t start, framepos_t end, InterThreadInfo& itt, bool enable_processing)
589 {
590         vector<boost::shared_ptr<Source> > srcs;
591         return _session.write_one_track (*this, start, end, false, srcs, itt, enable_processing);
592 }
593
594 void
595 AudioTrack::freeze_me (InterThreadInfo& itt)
596 {
597         vector<boost::shared_ptr<Source> > srcs;
598         string new_playlist_name;
599         boost::shared_ptr<Playlist> new_playlist;
600         string dir;
601         string region_name;
602         boost::shared_ptr<AudioDiskstream> diskstream = audio_diskstream();
603
604         if ((_freeze_record.playlist = boost::dynamic_pointer_cast<AudioPlaylist>(diskstream->playlist())) == 0) {
605                 return;
606         }
607
608         uint32_t n = 1;
609
610         while (n < (UINT_MAX-1)) {
611
612                 string candidate;
613
614                 candidate = string_compose ("<F%2>%1", _freeze_record.playlist->name(), n);
615
616                 if (_session.playlists->by_name (candidate) == 0) {
617                         new_playlist_name = candidate;
618                         break;
619                 }
620
621                 ++n;
622
623         }
624
625         if (n == (UINT_MAX-1)) {
626           error << string_compose (X_("There are too many frozen versions of playlist \"%1\""
627                             " to create another one"), _freeze_record.playlist->name())
628                << endmsg;
629                 return;
630         }
631
632         boost::shared_ptr<Region> res;
633
634         if ((res = _session.write_one_track (*this, _session.current_start_frame(), _session.current_end_frame(), true, srcs, itt)) == 0) {
635                 return;
636         }
637
638         _freeze_record.processor_info.clear ();
639
640         {
641                 Glib::RWLock::ReaderLock lm (_processor_lock);
642
643                 for (ProcessorList::iterator r = _processors.begin(); r != _processors.end(); ++r) {
644
645                         boost::shared_ptr<Processor> processor;
646
647                         if ((processor = boost::dynamic_pointer_cast<Processor>(*r)) != 0) {
648
649                                 FreezeRecordProcessorInfo* frii  = new FreezeRecordProcessorInfo ((*r)->get_state(), processor);
650
651                                 frii->id = processor->id();
652
653                                 _freeze_record.processor_info.push_back (frii);
654
655                                 /* now deactivate the processor */
656
657                                 processor->deactivate ();
658                                 _session.set_dirty ();
659                         }
660                 }
661         }
662
663         new_playlist = PlaylistFactory::create (DataType::AUDIO, _session, new_playlist_name, false);
664
665         /* XXX need main outs automation state _freeze_record.pan_automation_state = _mainpanner->automation_state(); */
666
667         region_name = new_playlist_name;
668
669         /* create a new region from all filesources, keep it private */
670
671         PropertyList plist;
672
673         plist.add (Properties::start, 0);
674         plist.add (Properties::length, srcs[0]->length(srcs[0]->timeline_position()));
675         plist.add (Properties::name, region_name);
676         plist.add (Properties::whole_file, true);
677
678         boost::shared_ptr<Region> region (RegionFactory::create (srcs, plist, false));
679
680         new_playlist->set_orig_diskstream_id (_diskstream->id());
681         new_playlist->add_region (region, _session.current_start_frame());
682         new_playlist->set_frozen (true);
683         region->set_locked (true);
684
685         diskstream->use_playlist (boost::dynamic_pointer_cast<AudioPlaylist>(new_playlist));
686         diskstream->set_record_enabled (false);
687
688         /* reset stuff that has already been accounted for in the freeze process */
689
690         set_gain (1.0, this);
691         _amp->gain_control()->set_automation_state (Off);
692         /* XXX need to use _main_outs _panner->set_automation_state (Off); */
693
694         _freeze_record.state = Frozen;
695         FreezeChange(); /* EMIT SIGNAL */
696 }
697
698 void
699 AudioTrack::unfreeze ()
700 {
701         if (_freeze_record.playlist) {
702                 audio_diskstream()->use_playlist (_freeze_record.playlist);
703
704                 {
705                         Glib::RWLock::ReaderLock lm (_processor_lock); // should this be a write lock? jlc
706                         for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
707                                 for (vector<FreezeRecordProcessorInfo*>::iterator ii = _freeze_record.processor_info.begin(); ii != _freeze_record.processor_info.end(); ++ii) {
708                                         if ((*ii)->id == (*i)->id()) {
709                                                 (*i)->set_state (((*ii)->state), Stateful::current_state_version);
710                                                 break;
711                                         }
712                                 }
713                         }
714                 }
715
716                 _freeze_record.playlist.reset ();
717                 /* XXX need to use _main_outs _panner->set_automation_state (_freeze_record.pan_automation_state); */
718         }
719
720         _freeze_record.state = UnFrozen;
721         FreezeChange (); /* EMIT SIGNAL */
722 }
723
724 boost::shared_ptr<AudioFileSource>
725 AudioTrack::write_source (uint32_t n)
726 {
727         boost::shared_ptr<AudioDiskstream> ds = boost::dynamic_pointer_cast<AudioDiskstream> (_diskstream);
728         assert (ds);
729         return ds->write_source (n);
730 }
731
732 bool
733 AudioTrack::bounceable () const
734 {
735         return n_inputs().n_audio() >= n_outputs().n_audio();
736 }