Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

play multiple raw PCM to multiple a2dp sbc sink device #5

Open
mdionisio opened this issue Sep 7, 2016 · 3 comments
Open

play multiple raw PCM to multiple a2dp sbc sink device #5

mdionisio opened this issue Sep 7, 2016 · 3 comments

Comments

@mdionisio
Copy link

I'm reading the documentation and the test demo but I don't undestant if it is possible to:

  1. have 1 media endpoint and connect to it 2 sink device to play same stream on 2 device ?
  2. have 2 media endpoint and connect to each one 1 sink device to play 2 different stream on 2 different device

is it possible to do that?

@liamw9534
Copy link
Owner

Hi,

A media endpoint is just a file descriptor with some SBC encoding/decoding
behind it. Ultimately each stream is represented as PCM audio samples
which you can do whatever you want with in the Python application code.

If you want to combine multiple PCM audio streams then you could implement
a digital audio mixer to combine them into a single raw PCM stream:

"Mixing audio samples means adding them together, that's all. Typically
you do add them into a larger data type so that you can detect overflow and
clamp the values before casting back into your destination buffer. If you
know beforehand that you will have overflow then you can scale their
amplitudes prior to addition - simply multiply by a floating point value
between 0 and 1, again keeping in mind the issue of precision, perhaps
converting to a larger data type first."

Once you've combined them, then you can write them to the destination media
endpoint.

If you want to pipe a single audio stream to two separate sinks then just
write each audio sample to each of the encoder file descriptors.

Both use-cases are eminently possible. I suggest looking at the demo.py
code to see how the underlying audio data is passed around. Ultimately,
the data manifests as raw PCM audio by either reading or writing a
transport file descriptor.

Liam.

On 7 September 2016 at 14:03, Michele Dionisio notifications@github.com
wrote:

I'm reading the documentation and the test demo but I don't undestant if
it is possible to:

  1. have 1 media endpoint and connect to it 2 sink device to play same
    stream on 2 device ?
  2. have 2 media endpoint and connect to each one 1 sink device to play 2
    different stream on 2 different device

is it possible to do that?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#5, or mute the thread
https://github.com/notifications/unsubscribe-auth/AGcZTyN2w1Yj7PDwrykm4oM9ExID-p3dks5qnrYOgaJpZM4J25NX
.

@mdionisio
Copy link
Author

mdionisio commented Sep 7, 2016

I don't want to make "mixing" but only "routing".

I'm try to undestand the demo application but I have some doubs.

the documentation say:

This registers your media endpoint service handler

BT> media-sbc-source-start /endpoint/a2dpsource

so an SBCAudioSource with path /endpoint/a2dpsource is created

Speakers are nornally passive and we have to initiate the connection

for ourselves

BT> sink-connect /org/bluez/2202/hci0/dev_00_11_67_D2_AB_EE

so an BTAudioSink with path /org/bluez/2202/hci0/dev_00_11_67_D2_AB_EE is created

Now we can start playing the PCM file to the speaker

BT> media-encode /endpoint/a2dpsource a2dpstream.raw

and this is strange for me. because I don't undestand who make the connection from
/endpoint/a2dpsource to /org/bluez/2202/hci0/dev_00_11_67_D2_AB_EE

When you're done, stop the media handler and unregister the endpoint

BT> media-stop /endpoint/a2dpsink

Can you help me

@liamw9534
Copy link
Owner

Hi,

The demo code functions support only a single endpoint for source and sink
so you would have to adapt the demo code to accomplish what you wish to
achieve.

The demo code is just an illustration of the things you can do with the
underlying library functions. There is nothing to stop you from modifying
the demo code to do things differently.

You really can't route two sources to a single sink without mixing because
the transport file descriptor for the sink expects a single PCM audio
stream.

Liam.

On 7 September 2016 at 17:27, Michele Dionisio notifications@github.com
wrote:

I don't want to make "mixing" but only "routing".

I'm try to undestand the demo application but I have some doubs.

the documentation say:

This registers your media endpoint service handler

BT> media-sbc-source-start /endpoint/a2dpsource
so an SBCAudioSource with path /endpoint/a2dpsource is created
Speakers are nornally passive and we have to initiate the connection for
ourselves

BT> sink-connect /org/bluez/2202/hci0/dev_00_11_67_D2_AB_EE
so an BTAudioSink with path /org/bluez/2202/hci0/dev_00_11_67_D2_AB_EE is
created

Now we can start playing the PCM file to the speaker

BT> media-encode /endpoint/a2dpsource a2dpstream.raw
and this is strange for me. because I don't undestand who make the
connection from
/endpoint/a2dpsource to /org/bluez/2202/hci0/dev_00_11_67_D2_AB_EE
When you're done, stop the media handler and unregister the endpoint

BT> media-stop /endpoint/a2dpsink

Can you help me


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#5 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGcZT1qTPXwx8TrHRvtsJPUAnNPFTF2Pks5qnuX-gaJpZM4J25NX
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants