Commit Graph

302 Commits

Author SHA1 Message Date
Ray
406861a4a1 Update raudio.c 2026-02-24 12:32:48 +01:00
Ray
11e3e6e0b9 REVIEWED: Formating, tested sound examples 2026-02-21 09:09:43 +01:00
David Reid
0c91f230fd Audio: Fix a glitch at the end of a sound. (#5578)
This is happening because the processing function keeps reading audio
data from the AudioBuffer even after it has been marked as stopped.

There is also an error in ReadAudioBufferFramesInInternalFormat() where
if it is called on a stopped sound, it'll still return audio frames.
This has also been addressed with this commit.
2026-02-21 08:04:32 +01:00
David Reid
005ff74eb0 Audio: Improvements to device configuration (#5577)
* Audio: Stop setting capture config options.

Since the device is being configured as a playback device, all capture
config options are unused and therefore need to not be set.

* Audio: Stop pre-silencing the miniaudio output buffer.

raylib already manually silences the output buffer prior to mixing so
there is no reason to have miniaudio also do it. It can therefore be
disabled via the device config to make data processing slightly more
efficient.

* Audio: Stop forcing fixed sized processing callbacks.

There is no requirement for raylib to have guaranteed fixed sized
audio processing. By disabling it, audio processing can be made more
efficient by not having to run the data through an internal intermediary
buffer.

* Audio: Make the period size (latency) configurable.

The default period size is 10ms, but this is inappropriate for certain
platforms so it is useful to be able to allow those platforms to
configure the period size as required.

* Audio: Fix documentation for pan.

The pan if -1..1, not 0..1.
2026-02-21 08:02:40 +01:00
David Reid
0aacd330d4 [raudio] Remove usage of ma_data_converter_get_required_input_frame_count() (#5568)
* Audio: Remove use of ma_data_converter_get_required_input_frame_count().

This function is being removed from miniaudio. To make this work with
the current architecture of raylib it requires the use of a cache.

This commit implements a generic solution that works across all
AudioBuffer types (static, streams and callback based), but the static
case could be optimized to avoid the cache by incorporating the
functionality of ReadAudioBufferFramesInInternalFormat() into
ReadAudioBufferFramesInMixingFormat(). It would be unpractical to avoid
the cache with streams and callback-based AudioBuffers however so this
commit sticks with a generic solution.

* Audio: Correct usage of miniaudio's dynamic rate adjustment.

This affects pitch shifting. The output rate is being modified with
ma_data_converter_set_rate(), but then that value is being used in the
computation of the output rate the next time SetAudioBufferPitch() which
results in a cascade. The correct way to do this is to use an anchored
output rate as the basis for the calculation after pitch shifting. In
this case, it's the device's sample rate that acts as the anchor.

* Audio: Optimize memory usage for data conversion.

This reduces the per-AudioBuffer conversion cache from 256 PCM frames
down to 8.
2026-02-20 13:46:41 +01:00
Ray
070082f8c9 REVIEWED: Comments to impersonal format 2026-02-12 18:55:40 +01:00
Ray
29896a2403 REVIEWED: Some comments (Code Gardening) 2026-01-19 12:40:32 +01:00
Ray
0c33c603f4 REVIEWED: EXTERNAL_CONFIG_FLAGS usage, check moved to config.h
Due to `utils` module removal, `EXTERNAL_CONFIG_FLAGS` was not working, so the system was redesigned.
This change is independent of #4411
2026-01-12 13:04:38 +01:00
Ray
dd7a1948f1 WARNING: REDESIGN: REMOVED: utils module, functionality moved to rcore module: logging and file-system #4551
[utils] was created long time ago, when [rcore] contained all the platforms code, the purpose of the file was exposing basic filesystem functionality across modules and also logging mechanism but many things have changed since then and there is no need to keep using this module.

 - Logging system has been move to [rcore] module and macros are exposed through `config.h` to other modules
 - File system functionality has also been centralized in [rcore] module that along the years it was already adding more and more file-system functions, now they are all in the same module
 - Android specific code has been moved to `rcore_android.c`, it had no sense to have specific platform code in `utils`, [rcore] is responsible of all platform code.
2026-01-10 12:13:07 +01:00
Marcos Paccor
16e6d325b9 [raudio] Fix freeing the wrong memory (#5481) 2026-01-08 22:04:09 +01:00
Ray
416af51a93 Update year to 2026 2026-01-02 13:40:15 +01:00
Ray
909f040dc5 Remove trailing spaces 2026-01-01 16:33:34 +01:00
Ray
b465b4e2ea RENAMED: Variable names for consistency, textLength (length in bytes) vs textSize (measure in pixels) 2025-12-11 21:41:25 +01:00
Ray
2a566544d4 ADDED: Multiply security checks to avoid crashes on wrongly provided string data #4751
- REVIEWED: Checking `NULL` input on functions getting `const char *text`, to avoid crashes
- REVIEWED: `strcpy()` usage, prioritize `strncpy()` with limited copy to buffer size
- REPLACED: `strlen()` by `TextLength()` on [rtext] module
- REVIEWED: Replaced some early returns (but keeping others, for easier code following)
2025-12-11 12:59:55 +01:00
Ray
4724f7cf1b REVIEWED: Comments for UpdateSound() specifying expected data format #5350 2025-11-30 19:02:38 +01:00
Ray
e1b9857b14 Some TODOs and format reviews 2025-11-23 21:40:39 +01:00
Ray
6c3ef8d9b4 Remove trailing spaces 2025-11-22 20:15:50 +01:00
Ray
ba65bd7f99 WARNING: BREAKING: Redesigned SetSoundPan() and SetMusicPan() #5350
Now it goes from -1.0 (full left) to 1.0 (full right) being 0.0 center
2025-11-20 00:03:03 +01:00
Ray
18e4d1d44f Reviewed formating 2025-10-15 19:20:11 +02:00
Saksham Goyal
adfe2c1704 C++ compiler support v2 (#5252)
* Get C++ compilers working

* Fix Formatting
2025-10-15 19:11:44 +02:00
Ray
64641c6a01 Update raudio.c 2025-09-04 10:33:26 +02:00
Ray
8f32c502a7 REVIEWED: Code sections definition 2025-09-02 12:10:40 +02:00
Andreas Rossberg
2deae294c6 [raudio] Properly close FLAC in UnloadMusicStream
Fix  raysan5/raylib#5131.
2025-08-21 13:02:19 +02:00
Jeffery Myers
572230c8ad Initialize sound alias properties as if it was a new sound 2025-08-19 08:16:20 -07:00
Ray
570082deba WARNING: **NEW** raylib code CONVENTION: Comments do not end with '.' 2025-08-07 18:23:20 +02:00
Ray
e09c9ce281 Minor tweaks 2025-08-04 23:36:07 +02:00
Ray
b40e53f11c Remove double line spacing 2025-07-30 16:07:08 +02:00
Ray
eb7f8912f8 Minor format tweaks 2025-07-26 12:50:29 +02:00
Ray
71b302846a Review formatting, avoid variable 2025-07-17 18:49:54 +02:00
veins1
0405de794a Fix for music stopping too early 2025-07-16 14:22:57 +00:00
veins1
d03ac97eff GetMusicTimePlayed fix for music shorter than buffer size 2025-07-16 14:18:38 +00:00
Maicon Santana
3320a2c837 Fix to prevent UpdateMusicStream to run without music playing 2025-07-15 19:07:15 +01:00
wwderw
8ef51850bf Update raudio.c
Allow for the use of raudio stand alone
2025-07-08 08:51:33 -05:00
Amy Wilder
205b6a0926 Merge branch 'raysan5:master' into safety-comments 2025-07-07 21:52:54 -04:00
Amy Wilder
d4f09984ac Add safety notes to 'Update_' functions 2025-07-07 21:51:27 -04:00
Ray
59bcf680aa Code gardening... 2025-06-07 20:14:24 +02:00
Ivan Ugryumov
ec5ce8c7fe Update raudio.c 2025-04-28 14:29:51 +03:00
Jeffery Myers
0f6b9ee738 format math the way ray likes it 2025-04-18 07:27:20 -07:00
Jeffery Myers
5185d4c427 use the device channels and sample size when computing the default buffer size. 2025-04-16 18:13:41 -07:00
Ralph Caraveo
4522ecae1a [raudio] Fixed memory leak on early-return of WaveFormat func (#4779)
In the case of a failure within miniaudio on the function: ma_convert_frames, the dynamic memory allocated for the `data` variable  will leak on the early return.
2025-02-21 15:29:12 +01:00
Ray
fa0eada61a Update year to 2025 2025-01-01 00:02:52 +01:00
Ray
1f45e7af76 REVIEWED: Coding conventions 2024-12-03 19:14:14 +01:00
Ray
962f1c26ff Review formatting to follow raylib conventions 2024-12-01 23:10:59 +01:00
Caleb Heydon
58fe34d9cc [raudio] Fixed buffer overflow when loading WAV files (#4539) 2024-11-28 22:58:35 +01:00
veins1
11429b48eb Fix for #4521 (#4523) 2024-11-20 21:28:46 +01:00
Ray
8cbf34ddc4 WARNING: BREAKING: Renamed several functions for data validation #3930 2024-10-16 19:26:12 +02:00
konstruktor227
b0c3013b51 [raudio] Support 24-bit FLACs in LoadMusicStreamFromMemory (#4279)
Force conversion to 16-bit, same as how it is done in `LoadMusicStream`.
This fixes the problem where 24-bit FLACs play silence or broken sound.
2024-08-23 22:51:29 +02:00
Ray
3abe728712 Minor tweaks 2024-07-08 22:54:19 +02:00
Ray
17cbc75aa7 REVIEWED: Formatting, follow raylib coding conventions 2024-06-30 11:07:38 +02:00
listeria
df849d2fb0 [raudio] fix mapping of wave data in LoadWaveSamples() (#4062)
Co-authored-by: Listeria monocytogenes <listeria@disroot.org>
2024-06-13 16:05:22 +02:00