correct switching between 16bit and 24bit USB audio playback?
  • Hello,

    I have an external USB audio DAC/sound card. The DAC is capable of 16bit and 24bit audio playback. When I play either a 16bit or 24bit file via gstreamer pipeline (through command line) the output to the card switches correctly as in the following example:

    for 16 bit file:

    ~ $ gst-launch-0.10 filesrc location=/home/hrvoje/Music/Folk/Linda_Perhacs/Parallelograms/01_-_Chimacum_Rain.flac ! decodebin ! audioconvert ! audioresample ! alsasink device="hw:0,0"

    ~$ cat /proc/asound/card0/stream0
    music hall 24bit USB Receiver at usb-0000:00:1d.0-1, full speed : USB Audio
    Playback:
    Status: Running
    Interface = 3
    Altset = 1
    URBs = 2 [ 5 6 ]
    Packet Size = 388
    Momentary freq = 44100 Hz (0x2c.199a)
    Interface 3
    Altset 1
    Format: S16_LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 8000, 16000, 32000, 44100, 48000, 96000
    Interface 3
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 8000, 16000, 32000, 44100, 48000, 96000

    or for 24bit file:

    ~ $ gst-launch-0.10 filesrc location=/home/hrvoje/Music/sample/sample2.flac ! decodebin ! audioconvert ! audioresample ! alsasink device="hw:0,0"

    ~$ cat /proc/asound/card0/stream0
    music hall 24bit USB Receiver at usb-0000:00:1d.0-1, full speed : USB Audio
    Playback:
    Status: Running
    Interface = 3
    Altset = 2
    URBs = 2 [ 5 5 ]
    Packet Size = 582
    Momentary freq = 96000 Hz (0x60.0000)
    Interface 3
    Altset 1
    Format: S16_LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 8000, 16000, 32000, 44100, 48000, 96000
    Interface 3
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 8000, 16000, 32000, 44100, 48000, 96000

    You can see that the frequency and packet size are correctly displayed, and the "Altset" switches between "Altset 1" and "Altset 2" for the two files, based on the bitrate.

    Now, I have Guayadeque set up so as to use "ALSA => hw:0,0" as audio device, which should pass the file directly to the soundcard and the output of the "cat /proc/asound/card0/stream0" should match the above. However, pay attention to the output when I play these same files through Guayadeque:

    File 1 (16bit file)
    ~ cat /proc/asound/card0/stream0
    music hall 24bit USB Receiver at usb-0000:00:1d.0-1, full speed : USB Audio
    Playback:
    Status: Running
    Interface = 3
    Altset = 2
    URBs = 2 [ 5 6 ]
    Packet Size = 582
    Momentary freq = 44100 Hz (0x2c.199a)
    Interface 3
    Altset 1
    Format: S16_LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 8000, 16000, 32000, 44100, 48000, 96000
    Interface 3
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 8000, 16000, 32000, 44100, 48000, 96000

    File 2 (24bit file )
    ~ cat /proc/asound/card0/stream0
    music hall 24bit USB Receiver at usb-0000:00:1d.0-1, full speed : USB Audio
    Playback:
    Status: Running
    Interface = 3
    Altset = 2
    URBs = 2 [ 5 6 ]
    Packet Size = 582
    Momentary freq = 96000 Hz (0x60.0000)
    Interface 3
    Altset 1
    Format: S16_LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 8000, 16000, 32000, 44100, 48000, 96000
    Interface 3
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 8000, 16000, 32000, 44100, 48000, 96000

    As you can see Guaydeque correctly uses the "Altset 2" for the 24bit file, but does not use "Altset 1" for the 16bit file. How can this be fixed?

    Thanks!
  • Can you try the same 1st test but using the playbin2 element instead of the filesrc ! decodebin ?

    ~ $ gst-launch-0.10 playbin2 uri=/home/hrvoje/Music/sample/sample2.flac audio-sink="alsasink device='hw:0,0'"

  • well, it could be that I am doing something wrong (maybe there is a typo) but I get an error:


    ~ $ gst-launch-0.10 playbin2 uri=file:///home/hrvoje/Music/Folk/Linda_Perhacs/Parallelograms/01_-_Chimacum_Rain.flac audio-sink="alsasink device='hw:0,0'"
    Setting pipeline to PAUSED ...
    Pipeline is PREROLLING ...
    ERROR: from element /GstPlayBin2:playbin20/GstPlaySink:playsink0: Configured audiosink bin0 is not working.
    Additional debug info:
    gstplaysink.c(1869): gen_audio_chain (): /GstPlayBin2:playbin20/GstPlaySink:playsink0
    ERROR: pipeline doesn't want to preroll.
    Setting pipeline to NULL ...
    Freeing pipeline ...


    does the command work on your computer when used as written?

  • never mind my previous post -- I figured out where the error was. I had to remove the inner quotation marks around hw:0,0. Now there is no error:

    for 16bit file:

    $ gst-launch-0.10 playbin2 uri=file:///home/hrvoje/Music/Folk/Linda_Perhacs/Parallelograms/01_-_Chimacum_Rain.flac audio-sink="alsasink device=hw:0,0"

    Playback:
    Status: Running
    Interface = 3
    Altset = 1
    URBs = 2 [ 5 6 ]
    Packet Size = 388
    Momentary freq = 44100 Hz (0x2c.199a)

    for 24 bit file:
    ~ $ gst-launch-0.10 playbin2 uri=file:///home/hrvoje/Music/sample/sample2.flac audio-sink="alsasink device=hw:0,0"
    Playback:
    Status: Running
    Interface = 3
    Altset = 2
    URBs = 2 [ 5 5 ]
    Packet Size = 582
    Momentary freq = 96000 Hz (0x60.0000)


    As you can see it switches between "Altset 1" and "Altset 2" correctly.


  • fine... now can you test with this pipeline ?

    gst-launch-0.10 playbin2 uri=file:///home/hrvoje/Music/Folk/Linda_Perhacs/Parallelograms/01_-_Chimacum_Rain.flac audio-sink="audioconvert ! audioresample ! rgvolume ! volume ! level ! volume ! equalizer-10bands ! rglimiter ! audioconvert ! audioresample ! alsasink device=hw:0,0"

    Thanks
  • If I play the 16bit file as written in your command I get the incorrect "ALtset 2".
    Playback:
    Status: Running
    Interface = 3
    Altset = 2
    URBs = 2 [ 5 6 ]
    Packet Size = 582
    Momentary freq = 44100 Hz (0x2c.199a)

    However, if I remove the second instance of the "audioconvert" command such as:
    ~ $ gst-launch-0.10 playbin2 uri=file:///home/hrvoje/Music/Folk/Linda_Perhacs/Parallelograms/01_-_Chimacum_Rain.flac audio-sink="audioconvert ! audioresample ! rgvolume ! volume ! level ! volume ! equalizer-10bands ! rglimiter ! audioresample ! alsasink device=hw:0,0"

    then I get the correct "Altset 1" and packet size --
    Playback:
    Status: Running
    Interface = 3
    Altset = 1
    URBs = 2 [ 5 6 ]
    Packet Size = 388
    Momentary freq = 44100 Hz (0x2c.199a)

    I played some more with this command, and removing any other pieces does not give the desired "Altset 1". Only when I also remove the second "audioconvert", do I get the desired outcome.

    It seems that all the commands except "alsasink device=hw:0,0" are unnecessary to play this file correctly. Since I would like to avoid unnecessary alterations to the music file by the program, perhaps there could be an option to just use this barebones command to play flac files.




  • also, just thought that I'd mention -- I tried the 16bit and 24bit files through some other media players using "hw:0,0":
    -- with VLC both files were forced through "Altset 1" (interesting)
    -- with Clementine both files were forced through "Altset 2" (as with Guayadeque)

    either way, they both gave incorrect results. Hope this helps find the problem.

  • lusich said:

    also, just thought that I'd mention -- I tried the 16bit and 24bit files through some other media players using "hw:0,0":
    -- with VLC both files were forced through "Altset 1" (interesting)
    -- with Clementine both files were forced through "Altset 2" (as with Guayadeque)

    either way, they both gave incorrect results. Hope this helps find the problem.


    You already told what the problem is. 'In my case the 2nd audioconverter ! audioresample forces the selection to the Altset 2'
    That is something done by gstreamer and Im not sure If I can decide anything about it. The 2nd converter is in case the audio output need it. Most of the times does nothing. If I remove it I can loose compatibility with some output devices.
  • Can i change it in the program, on my installation by myself? Which file should I look at?

  • email me to anonbeat at gmail dot com and I will give you a patch for it
  • wow, that's what I call support. Try that with a paid application :)
  • yeah, I agree -- anonbeat might just have the greatest customer service operation in the entire western hemisphere :)

    I'll post the results of the patch later.
  • Hi,

    so I tried the patch on the svn build 1764. The patch was successfully applied, but when I choose ALSA: hw:0,0 output I get an error:

    Loading 0 -1 => 0 '/home/hrvoje/Music/sample/sample2.flac'
    07:29:58 PM: SOListBox::GetSelectedTracks <- 1<br />07:29:58 PM: OnMediaLoaded Cur: 0 1 565704033
    07:29:58 PM: Track starts at 0 with length 1537000
    07:29:58 PM: StatusChanged( 0, 0, 0, 0 )
    07:29:58 PM: Error: Gstreamer error 'GStreamer encountered a general stream error.'

    I can play music under the Automatic setting, but then it forces all music into 16bits, and outputs it to ALtsat 1.

  • also, just a thought -- perhaps this is something to add to a future release of the Guaydeque player -- I was trying different music players yesterday, and I found that Quod Libet actually properly outputs the 16bit and 24bit music.

    In the options for playback it allows for the user to define a custom gstreamer "Output pipeline" rather than just output device. So you can type in "alsasink device=hw:0,0" and it works correctly with good results. Maybe this approach can be implemented as an option in the Guayadeque as well.

    I also noticed this same option for a custom gstreamer pipeline in Gmusicbrowser, but the program crashed.

  • Can you try with dmix:0,0 instead of hw:0,0 please ?

  • if that worked :

    gst-launch-0.10 playbin2 uri=file:///home/hrvoje/Music/Folk/Linda_Perhacs/Parallelograms/01_-_Chimacum_Rain.flac audio-sink="audioconvert ! audioresample ! rgvolume ! volume ! level ! volume ! equalizer-10bands ! rglimiter ! audioresample ! alsasink device=hw:0,0"

    The patch should work fine. I will contact you by email
  • I'll be away for two weeks. But I will report on this when I get back. Thanks for all the hard work.
  • OK, so I tried it again with the patch and svn. The hw:1,0 option gives the same error as last time.

    The dmix:1,0 option also gives an error:

    02:44:29 PM: Track starts at 0 with length 160000
    02:44:30 PM: StatusChanged( 0, 0, 0, 0 )
    02:44:30 PM: Error: Gstreamer error 'GStreamer encountered a general stream error.'

    Trying the above gst-launch-0.10 command as written, gives the correct rate:
    Playback:
    Status: Running
    Interface = 3
    Altset = 1
    URBs = 2 [ 5 6 ]
    Packet Size = 388
    Momentary freq = 44100 Hz (0x2c.199a)

    Trying the same command on a 24-bit song gives also the correct:
    Playback:
    Status: Running
    Interface = 3
    Altset = 2
    URBs = 2 [ 5 5 ]
    Packet Size = 582
    Momentary freq = 96000 Hz (0x60.0000)

    Where do we go now? :)

    I still vote for including an option in the program to be able to input a desired output pipeline in the "preferences" section -- kind of like Quod Libet. I think that might be the most versatile solution for many people.

    PS. My card designation has changed to hw:1,0 so the above is not a typo.

    Thanks for the help!

  • The problem is not the pipeline. The pipeline is built correctly for you if you applied the patch correctly.
    Can you tell me if you can at least play first track ?
  • Just added in svn revision 1787 to Preferences -> Playback the option to select the complete output pipeline using Other as output device.
  • Hi,

    well, my programing knowledge is limited. I did follow the instructions for applying the patch and building the program. And everything seemed to be fine and the patch seemed to apply correctly.
    With the patched program I can play music under "PulseAudio" and "Automatic" settings, but not under "Alsa" with hw:1,0 or dmix:1,0. (As you can see I get an error message, regardless of the music file).

    I will try again from scratch, patching and building and let you know the result. However, I am most interested in seeing how the svn 1787 performs. I will try it ASAP and report on the result as well.

    Many thank for all the hard work!

  • SOLVED!

    I installed SVN 1787 and used the "Other" option in playback. I put "alsasink device=hw:1,0" as the option and now the player outputs to the proper channels.

    Out of curiosity -- I take it the default "Other" gstreamer pipeline is of the following format:

    gst-launch-0.10 playbin2 uri=file:///XXX audio-sink=

    and then we can put in one or more of the following into the box:

    "audioconvert ! audioresample ! rgvolume ! volume ! level ! volume ! equalizer-10bands ! rglimiter ! audioresample ! alsasink device=hw:1,0"

    is this correct? Just want to make sure I understand it?


  • Yes you can define elements to be added to the output but there are elements already added by the application that are needed and you will be duplicating elements. I posted earlier what elements guayadeque uses.

    Thanks for your help
  • I am interested -- in this case, does Guayadeque application change the specific elements in the pipeline automatically, when it detects a particular type of file? Or does it include all elements for all files?



  • Only change with some preferences like replaygain.
  • I think I'm having a similar issue. In one of the posts above it was suggested to change the info in the alsa pipeline box under "player" settings from hw:1,0 to dmix:1,0. That worked for me, and solved the issue of the program crashing, or error messages, occurring when going from one track to the next. However, when plaing back a hi resolution audio file (24 bit, 96 kHz for example), the player will only output the steam at 24 bit 48 kHz. Any thoughts on this?
  • @whell: If you can build guayadeque from svn please email me to send you a patch to check if that helps you.

  • Thanks. I now have the svn version installed. I'll send you an email shortly.
  • After some back and forth with anonbeat via email - awesome customer service by the way! - we weren't able to resolve the issue. Then by chance, I came across this post on the XBMC forum.

    http://wiki.xbmc.org/?title=XBMC_for_Linux_specific_FAQ#Audio_issues

    Turns out that I did not have the ~./asound file on my computer. So, I created and saved it exactly as shown in the thread above. (I did modify it a bit by changing the reference to my sound card location: changing the reference "hw:0,1 to "hw:1,0"). I then returned to guayadeque and selected ALSA output and typed in "plughw:1,0" to point to my sound card. So far this evening after a couple of hours of playing, guayadeque is working perfectly!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

In this Discussion