Skip to content
This repository has been archived by the owner on Oct 24, 2021. It is now read-only.

Information about playing audio on DS4 #123

Open
a1ien opened this issue Jun 1, 2016 · 16 comments
Open

Information about playing audio on DS4 #123

a1ien opened this issue Jun 1, 2016 · 16 comments

Comments

@a1ien
Copy link

a1ien commented Jun 1, 2016

I have some research to be able playing audio on DS4.
Audio data send by opcode 0x14, 0x15, 0x17, 0x19.
And code by SBC audio codec.
I used this python script to wrap the audio data
play.py
This script was written to run on Linux, he takes the SBC audio data and send it to DS4
You can use gstreamer to prepare audio data.
gst-launch-1.0 -q audiotestsrc ! sbcenc ! 'audio/x-sbc,channels=2,rate=32000,channel-mode=dual,blocks=16,subbands=8,bitpool=25' ! queue ! fdsink | ./play.py
But there is a small problem, periodically occur stuttering.
But it may be caused by improper operation with HID device. Perhaps under Windows
such problems will not
I hope this helps to add audio support.

@a1ien
Copy link
Author

a1ien commented Jun 5, 2016

And small addition
If add is-live=true to audiotestsrc
gst-launch-1.0 -q audiotestsrc is-live=true ! sbcenc ....
Stuttering becomes much less
And useful pipeline to play all output to DS4
gst-launch-1.0 -q pulsesrc device="alsa_output.pci-0000_00_1b.0.analog-stereo.monitor" ! queue ! audioresample ! 'audio/x-raw,rate=32000' ! audioconvert ! sbcenc ! 'audio/x-sbc,channels=2,rate=32000,channel-mode=dual,blocks=16,subbands=8,bitpool=25' ! queue ! fdsink | ./play.py
To get device name u can use
pacmd list-sources | grep -e device.string -e 'name:'

@OscBacon
Copy link

OscBacon commented Jun 6, 2016

Hi,
I tried to test your script on Windows, after connecting my DS4 through bluetooth, but I get the following error:

Traceback (most recent call last):
File "D:\Users[USER]\Desktop\play.py", line 7, in
hiddev = os.open("/dev/hidraw5", os.O_RDWR | os.O_NONBLOCK)
AttributeError: module 'os' has no attribute 'O_NONBLOCK'

Am I doing anything wrong?

@a1ien
Copy link
Author

a1ien commented Jun 6, 2016

This script only for Linux. And only for information about packet. For Windows need rewrite this script

@hanetzer
Copy link

hanetzer commented Jun 6, 2016

Wow, amazing. choppy as hell but it works! Huge thanks on that 👍

@Andrysky
Copy link

Andrysky commented Jun 7, 2016

I can not find SBC codec may suggest where to find it?
я не могу найти SBC кодек,можете подсказать где можно его найти?

@a1ien
Copy link
Author

a1ien commented Jun 7, 2016

Где вы пытаетесь его найти? Вы хотите найти исходный код? Или плагин для gstreamer?
Where are you trying to find? You want to find the source code? Or plugin for gstreamer?

@SiTWulf
Copy link

SiTWulf commented Jun 7, 2016

a1ien Really good JOB dude!!!!
But looks like this program is almost dead for now..

@Andrysky
Copy link

Andrysky commented Jun 7, 2016

SiTWulf why dead? I use. :)
a1ien
Я думал использовать FFmpeg но не нашел в нём СБС.
В gstreamer сейчас кажется нашел этот плагин.
Но наверное лучше найти библиотеку чтобы не тянуть весь gstreamer с собой.
I thought to use FFmpeg but found there SBS.
The gstreamer now it seems to have found this plugin.
But probably it is better to find a library that does not pull all the gstreamer with him.

@a1ien
Copy link
Author

a1ien commented Jun 7, 2016

@OsirizX
Copy link

OsirizX commented Jun 9, 2016

Nice work a1ien. We can also play mp3's and adjust volume.

gst-launch-1.0 -q filesrc location=song.mp3 ! decodebin ! audioconvert ! audioresample ! volume volume=0.5 ! sbcenc ! "audio/x-sbc,channels=2,rate=32000,channel-mode=dual,blocks=16,subbands=8,bitpool=25" ! queue ! fdsink | ./play.py

Some things I noticed when plugging headphones in. Only the left headphone speaker gives output and main controller speaker still gives out sound. Is there a way to mute main speaker and only give output to headphones?

@a1ien
Copy link
Author

a1ien commented Jun 9, 2016

Yes, you can read the discussion in this thread. It's linux driver.
And last version play.py output sound to headphones. See diff https://gist.github.com/a1ien/e8a82f71c13ae54f886fbf94f0606073/revisions

@mirh
Copy link

mirh commented Jul 17, 2016

chrippa/ds4drv#76

@zZakoN
Copy link

zZakoN commented Jul 20, 2016

Если я правильно все понял получается - Если переписать скрипт под Win, добавить библиотеку SBS кодека и вставить это все в DS4Windows то Джек на геймпаде будет (вероятно) работать. Правильно? (Я абсолютно в этом не смыслю но за этим наблюдаю)

@a1ien
Copy link
Author

a1ien commented Jul 20, 2016

Да, все правильно. Но только нужно еще написать код по захвату звука в windows. Либо собрать sbc plugin для gstreamer.

@zZakoN
Copy link

zZakoN commented Jul 21, 2016

Воу, потрясающе, удачи вам

@Stardidi
Copy link

Stardidi commented Aug 5, 2016

I am currently trying to get this working under windows, but running into several issues, especially with gst-launch. Is it possible for someone to provide a binary file of the output gst-launch delivers?

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

No branches or pull requests

9 participants