Skip to content

Commit

Permalink
fluidsynth: default windows audio driver is now wasapi. Fixed pulseau…
Browse files Browse the repository at this point in the history
…dio settings.

git-svn-id: https://svn.code.sf.net/p/drumstick/code/trunk@666 b2133143-ca9b-4e53-b430-e31f198fbdac
  • Loading branch information
pedrolcl committed Jul 21, 2022
1 parent 6dbfe6c commit 93a41f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 11 additions & 6 deletions library/rt-backends/fluidsynth/fluidsynthengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const QString FluidSynthEngine::QSTR_INSTRUMENTSDEFINITION = QStringLiteral("Ins
const QString FluidSynthEngine::QSTR_DATADIR = QStringLiteral("soundfonts");
const QString FluidSynthEngine::QSTR_DATADIR2 = QStringLiteral("sounds/sf2");
const QString FluidSynthEngine::QSTR_SOUNDFONT = QStringLiteral("default.sf2");
const QString FluidSynthEngine::QSTR_PULSEAUDIO = QStringLiteral("pulseaudio");

const QString FluidSynthEngine::QSTR_AUDIODRIVER = QStringLiteral("AudioDriver");
const QString FluidSynthEngine::QSTR_BUFFERTIME = QStringLiteral("BufferTime");
Expand All @@ -47,9 +48,9 @@ const QString FluidSynthEngine::QSTR_POLYPHONY = QStringLiteral("Polyphony");

const QString FluidSynthEngine::QSTR_DEFAULT_AUDIODRIVER =
#if defined(Q_OS_LINUX)
QStringLiteral("pulseaudio");
QSTR_PULSEAUDIO;
#elif defined(Q_OS_WIN)
QStringLiteral("dsound");
QStringLiteral("wasapi");
#elif defined(Q_OS_OSX)
QStringLiteral("coreaudio");
#else
Expand Down Expand Up @@ -120,7 +121,9 @@ void FluidSynthEngine::initializeSynth()
::fluid_settings_setstr(m_settings, "audio.driver", qPrintable(fs_audiodriver));
::fluid_settings_setint(m_settings, "audio.period-size", fs_periodSize);
::fluid_settings_setint(m_settings, "audio.periods", fs_periods);
::fluid_settings_setint(m_settings, "audio.pulseaudio.adjust-latency", 0);
if (fs_audiodriver == QSTR_PULSEAUDIO) {
::fluid_settings_setint(m_settings, "audio.pulseaudio.adjust-latency", 0);
}
::fluid_settings_setnum(m_settings, "synth.sample-rate", fs_sampleRate);
::fluid_settings_setint(m_settings, "synth.chorus.active", fs_chorus);
::fluid_settings_setint(m_settings, "synth.reverb.active", fs_reverb);
Expand Down Expand Up @@ -334,9 +337,11 @@ void FluidSynthEngine::readSettings(QSettings *settings)
fs_polyphony = settings->value(QSTR_POLYPHONY, DEFAULT_POLYPHONY).toInt();
settings->endGroup();
//qDebug() << Q_FUNC_INFO << "audioDriver:" << fs_audiodriver << "buffer" << fs_periodSize << '*' << fs_periods;
int bufferTime = 1000 * fs_periodSize * fs_periods / fs_sampleRate;
qputenv("PULSE_LATENCY_MSEC", QByteArray::number( bufferTime ) );
//qDebug() << Q_FUNC_INFO << "$PULSE_LATENCY_MSEC=" << bufferTime;
if (fs_audiodriver == QSTR_PULSEAUDIO) {
int bufferTime = 1000 * fs_periodSize * fs_periods / fs_sampleRate;
qputenv("PULSE_LATENCY_MSEC", QByteArray::number( bufferTime ) );
//qDebug() << Q_FUNC_INFO << "$PULSE_LATENCY_MSEC=" << bufferTime;
}
}

void FluidSynthEngine::close()
Expand Down
1 change: 1 addition & 0 deletions library/rt-backends/fluidsynth/fluidsynthengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class FluidSynthEngine : public QObject
static const QString QSTR_POLYPHONY;
static const QString QSTR_DEFAULT_AUDIODRIVER;
static const QString QSTR_BUFFERTIME;
static const QString QSTR_PULSEAUDIO;

static const int DEFAULT_PERIODS;
static const int DEFAULT_PERIODSIZE;
Expand Down

0 comments on commit 93a41f2

Please sign in to comment.