[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] Fluidsynth + Portaudio device selection

From: Massimo Callegari
Subject: Re: [fluid-dev] Fluidsynth + Portaudio device selection
Date: Wed, 6 Jun 2012 08:47:22 +0100 (BST)

My comments below.

Da: Pedro Lopez-Cabanillas <address@hidden>
A: Massimo Callegari <address@hidden>; FluidSynth mailing list <address@hidden>
Inviato: Martedì 5 Giugno 2012 23:08
Oggetto: Re: [fluid-dev] Fluidsynth + Portaudio device selection

On Tuesday 05 June 2012, Massimo Callegari wrote:
> Hi again !
> After debugging a while I found the cause of this.
> I needed to register the parallel list name "audio.portaudio.dev_idx_list"
> to fluid_settings !

Correct, all settings must be registered. However, that setting is not
required. See below.

> Now the index lookup seems to be working fine. Attached the new file.
> This solution still looks quite complicated to me but for now it is working.
> If you like the implementation, then you can remove/replace all the fprintf
> I left in the code.

We don't use fprintf() for debugging, there is a FLUID_LOG macro with the
argument FLUID_DBG for that.

I know, I'm not that retarded. Since debugging a windows DLL is not that comfortable I used a quick&dirty way.

> Basically, for the application point of view, I've added the
> "audio.portaudio.index" key to select a device by index (the Fluidsynth
> index) and not by name.

But you didn't register this "audio.portaudio.index" setting. It should be
registered as an integer: fluid_settings_register_int().

Not registered but it works just by calling fluid_settings_setint from the application level (in my case a JNI)

No, I don't like that solution. You don't need a parallel list at all. If the
user has set "audio.portaudio.index" to some value, then you only need to
check that it is in range (0 to numDevices) and has outputs. For instance:

if (fluid_settings_getint (settings, "audio.portaudio.index", &device_index))
  if (device_index >= 0 && device_index <= numDevices) 
    deviceInfo = Pa_GetDeviceInfo (device_index);
    if (deviceInfo && deviceInfo->maxOutputChannels >= 2 )
        outputParams.device = device_index;
        FLUID_LOG (FLUID_DBG, "Selected PortAudio index: %d Device: %s\n",
                  device_index, deviceInfo->name);     

The option "audio.portaudio.index" may be useful for some use cases, but the
problem for Qsynth users remains: PortAudio may return the same name for two
different indexes (one for DirectSound, and another for WDMKS) so FluidSynth
will remember only one option. The only general solution for this problem is
modifying the strings stored as options for "audio.portaudio.device",
including the device type, index, both, or whatever else.

I do not agree here. "audio.portaudio.index" can NOT be the PortAudio index, since we're talking about applications linking Fluidsynth, and not PortAudio directly. So "audio.portaudio.index" has to be an index of the FS devices list. That's the whole point of doing this change.
Moreover in my solution I kept backward compatibility. Changing the names of the PA devices returned by FS would break all the applications out there that work on devices names.

> Another thing. When I started to compile Fluidsynth+PortAudio in Windows I
> had troubles with the unistd.h header and Visual C. Since only "bzero" was
> used from it, I converted it to "memset(0)". (please have a look at this:
> http://stackoverflow.com/questions/4813267/problem-with-unistd-h-in-vc )

I guess that nobody compiled PortAudio in Windows lately. First, bzero()
belongs to <strings.h>, http://linux.die.net/man/3/bzero , but you are right
replacing it with memset.

OTOH, the <unistd.h> header inclusion should be protected (instead of removed)

#include <unistd.h>

HAVE_UNISTD_H is defined (or not) in the cmake generated header "config.h"

Unistd.h include can be removed. It's useless either in Windows or Linux, since FS builds fine without it.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]