BSoftSynth: Select the soundfont from the settings file
This commit is contained in:
+24
-21
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include <MidiRoster.h>
|
#include <MidiRoster.h>
|
||||||
#include <MidiConsumer.h>
|
#include <MidiConsumer.h>
|
||||||
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -25,8 +26,6 @@
|
|||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
const static char* kSynthFileName = "synth/synth.sf2";
|
|
||||||
|
|
||||||
struct ReverbSettings {
|
struct ReverbSettings {
|
||||||
double room, damp, width, level;
|
double room, damp, width, level;
|
||||||
} gReverbSettings[] = {
|
} gReverbSettings[] = {
|
||||||
@@ -101,34 +100,38 @@ BSoftSynth::IsLoaded(void) const
|
|||||||
status_t
|
status_t
|
||||||
BSoftSynth::SetDefaultInstrumentsFile()
|
BSoftSynth::SetDefaultInstrumentsFile()
|
||||||
{
|
{
|
||||||
// We first search for a softsynth file (or symlink to it)
|
// We first search for a setting file (or symlink to it)
|
||||||
// in the user settings directory
|
// in the user settings directory
|
||||||
|
char buffer[512];
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, false, NULL) == B_OK) {
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
|
||||||
path.Append(kSynthFileName);
|
path.Append("midi");
|
||||||
if (BEntry(path.Path()).Exists())
|
BFile file(path.Path(), B_READ_ONLY);
|
||||||
return SetInstrumentsFile(path.Path());
|
if (file.InitCheck() == B_OK
|
||||||
|
&& file.Read(buffer, sizeof(buffer)) > 0) {
|
||||||
|
char soundFont[512];
|
||||||
|
sscanf(buffer, "# Midi Settings\n soundfont = %s\n",
|
||||||
|
soundFont);
|
||||||
|
return SetInstrumentsFile(soundFont);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then in the system settings directory
|
// fall back to the old default
|
||||||
if (find_directory(B_SYSTEM_SETTINGS_DIRECTORY, &path, false, NULL) == B_OK) {
|
|
||||||
path.Append(kSynthFileName);
|
|
||||||
if (BEntry(path.Path()).Exists())
|
|
||||||
return SetInstrumentsFile(path.Path());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (find_directory(B_SYNTH_DIRECTORY, &path, false, NULL) == B_OK) {
|
|
||||||
path.Append(kSynthFileName);
|
|
||||||
if (BEntry(path.Path()).Exists())
|
|
||||||
return SetInstrumentsFile(path.Path());
|
|
||||||
}
|
|
||||||
|
|
||||||
// If no link is present, fall back to the default
|
|
||||||
// softsynth (big_synth.sy)
|
// softsynth (big_synth.sy)
|
||||||
|
// TODO: Remove this
|
||||||
if (find_directory(B_SYNTH_DIRECTORY, &path, false, NULL) == B_OK) {
|
if (find_directory(B_SYNTH_DIRECTORY, &path, false, NULL) == B_OK) {
|
||||||
path.Append(B_BIG_SYNTH_FILE);
|
path.Append(B_BIG_SYNTH_FILE);
|
||||||
return SetInstrumentsFile(path.Path());
|
return SetInstrumentsFile(path.Path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Use the first soundfont found in the synth directory
|
||||||
|
// instead of hardcoding
|
||||||
|
if (find_directory(B_SYNTH_DIRECTORY, &path, false, NULL) == B_OK) {
|
||||||
|
path.Append("TimGM6mb.sf2");
|
||||||
|
return SetInstrumentsFile(path.Path());
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Write the settings file
|
||||||
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user