GithubHelp home page GithubHelp logo

Comments (9)

Arika-Lei avatar Arika-Lei commented on July 2, 2024

l stop the bluealsa-aplay service, capture is OK!
But when l replay the recorded audio file, it sounds like...fast forward?
(Music on the phone has played almost 20 seconds, recorded file is just 2 seconds)

from bluez-alsa.

borine avatar borine commented on July 2, 2024

l didn't setup my local .asoundrc file and it is empty in my asound.conf

Those files are not necessary, and it is usually easier to debug without them, so that is OK.

But when l replay the recorded audio file, it sounds like...fast forward?

If you have the ffmpeg package installed, please post the output of

ffprobe -hide_banner test.wav

or if not, then the output of

file test.wav
ls -l test.wav

where test.wav is the file created by

arecord -D bluealsa:DEV=A4:CC:B3:7C:24:27 -f S16_le -c 2 -r 44100 test.wav

from bluez-alsa.

Arika-Lei avatar Arika-Lei commented on July 2, 2024

It's very nice of you to reply so fast.

that is the result of the command:
root@raspberrypi:/home/pi# file test.wav
test.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz

root@raspberrypi:/home/pi# ls -l test.wav
-rw-r--r-- 1 root root 5644332 Jun 18 09:39 test.wav

root@raspberrypi:/home/pi# ffprobe -hide_banner test.wav
[wav @ 0x55a7f5beb0] Estimating duration from bitrate, this may be inaccurate
Input #0, wav, from 'test.wav':
Duration: 00:00:32.00, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s

and that is the process:
root@raspberrypi:/home/pi# arecord -D bluealsa:DEV=A4:CC:B3:7C:24:27 -f S16_le -c 2 -r 44100 test.wav
[2381] D: ../../../src/asound/bluealsa-pcm.c:1473: Getting BlueALSA PCM: CAPTURE A4:CC:B3:7C:24:27 a2dp
[2381] D: ../../../src/asound/bluealsa-pcm.c:1222: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Setting constraints
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
[2381] D: ../../../src/asound/bluealsa-pcm.c:561: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Initializing HW
[2381] D: ../../../src/asound/bluealsa-pcm.c:600: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: FIFO buffer size: 16384 frames
[2381] D: ../../../src/asound/bluealsa-pcm.c:605: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Selected HW buffer: 4 periods x 22048 bytes <= 88200 bytes
[2381] D: ../../../src/asound/bluealsa-pcm.c:636: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Initializing SW
[2381] D: ../../../src/asound/bluealsa-pcm.c:636: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Initializing SW
[2381] D: ../../../src/asound/bluealsa-pcm.c:677: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Prepared
[2381] D: ../../../src/asound/bluealsa-pcm.c:636: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Initializing SW
[2381] D: ../../../src/asound/bluealsa-pcm.c:388: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Starting
[2383] D: ../../../src/asound/bluealsa-pcm.c:231: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Starting IO loop: 7
^CAborted by signal Interrupt...
arecord: pcm_read:2221: read error: Interrupted system call
[2381] D: ../../../src/asound/bluealsa-pcm.c:424: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Stopping
[2383] D: ../../../src/asound/bluealsa-pcm.c:167: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: IO thread cleanup
[2381] D: ../../../src/asound/bluealsa-pcm.c:615: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Freeing HW
[2381] D: ../../../src/asound/bluealsa-pcm.c:471: /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source: Closing

from bluez-alsa.

borine avatar borine commented on July 2, 2024

arecord always writes a WAV file header of 44 bytes (i.e. no content metadata), followed by the PCM audio frames. So your file contains (5644332 - 44) bytes of audio frames.

The frame size for 2ch s16_le is 4 bytes, so your file contains ((5644332 - 44) / 4) PCM frames.

So, sampled at 44100 frames per second, your file contains 32 seconds of audio.

I can only assume that your playback application is playing it at the wrong speed if it is only taking 2 seconds to play it!

from bluez-alsa.

Arika-Lei avatar Arika-Lei commented on July 2, 2024

l'm sorry for that l had a new record today. The playback application also displays almost 32 seconds, but actually l have played maybe 1m10s on my phone. l have played the 32 seconds audio file, and the speed looks like fast->normal->fast...
l cannot say the exact playtime now because l have broken the environment...

Today l tried to install bluez-alsa from Github, so l remove the 'bluez-alsa-utils' from Debian.
After l installed FDK-AAC from Github, l tried the following steps:

download the current code
git clone https://github.com/Arkq/bluez-alsa.git
cd bluez-alsa

configure build environment only after all dependencies are done
autoreconf --install --force
mkdir build
cd build

based on existing Moode build scripts with aac enabled
../configure --disable-hcitop --with-alsaplugindir=/usr/lib/arm-linux-gnueabihf/alsa-lib --enable-aac

compile and install
make
sudo make install

reboot and test
sudo reboot

Problem
root@raspberrypi:/home/pi# sudo systemctl enable bluealsa.service
Failed to enable unit: Unit file bluealsa.service does not exist.
root@raspberrypi:/home/pi# sudo systemctl enable bluealsa-aplay.service
Failed to enable unit: Unit file bluealsa-aplay.service does not exist.
root@raspberrypi:/home/pi# sudo systemctl start bluealsa.service
Failed to start bluealsa.service: Unit bluealsa.service not found.

