How to generate 2 audio tones and map to specific channel positions (bitmask)

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

How to generate 2 audio tones and map to specific channel positions (bitmask)

Nick_law
Really struggling to work out how one would generate 2 audiotestsrc and then
map/duplicate them to multiple channels.

i.e
a sine wave on channel 1,3
a sawtooth on channel 2,4

or
a sine wave on channel 1,4
a sawtooth on channel 2,3

Here there are 4 channels (but 5 would also be good):

My working example of generating two tones is below:

gst-launch-1.0 interleave name=i  \
audiotestsrc wave=0 freq=100 volume=0.4 ! decodebin ! audioconvert !  \
"audio/x-raw,format=S16BE,channels=1,channel-mask=(bitmask)0x1" ! queue !
i.sink_0  \
audiotestsrc wave=2 freq=100 volume=0.4 ! decodebin ! audioconvert !  \
"audio/x-raw,format=S16BE,channels=1,channel-mask=(bitmask)0x1" ! queue !
i.sink_1  \
i.src ! capssetter
caps="audio/x-raw,format=S16BE,channels=6,channel-mask=(bitmask)0x3f"  \
! audioconvert ! audioresample ! wavenc ! filesink location=test.wav

I though that setting the bitmask for each source and channels (0xa and 0x5)
would allow gstreamer to populate the correct amount of channels and the
correct signals mapped but alas no go: What I tried was:

gst-launch-1.0 interleave name=i  \
audiotestsrc wave=0 freq=100 volume=0.4 ! decodebin ! audioconvert !  \
"audio/x-raw,format=S16BE,channels=2,channel-mask=(bitmask)0xA" ! queue !
i.sink_0  \
audiotestsrc wave=2 freq=100 volume=0.4 ! decodebin ! audioconvert !  \
"audio/x-raw,format=S16BE,channels=2,channel-mask=(bitmask)0x5" ! queue !
i.sink_1  \
i.src ! capssetter
caps="audio/x-raw,format=S16BE,channels=4,channel-mask=(bitmask)0xf"  \
! audioconvert ! audioresample ! wavenc ! filesink location=test.wav

but I get
WARNING: erroneous pipeline: could not link queue0 to i

I also tried setting the tone channels to 4 with the same bitmask

I have also tried an audio convert after i.sink_0 and i.sink_1 also with no
luck.

Is this even possible? Any help would be much appreciated.



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

Re: How to generate 2 audio tones and map to specific channel positions (bitmask)

Chris Wine
Something like this might work for you:

gst-launch-1.0 \
  interleave name=i ! wavenc ! filesink location=test.wav \
  audiotestsrc wave=0 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i. \
  audiotestsrc wave=2 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i. \
  audiotestsrc wave=0 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i. \
  audiotestsrc wave=2 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i.

it's just using 4 different audiotestsrc elements, and with the capsfilters, force them to produce mono audio which gets interlaced into 1 stream before being written to the file. Right now, this will run infinitely, so you might want to set the num-buffers property on the audiotestsrc elements to limit them.

--Chris

On Thu, Jan 14, 2021 at 6:03 AM Nick_law <[hidden email]> wrote:
Really struggling to work out how one would generate 2 audiotestsrc and then
map/duplicate them to multiple channels.

i.e
a sine wave on channel 1,3
a sawtooth on channel 2,4

or
a sine wave on channel 1,4
a sawtooth on channel 2,3

Here there are 4 channels (but 5 would also be good):

My working example of generating two tones is below:

gst-launch-1.0 interleave name=i  \
audiotestsrc wave=0 freq=100 volume=0.4 ! decodebin ! audioconvert !  \
"audio/x-raw,format=S16BE,channels=1,channel-mask=(bitmask)0x1" ! queue !
i.sink_0  \
audiotestsrc wave=2 freq=100 volume=0.4 ! decodebin ! audioconvert !  \
"audio/x-raw,format=S16BE,channels=1,channel-mask=(bitmask)0x1" ! queue !
i.sink_1  \
i.src ! capssetter
caps="audio/x-raw,format=S16BE,channels=6,channel-mask=(bitmask)0x3f"  \
! audioconvert ! audioresample ! wavenc ! filesink location=test.wav

I though that setting the bitmask for each source and channels (0xa and 0x5)
would allow gstreamer to populate the correct amount of channels and the
correct signals mapped but alas no go: What I tried was:

gst-launch-1.0 interleave name=i  \
audiotestsrc wave=0 freq=100 volume=0.4 ! decodebin ! audioconvert !  \
"audio/x-raw,format=S16BE,channels=2,channel-mask=(bitmask)0xA" ! queue !
i.sink_0  \
audiotestsrc wave=2 freq=100 volume=0.4 ! decodebin ! audioconvert !  \
"audio/x-raw,format=S16BE,channels=2,channel-mask=(bitmask)0x5" ! queue !
i.sink_1  \
i.src ! capssetter
caps="audio/x-raw,format=S16BE,channels=4,channel-mask=(bitmask)0xf"  \
! audioconvert ! audioresample ! wavenc ! filesink location=test.wav

but I get
WARNING: erroneous pipeline: could not link queue0 to i

I also tried setting the tone channels to 4 with the same bitmask

I have also tried an audio convert after i.sink_0 and i.sink_1 also with no
luck.

Is this even possible? Any help would be much appreciated.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

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

Re: How to generate 2 audio tones and map to specific channel positions (bitmask)

Nick_law
Chris Wine wrote

