Board index FlightGear Support Tools FGCom

FGCom not working SPDIF or Multiple Sound Card Issue? SOLVED

FGCom is a realtime voice communication system specially designed for FlightGear.

FGCom not working SPDIF or Multiple Sound Card Issue? SOLVED

Postby rogerx » Sun Apr 20, 2014 6:28 am

Gentoo Linux
FlightGear-3.0.0
NVidia
SPDIF Sound using ALSA (no Pulse Audio)
ALSA asoundrc preventing plug:dmix, while OpenAL alsoftrc specifies plug:dmix, FlightGear is using plug:dmix, but FGCom appears not to be using plug:dmix!

I have enabled FGCom and activated Debug output, but do not get the [speak] prompts using flightgear-3.0.

According to http://fgcom.flightgear.org/history.php, my rogerx callsign appears to be showing, alongside the record time.

I'm using a ASUS XONAR STX card, using S/PDIF for output to surround sound, and a microphone using the line in (along side using a separate pre-amp).

I get some awesome sound using the following:
alias arecord-mic-3s="arecord --channels=1 --device=plughw:0,0 --duration=3 --format=S32_LE --rate 48000 --vumeter=mono /tmp/test.wav && aplay /tmp/test.wav"

However on the loop FGCom test (ie. 910 or Test), I get nothing but silence. Audio works find within FlightGear, but I am not allowing ALSA to mix, and am only allowing one application output sound. For example, a clip of my .asoundrc file:

pcm.!default {
type plug
slave {
pcm "spdif"
}
}

So if FGCom is spawning sound within a separate thread, the ALSA interface will refuse to accept any other connections to the S/PDIF output. (Guess I could temporarily move/remove the asoundrc file quickly to test this.)

Another possible scenario, this NVidia GTX 670 has HDMI output, and is also showing up within the ALSA card listing.

Finally, when performing radio checks on the default 120.5 frequency, I get no replies even though others are talking. After so many radio checks with no replies, I would think it's safe to assume they hear nothing but silence! ;-)
Last edited by rogerx on Mon Apr 21, 2014 10:32 pm, edited 3 times in total.
rogerx
 
Posts: 65
Joined: Sun Jan 08, 2012 9:39 am
Location: Conneaut, Ohio

Re: FGCom not working S/PDIF or Multiple Sound Card Issue?

Postby rogerx » Sun Apr 20, 2014 6:35 am

OK! I just confirmed my own scenario to be the fact FGCom is trying to open a separate channel to an already in use S/PDIF output device!

$ mv .asoundrc .asoundrc.backup

$ gdb -e fgfs
> run

Perform FGCom > Echo Test and I now get a reverberating echo of what I just said!

But I don't think this should occur, or a user should not have to remove their asoundrc file because they're not using the default ALSA mixing. I think the FGCom should be producing the audio inline with FlightGear correct? (Many users whom do not want their sounds or audio remixed by the operating system, and only want one application's audio at one time, much prefer the above formated asoundrc file! As such, many audiophiles are going to run into this problem!)

I think I've got it now, allow FGCom to be able to use a different device given by the .asoundrc, allowing the default ALSA mixing of sound between applications. However, FlightGear would also need to be configured to also use this optional device provided by the .asoundrc file. So far, FlightGear is only allowing users to use device provided by "aplay -l" and no other custom mixer options specified within their .asoundrc file.

I would at least suggest the FGCom wiki page also include this likely very popular issue concerning locking sound to only one application at a time.
rogerx
 
Posts: 65
Joined: Sun Jan 08, 2012 9:39 am
Location: Conneaut, Ohio

Re: FGCom not working S/PDIF or Multiple Sound Card Issue?

Postby F-JJTH » Sun Apr 20, 2014 8:01 am

Hi,

Your audio installation is definitely more complicated than the simple audio installation that "everybody has at home" (i.e a simple audio card with 1 output + 1 input)
FGCom is working fine on a "simple" audio installation.

Hopefully you have much more skills about audio installation on Linux than me (I'm using Linux since +6 years and never touched at any file called ".asoundrc", but everything works fine, I'm able to listen music everyday and FGCom works fine :) )

Please feel you free to add what you think interesting in the wiki ( http://wiki.flightgear.org/FGCom_3.0 ), I should admit that I didn't understand any line of your audio installation :) so please be more precise/explicit/understandable when you write down on the wiki, that way our "neebie" users (like me) can understand you.

Thanks you,
Regards,
Clément
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: FGCom not working S/PDIF or Multiple Sound Card Issue?

Postby rogerx » Sun Apr 20, 2014 10:54 pm

There are probably about two major types of ALSA implementations, 1) People having a sound card and outputting analog signals directly to speakers and 2) those outputing through S/PDIF (or HDMI) of their sound cards to a home stereo system.

In both the previously mentioned layouts, sound can only be played from one source at a time! The only method an operating system (or ALSA or Pulse audio or Windows' KMix layer) can successfully play sound from more than one source (or application) at a time, is by mixing and sometimes resampling the sounds trying to play all at once! (ie. See Windows configuration GUI for "Speakers Properties > Advanced > Select the sample rate ... when running in shared mode." or a more indepth description is reading Microsoft Windows' KMix "Policy for Mixing Audio Streams..." .) For audiophiles whom enjoy listening to music or those people only wanting to hear sound or music coming from one application at a time, this "mixing" is basically considered a sin. ALSA users simply avoid this (additional software mixing action) by simply adding something similar to the following clipping within their asoundrc file:

Code: Select all
pcm.!spdif {                                                                                                                               
    type hw                                                                                                                               
    card 0                                                                                                                                 
    device 1                                                                                                                               
}

pcm.!default
  {
    type plug
    slave
      {
        pcm "spdif"
      }
}


From memory, the above prevents ALSA from remixing any sound coming from any other applications producing sound. (ie. You are listening to some wonderful classical music, and while browsing some annoying advertisement pops-up some sound producing advertisement, and this will prevent additional noise from interrupting your music. Or you're an audiophile and don't want any remixing of your music.)

If I'm not mistaken, the above simple disables DMix, whereas the default is to use DMix by default. (ie. http://alsa.opensrc.org/Dmix)

Aside from what is considered basic, from an ordinary user never fussing with S/PDIF then this would be considered extravagant as the asoundrc file format is similar to C programming/shell syntax. Those using S/PDIF (or HDMI) or accustomed to messing with the asoundrc, this would be considered the very basics.

Typically, applications (ie. aplay or mplayer) will allow using or specifying additional plugins or devices specified within the .asoundrc file. (Devices shown by "aplay -L".) However, I have yet to see if FlightGear allows this, as the FlightGear graphical front-end only shows "aplay -l" devices. You'll likely encounter this issue once you've decided to start using S/PDIF and enjoying classical music as I have. HDMI audio is also a form of S/PDIF.

I think http://wiki.flightgear.org/Linux_softwa ... 3F_ALSA.3F touches on some issues with using these additional plugins within the asoundrc file. (ie. aplay -D plug:duplex test.wav, and aplay allows specifying an additional audio device from the list provided by aplay -L.)

Another relevant thread is here: http://www.mail-archive.com/flightgear- ... 24713.html

Seems FlightGear uses OpenAL (or SDL) on Linux for outputting sound. PulseAudio maybe able to itemize SDL output, but most audiophiles do not enjoy working with Pulse Audio due to Pulse Audio being more complicated than ALSA.

More research, http://ehc.ac/p/alsa/mailman/message/15529893/

Maybe doing something like this?
$ export SDL_AUDIODRIVER=alsa AUDIODEV=plug:dmix /usr/games/bin/fgfs

Anyways, I've run-out of time for testing and have written plenty for those researching & finding this similar issue. I'll follow-up with my results a little later if possible.

2014.04.21: NOTE -> It would appear FlightGear is not using SDL for audio output and is instead using OpenAL for audio/sound interfacing. And as such, "$ ALSOFT_LOGLEVEL=3 fgfs"!
Last edited by rogerx on Mon Apr 21, 2014 9:07 pm, edited 1 time in total.
rogerx
 
Posts: 65
Joined: Sun Jan 08, 2012 9:39 am
Location: Conneaut, Ohio

Re: FGCom not working S/PDIF or Multiple Sound Card Issue?

Postby rogerx » Mon Apr 21, 2014 2:05 am

Some more testing. Basic testing to test if two sounds will play at once, using the above snippet for disabling the ALSA DMix by default.

This works!
aplay -D "plug:dmix" Music/Alisa_Weilerstein/Dvorak/01.Cello_Concerto_in_B_minor_1.wav & aplay -D "plug:dmix" Music/Alisa_Weilerstein/Dvorak/02.Cello_Concerto_in_B_minor_2.wav

This does not work! FGCom still doesn't play sound for the echo test, so likely fgfs isn't using plug:dmix
$ SDL_AUDIODRIVER=alsa AUDIODEV=plug:dmix fgfs

NOTE: SDL_AUDIODRIVER & AUDIODEV are SDL Environmental variables, not related to ALSA.

I'm finding the above SDL environmental variables are possilbly not working, since I'm getting now SDL DEBUG output. OpenAL is outputing debug information though!

$ ALSOFT_LOGLEVEL=3 SDL_DEBUG=1 SDL_AUDIODRIVER=alsa AUDIODEV=plug:dmix fgfs

Per http://wiki.flightgear.org/FGCOM_Testing, trying to force OpenAL to use the ALSA plug:dmix within $HOME/.alsoftrc. ($HOME/.openalrc is supposedly the older file? Odd.)
Code: Select all
drivers = alsa
[alsa]
device = plug:dmix


The results of using this .alsoftrc file alongside fgfs is, this still does not force OpenAL/SDL to use the default ALSA dmix plug regardless of what's written within a users .asoundrc file. (I'm pretty sure plug:dmix requires no additional configuration within a .asoundrc file, as it's a default plug for ALSA.)

I do now have "AL lib: (II) LoadConfigFromFile: found 'device' = 'plug:dmix'" within OpenAL debug after using "$ ALSOFT_LOGLEVEL=3 fgfs", but OpenAL isn't using this and defaulting to the devices listed via "aplay -l".
Last edited by rogerx on Mon Apr 21, 2014 3:29 am, edited 3 times in total.
rogerx
 
Posts: 65
Joined: Sun Jan 08, 2012 9:39 am
Location: Conneaut, Ohio

Re: FGCom not working S/PDIF or Multiple Sound Card Issue?

Postby Philosopher » Mon Apr 21, 2014 2:29 am

offtopic: Go Dvorak et cello :)
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: FGCom not working S/PDIF or Multiple Sound Card Issue?

Postby rogerx » Mon Apr 21, 2014 9:04 pm

I have just found out from the OpenAL mailing list that the "device = plug:dmix" is still the proper method of specifying using ALSA plug:dmix within the OpenAL alsoftrc file.

I have further tested FlightGear is using the ALSA plug:dmix as specified within the OpenAL asoftrc file by removing my .asoundrc (preventing plug:dmix usage) after FlightGear has started, and then playing a sound file while FlightGear sound was being played. And then reversed the test and found FlightGear did lock the sound device when plug:dmix was removed from the alsoftrc file.

So the point of failure seems to be with FGCom code (whether Playback or Capture device), not using the plug:dmix filter when specified via OpenAL asoftrc? My next step appears to be tracing the FGCom code.

(Since I've pretty much confirmed FlightGear is using plug:dmix when specified within the OpenAL $HOME/.alsoftrc file, this issue now seems to remain still appropriate for the FGCom subsection. ;-)


SOLVED!

OK. So I'm a dumb butt! I was batting around the issue, and always skimming over the (plug:dsnoop) solution all along!

$HOME/.alsoftrc requires "capture = plug:dsnoop" to enable sharing the capture device as well! So if users have a .asoundrc file restricting plug:dmix usage, they're going to encounter this same issue with recording and possibly be misled by the "plug:dsnoop" not being explicit enough. From the ALSA page, "dsnoop is the equivalent of the dmix plugin, but for recording sound."

So for users encountering this issue with FGCom not working with their custom asoundrc file, ensure they have created a $HOME/.alsoftrc file within the following contents:
drivers = alsa
[alsa]
device = plug:dmix
capture = plug:dsnoop

This basically avoids user's asoundrc files restricting the default ALSA dmix configuration, possibly locking the sound device to only one application or one thread.

(The alsoftrc file also accepts other asoundrc plug: incanatations, such as sections containing Dmix - alsa.opensrc.org's "pcm.dmixs51" customizations, and called as "plug:dmixs51" or "device = plug:dmixs51". ;-)



F-JJTH: I've updated FGCom Testing and FGCom-3.0 Wiki pages with the relevant information. I've also updated some of their Talk sections as well. I also spent a little time reformatting FGCom-3.0 Wiki page, and hopefully it looks a little better now. Granted, I know the Linux ALSA section is sort of big & ugly, but it's needed and will likely be very useful!
rogerx
 
Posts: 65
Joined: Sun Jan 08, 2012 9:39 am
Location: Conneaut, Ohio

Re: FGCom not working SPDIF or Multiple Sound Card Issue? SO

Postby F-JJTH » Tue Apr 22, 2014 8:50 am

Hi,
I would prefer that you move the "Linux Alsa" parts to the FAQ section.
Also you have added informations that I would avoid to expose to the users for 2 raisons:
- makes FGCom easy to understand
- avoid abusive use of unwanted feature (910.000MHz)

Also I would avoid to create dozens of section in order to keep the summary as clean as possible.
The goal is to avoid that FGCom 3.0 becomes like the old FGCom documentation: an unreadable documentation because multiple page and long long long page with unecessary informations.

For example the new section "Quick Frequency Setup" is not related to FGCom but related to "How to use FlightGear".

I'm more and more thinking to restrict authorized freq in FG in order to restrict the 910.00MHz freq.

Maybe we need to create a new page named "FGCom_3.0_advanced_setup"

Regards,
Clément
Last edited by F-JJTH on Tue Apr 22, 2014 8:20 pm, edited 2 times in total.
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: FGCom not working SPDIF or Multiple Sound Card Issue? SO

Postby rogerx » Tue Apr 22, 2014 7:04 pm

Continuing the discussion of this Wiki editing over at the Talk page of http://wiki.flightgear.org/FGCom_3.0
rogerx
 
Posts: 65
Joined: Sun Jan 08, 2012 9:39 am
Location: Conneaut, Ohio


Return to FGCom

Who is online

Users browsing this forum: No registered users and 2 guests