Prepare PortExportChannel API for MIDI export
This commit is contained in:
parent
b11f76d748
commit
4c4ab9cf51
@ -32,6 +32,7 @@
|
||||
#include "pbd/ringbuffer.h"
|
||||
#include "pbd/signals.h"
|
||||
|
||||
#include "ardour/audio_buffer.h"
|
||||
#include "ardour/buffer_set.h"
|
||||
#include "ardour/export_pointers.h"
|
||||
|
||||
@ -52,7 +53,7 @@ public:
|
||||
virtual samplecnt_t common_port_playback_latency () const { return 0; }
|
||||
virtual void prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency) {}
|
||||
|
||||
virtual void read (Sample const*& data, samplecnt_t samples) const = 0;
|
||||
virtual void read (Buffer const*&, samplecnt_t samples) const = 0;
|
||||
|
||||
virtual bool empty () const = 0;
|
||||
|
||||
@ -78,7 +79,7 @@ public:
|
||||
samplecnt_t common_port_playback_latency () const;
|
||||
void prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency);
|
||||
|
||||
void read (Sample const*& data, samplecnt_t samples) const;
|
||||
void read (Buffer const*&, samplecnt_t samples) const;
|
||||
|
||||
bool empty () const { return ports.empty (); }
|
||||
|
||||
@ -94,6 +95,7 @@ private:
|
||||
PortSet ports;
|
||||
samplecnt_t _buffer_size;
|
||||
boost::scoped_array<Sample> _buffer;
|
||||
mutable AudioBuffer _buf;
|
||||
std::list<boost::shared_ptr<PBD::RingBuffer<Sample>>> _delaylines;
|
||||
};
|
||||
|
||||
@ -112,7 +114,7 @@ public:
|
||||
|
||||
ExportChannelPtr create (uint32_t channel);
|
||||
|
||||
void read (uint32_t channel, Sample const*& data, samplecnt_t samples_to_read);
|
||||
void read (uint32_t channel, Buffer const*&, samplecnt_t samples_to_read);
|
||||
|
||||
private:
|
||||
int new_cycle_started (samplecnt_t)
|
||||
@ -145,9 +147,9 @@ class LIBARDOUR_API RegionExportChannel : public ExportChannel
|
||||
friend class RegionExportChannelFactory;
|
||||
|
||||
public:
|
||||
void read (Sample const*& data, samplecnt_t samples_to_read) const
|
||||
void read (Buffer const*& buf, samplecnt_t samples_to_read) const
|
||||
{
|
||||
factory.read (channel, data, samples_to_read);
|
||||
factory.read (channel, buf, samples_to_read);
|
||||
}
|
||||
|
||||
void get_state (XMLNode* /*node*/) const {};
|
||||
@ -188,7 +190,7 @@ public:
|
||||
public: // ExportChannel interface
|
||||
void prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency);
|
||||
|
||||
void read (Sample const*& data, samplecnt_t samples) const;
|
||||
void read (Buffer const*&, samplecnt_t samples) const;
|
||||
|
||||
bool empty () const { return false; }
|
||||
|
||||
|
@ -38,6 +38,7 @@ using namespace ARDOUR;
|
||||
|
||||
PortExportChannel::PortExportChannel ()
|
||||
: _buffer_size (0)
|
||||
, _buf (0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -101,7 +102,7 @@ PortExportChannel::operator< (ExportChannel const& other) const
|
||||
}
|
||||
|
||||
void
|
||||
PortExportChannel::read (Sample const*& data, samplecnt_t samples) const
|
||||
PortExportChannel::read (Buffer const*& buf, samplecnt_t samples) const
|
||||
{
|
||||
assert (_buffer);
|
||||
assert (samples <= _buffer_size);
|
||||
@ -109,8 +110,8 @@ PortExportChannel::read (Sample const*& data, samplecnt_t samples) const
|
||||
if (ports.size () == 1 && _delaylines.size () == 1 && _delaylines.front ()->bufsize () == _buffer_size + 1) {
|
||||
boost::shared_ptr<AudioPort> p = ports.begin ()->lock ();
|
||||
AudioBuffer& ab (p->get_audio_buffer (samples)); // unsets AudioBuffer::_written
|
||||
data = ab.data ();
|
||||
ab.set_written (true);
|
||||
buf = &ab;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -143,7 +144,8 @@ PortExportChannel::read (Sample const*& data, samplecnt_t samples) const
|
||||
++di;
|
||||
}
|
||||
|
||||
data = _buffer.get ();
|
||||
_buf.set_data (_buffer.get(), samples);
|
||||
buf = &_buf;
|
||||
}
|
||||
|
||||
void
|
||||
@ -217,7 +219,7 @@ RegionExportChannelFactory::create (uint32_t channel)
|
||||
}
|
||||
|
||||
void
|
||||
RegionExportChannelFactory::read (uint32_t channel, Sample const*& data, samplecnt_t samples_to_read)
|
||||
RegionExportChannelFactory::read (uint32_t channel, Buffer const*& buf, samplecnt_t samples_to_read)
|
||||
{
|
||||
assert (channel < n_channels);
|
||||
assert (samples_to_read <= samples_per_cycle);
|
||||
@ -227,7 +229,7 @@ RegionExportChannelFactory::read (uint32_t channel, Sample const*& data, samplec
|
||||
buffers_up_to_date = true;
|
||||
}
|
||||
|
||||
data = buffers.get_audio (channel).data ();
|
||||
buf = &buffers.get_audio (channel);
|
||||
}
|
||||
|
||||
void
|
||||
@ -290,7 +292,7 @@ RouteExportChannel::prepare_export (samplecnt_t max_samples, sampleoffset_t)
|
||||
}
|
||||
|
||||
void
|
||||
RouteExportChannel::read (Sample const*& data, samplecnt_t samples) const
|
||||
RouteExportChannel::read (Buffer const*& buf, samplecnt_t samples) const
|
||||
{
|
||||
assert (processor);
|
||||
AudioBuffer const& buffer = processor->get_capture_buffers ().get_audio (channel);
|
||||
@ -299,7 +301,7 @@ RouteExportChannel::read (Sample const*& data, samplecnt_t samples) const
|
||||
#else
|
||||
assert (samples <= (samplecnt_t)buffer.capacity ());
|
||||
#endif
|
||||
data = buffer.data ();
|
||||
buf = &buffer;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -86,8 +86,12 @@ ExportGraphBuilder::process (samplecnt_t samples, bool last_cycle)
|
||||
|
||||
sampleoffset_t off = 0;
|
||||
for (ChannelMap::iterator it = channels.begin(); it != channels.end(); ++it) {
|
||||
Sample const * process_buffer = 0;
|
||||
it->first->read (process_buffer, samples);
|
||||
// TODO special case MIDI..
|
||||
Buffer const* buf;
|
||||
it->first->read (buf, samples);
|
||||
AudioBuffer const* ab = dynamic_cast<AudioBuffer const*> (buf);
|
||||
assert (ab);
|
||||
Sample const* process_buffer = ab->data ();
|
||||
|
||||
if (session.remaining_latency_preroll () >= _master_align + samples) {
|
||||
/* Skip processing during pre-roll, only read/write export ringbuffers */
|
||||
|
Loading…
Reference in New Issue
Block a user