-
Notifications
You must be signed in to change notification settings - Fork 67
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
Android: Switch AudioTrack to the AudioFormat.ENCODING_PCM_16BIT #179
Conversation
- removes clipping - makes louder
1) deals with ESP32 ADC reference voltage variation 2) 16 bit i2s transfers
As some devices have broken PCM8 support
Please merge the latest changes in main into this and resolve any conflicts. The Android app DB has changed schema, so I can't easily install this to test it (my devices are using the new schema). |
@VanceVagell merged |
I'm hearing audio artifacts as of this PR, please see attached test video. Listen at 0:16, 0:17, and 0:24. There is some popping. It was subtle in that recording, but earlier I was hearing a lot of popping when first testing this. Reminds me of small buffer underruns, but not 100% sure that's what this is. (Note that I merged with the latest in main again to test this, which adds UHF support. Please merge on your side as well.) screen-20250120-221459.mp4 |
I retested on main without your PR and I still hear the clicking, so it's unrelated, was just a red herring. Please merge once more and I think we're good to finalize this PR. |
|
@VanceVagell re-merged and tested. Seems ok to me.
in java it is better to do:
to be null safe (it would not help in this particular case, though) this is null safe for this case:
|
This PR makes two key changes to improve audio playback and handling:
AudioTrack
to useAudioFormat.ENCODING_PCM_16BIT
for better device compatibility.int8_t
to address issues with Android USB drivers.Rationale
Some devices don’t support PCM 8-bit , as documented [here](https://developer.android.com/reference/android/media/AudioFormat#ENCODING_PCM_8BIT). Switching to PCM 16-bit ensures consistent playback across devices.
Android USB drivers can add zeros to audio chunks ([issue](Missing/Corrupt data with high baud rates. mik3y/usb-serial-for-android#599)). Using
int8_t
, where0
represents silence, minimizes audio artifacts caused by this bug.