From a227872303382ecb2020e4408525f0b25f41e88d Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Tue, 18 Dec 2012 16:19:29 +0000 Subject: fluidsynth and simpledrums search project folder for missing sounds --- muse2/synti/fluidsynth/fluidsynti.cpp | 24 +++++++++++++++--------- muse2/synti/simpledrums2/simpledrums.cpp | 28 ++++++++++++++++++---------- muse2/synti/simpledrums2/simpledrumsgui.cpp | 4 ++-- 3 files changed, 35 insertions(+), 21 deletions(-) (limited to 'muse2/synti') diff --git a/muse2/synti/fluidsynth/fluidsynti.cpp b/muse2/synti/fluidsynth/fluidsynti.cpp index d3561fb9..eddedc87 100644 --- a/muse2/synti/fluidsynth/fluidsynti.cpp +++ b/muse2/synti/fluidsynth/fluidsynti.cpp @@ -616,15 +616,21 @@ bool FluidSynth::pushSoundfont (const char* filename, int extid) else { - // TODO: Strings should be translated, this does - // however require the class to be derived from qobject - // tried in vain to make the call in the gui object - // could'nt get it to work due to symbol missing in .so ... - QString newName = QFileDialog::getOpenFileName(0, - QString("Can't find soundfont: %1 - Choose soundfont").arg(filename), - filename, - QString("Soundfonts (*.sf2);;All files (*)")); - helper->filename = newName.toStdString(); + //printf("current path: %s \nmuseProject %s\nfilename %s\n",QDir::currentPath().toLatin1().data(), MusEGlobal::museProject.toLatin1().data(), filename); + QFileInfo fi(filename); + if (QFile::exists(fi.fileName())) + helper->filename = QDir::currentPath().toStdString() + "/" + fi.fileName().toStdString(); + else { + // TODO: Strings should be translated, this does + // however require the class to be derived from qobject + // tried in vain to make the call in the gui object + // could'nt get it to work due to symbol missing in .so ... + QString newName = QFileDialog::getOpenFileName(0, + QString("Can't find soundfont: %1 - Choose soundfont").arg(filename), + filename, + QString("Soundfonts (*.sf2);;All files (*)")); + helper->filename = newName.toStdString(); + } } if (pthread_create(&fontThread, attributes, ::fontLoadThread, (void*) helper)) diff --git a/muse2/synti/simpledrums2/simpledrums.cpp b/muse2/synti/simpledrums2/simpledrums.cpp index d62c5374..a723c133 100644 --- a/muse2/synti/simpledrums2/simpledrums.cpp +++ b/muse2/synti/simpledrums2/simpledrums.cpp @@ -29,6 +29,7 @@ #include "muse/mpevent.h" //#include "common_defs.h" #include "simpledrums.h" +#include "globals.h" #include #include @@ -1345,16 +1346,23 @@ bool SimpleSynth::loadSample(int chno, const char* filename) } else { - - // TODO: Strings should be translated, this does - // however require the class to be derived from qobject - // tried in vain to make the call in the gui object - // could'nt get it to work due to symbol missing in .so ... - QString newName = QFileDialog::getOpenFileName(0, - QString("Can't find sample: %1 - Choose sample").arg(filename), - filename, - QString("Samples *.wav *.ogg *.flac (*.wav *.WAV *.ogg *.flac);;All files (*)")); - loader->filename = newName.toStdString(); + //printf("current path: %s \nmuseProject %s\nfilename %s\n",QDir::currentPath().toLatin1().data(), MusEGlobal::museProject.toLatin1().data(), filename); + //MusEGlobal::museProject + QFileInfo fi(filename); + if (QFile::exists(fi.fileName())) + loader->filename = QDir::currentPath().toStdString() + "/" + fi.fileName().toStdString(); + else { + + // TODO: Strings should be translated, this does + // however require the class to be derived from qobject + // tried in vain to make the call in the gui object + // could'nt get it to work due to symbol missing in .so ... + QString newName = QFileDialog::getOpenFileName(0, + QString("Can't find sample: %1 - Choose sample").arg(filename), + filename, + QString("Samples *.wav *.ogg *.flac (*.wav *.WAV *.ogg *.flac);;All files (*)")); + loader->filename = newName.toStdString(); + } } diff --git a/muse2/synti/simpledrums2/simpledrumsgui.cpp b/muse2/synti/simpledrums2/simpledrumsgui.cpp index b68a441e..640ea3b6 100644 --- a/muse2/synti/simpledrums2/simpledrumsgui.cpp +++ b/muse2/synti/simpledrums2/simpledrumsgui.cpp @@ -805,9 +805,9 @@ void SimpleSynthGui::loadSampleDialogue(int channel) { QString filename = QFileDialog::getOpenFileName( - this, + this, tr("Load sample dialog"), - lastDir, + lastDir, QString("Samples *.wav *.ogg *.flac (*.wav *.WAV *.ogg *.flac);;All files (*)")); if (filename != QString::null) { -- cgit v1.2.3