Merge with 2.0-ongoing R3082.

Superficial generification of export stuff.


git-svn-id: svn://localhost/ardour2/branches/3.0@3088 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2008-02-19 22:10:27 +00:00
parent 4cbd7f0eab
commit a2a6cc0404
31 changed files with 657 additions and 367 deletions

View file

@ -125,7 +125,7 @@ class AudioRegion : public Region
/* export */
int exportme (ARDOUR::Session&, ARDOUR::AudioExportSpecification&);
int exportme (ARDOUR::Session&, ARDOUR::ExportSpecification&);
/* xfade/fade interactions */

View file

@ -42,12 +42,12 @@ namespace ARDOUR
class Port;
typedef pair<Port *, uint32_t> PortChannelPair;
typedef map<uint32_t, vector<PortChannelPair> > AudioExportPortMap;
typedef map<uint32_t, vector<PortChannelPair> > ExportPortMap;
struct AudioExportSpecification : public SF_INFO, public sigc::trackable {
struct ExportSpecification : public SF_INFO, public sigc::trackable {
AudioExportSpecification();
~AudioExportSpecification ();
ExportSpecification();
~ExportSpecification ();
void init ();
void clear ();
@ -62,36 +62,36 @@ namespace ARDOUR
string path;
nframes_t sample_rate;
int src_quality;
SNDFILE* out;
int src_quality;
SNDFILE* out;
uint32_t channels;
AudioExportPortMap port_map;
ExportPortMap port_map;
nframes_t start_frame;
nframes_t end_frame;
GDitherType dither_type;
bool do_freewheel;
GDitherType dither_type;
bool do_freewheel;
/* used exclusively during export */
nframes_t frame_rate;
GDither dither;
float* dataF;
float* dataF2;
float* leftoverF;
GDither dither;
float* dataF;
float* dataF2;
float* leftoverF;
nframes_t leftover_frames;
nframes_t max_leftover_frames;
void* output_data;
void* output_data;
nframes_t out_samples_max;
uint32_t sample_bytes;
uint32_t data_width;
uint32_t sample_bytes;
uint32_t data_width;
nframes_t total_frames;
SF_INFO sfinfo;
SRC_DATA src_data;
SRC_STATE* src_state;
SF_INFO sfinfo;
SRC_DATA src_data;
SRC_STATE* src_state;
nframes_t pos;
sigc::connection freewheel_connection;
sigc::connection freewheel_connection;
/* shared between UI thread and audio thread */
@ -99,9 +99,9 @@ namespace ARDOUR
volatile bool stop; /* UI sets this */
volatile bool running; /* audio thread sets to false when export is done */
int status;
int status;
};
} // namespace ARDOUR
#endif /* __ardour_export_h__ */

View file

@ -84,6 +84,8 @@ class MidiRegion : public Region
boost::shared_ptr<const AutomationControl> control(Parameter id) const
{ return midi_source()->model()->control(id); }
int exportme (ARDOUR::Session&, ARDOUR::ExportSpecification&);
private:
friend class RegionFactory;

View file

@ -37,6 +37,7 @@ namespace ARDOUR {
class Playlist;
class Filter;
class ExportSpecification;
enum RegionEditState {
EditChangesNothing = 0,
@ -222,6 +223,8 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region>
virtual bool is_dependent() const { return false; }
virtual bool depends_on (boost::shared_ptr<Region> other) const { return false; }
virtual int exportme (ARDOUR::Session&, ARDOUR::ExportSpecification&) = 0;
virtual int get_transients (AnalysisFeatureList&, bool force_new = false) {
// no transients, but its OK
return 0;

View file

@ -109,7 +109,7 @@ class SMFSource;
class SessionDirectory;
struct AudioExportSpecification;
struct ExportSpecification;
struct RouteGroup;
using std::vector;
@ -606,8 +606,8 @@ class Session : public PBD::StatefulDestructible
SlaveSource post_export_slave;
nframes_t post_export_position;
int start_audio_export (ARDOUR::AudioExportSpecification&);
int stop_audio_export (ARDOUR::AudioExportSpecification&);
int start_export (ARDOUR::ExportSpecification&);
int stop_export (ARDOUR::ExportSpecification&);
void finalize_audio_export ();
void add_source (boost::shared_ptr<Source>);
@ -1037,7 +1037,7 @@ class Session : public PBD::StatefulDestructible
void process_without_events (nframes_t);
void process_with_events (nframes_t);
void process_audition (nframes_t);
int process_export (nframes_t, ARDOUR::AudioExportSpecification*);
int process_export (nframes_t, ARDOUR::ExportSpecification*);
/* slave tracking */
@ -1062,7 +1062,7 @@ class Session : public PBD::StatefulDestructible
void set_slave_source (SlaveSource);
bool _exporting;
int prepare_to_export (ARDOUR::AudioExportSpecification&);
int prepare_to_export (ARDOUR::ExportSpecification&);
void prepare_diskstreams ();
void commit_diskstreams (nframes_t, bool& session_requires_butler);

View file

@ -119,7 +119,7 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel)
/* zero fill buffer if necessary */
if (to_read != bufsize) {
memset (data + to_read, 0, (bufsize - to_read));
memset (data + to_read, 0, (bufsize - to_read) * sizeof (Sample));
}
features = plugin->process (bufs, RealTime::fromSeconds ((double) pos / sample_rate));
@ -128,7 +128,7 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel)
goto out;
}
pos += stepsize;
pos += min (stepsize, to_read);
if (pos >= len) {
done = true;

View file

@ -1022,7 +1022,7 @@ AudioRegion::read_raw_internal (Sample* buf, nframes_t pos, nframes_t cnt) const
int
AudioRegion::exportme (Session& session, AudioExportSpecification& spec)
AudioRegion::exportme (Session& session, ARDOUR::ExportSpecification& spec)
{
const nframes_t blocksize = 4096;
nframes_t to_read;

View file

@ -310,6 +310,12 @@ MidiRegion::separate_by_channel (Session& session, vector<MidiRegion*>& v) const
return -1;
}
int
MidiRegion::exportme (ARDOUR::Session&, ARDOUR::ExportSpecification&)
{
return -1;
}
boost::shared_ptr<MidiSource>
MidiRegion::midi_source (uint32_t n) const
{

View file

@ -57,7 +57,7 @@ using namespace ARDOUR;
using namespace PBD;
static int
convert_spec_to_info (AudioExportSpecification& spec, SF_INFO& sfinfo)
convert_spec_to_info (ExportSpecification& spec, SF_INFO& sfinfo)
{
if (spec.path.length() == 0) {
error << _("Export: no output file specified") << endmsg;
@ -76,18 +76,18 @@ convert_spec_to_info (AudioExportSpecification& spec, SF_INFO& sfinfo)
return 0;
}
AudioExportSpecification::AudioExportSpecification ()
ExportSpecification::ExportSpecification ()
{
init ();
}
AudioExportSpecification::~AudioExportSpecification ()
ExportSpecification::~ExportSpecification ()
{
clear ();
}
void
AudioExportSpecification::init ()
ExportSpecification::init ()
{
src_state = 0;
pos = 0;
@ -113,7 +113,7 @@ AudioExportSpecification::init ()
}
void
AudioExportSpecification::clear ()
ExportSpecification::clear ()
{
if (out) {
sf_close (out);
@ -153,7 +153,7 @@ AudioExportSpecification::clear ()
}
int
AudioExportSpecification::prepare (nframes_t blocksize, nframes_t frate)
ExportSpecification::prepare (nframes_t blocksize, nframes_t frate)
{
char errbuf[256];
GDitherSize dither_size;
@ -161,7 +161,7 @@ AudioExportSpecification::prepare (nframes_t blocksize, nframes_t frate)
frame_rate = frate;
if (channels == 0) {
error << _("illegal frame range in export specification") << endmsg;
error << _("illegal channel count in export specification") << endmsg;
return -1;
}
@ -258,7 +258,7 @@ AudioExportSpecification::prepare (nframes_t blocksize, nframes_t frate)
}
int
AudioExportSpecification::process (nframes_t nframes)
ExportSpecification::process (nframes_t nframes)
{
float* float_buffer = 0;
uint32_t chn;
@ -426,7 +426,7 @@ AudioExportSpecification::process (nframes_t nframes)
}
int
Session::start_audio_export (AudioExportSpecification& spec)
Session::start_export (ExportSpecification& spec)
{
if (!_engine.connected()) {
return -1;
@ -448,7 +448,7 @@ Session::start_audio_export (AudioExportSpecification& spec)
}
int
Session::stop_audio_export (AudioExportSpecification& spec)
Session::stop_export (ExportSpecification& spec)
{
/* don't stop freewheeling but do stop paying attention to it for now */
@ -459,7 +459,7 @@ Session::stop_audio_export (AudioExportSpecification& spec)
}
int
Session::prepare_to_export (AudioExportSpecification& spec)
Session::prepare_to_export (ExportSpecification& spec)
{
int ret = -1;
@ -521,7 +521,7 @@ Session::prepare_to_export (AudioExportSpecification& spec)
}
int
Session::process_export (nframes_t nframes, AudioExportSpecification* spec)
Session::process_export (nframes_t nframes, ExportSpecification* spec)
{
uint32_t chn;
uint32_t x;
@ -551,7 +551,7 @@ Session::process_export (nframes_t nframes, AudioExportSpecification* spec)
if (!spec->running || spec->stop || (this_nframes = min ((spec->end_frame - spec->pos), nframes)) == 0) {
process_without_events (nframes);
return stop_audio_export (*spec);
return stop_export (*spec);
}
/* make sure we've caught up with disk i/o, since
@ -574,7 +574,7 @@ Session::process_export (nframes_t nframes, AudioExportSpecification* spec)
for (chn = 0; chn < spec->channels; ++chn) {
AudioExportPortMap::iterator mi = spec->port_map.find (chn);
ExportPortMap::iterator mi = spec->port_map.find (chn);
if (mi == spec->port_map.end()) {
/* no ports exported to this channel */
@ -588,17 +588,18 @@ Session::process_export (nframes_t nframes, AudioExportSpecification* spec)
/* OK, this port's output is supposed to appear on this channel
*/
AudioPort* const port = dynamic_cast<AudioPort*>((*t).first);
if (port == 0) {
cerr << "FIXME: Non-audio export" << endl;
continue;
}
Sample* port_buffer = port->get_audio_buffer().data();
AudioPort* const aport = dynamic_cast<AudioPort*>((*t).first);
MidiPort* const mport = dynamic_cast<MidiPort*>((*t).first);
if (aport != 0) {
Sample* port_buffer = aport->get_audio_buffer().data();
/* now interleave the data from the channel into the float buffer */
for (x = 0; x < nframes; ++x) {
spec->dataF[chn+(x*spec->channels)] += (float) port_buffer[x];
/* now interleave the data from the channel into the float buffer */
for (x = 0; x < nframes; ++x) {
spec->dataF[chn+(x*spec->channels)] += (float) port_buffer[x];
}
} else if (mport != 0) {
cerr << "EXPORT MIDI PORT" << endl;
}
}
}

View file

@ -1141,16 +1141,16 @@ TempoMap::round_to_type (nframes_t frame, int dir, BBTPointType type)
case Bar:
if (dir < 0) {
/* relax */
} else if (dir > 0) {
if (bbt.beats > 0) {
bbt.bars++;
} else if (metric.frame() < frame) {
bbt.bars++;
}
} else {
if (bbt.beats > metric.meter().beats_per_bar()/2) {
bbt.bars++;
}
}
bbt.beats = 1;
bbt.ticks = 0;
@ -1162,6 +1162,8 @@ TempoMap::round_to_type (nframes_t frame, int dir, BBTPointType type)
} else if (dir > 0) {
if (bbt.ticks > 0) {
bbt.beats++;
} else if (metric.frame() < frame) {
bbt.beats++;
}
} else {
if (bbt.ticks >= (Meter::ticks_per_beat/2)) {
@ -1177,11 +1179,9 @@ TempoMap::round_to_type (nframes_t frame, int dir, BBTPointType type)
}
/*
cerr << "for " << frame << " round to " << bbt << " using "
<< metric.start()
<< endl;
*/
cerr << "for " << frame << " round to " << bbt << " using "
<< metric.start()
<< endl;
return metric.frame() + count_frames_between (metric.start(), bbt);
}

View file

@ -54,7 +54,7 @@ TransientDetector::use_features (Plugin::FeatureSet& features, ostream* out)
if (out) {
(*out) << (*f).timestamp.toString() << endl;
}
current_results->push_back (RealTime::realTime2Frame ((*f).timestamp, (nframes_t) floor(sample_rate)));
}
}