summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-03-21 19:47:34 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2017-03-21 19:54:26 +0100
commitb5ed4063e7370f2472f77d8c59d645a156698980 (patch)
tree83eb2cb750cf2094433d8d76566088a66b4d665f
parent5f6e1171536490ed451226ace2ca83b3b77afaf1 (diff)
Store input samplerate and use that for the output files instead of hardcoded 44k1Hz.
-rw-r--r--src/audioextractor.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/audioextractor.cc b/src/audioextractor.cc
index 71e0b2a..c249949 100644
--- a/src/audioextractor.cc
+++ b/src/audioextractor.cc
@@ -47,6 +47,7 @@ AudioExtractor::AudioExtractor(Selections &s, QObject *parent)
void AudioExtractor::exportSelections()
{
+ int samplerate = -1;
emit setMaximumProgress(selections.ids().size() + 1/* for xml writing*/);
int progress = 0;
emit progressUpdate(progress++);
@@ -67,6 +68,11 @@ void AudioExtractor::exportSelections()
return;
}
+ if(samplerate == -1) {
+ // Store the first samplerate we meet
+ samplerate = sf_info.samplerate;
+ }
+
audiodata[idx].data = NULL;
j++;
@@ -91,6 +97,11 @@ void AudioExtractor::exportSelections()
}
}
+ if(samplerate == -1) {
+ // For some reason we never got a samplerate. Set it to 44k1Hz
+ samplerate = 44100;
+ }
+
// Iterate and write audio files
QVector<sel_id_t>::iterator si = sels.begin();
while(si != sels.end()) {
@@ -145,7 +156,7 @@ void AudioExtractor::exportSelections()
SF_INFO sf_info;
sf_info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
- sf_info.samplerate = 44100;
+ sf_info.samplerate = samplerate;
sf_info.channels = audiofiles.size();
SNDFILE *ofh = sf_open(file.toStdString().c_str(), SFM_WRITE, &sf_info);