l cannot start the bluealsa.service and bluealsa-aplay.service :(

Additional context
First command l tried:
root@raspberrypi:/home/pi# ls /usr/lib/arm-linux-gnueabihf/alsa-lib
libasound_module_ctl_bluealsa.a libasound_module_pcm_bluealsa.a
libasound_module_ctl_bluealsa.la libasound_module_pcm_bluealsa.la
libasound_module_ctl_bluealsa.so libasound_module_pcm_bluealsa.so

Second command l tried:
root@raspberrypi:/home/pi# sudo bluealsa -i hci0 -p a2dp-source -p a2dp-sink
bluealsa: W: UUID already registered in BlueZ [hci0]: 0000110A-0000-1000-8000-00805F9B34FB
bluealsa: W: UUID already registered in BlueZ [hci0]: 0000110B-0000-1000-8000-00805F9B34FB

Third command l tried:
root@raspberrypi:/home/pi# sudo systemctl daemon-reload

Forth command l tried:
root@raspberrypi:/home/pi# ls /usr/lib/systemd/system/bluealsa.service
ls: cannot access '/usr/lib/systemd/system/bluealsa.service': No such file or directory
root@raspberrypi:/home/pi# ls /etc/systemd/system/bluealsa.service
ls: cannot access '/etc/systemd/system/bluealsa.service': No such file or directory

Fifth command l tried:
root@raspberrypi:/home/pi# service --status-all
[ - ] alsa-utils
[ - ] apparmor
[ + ] bluetooth
[ - ] console-setup.sh
[ + ] cron
[ + ] cups
[ + ] cups-browsed
[ + ] dbus
[ + ] dphys-swapfile
[ + ] fake-hwclock
[ - ] fio
[ - ] hwclock.sh
[ - ] keyboard-setup.sh
[ + ] kmod
[ + ] lightdm
[ + ] networking
[ - ] nfs-common
[ - ] plymouth
[ + ] plymouth-log
[ + ] procps
[ + ] raspi-config
[ - ] rpcbind
[ - ] rsync
[ - ] saned
[ + ] ssh
[ - ] sudo
[ + ] triggerhappy
[ + ] udev
[ - ] x11-common

Setup
the version of BlueALSA (bluealsa --version): v4.2.0-16-gdd85a7b
the version of BlueZ (bluetoothd --version): 5.66
the version of ALSA (aplay --version): version 1.2.8

from bluez-alsa.

borine avatar borine commented on July 2, 2024

based on existing Moode build scripts

You have not said what OS you are using, but if you are using Moode then please seek help from the Moode maintainers - from what you have said above it appears that Moode does not use the BlueALSA systemd unit files; I guess they must use their own, so you will have to make sure you have them installed.

If you are not using Moode, then its probably best not to use their build scripts because they are clearly specialized for the Moode environment. Instead, follow the guidance on the wiki - the configure options for using systemd are explained there. If you need AAC support I suggest you try

../configure --enable-systemd --enable-aac 

... and also, please make sure you do not have pulseaudio or pipewire running.

from bluez-alsa.

Arika-Lei avatar Arika-Lei commented on July 2, 2024

The OS l am using is Raspberry Pi 4 64bit under Debian. l was not aware that l had used another environment (till today l get to know what Moode is).
Fortunately, l follow the right way, bluealsa starts again, and has AAC, aptX, LDAC installed!
(../configure --enable-systemd --enable-aac --enable-aptx --with-libopenaptx --enable-aptx-hd --enable-ldac)

Available BT audio codecs:
a2dp-source: SBC, AAC, aptX, aptX-HD, LDAC
a2dp-sink: SBC, AAC, aptX, aptX-HD
hfp-*: CVSD

Unfortunately, the same problem happens again, AAC is much better than SBC, fast foward just sometimes happened.
(root@raspberrypi:/home/pi# arecord -D bluealsa:DEV=A4:CC:B3:7C:24:27 -f S16_le -c 2 -r 44100 test.wav)
SBC: phone played likely 1min, record file is 8 seconds, and the file size is 1455212
AAC: phone played likely 1min, record file is 38 seconds, and the file size is 6879020

Maybe the better codec, the better record? l have no ideas...
Although l have setup aptX, apX-HD, it doesn't work when l choose Qualcomm aptX or aptX-HD on my phone. (No capture device)

l will keep trying...

from bluez-alsa.

Arika-Lei avatar Arika-Lei commented on July 2, 2024

root@raspberrypi:/home/pi# ../configure --enable-systemd --enable-aac --enable-aptx --with-libopenaptx --enable-aptx-hd --enable-ldac --enable-cli --with-systemdbluealsaargs="-S -p a2dp-source -p a2dp-sink -c ldac -c aptx -c aptx-hd"

l try to configure like that, but aptx or ldac is still not effective

root@raspberrypi:/home/pi# bluealsa-cli info /org/bluealsa/hci0/dev_A4_CC_B3_7C_24_27/a2dpsnk/source
Device: /org/bluez/hci0/dev_A4_CC_B3_7C_24_27
Sequence: 2
Transport: A2DP-sink
Mode: source
Running: false
Format: S16_LE
Channels: 2
Sampling: 44100 Hz
Available codecs: SBC AAC
Selected codec: SBC
Delay: 15.0 ms
DelayAdjustment: 0.0 ms
SoftVolume: true
Volume: L: 127 R: 127
Muted: L: false R: false

It seems like my phone doesn't have the ability of aptx and ldac, so l need to find other ways to solve the input stream.

from bluez-alsa.

Arika-Lei avatar Arika-Lei commented on July 2, 2024

l try to set my RPI 4's WIFI from 2.4GHz to 5GHz, and then everything becomes OK. l have no ideas about the relationship between the RPI 4's WIFI and the Bluetooth capture.

from bluez-alsa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.