> Something like this might work for you:
>
> gst-launch-1.0 \
>   interleave name=i ! wavenc ! filesink location=test.wav \
>   audiotestsrc wave=0 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i. \
>   audiotestsrc wave=2 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i. \
>   audiotestsrc wave=0 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i. \
>   audiotestsrc wave=2 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i.
>
> it's just using 4 different audiotestsrc elements, and with the
> capsfilters, force them to produce mono audio which gets interlaced into 1
> stream before being written to the file. Right now, this will run
> infinitely, so you might want to set the num-buffers property on the
> audiotestsrc elements to limit them.
>
> --Chris


I am actually currently doing this but I think this is not the most
efficient way?

For example I may create 25 channel audio that may play a filesrc on some
channels, and audiotst src on others.

My thinking it will require less computation to create a few sources and
duplicate them accordingly rather than recreating each source multiple
times.



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

Re: How to generate 2 audio tones and map to specific channel positions (bitmask)

Chris Wine
Ok, I see. You probably don't need to worry about the performance too much of the audio generation, unless you're really resource constrained, nevertheless, you can use the tee element to use the generated source multiple times:

gst-launch-1.0 \
  interleave name=i ! wavenc ! filesink location=test.wav \
  audiotestsrc wave=0 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! tee name=t1 \
  audiotestsrc wave=2 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! tee name=t2 \
  t1. ! queue ! i. \
  t2. ! queue ! i. \
  t1. ! queue ! i. \
  t2. ! queue ! i.


On Thu, Jan 14, 2021 at 9:11 PM Nick_law <[hidden email]> wrote:
Chris Wine wrote
> Something like this might work for you:
>
> gst-launch-1.0 \
>   interleave name=i ! wavenc ! filesink location=test.wav \
>   audiotestsrc wave=0 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i. \
>   audiotestsrc wave=2 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i. \
>   audiotestsrc wave=0 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i. \
>   audiotestsrc wave=2 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! i.
>
> it's just using 4 different audiotestsrc elements, and with the
> capsfilters, force them to produce mono audio which gets interlaced into 1
> stream before being written to the file. Right now, this will run
> infinitely, so you might want to set the num-buffers property on the
> audiotestsrc elements to limit them.
>
> --Chris


I am actually currently doing this but I think this is not the most
efficient way?

For example I may create 25 channel audio that may play a filesrc on some
channels, and audiotst src on others.

My thinking it will require less computation to create a few sources and
duplicate them accordingly rather than recreating each source multiple
times.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

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

Re: How to generate 2 audio tones and map to specific channel positions (bitmask)

Nick_law
Chris Wine wrote

> Ok, I see. You probably don't need to worry about the performance too much
> of the audio generation, unless you're really resource constrained,
> nevertheless, you can use the tee element to use the generated source
> multiple times:
>
> gst-launch-1.0 \
>   interleave name=i ! wavenc ! filesink location=test.wav \
>   audiotestsrc wave=0 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! tee
> name=t1 \
>   audiotestsrc wave=2 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! tee
> name=t2 \
>   t1. ! queue ! i. \
>   t2. ! queue ! i. \
>   t1. ! queue ! i. \
>   t2. ! queue ! i.

Thanks Chris this is exactly the kind of thing I'm looking for.
Please excuse my ignorance but not sure how to then link i (i.src) to
complete the command and generate a wav.

gst-launch-1.0
interleave name=i ! wavenc ! filesink location=test.wav
audiotestsrc wave=0 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! tee
name=t1
audiotestsrc wave=2 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! tee
name=t2
t1. ! queue ! i.
t2. ! queue ! i.
t1. ! queue ! i.
t2. ! queue ! i.
i.src ! capssetter
caps="audio/x-raw,format=S16BE,channels=4,channel-mask=(bitmask)0xf"
! audioconvert ! audioresample ! wavenc ! filesink location=test.wav

gives the error:
WARNING: erroneous pipeline: could not link i to capssetter0

what am I missing?



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

Re: How to generate 2 audio tones and map to specific channel positions (bitmask)

Nick_law
This post was updated on .
Sorry I see the issue, just the order of linking the interleave, you do that
first while I do it last.

here is my working solution for future readers:

gst-launch-1.0 interleave name=i \
audiotestsrc wave=0 freq=100 volume=0.4 ! decodebin ! audioconvert ! \
"audio/x-raw,format=S16BE,channels=1" ! tee name=t1 \
audiotestsrc wave=2 freq=100 volume=0.4 ! decodebin ! audioconvert ! \
"audio/x-raw,format=S16BE,channels=1" ! tee name=t2 \
t1. ! queue ! i. \
t2. ! queue ! i. \
t1. ! queue ! i. \
t2. ! queue ! i. \
i.src ! capssetter
caps="audio/x-raw,format=S16BE,channels=4,channel-mask=(bitmask)0xf" \
! audioconvert ! audioresample ! wavenc ! filesink location=test.wav

Thanks so much Chris!

Nick_law wrote
> Thanks Chris this is exactly the kind of thing I'm looking for.
> Please excuse my ignorance but not sure how to then link i (i.src) to
> complete the command and generate a wav.
>
> gst-launch-1.0
> interleave name=i ! wavenc ! filesink location=test.wav
> audiotestsrc wave=0 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! tee
> name=t1
> audiotestsrc wave=2 freq=100 volume=0.4 ! audio/x-raw,channels=1 ! tee
> name=t2
> t1. ! queue ! i.
> t2. ! queue ! i.
> t1. ! queue ! i.
> t2. ! queue ! i.
> i.src ! capssetter
> caps="audio/x-raw,format=S16BE,channels=4,channel-mask=(bitmask)0xf"
> ! audioconvert ! audioresample ! wavenc ! filesink location=test.wav
>
> gives the error:
> WARNING: erroneous pipeline: could not link i to capssetter0
>
> what am I missing?





--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel