[examples] Review audio examples audio_raw_stream(split) and audio_sound_loading to add more clarity
#5350
+260
−38
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.
Review audio examples to provide more clarity
I was encountering many time-consuming audio specification issues in my own tests and so I thought things could be improved documentation-wise in this area. My idea is simply updating the following examples to be a little more clear/expressive with how
raudio.cworks, especially in relation to theUpdaterelated functions.NOTE: the main diff for this reviewing this PR is:b3c2518 because it allows you to see how the original
audio_raw_streamwas updated after it was COPIED/SPLIT for both manual and callbacks variations.audio_raw_stream: (manual) diff with originalmanualand thecallbackinto two separate examplescallbackandmanual(manual resulted in an octave pitch higher than callback version):waveLength = (int)(22050/frequency);towaveLength = (int)(stream.sampleRate/frequency);<- this will use44100viasampleRateaudio_raw_stream_callback: diff with originalaudio_sound_loadingUpdateSoundanywhere in the raylib codebase, so I added a simple reversal effect using that function in the existingaudio_load_soundexample. If this is inappropriate then perhapsUpdateSoundas a function should be removed from raudio? as it is never used and just callsStopAudioBufferandmemcpy(which is very different behavior than something likeUpdateAudioStream, and AudioProcessors take care of all the sort of effects you can do on sounds anyways i believe)Soundalways setting stream specifications 'sampleSizeto32`, and channels as stereo, so I also thought it would be helpful to have this example for showing that updating sound you need to also always match those specs between any scratch data you want to work withsampleSize(code refs)LoadSoundFromWave32 sampleSizeraudio.cAUDIO_DEVICE_FORMAT32config.hAUDIO_DEVICE_FORMAT32LoadSoundFromWavereturnchannelsas stereoraudio.cAUDIO_DEVICE_CHANNELS2config.hAUDIO_DEVICE_CHANNELS2Also since it provides really simple opportunity to demonstrate how strict the
Soundstreams are, I believe it is appropriate to add to this bare mininum load sound example, rather than try to add it somewhere else.