Skip to content

Commit

Permalink
- Restore all MIDI channels synth-engine funcionality, when the
Browse files Browse the repository at this point in the history
  output peak-meters aren't opted in. (EXPERIMENTAL)
  • Loading branch information
rncbc committed Jul 22, 2023
1 parent a26800c commit c89c4d6
Show file tree
Hide file tree
Showing 8 changed files with 460 additions and 445 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ ChangeLog

GIT HEAD

- Restore all MIDI channels synth-engine funcionality, when the
output peak-meters aren't opted in. (EXPERIMENTAL)

- Preppings to next development cycle (Qt >= 6.6)


Expand Down
26 changes: 19 additions & 7 deletions src/qsynthMainForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,23 @@ int qsynth_process ( void *pvData, int len,
int nfx, float **fx, int nout, float **out )
{
qsynthEngine *pEngine = (qsynthEngine *) pvData;
#if FLUIDSYNTH_VERSION_MAJOR >= 2
nfx = nout; fx = out;
#endif
// Call the synthesizer process function to fill
// the output buffers with its audio output.
return ::fluid_synth_process(pEngine->pSynth, len, nfx, fx, nout, out);
}

int qsynth_process_meters ( void *pvData, int len,
int nfx, float **fx, int nout, float **out )
{
qsynthEngine *pEngine = (qsynthEngine *) pvData;
#if FLUIDSYNTH_VERSION_MAJOR >= 2
nfx = nout; fx = out;
#endif
// Call the synthesizer process function to fill
// the output buffers with its audio output.
if (::fluid_synth_process(pEngine->pSynth, len, nfx, fx, nout, out) != 0)
return -1;
// Now find the peak level for this buffer run...
Expand Down Expand Up @@ -332,7 +344,7 @@ static void qsynth_midi_event ( qsynthEngine *pEngine,
const int iType = ::fluid_midi_event_get_type(pMidiEvent);
const int iKey = ::fluid_midi_event_get_control(pMidiEvent);
const int iVal = ::fluid_midi_event_get_value(pMidiEvent);
fprintf(stderr, "Type=%03d (0x%02x) Chan=%02d Key=%03d (0x%02x) Val=%03d (0x%02x).\n",
qDebug("Type=%03d (0x%02x) Chan=%02d Key=%03d (0x%02x) Val=%03d (0x%02x).",
iType, iType, iChan, iKey, iKey, iVal, iVal);
#endif
if (iChan >= 0 && iChan < g_iMidiChannels) {
Expand Down Expand Up @@ -430,7 +442,7 @@ struct qsynthEngineNode
static int qsynth_sfont_free ( fluid_sfont_t *pSoundFont )
{
#ifdef CONFIG_DEBUG
fprintf(stderr, "qsynth_sfont_free(%p)\n", pSoundFont);
qDebug("qsynth_sfont_free(%p)", pSoundFont);
#endif
if (pSoundFont) ::free(pSoundFont);
return 0;
Expand All @@ -439,7 +451,7 @@ static int qsynth_sfont_free ( fluid_sfont_t *pSoundFont )
static int qsynth_sfloader_free ( fluid_sfloader_t * pLoader )
{
#ifdef CONFIG_DEBUG
fprintf(stderr, "qsynth_sfloader_free(%p)\n", pLoader);
qDebug("qsynth_sfloader_free(%p)", pLoader);
#endif
if (pLoader) ::free(pLoader);
return 0;
Expand All @@ -450,7 +462,7 @@ static fluid_sfont_t *qsynth_sfloader_load (
fluid_sfloader_t *pLoader, const char *pszFilename )
{
#ifdef CONFIG_DEBUG
fprintf(stderr, "qsynth_sfloader_load(%p, \"%s\")\n", pLoader, pszFilename);
qDebug("qsynth_sfloader_load(%p, \"%s\")", pLoader, pszFilename);
#endif

if (pLoader == nullptr)
Expand Down Expand Up @@ -2056,12 +2068,12 @@ bool qsynthMainForm::startEngine ( qsynthEngine *pEngine )
pEngine->bMeterEnabled = false;
if (m_pOptions->bOutputMeters) {
pEngine->pAudioDriver = ::new_fluid_audio_driver2(
pSetup->fluid_settings(), qsynth_process, pEngine);
pSetup->fluid_settings(), qsynth_process_meters, pEngine);
pEngine->bMeterEnabled = (pEngine->pAudioDriver != nullptr);
}
if (pEngine->pAudioDriver == nullptr)
pEngine->pAudioDriver = ::new_fluid_audio_driver(
pSetup->fluid_settings(), pEngine->pSynth);
pEngine->pAudioDriver = ::new_fluid_audio_driver2(
pSetup->fluid_settings(), qsynth_process, pEngine);
if (pEngine->pAudioDriver == nullptr) {
appendMessagesError(sPrefix +
tr("Failed to create the audio driver (%1).\n\n"
Expand Down
Loading

0 comments on commit c89c4d6

Please sign in to comment.