From 725882fcdbc35ce82883e4de0b1eedb0a8922669 Mon Sep 17 00:00:00 2001 From: ws Date: Thu, 18 Apr 2013 16:54:51 +0200 Subject: [PATCH] fix audio export for zerberus; fix progress bar --- mscore/exportaudio.cpp | 5 +++-- zerberus/zerberus.cpp | 14 +++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mscore/exportaudio.cpp b/mscore/exportaudio.cpp index ef25c9342b..a91118eeca 100644 --- a/mscore/exportaudio.cpp +++ b/mscore/exportaudio.cpp @@ -80,10 +80,11 @@ bool MuseScore::saveAudio(Score* score, const QString& name, const QString& ext) EventMap::const_iterator endPos = events.cend(); --endPos; const int et = (score->utick2utime(endPos->first) + 1) * MScore::sampleRate; + pBar->setRange(0, et); + for (int pass = 0; pass < 2; ++pass) { EventMap::const_iterator playPos; playPos = events.cbegin(); - pBar->setRange(0, et); // // init instruments @@ -148,7 +149,7 @@ bool MuseScore::saveAudio(Score* score, const QString& name, const QString& ext) peak = qMax(peak, qAbs(buffer[i])); } playTime = endTime; - pBar->setValue(playTime); + pBar->setValue((pass * et + playTime) / 2); if (playTime >= et) break; diff --git a/zerberus/zerberus.cpp b/zerberus/zerberus.cpp index 6aa08d95bc..e1914e4629 100644 --- a/zerberus/zerberus.cpp +++ b/zerberus/zerberus.cpp @@ -42,6 +42,7 @@ Zerberus::Zerberus() freeVoices.push(new Voice(this)); for (int i = 0; i < MAX_CHANNEL; ++i) _channel[i] = new Channel(this, i); + busy = true; // no sf loaded yet } //--------------------------------------------------------- @@ -50,6 +51,7 @@ Zerberus::Zerberus() Zerberus::~Zerberus() { + busy = true; while (!instruments.empty()) { auto i = instruments.front(); auto it = instruments.begin(); @@ -57,6 +59,7 @@ Zerberus::~Zerberus() i->setRefCount(i->refCount() - 1); if (i->refCount() <= 0) { +printf("delete sf <%s>\n", qPrintable(i->name())); delete i; auto it = find(globalInstruments.begin(), globalInstruments.end(), i); if (it != globalInstruments.end()) @@ -205,8 +208,10 @@ void Zerberus::play(const PlayEvent& event) void Zerberus::process(unsigned frames, float* p, float*, float*) { - if (busy) + if (busy) { + printf("busy\n"); return; + } Voice* v = activeVoices; Voice* pv = 0; while (v) { @@ -336,6 +341,7 @@ bool Zerberus::removeSoundFont(const QString& s) if (it == globalInstruments.end()) return false; globalInstruments.erase(it); +printf("delete sf <%s>\n", qPrintable(i->name())); delete i; } return true; @@ -393,6 +399,7 @@ ZInstrument* Zerberus::instrument(int n) const bool Zerberus::loadInstrument(const QString& s) { + printf("Zerberus::loadInstrument(%s)\n", qPrintable(s)); if (s.isEmpty()) return false; for (ZInstrument* instr : instruments) { @@ -406,6 +413,11 @@ bool Zerberus::loadInstrument(const QString& s) instruments.push_back(instr); instr->setRefCount(instr->refCount() + 1); printf("2: sf already loaded\n"); + if (instruments.size() == 1) { + for (int i = 0; i < MAX_CHANNEL; ++i) + _channel[i]->setInstrument(instr); + } + busy = false; return true; } }