summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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);