summaryrefslogtreecommitdiff
path: root/libs/ardour/convolver.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-01-31 16:26:41 +0100
committerRobin Gareus <robin@gareus.org>2020-02-06 17:30:21 +0100
commit56c1fa0c901fedcb04d8ed2cacf6f304190a50e3 (patch)
tree58ff81c2e619a88039a8da87520895da60962a0b /libs/ardour/convolver.cc
parent34c4602e61b61f6e7795d02bd64b477c9f26cfd7 (diff)
Break out API to create readables from files
Diffstat (limited to 'libs/ardour/convolver.cc')
-rw-r--r--libs/ardour/convolver.cc35
1 files changed, 5 insertions, 30 deletions
diff --git a/libs/ardour/convolver.cc b/libs/ardour/convolver.cc
index b556c212b3..2b00f0894e 100644
--- a/libs/ardour/convolver.cc
+++ b/libs/ardour/convolver.cc
@@ -24,6 +24,7 @@
#include "ardour/audioengine.h"
#include "ardour/audiofilesource.h"
#include "ardour/convolver.h"
+#include "ardour/readable.h"
#include "ardour/session.h"
#include "ardour/srcfilesource.h"
#include "ardour/source_factory.h"
@@ -48,44 +49,18 @@ Convolver::Convolver (
, _offset (0)
, _configured (false)
{
- ARDOUR::SoundFileInfo sf_info;
- std::string error_msg;
+ _readables = Readable::load (_session, path);
- if (!AudioFileSource::get_soundfile_info (path, sf_info, error_msg)) {
- PBD::error << string_compose(_("Convolver: cannot open IR \"%1\": %2"), path, error_msg) << endmsg;
+ if (_readables.empty ()) {
+ PBD::error << string_compose (_("Convolver: IR \"%1\" no usable audio-channels sound."), path) << endmsg;
throw failed_constructor ();
}
- if (sf_info.length > 0x1000000 /*2^24*/) {
+ if (_readables[0]->readable_length () > 0x1000000 /*2^24*/) {
PBD::error << string_compose(_("Convolver: IR \"%1\" file too long."), path) << endmsg;
throw failed_constructor ();
}
- for (unsigned int n = 0; n < sf_info.channels; ++n) {
- try {
- boost::shared_ptr<AudioFileSource> afs;
- afs = boost::dynamic_pointer_cast<AudioFileSource> (
- SourceFactory::createExternal (DataType::AUDIO, _session,
- path, n,
- Source::Flag (ARDOUR::AudioFileSource::NoPeakFile), false));
-
- if (afs->sample_rate() != _session.nominal_sample_rate()) {
- boost::shared_ptr<SrcFileSource> sfs (new SrcFileSource(_session, afs, ARDOUR::SrcBest));
- _readables.push_back(sfs);
- } else {
- _readables.push_back (afs);
- }
- } catch (failed_constructor& err) {
- PBD::error << string_compose(_("Convolver: Could not open IR \"%1\"."), path) << endmsg;
- throw failed_constructor ();
- }
- }
-
- if (_readables.empty ()) {
- PBD::error << string_compose (_("Convolver: IR \"%1\" no usable audio-channels sound."), path) << endmsg;
- throw failed_constructor ();
- }
-
AudioEngine::instance ()->BufferSizeChanged.connect_same_thread (*this, boost::bind (&Convolver::reconfigure, this));
reconfigure ();