Skip to content

[raudio] Support basic capture streaming to speakers#5913

Open
Q-Wa-Ha wants to merge 3 commits into
raysan5:masterfrom
Q-Wa-Ha:Basic-Audio-Capture
Open

[raudio] Support basic capture streaming to speakers#5913
Q-Wa-Ha wants to merge 3 commits into
raysan5:masterfrom
Q-Wa-Ha:Basic-Audio-Capture

Conversation

@Q-Wa-Ha

@Q-Wa-Ha Q-Wa-Ha commented Jun 8, 2026

Copy link
Copy Markdown

This commit introduces basic streaming from a capture source (e.g. a microphone) to the device speakers. The playback format was changed from ma_format_f32 to ma_format_s32 to support capturing audio.

Hopefully this commit can be a basis for future capture-related functionality

Note: I have tested this on Windows, macOS, and Linux.

This commit introduces basic streaming from a capture source (e.g. a
microphone) to the device speakers. The playback format was changed from
ma_format_f32 to ma_format_s32 to support capturing audio.
@Q-Wa-Ha Q-Wa-Ha changed the title Support basic capture streaming to speakers [raudio] Support basic capture streaming to speakers Jun 8, 2026
Comment thread src/raudio.c Outdated
//----------------------------------------------------------------------------------
#ifndef AUDIO_DEVICE_FORMAT
#define AUDIO_DEVICE_FORMAT ma_format_f32 // Device output format (float-32bit)
#define AUDIO_DEVICE_FORMAT ma_format_s32 // Device output format (signed-32bit)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a potentially breaking change for many raylib users, did you consider that?

@Q-Wa-Ha Q-Wa-Ha Jun 8, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested audio playback and it appears to be just the same as before. I found that recording audio and playing audio from the same device only works properly with this format. However, if changing the audio format will cause breaking changes, I may be able to revert the audio device back to its original format and playback-only mode and create a secondary device with the new format in capture-only mode. Then convert between formats when playing from the capture device to the playback device.

@raysan5 raysan5 added the new feature This is an addition to the library label Jun 9, 2026
@Q-Wa-Ha

Q-Wa-Ha commented Jun 10, 2026

Copy link
Copy Markdown
Author

I played around with the original f32 format some more and I think the issue I was originally having that caused me to change formats was with my own hardware. I was able to change the format back and leave the rest of the code alone, so hopefully there should be no more breaking changes.

Note: There does seem to be an issue where the microphone output is being panned to one side only (and this has nothing to do with formats). I can try to fix this in a future PR, unless you would prefer it done now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature This is an addition to the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants