Resampling audio from 88200 to 96000 samples per second

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Resampling audio from 88200 to 96000 samples per second

Nick
I have an audio file recorded with a sample rate of 88200 that I want to play on a USB DAC that supports 96000 but not 88200.

The following pipeline plays the file but re-samples to 48000:

% gst-launch-0.10 filesrc location=Song.flac ! decodebin ! alsasink, device=hw:0,0 -v

/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:src0: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)24, rate=(int)88200, channels=(int)2
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacDec:flacdec0.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)24, rate=(int)88200, channels=(int)2
/GstPipeline:pipeline0/GstAlsaSink:alsasink0.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)24, rate=(int)88200, channels=(int)2
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:src0.GstProxyPad:proxypad1: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)24, rate=(int)88200, channels=(int)2
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstAudioSinkClock
I confirmed the sampling rate with 'cat /proc/asound/card0/stream0':
Playback:
  Status: Running
    Interface = 3
    Altset = 1
    URBs = 3 [ 7 7 8 ]
    Packet Size = 388
    Momentary freq = 48000 Hz (0x30.0000)

This mailing list post suggests something like this:

% gst-launch-0.10 filesrc location=Song.flac ! decodebin ! audioresample ! 'audio/x-raw-int, rate=96000' ! alsasink, device=hw:0,0 -v

However, this does not produce sound and provides the following message:

