diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/export_channel.h | 5 | ||||
-rw-r--r-- | libs/ardour/export_channel.cc | 34 |
2 files changed, 37 insertions, 2 deletions
diff --git a/libs/ardour/ardour/export_channel.h b/libs/ardour/ardour/export_channel.h index dd351bfd70..d9e39c8850 100644 --- a/libs/ardour/ardour/export_channel.h +++ b/libs/ardour/ardour/export_channel.h @@ -90,10 +90,12 @@ class RegionExportChannelFactory : public sigc::trackable public: enum Type { Raw, + Fades, Processed }; RegionExportChannelFactory (Session * session, AudioRegion const & region, AudioTrack & track, Type type); + ~RegionExportChannelFactory (); ExportChannelPtr create (uint32_t channel); void read (uint32_t channel, Sample * data, nframes_t frames_to_read); @@ -113,6 +115,9 @@ class RegionExportChannelFactory : public sigc::trackable bool buffers_up_to_date; nframes_t region_start; nframes_t position; + + Sample * mixdown_buffer; + Sample * gain_buffer; }; /// Export channel that reads from region channel diff --git a/libs/ardour/export_channel.cc b/libs/ardour/export_channel.cc index e0242a9f52..094d6f9104 100644 --- a/libs/ardour/export_channel.cc +++ b/libs/ardour/export_channel.cc @@ -81,12 +81,23 @@ RegionExportChannelFactory::RegionExportChannelFactory (Session * session, Audio frames_per_cycle (session->engine().frames_per_cycle ()), buffers_up_to_date (false), region_start (region.position()), - position (region_start) + position (region_start), + + mixdown_buffer (0), + gain_buffer (0) { switch (type) { case Raw: n_channels = region.n_channels(); break; + case Fades: + n_channels = region.n_channels(); + + mixdown_buffer = new Sample [frames_per_cycle]; + gain_buffer = new Sample [frames_per_cycle]; + memset (gain_buffer, 1.0, sizeof (Sample) * frames_per_cycle); + + break; case Processed: n_channels = track.n_outputs().n_audio(); break; @@ -100,6 +111,17 @@ RegionExportChannelFactory::RegionExportChannelFactory (Session * session, Audio buffers.ensure_buffers (DataType::AUDIO, n_channels, frames_per_cycle); } +RegionExportChannelFactory::~RegionExportChannelFactory () +{ + if (mixdown_buffer) { + delete[] mixdown_buffer; + } + + if (gain_buffer) { + delete[] gain_buffer; + } +} + ExportChannelPtr RegionExportChannelFactory::create (uint32_t channel) { @@ -124,14 +146,22 @@ RegionExportChannelFactory::read (uint32_t channel, Sample * data, nframes_t fra void RegionExportChannelFactory::update_buffers (nframes_t frames) { + assert (frames <= frames_per_cycle); + switch (type) { case Raw: for (size_t channel = 0; channel < n_channels; ++channel) { region.read (buffers.get_audio (channel).data(), position - region_start, frames, channel); } break; + case Fades: + assert (mixdown_buffer && gain_buffer); + for (size_t channel = 0; channel < n_channels; ++channel) { + memset (mixdown_buffer, 0, sizeof (Sample) * frames); + region.read_at (buffers.get_audio (channel).data(), mixdown_buffer, gain_buffer, position, frames, channel); + } + break; case Processed: - std::cout << "exporting " << frames << " frames from position " << position << std::endl; track.export_stuff (buffers, position, frames); break; default: |