[raudio] Audio recording#5941
Open
jn-jairo wants to merge 2 commits into
Open
Conversation
|
|
||
| InitAudioDevice(); | ||
| InitAudioRecordingDevice(); | ||
| // InitAudioRecordingDeviceEx(24000, 16, 1); |
Contributor
Author
There was a problem hiding this comment.
It's an example of an alternative method to initialize the audio recording device.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds basic audio recording.
Notes:
InitAudioRecordingDevice()uses defines for config (the same one from playback)InitAudioRecordingDeviceEx()uses custom sampleRate, sampleSize and channelsSetAudioRecordingCallback()AudioRecordingCallbackcallback instead of usingAudioCallbackbecause the input data isconst void *instead of thevoid *of the output and the compiler was showing a warning, if it's ok to useAudioCallbackand ignore the warning I can change itGetAudioRecordingSampleRate(),GetAudioRecordingSampleSize()andGetAudioRecordingChannels()because it is needed to process the data as shown in the exampleStartAudioRecording()andStopAudioRecording()use thema_device_start()andma_device_stop(), so the capture device is not always running like the playback one, and the recording status is if the device is startedThis interface is the simplest I got that enables all use cases I could imagine.
In games audio recording is mainly for voice chat and a stream of data is all you need.
For other softwares like audio recording/editing, you would need to be able to set the sample rate and so on at runtime, that is why I added this option, and creating a wave is trivial if you have the stream of data like shown in the example, so we don't need to have it builtin in raylib.
Please let me know if there is anything I need to change. I tested in Linux (kubuntu 24.04) with zig and make, I didn't commit the changes in the makefile because I believe there is a
rexmto manage that but it is crashing when I try to add the example.