/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:src0: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)24, rate=(int)88200, channels=(int)2
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacDec:flacdec0.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)24, rate=(int)88200, channels=(int)2
ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacParse:flacparse0: GStreamer encountered a general stream error.
Additional debug info:
gstbaseparse.c(2890): gst_base_parse_loop (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacParse:flacparse0:
streaming stopped, reason not-negotiated
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:src0: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacDec:flacdec0.GstPad:src: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacDec:flacdec0.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacParse:flacparse0.GstPad:src: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacParse:flacparse0.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind.GstPad:src: caps = NULL
Freeing pipeline ...

I'm sure the NULL caps is not a good sign.  Can someone help me understand what I'm doing wrong?

Thanks in advance,

n


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Resampling audio from 88200 to 96000 samples per second

Tim-Philipp Müller-2
On Fri, 2012-11-23 at 08:17 -0800, Nick Okasinski wrote:

> This mailing list post suggests something like this:
>
> % gst-launch-0.10 filesrc location=Song.flac ! decodebin !
> audioresample ! 'audio/x-raw-int, rate=96000' ! alsasink,
> device=hw:0,0 -v
>
> However, this does not produce sound and provides the following
> message:
>
> > /GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:src0:
> > caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true,
> > width=(int)32, depth=(int)24, rate=(int)88200, channels=(int)2
> > /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacDec:flacdec0.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)24, rate=(int)88200, channels=(int)2
> > ERROR: from
> > element /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacParse:flacparse0: GStreamer encountered a general stream error.
> > Additional debug info:
> > gstbaseparse.c(2890): gst_base_parse_loop
> > (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacParse:flacparse0:
> > streaming stopped, reason not-negotiated
> > ERROR: pipeline doesn't want to preroll.
> > (snip)
>
> I'm sure the NULL caps is not a good sign.  Can someone help me
> understand what I'm doing wrong?

The NULL caps are normal when shutting down the pipeline.

Try:  ... ! decodebin2 ! audioconvert ! audioresample ! alsasink ...

Cheers
 -Tim

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Resampling audio from 88200 to 96000 samples per second

Nick
Tim-Philipp Müller-2 wrote
Try:  ... ! decodebin2 ! audioconvert ! audioresample ! alsasink ...
Tim, thanks for your astonishingly fast response.

I've tried the following:

% gst-launch-0.10 filesrc location=Song.flac ! decodebin2 ! audioconvert ! audioresample ! alsasink, device=hw:0,0 -v

It produces sound but still at 48000 Hz rather than the desired 96000 Hz.

One thing that puzzles me is how the pipeline knows that the output should be 96000 samples/sec.  I tried many things:

(1)% gst-launch-0.10 filesrc location=Song.flac ! decodebin2 ! audioconvert ! audioresample ! 'alsasink, device=rate96000' -v

... where: /etc/asound.conf contains "pcm.rate96000 { type plug slave { pcm "hw:0,0" rate 96000 }}"  The idea being that since 'alsasink' doesn't have a "rate" option, to do it indirectly in the alsa config.

(2)% gst-launch-0.10 filesrc location=Song.flac ! decodebin2 ! audioconvert ! audioresample ! 'alsasink, slave-method=0, device=rate96000' -v

... where "slave-method=0" signifies "resample".

I've tried dozens of variations with arguments to decodebin and decodebin2; inserting audio/x-raw elements with rate=96000... all to no avail.

Here is some more information about the capabilities of the DAC I'm trying to drive.  My goal is to see it using "Altset 3" at "Momentary freq" of 96000.

> GFEC ASSP DigiHug USB Audio at usb-0000:00:13.0-1, full speed : USB Audio
>
> Playback:
>   Status: Running
>     Interface = 3
>     Altset = 1
>     URBs = 3 [ 7 7 8 ]
>     Packet Size = 388
>     Momentary freq = 48000 Hz (0x30.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
>

Thanks again for your help.
n.
Reply | Threaded
Open this post in threaded view
|

Re: Resampling audio from 88200 to 96000 samples per second

Tim-Philipp Müller-2
On Fri, 2012-11-23 at 11:02 -0800, Nick wrote:

> I've tried the following:
>
> % gst-launch-0.10 filesrc location=Song.flac ! decodebin2 ! audioconvert !
> audioresample ! alsasink, device=hw:0,0 -v
>
> It produces sound but still at 48000 Hz rather than the desired 96000 Hz.
>
> One thing that puzzles me is how the pipeline knows that the output should
> be 96000 samples/sec.  I tried many things:

Sorry, what I actually meant was:

Try:  ... ! decodebin2 ! audioconvert ! audioresample !
audio/x-raw-int,rate=96000 ! alsasink ...

Cheers
 -Tim

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Resampling audio from 88200 to 96000 samples per second

Nick
Tim-Philipp Müller-2 wrote
Sorry, what I actually meant was:

Try:  ... ! decodebin2 ! audioconvert ! audioresample !
audio/x-raw-int,rate=96000 ! alsasink ...
Yes, the following command:

% gst-launch-0.10 filesrc location=Song.flac .flac ! decodebin2 ! audioconvert ! audioresample,quality=10 ! audio/x-raw-int,rate=96000 ! alsasink

correctly selects "Altset 2" at 96000 Hz.  This resolves my issue.  Thanks!!

PS: (In case someone in the future is having a similar issue), be advised that I had to add the following to my /etc/asound.conf file:

"""
pcm.!default {
        type hw
        card 0
}

ctl.!default {
        type hw
        card 0
}
"""
... and then restart ALSA.  I had no success with the ... ! alsasink,device="..." syntax.


Reply | Threaded
Open this post in threaded view
|

Re: Resampling audio from 88200 to 96000 samples per second

Tim-Philipp Müller-2
On Fri, 2012-11-23 at 12:33 -0800, Nick wrote:

> I had no success with the ... ! alsasink,device="..." syntax.

That's possibly because of the comma. It should be:

 ... ! alsasink device=hw:1,0 foo=bar et=cetera

Cheers
 -Tim

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Resampling audio from 88200 to 96000 samples per second

solomon
Hi does anybody know if gstreamer can be use for music aggregation?


From: Tim-Philipp Müller <[hidden email]>
To: [hidden email]
Sent: Friday, November 23, 2012 1:44 PM
Subject: Re: Resampling audio from 88200 to 96000 samples per second

On Fri, 2012-11-23 at 12:33 -0800, Nick wrote:

> I had no success with the ... ! alsasink,device="..." syntax.

That's possibly because of the comma. It should be:

... ! alsasink device=hw:1,0 foo=bar et=cetera

Cheers
-Tim

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel