mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-21 06:06:25 +01:00
Back-port tim mayberry's fixes for import; fix JACK slaving to never pay attention to timecode-source-is-synced
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2824 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
9a45f09e15
commit
0e488bf060
8 changed files with 273 additions and 227 deletions
|
|
@ -21,26 +21,39 @@
|
||||||
#define __ardour_importable_source_h__
|
#define __ardour_importable_source_h__
|
||||||
|
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
|
#include <pbd/failed_constructor.h>
|
||||||
#include <ardour/types.h>
|
#include <ardour/types.h>
|
||||||
|
|
||||||
namespace ARDOUR {
|
namespace ARDOUR {
|
||||||
|
|
||||||
class ImportableSource {
|
class ImportableSource {
|
||||||
public:
|
public:
|
||||||
ImportableSource (SNDFILE* sf, SF_INFO* info) : in (sf), sf_info (info) {}
|
ImportableSource (const std::string& path)
|
||||||
virtual ~ImportableSource() {}
|
: in (sf_open (path.c_str(), SFM_READ, &sf_info), sf_close)
|
||||||
|
{
|
||||||
|
if (!in) throw failed_constructor();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~ImportableSource() {}
|
||||||
|
|
||||||
virtual nframes_t read (Sample* buffer, nframes_t nframes) {
|
virtual nframes_t read (Sample* buffer, nframes_t nframes) {
|
||||||
nframes_t per_channel = nframes / sf_info->channels;
|
nframes_t per_channel = nframes / sf_info.channels;
|
||||||
per_channel = sf_readf_float (in, buffer, per_channel);
|
per_channel = sf_readf_float (in.get(), buffer, per_channel);
|
||||||
return per_channel * sf_info->channels;
|
return per_channel * sf_info.channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float ratio() const { return 1.0f; }
|
virtual float ratio() const { return 1.0f; }
|
||||||
|
|
||||||
|
uint channels() const { return sf_info.channels; }
|
||||||
|
|
||||||
|
nframes_t length() const { return sf_info.frames; }
|
||||||
|
|
||||||
|
nframes_t samplerate() const { return sf_info.samplerate; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SNDFILE* in;
|
SF_INFO sf_info;
|
||||||
SF_INFO* sf_info;
|
boost::shared_ptr<SNDFILE> in;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,9 @@ namespace ARDOUR {
|
||||||
class ResampledImportableSource : public ImportableSource
|
class ResampledImportableSource : public ImportableSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ResampledImportableSource (SNDFILE* sf, SF_INFO* info, nframes_t rate, SrcQuality);
|
ResampledImportableSource (const std::string& path,
|
||||||
|
nframes_t rate, SrcQuality);
|
||||||
|
|
||||||
~ResampledImportableSource ();
|
~ResampledImportableSource ();
|
||||||
|
|
||||||
nframes_t read (Sample* buffer, nframes_t nframes);
|
nframes_t read (Sample* buffer, nframes_t nframes);
|
||||||
|
|
|
||||||
|
|
@ -578,7 +578,7 @@ class Session : public PBD::StatefulDestructible
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int import_audiofile (import_status&);
|
void import_audiofiles (import_status&);
|
||||||
bool sample_rate_convert (import_status&, string infile, string& outfile);
|
bool sample_rate_convert (import_status&, string infile, string& outfile);
|
||||||
string build_tmp_convert_name (string file);
|
string build_tmp_convert_name (string file);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ class Slave {
|
||||||
virtual bool starting() const { return false; }
|
virtual bool starting() const { return false; }
|
||||||
virtual nframes_t resolution() const = 0;
|
virtual nframes_t resolution() const = 0;
|
||||||
virtual bool requires_seekahead () const = 0;
|
virtual bool requires_seekahead () const = 0;
|
||||||
|
virtual bool is_always_synced() const { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -139,6 +140,7 @@ class JACK_Slave : public Slave
|
||||||
nframes_t resolution() const { return 1; }
|
nframes_t resolution() const { return 1; }
|
||||||
bool requires_seekahead () const { return false; }
|
bool requires_seekahead () const { return false; }
|
||||||
void reset_client (jack_client_t* jack);
|
void reset_client (jack_client_t* jack);
|
||||||
|
bool is_always_synced() const { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
jack_client_t* jack;
|
jack_client_t* jack;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@
|
||||||
|
|
||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
|
|
||||||
|
#include <boost/scoped_array.hpp>
|
||||||
|
#include <boost/shared_array.hpp>
|
||||||
|
|
||||||
#include <pbd/basename.h>
|
#include <pbd/basename.h>
|
||||||
#include <pbd/convert.h>
|
#include <pbd/convert.h>
|
||||||
|
|
||||||
|
|
@ -49,226 +52,258 @@
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
using namespace PBD;
|
using namespace PBD;
|
||||||
|
|
||||||
int
|
static std::auto_ptr<ImportableSource>
|
||||||
Session::import_audiofile (import_status& status)
|
open_importable_source (const string& path, nframes_t samplerate, ARDOUR::SrcQuality quality)
|
||||||
|
{
|
||||||
|
std::auto_ptr<ImportableSource> source(new ImportableSource(path));
|
||||||
|
|
||||||
|
if (source->samplerate() == samplerate) {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::auto_ptr<ImportableSource>(new ResampledImportableSource(path, samplerate, quality));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string
|
||||||
|
get_non_existent_filename (const std::string& basename, uint channel, uint channels)
|
||||||
{
|
{
|
||||||
SNDFILE *in;
|
|
||||||
vector<boost::shared_ptr<AudioFileSource> > newfiles;
|
|
||||||
SF_INFO info;
|
|
||||||
float *data = 0;
|
|
||||||
Sample **channel_data = 0;
|
|
||||||
int nfiles = 0;
|
|
||||||
string basepath;
|
|
||||||
string sounds_dir;
|
|
||||||
nframes_t so_far;
|
|
||||||
char buf[PATH_MAX+1];
|
char buf[PATH_MAX+1];
|
||||||
int ret = -1;
|
bool goodfile = false;
|
||||||
|
string base(basename);
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (channels == 2) {
|
||||||
|
if (channel == 0) {
|
||||||
|
snprintf (buf, sizeof(buf), "%s-L.wav", base.c_str());
|
||||||
|
} else {
|
||||||
|
snprintf (buf, sizeof(buf), "%s-R.wav", base.c_str());
|
||||||
|
}
|
||||||
|
} else if (channels > 1) {
|
||||||
|
snprintf (buf, sizeof(buf), "%s-c%d.wav", base.c_str(), channel+1);
|
||||||
|
} else {
|
||||||
|
snprintf (buf, sizeof(buf), "%s.wav", base.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Glib::file_test (buf, Glib::FILE_TEST_EXISTS)) {
|
||||||
|
|
||||||
|
/* if the file already exists, we must come up with
|
||||||
|
* a new name for it. for now we just keep appending
|
||||||
|
* _ to basename
|
||||||
|
*/
|
||||||
|
|
||||||
|
base += "_";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
goodfile = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while ( !goodfile);
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static vector<string>
|
||||||
|
get_paths_for_new_sources (const string& import_file_path, const string& session_dir, uint channels)
|
||||||
|
{
|
||||||
vector<string> new_paths;
|
vector<string> new_paths;
|
||||||
struct tm* now;
|
const string basename = basename_nosuffix (import_file_path);
|
||||||
ImportableSource* importable = 0;
|
|
||||||
|
for (uint n = 0; n < channels; ++n) {
|
||||||
|
|
||||||
|
std::string filepath;
|
||||||
|
|
||||||
|
filepath = session_dir;
|
||||||
|
filepath += '/';
|
||||||
|
filepath += get_non_existent_filename (basename, n, channels);
|
||||||
|
|
||||||
|
new_paths.push_back (filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
create_mono_sources_for_writing (const vector<string>& new_paths, Session& sess,
|
||||||
|
uint samplerate, vector<boost::shared_ptr<AudioFileSource> >& newfiles)
|
||||||
|
{
|
||||||
|
for (vector<string>::const_iterator i = new_paths.begin();
|
||||||
|
i != new_paths.end(); ++i)
|
||||||
|
{
|
||||||
|
boost::shared_ptr<Source> source;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
source = SourceFactory::createWritable (
|
||||||
|
sess,
|
||||||
|
i->c_str(),
|
||||||
|
false, // destructive
|
||||||
|
samplerate
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (const failed_constructor& err)
|
||||||
|
{
|
||||||
|
error << string_compose (_("Unable to create file %1 during import"), *i) << endmsg;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
newfiles.push_back(boost::dynamic_pointer_cast<AudioFileSource>(source));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Glib::ustring
|
||||||
|
compose_status_message (const string& path,
|
||||||
|
uint file_samplerate,
|
||||||
|
uint session_samplerate,
|
||||||
|
uint current_file,
|
||||||
|
uint total_files)
|
||||||
|
{
|
||||||
|
if (file_samplerate != session_samplerate) {
|
||||||
|
return string_compose (_("converting %1\n(resample from %2KHz to %3KHz)\n(%4 of %5)"),
|
||||||
|
Glib::path_get_basename (path),
|
||||||
|
file_samplerate/1000.0f,
|
||||||
|
session_samplerate/1000.0f,
|
||||||
|
current_file, total_files);
|
||||||
|
}
|
||||||
|
|
||||||
|
return string_compose (_("converting %1\n(%2 of %3)"),
|
||||||
|
Glib::path_get_basename (path),
|
||||||
|
current_file, total_files);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
write_audio_data_to_new_files (ImportableSource* source, Session::import_status& status,
|
||||||
|
vector<boost::shared_ptr<AudioFileSource> >& newfiles)
|
||||||
|
{
|
||||||
const nframes_t nframes = ResampledImportableSource::blocksize;
|
const nframes_t nframes = ResampledImportableSource::blocksize;
|
||||||
|
uint channels = source->channels();
|
||||||
|
|
||||||
|
boost::scoped_array<float> data(new float[nframes * channels]);
|
||||||
|
vector<boost::shared_array<Sample> > channel_data;
|
||||||
|
|
||||||
|
for (uint n = 0; n < channels; ++n) {
|
||||||
|
channel_data.push_back(boost::shared_array<Sample>(new Sample[nframes]));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint read_count = 0;
|
||||||
|
status.progress = 0.0f;
|
||||||
|
|
||||||
|
while (!status.cancel) {
|
||||||
|
|
||||||
|
nframes_t nread, nfread;
|
||||||
|
uint x;
|
||||||
|
uint chn;
|
||||||
|
|
||||||
|
if ((nread = source->read (data.get(), nframes)) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nfread = nread / channels;
|
||||||
|
|
||||||
|
/* de-interleave */
|
||||||
|
|
||||||
|
for (chn = 0; chn < channels; ++chn) {
|
||||||
|
|
||||||
|
nframes_t n;
|
||||||
|
for (x = chn, n = 0; n < nfread; x += channels, ++n) {
|
||||||
|
channel_data[chn][n] = (Sample) data[x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* flush to disk */
|
||||||
|
|
||||||
|
for (chn = 0; chn < channels; ++chn) {
|
||||||
|
newfiles[chn]->write (channel_data[chn].get(), nfread);
|
||||||
|
}
|
||||||
|
|
||||||
|
read_count += nread;
|
||||||
|
status.progress = read_count / (source->ratio () * source->length() * channels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_file_source (boost::shared_ptr<AudioFileSource> file_source)
|
||||||
|
{
|
||||||
|
::unlink (file_source->path().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Session::import_audiofiles (import_status& status)
|
||||||
|
{
|
||||||
uint32_t cnt = 1;
|
uint32_t cnt = 1;
|
||||||
|
typedef vector<boost::shared_ptr<AudioFileSource> > AudioSources;
|
||||||
|
AudioSources all_new_sources;
|
||||||
|
|
||||||
status.sources.clear ();
|
status.sources.clear ();
|
||||||
|
|
||||||
for (vector<Glib::ustring>::iterator p = status.paths.begin(); p != status.paths.end(); ++p, ++cnt) {
|
for (vector<Glib::ustring>::iterator p = status.paths.begin();
|
||||||
|
p != status.paths.end() && !status.cancel;
|
||||||
|
++p, ++cnt)
|
||||||
|
{
|
||||||
|
std::auto_ptr<ImportableSource> source;
|
||||||
|
|
||||||
if ((in = sf_open ((*p).c_str(), SFM_READ, &info)) == 0) {
|
try
|
||||||
|
{
|
||||||
|
source = open_importable_source (*p, frame_rate(), status.quality);
|
||||||
|
}
|
||||||
|
catch (const failed_constructor& err)
|
||||||
|
{
|
||||||
error << string_compose(_("Import: cannot open input sound file \"%1\""), (*p)) << endmsg;
|
error << string_compose(_("Import: cannot open input sound file \"%1\""), (*p)) << endmsg;
|
||||||
status.done = 1;
|
status.done = status.cancel = true;
|
||||||
status.cancel = 1;
|
return;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<string> new_paths = get_paths_for_new_sources (*p,
|
||||||
|
discover_best_sound_dir (),
|
||||||
|
source->channels());
|
||||||
|
|
||||||
if ((nframes_t) info.samplerate != frame_rate()) {
|
AudioSources newfiles;
|
||||||
importable = new ResampledImportableSource (in, &info, frame_rate(), status.quality);
|
|
||||||
} else {
|
|
||||||
importable = new ImportableSource (in, &info);
|
|
||||||
}
|
|
||||||
|
|
||||||
newfiles.clear ();
|
|
||||||
|
|
||||||
for (int n = 0; n < info.channels; ++n) {
|
status.cancel = !create_mono_sources_for_writing (new_paths, *this, frame_rate(), newfiles);
|
||||||
newfiles.push_back (boost::shared_ptr<AudioFileSource>());
|
|
||||||
}
|
|
||||||
|
|
||||||
sounds_dir = discover_best_sound_dir ();
|
|
||||||
basepath = PBD::basename_nosuffix ((*p));
|
|
||||||
|
|
||||||
for (int n = 0; n < info.channels; ++n) {
|
|
||||||
|
|
||||||
bool goodfile = false;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (info.channels == 2) {
|
|
||||||
if (n == 0) {
|
|
||||||
snprintf (buf, sizeof(buf), "%s/%s-L.wav", sounds_dir.c_str(), basepath.c_str());
|
|
||||||
} else {
|
|
||||||
snprintf (buf, sizeof(buf), "%s/%s-R.wav", sounds_dir.c_str(), basepath.c_str());
|
|
||||||
}
|
|
||||||
} else if (info.channels > 1) {
|
|
||||||
snprintf (buf, sizeof(buf), "%s/%s-c%d.wav", sounds_dir.c_str(), basepath.c_str(), n+1);
|
|
||||||
} else {
|
|
||||||
snprintf (buf, sizeof(buf), "%s/%s.wav", sounds_dir.c_str(), basepath.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Glib::file_test (buf, Glib::FILE_TEST_EXISTS)) {
|
// copy on cancel/failure so that any files that were created will be removed below
|
||||||
|
std::copy (newfiles.begin(), newfiles.end(), std::back_inserter(all_new_sources));
|
||||||
|
|
||||||
/* if the file already exists, we must come up with
|
if (status.cancel) break;
|
||||||
* a new name for it. for now we just keep appending
|
|
||||||
* _ to basepath
|
|
||||||
*/
|
|
||||||
|
|
||||||
basepath += "_";
|
|
||||||
|
|
||||||
} else {
|
for (AudioSources::iterator i = newfiles.begin(); i != newfiles.end(); ++i) {
|
||||||
|
(*i)->prepare_for_peakfile_writes ();
|
||||||
goodfile = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while ( !goodfile);
|
|
||||||
|
|
||||||
try {
|
|
||||||
newfiles[n] = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createWritable (*this, buf, false, frame_rate()));
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (failed_constructor& err) {
|
|
||||||
error << string_compose(_("Session::import_audiofile: cannot open new file source for channel %1"), n+1) << endmsg;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_paths.push_back (buf);
|
|
||||||
newfiles[n]->prepare_for_peakfile_writes ();
|
|
||||||
nfiles++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
delete [] data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data = new float[nframes * info.channels];
|
status.doing_what = compose_status_message (*p, source->samplerate(),
|
||||||
|
frame_rate(), cnt, status.paths.size());
|
||||||
|
|
||||||
if (channel_data) {
|
write_audio_data_to_new_files (source.get(), status, newfiles);
|
||||||
delete [] channel_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
channel_data = new Sample * [ info.channels ];
|
|
||||||
|
|
||||||
for (int n = 0; n < info.channels; ++n) {
|
|
||||||
channel_data[n] = new Sample[nframes];
|
|
||||||
}
|
|
||||||
|
|
||||||
so_far = 0;
|
|
||||||
|
|
||||||
if ((nframes_t) info.samplerate != frame_rate()) {
|
|
||||||
status.doing_what = string_compose (_("converting %1\n(resample from %2KHz to %3KHz)\n(%4 of %5)"),
|
|
||||||
basepath,
|
|
||||||
info.samplerate/1000.0f,
|
|
||||||
frame_rate()/1000.0f,
|
|
||||||
cnt, status.paths.size());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
status.doing_what = string_compose (_("converting %1\n(%2 of %3)"),
|
|
||||||
basepath,
|
|
||||||
cnt, status.paths.size());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
status.progress = 0.0;
|
|
||||||
|
|
||||||
while (!status.cancel) {
|
|
||||||
|
|
||||||
nframes_t nread, nfread;
|
|
||||||
long x;
|
|
||||||
long chn;
|
|
||||||
|
|
||||||
if ((nread = importable->read (data, nframes)) == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
nfread = nread / info.channels;
|
|
||||||
|
|
||||||
/* de-interleave */
|
|
||||||
|
|
||||||
for (chn = 0; chn < info.channels; ++chn) {
|
|
||||||
|
|
||||||
nframes_t n;
|
|
||||||
for (x = chn, n = 0; n < nfread; x += info.channels, ++n) {
|
|
||||||
channel_data[chn][n] = (Sample) data[x];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush to disk */
|
|
||||||
|
|
||||||
for (chn = 0; chn < info.channels; ++chn) {
|
|
||||||
newfiles[chn]->write (channel_data[chn], nfread);
|
|
||||||
}
|
|
||||||
|
|
||||||
so_far += nread;
|
|
||||||
status.progress = so_far / (importable->ratio () * info.frames * info.channels);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status.cancel) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int n = 0; n < info.channels; ++n) {
|
|
||||||
status.sources.push_back (newfiles[n]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status.cancel) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status.freeze = true;
|
|
||||||
|
|
||||||
time_t xnow;
|
|
||||||
time (&xnow);
|
|
||||||
now = localtime (&xnow);
|
|
||||||
|
|
||||||
/* flush the final length(s) to the header(s) */
|
|
||||||
|
|
||||||
for (SourceList::iterator x = status.sources.begin(); x != status.sources.end() && !status.cancel; ++x) {
|
|
||||||
boost::dynamic_pointer_cast<AudioFileSource>(*x)->update_header(0, *now, xnow);
|
|
||||||
boost::dynamic_pointer_cast<AudioSource>(*x)->done_with_peakfile_writes ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* save state so that we don't lose these new Sources */
|
|
||||||
|
|
||||||
if (!status.cancel) {
|
if (!status.cancel) {
|
||||||
|
struct tm* now;
|
||||||
|
time_t xnow;
|
||||||
|
time (&xnow);
|
||||||
|
now = localtime (&xnow);
|
||||||
|
status.freeze = true;
|
||||||
|
|
||||||
|
/* flush the final length(s) to the header(s) */
|
||||||
|
|
||||||
|
for (AudioSources::iterator x = all_new_sources.begin();
|
||||||
|
x != all_new_sources.end(); ++x)
|
||||||
|
{
|
||||||
|
(*x)->update_header(0, *now, xnow);
|
||||||
|
(*x)->done_with_peakfile_writes ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* save state so that we don't lose these new Sources */
|
||||||
|
|
||||||
save_state (_name);
|
save_state (_name);
|
||||||
|
|
||||||
|
std::copy (all_new_sources.begin(), all_new_sources.end(),
|
||||||
|
std::back_inserter(status.sources));
|
||||||
|
} else {
|
||||||
|
// this can throw...but it seems very unlikely
|
||||||
|
std::for_each (all_new_sources.begin(), all_new_sources.end(), remove_file_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
out:
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
delete [] data;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channel_data) {
|
|
||||||
for (int n = 0; n < info.channels; ++n) {
|
|
||||||
delete [] channel_data[n];
|
|
||||||
}
|
|
||||||
delete [] channel_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status.cancel) {
|
|
||||||
|
|
||||||
status.sources.clear ();
|
|
||||||
|
|
||||||
for (vector<string>::iterator i = new_paths.begin(); i != new_paths.end(); ++i) {
|
|
||||||
unlink ((*i).c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (importable) {
|
|
||||||
delete importable;
|
|
||||||
}
|
|
||||||
|
|
||||||
sf_close (in);
|
|
||||||
status.done = true;
|
status.done = true;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,13 @@ using namespace PBD;
|
||||||
|
|
||||||
const uint32_t ResampledImportableSource::blocksize = 4096U;
|
const uint32_t ResampledImportableSource::blocksize = 4096U;
|
||||||
|
|
||||||
ResampledImportableSource::ResampledImportableSource (SNDFILE* sf, SF_INFO* info, nframes_t rate, SrcQuality srcq)
|
ResampledImportableSource::ResampledImportableSource (const std::string& path,
|
||||||
: ImportableSource (sf, info)
|
nframes_t rate, SrcQuality srcq)
|
||||||
|
: ImportableSource (path)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
sf_seek (in, 0, SEEK_SET) ;
|
sf_seek (in.get(), 0, SEEK_SET) ;
|
||||||
|
|
||||||
/* Initialize the sample rate converter. */
|
/* Initialize the sample rate converter. */
|
||||||
|
|
||||||
|
|
@ -57,7 +58,7 @@ ResampledImportableSource::ResampledImportableSource (SNDFILE* sf, SF_INFO* info
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((src_state = src_new (src_type, sf_info->channels, &err)) == 0) {
|
if ((src_state = src_new (src_type, sf_info.channels, &err)) == 0) {
|
||||||
error << string_compose(_("Import: src_new() failed : %1"), src_strerror (err)) << endmsg ;
|
error << string_compose(_("Import: src_new() failed : %1"), src_strerror (err)) << endmsg ;
|
||||||
throw failed_constructor ();
|
throw failed_constructor ();
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +70,7 @@ ResampledImportableSource::ResampledImportableSource (SNDFILE* sf, SF_INFO* info
|
||||||
src_data.input_frames = 0 ;
|
src_data.input_frames = 0 ;
|
||||||
src_data.data_in = input ;
|
src_data.data_in = input ;
|
||||||
|
|
||||||
src_data.src_ratio = ((float) rate) / sf_info->samplerate ;
|
src_data.src_ratio = ((float) rate) / sf_info.samplerate ;
|
||||||
|
|
||||||
input = new float[blocksize];
|
input = new float[blocksize];
|
||||||
}
|
}
|
||||||
|
|
@ -97,14 +98,14 @@ ResampledImportableSource::read (Sample* output, nframes_t nframes)
|
||||||
src_data.end_of_input = SF_TRUE ;
|
src_data.end_of_input = SF_TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
src_data.input_frames /= sf_info->channels;
|
src_data.input_frames /= sf_info.channels;
|
||||||
src_data.data_in = input ;
|
src_data.data_in = input ;
|
||||||
}
|
}
|
||||||
|
|
||||||
src_data.data_out = output;
|
src_data.data_out = output;
|
||||||
|
|
||||||
if (!src_data.end_of_input) {
|
if (!src_data.end_of_input) {
|
||||||
src_data.output_frames = nframes / sf_info->channels ;
|
src_data.output_frames = nframes / sf_info.channels ;
|
||||||
} else {
|
} else {
|
||||||
src_data.output_frames = src_data.input_frames;
|
src_data.output_frames = src_data.input_frames;
|
||||||
}
|
}
|
||||||
|
|
@ -120,9 +121,9 @@ ResampledImportableSource::read (Sample* output, nframes_t nframes)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
src_data.data_in += src_data.input_frames_used * sf_info->channels ;
|
src_data.data_in += src_data.input_frames_used * sf_info.channels ;
|
||||||
src_data.input_frames -= src_data.input_frames_used ;
|
src_data.input_frames -= src_data.input_frames_used ;
|
||||||
|
|
||||||
return src_data.output_frames_gen * sf_info->channels;
|
return src_data.output_frames_gen * sf_info.channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -477,7 +477,7 @@ Session::follow_slave (nframes_t nframes, nframes_t offset)
|
||||||
<< endl;
|
<< endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Config->get_timecode_source_is_synced()) {
|
if (_slave->is_always_synced() || Config->get_timecode_source_is_synced()) {
|
||||||
|
|
||||||
/* if the TC source is synced, then we assume that its
|
/* if the TC source is synced, then we assume that its
|
||||||
speed is binary: 0.0 or 1.0
|
speed is binary: 0.0 or 1.0
|
||||||
|
|
@ -626,7 +626,7 @@ Session::follow_slave (nframes_t nframes, nframes_t offset)
|
||||||
slave_state = Stopped;
|
slave_state = Stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slave_state == Running && !Config->get_timecode_source_is_synced()) {
|
if (slave_state == Running && !_slave->is_always_synced() && !Config->get_timecode_source_is_synced()) {
|
||||||
|
|
||||||
|
|
||||||
if (_transport_speed != 0.0f) {
|
if (_transport_speed != 0.0f) {
|
||||||
|
|
|
||||||
|
|
@ -76,10 +76,6 @@ Session::request_slave_source (SlaveSource src)
|
||||||
void
|
void
|
||||||
Session::request_transport_speed (float speed)
|
Session::request_transport_speed (float speed)
|
||||||
{
|
{
|
||||||
if (speed != 0.0 && speed != 1.0) {
|
|
||||||
cerr << "odd speed requested\n";
|
|
||||||
stacktrace (cerr, 20);
|
|
||||||
}
|
|
||||||
Event* ev = new Event (Event::SetTransportSpeed, Event::Add, Event::Immediate, 0, speed);
|
Event* ev = new Event (Event::SetTransportSpeed, Event::Add, Event::Immediate, 0, speed);
|
||||||
queue_event (ev);
|
queue_event (ev);
|
||||||
}
|
}
|
||||||
|
|
@ -756,8 +752,6 @@ Session::locate (nframes_t target_frame, bool with_roll, bool with_flush, bool w
|
||||||
void
|
void
|
||||||
Session::set_transport_speed (float speed, bool abort)
|
Session::set_transport_speed (float speed, bool abort)
|
||||||
{
|
{
|
||||||
cerr << "Session::set_transport_speed " << speed << " abort capture ? " << abort << endl;
|
|
||||||
|
|
||||||
if (_transport_speed == speed) {
|
if (_transport_speed == speed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -819,7 +813,6 @@ Session::set_transport_speed (float speed, bool abort)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((synced_to_jack()) && speed != 0.0 && speed != 1.0) {
|
if ((synced_to_jack()) && speed != 0.0 && speed != 1.0) {
|
||||||
cerr << "synced to jack and speed == " << speed << endl;
|
|
||||||
warning << _("Global varispeed cannot be supported while Ardour is connected to JACK transport control")
|
warning << _("Global varispeed cannot be supported while Ardour is connected to JACK transport control")
|
||||||
<< endmsg;
|
<< endmsg;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue