13
0

Fix session-archive of stereo files #9122

Archiving creates a dedicated mono file for each Source.
When the original session has (embedded) stereo files, the
channel needs to be temporarily set to 0.
This commit is contained in:
Robin Gareus 2022-11-28 00:39:58 +01:00
parent 03575011b5
commit 842f4517de
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 7 additions and 0 deletions

View File

@ -63,6 +63,7 @@ public:
float gain() const { return _gain; } float gain() const { return _gain; }
virtual void set_gain (float g, bool temporarily = false) { _gain = g; } virtual void set_gain (float g, bool temporarily = false) { _gain = g; }
virtual void set_channel (uint16_t c) { _channel = c; }
int set_state (const XMLNode&, int version); int set_state (const XMLNode&, int version);

View File

@ -5628,6 +5628,7 @@ Session::archive_session (const std::string& dest,
std::map<boost::shared_ptr<AudioFileSource>, std::string> orig_sources; std::map<boost::shared_ptr<AudioFileSource>, std::string> orig_sources;
std::map<boost::shared_ptr<AudioFileSource>, std::string> orig_origin; std::map<boost::shared_ptr<AudioFileSource>, std::string> orig_origin;
std::map<boost::shared_ptr<AudioFileSource>, float> orig_gain; std::map<boost::shared_ptr<AudioFileSource>, float> orig_gain;
std::map<boost::shared_ptr<AudioFileSource>, uint16_t> orig_channel;
set<boost::shared_ptr<Source> > sources_used_by_this_snapshot; set<boost::shared_ptr<Source> > sources_used_by_this_snapshot;
if (only_used_sources) { if (only_used_sources) {
@ -5746,6 +5747,7 @@ Session::archive_session (const std::string& dest,
orig_sources[afs] = afs->path(); orig_sources[afs] = afs->path();
orig_gain[afs] = afs->gain(); orig_gain[afs] = afs->gain();
orig_channel[afs] = afs->channel();
std::string new_path = make_new_media_path (afs->path (), to_dir, name); std::string new_path = make_new_media_path (afs->path (), to_dir, name);
@ -5773,6 +5775,7 @@ Session::archive_session (const std::string& dest,
SndFileSource* ns = new SndFileSource (*this, *(afs.get()), new_path, compress_audio == FLAC_16BIT, progress); SndFileSource* ns = new SndFileSource (*this, *(afs.get()), new_path, compress_audio == FLAC_16BIT, progress);
afs->replace_file (new_path); afs->replace_file (new_path);
afs->set_gain (ns->gain(), true); afs->set_gain (ns->gain(), true);
afs->set_channel (0);
delete ns; delete ns;
} catch (...) { } catch (...) {
error << "failed to encode " << afs->path() << " to " << new_path << endmsg; error << "failed to encode " << afs->path() << " to " << new_path << endmsg;
@ -5902,6 +5905,9 @@ Session::archive_session (const std::string& dest,
for (std::map<boost::shared_ptr<AudioFileSource>, float>::iterator i = orig_gain.begin (); i != orig_gain.end (); ++i) { for (std::map<boost::shared_ptr<AudioFileSource>, float>::iterator i = orig_gain.begin (); i != orig_gain.end (); ++i) {
i->first->set_gain (i->second, true); i->first->set_gain (i->second, true);
} }
for (std::map<boost::shared_ptr<AudioFileSource>, uint16_t>::iterator i = orig_channel.begin (); i != orig_channel.end (); ++i) {
i->first->set_channel (i->second);
}
int rv = ar.create (filemap, compression_level); int rv = ar.create (filemap, compression_level);
remove_directory (to_dir); remove_directory (to_dir);