Commit Graph

4574 Commits

Author SHA1 Message Date
David Reid 0aef190a59 Resampler: Improve stability when ratio is 1. 2026-02-18 13:01:20 +10:00
David Reid 7e944566c4 Resampler: Add back support for passing in NULL for the input/output. 2026-02-18 12:51:58 +10:00
David Reid 3ea9cc468a Documentation fixes. 2026-02-17 07:23:36 +10:00
David Reid 4d8bd6ed84 Add PipeWire to readme. 2026-02-17 06:53:13 +10:00
David Reid 60a96123db Add Dreamcast to CMake script and readme. 2026-02-17 06:52:47 +10:00
David Reid 282ed02f46 Dreamcast: Add a readme to the romdisk folder. 2026-02-17 06:22:55 +10:00
David Reid 788b78169a Use newer tagging system for backend-specific functions. 2026-02-16 20:33:40 +10:00
David Reid c0f0500e43 Code rearrangement. 2026-02-16 20:24:56 +10:00
David Reid 2324d5ad9e Add Dreamcast backend. 2026-02-16 19:07:35 +10:00
David Reid f6662fdb2e Minor documentation fix. 2026-02-16 18:00:20 +10:00
David Reid 2f148fdd12 Channel Converter: Stop doing a micro heap allocation.
With small channel counts, mono and stereo, the channel converter will
no longer allocate memory on the heap for the channel map, but will
instead just store it in the struct directly. For larger channel counts
it will fall back to a heap allocation. This prevents stereo channel
maps resulting in a heap allocation of 8 bytes.

With this change a stereo passthrough `ma_device` can be initialized
with a heap allocation for the internal data converter.

This only affects passthrough channel conversion. When shuffling or
weights are required, a heap allocation will still be done. This
optimization is specifically for passthrough.
2026-02-16 16:36:27 +10:00
David Reid 0d7a9f960f Update documentation to suggest getters instead of direct struct access.
This is for the format, channels, sample rate and channel map.
2026-02-16 14:48:00 +10:00
David Reid e0e05c7b8c Add some more intuitive getters for ma_device.
This adds the following APIs:

    ma_device_get_playback_format()
    ma_device_get_capture_format()
    ma_device_get_playback_channels()
    ma_device_get_capture_channels()
    ma_device_get_playback_channel_map()
    ma_device_get_capture_channel_map()
2026-02-16 10:36:38 +10:00
David Reid ebbe9707e2 Use a heap allocation for the duplex ring buffer in ma_device.
The heap allocation is aligned to MA_CACHE_LINE_SIZE which is an
optimal alignment for ring buffers.

This also reduces the size of the `ma_device` struct for non-duplex
devices which is the most common setup.
2026-02-16 09:50:10 +10:00
David Reid dbc955fb0d Remove some unused placeholder functions. 2026-02-16 07:30:24 +10:00
David Reid d6d26deeda Fix some compilation errors with the resampling test. 2026-02-16 07:12:42 +10:00
David Reid dd6c57664b Add a deinterleaving code path for unaligned buffers. 2026-02-16 07:04:45 +10:00
David Reid e490db3085 Optimizations to ma_interleave_pcm_frames(). 2026-02-16 06:52:12 +10:00
David Reid 6851858937 Fix a bug in the profiling test. 2026-02-16 06:01:35 +10:00
David Reid 242cbf4d8c Optimizations to ma_deinterleave_pcm_frames() for stereo. 2026-02-15 21:54:29 +10:00
David Reid 01e5042bfb Fix an error with s24 deinterleaving. 2026-02-15 16:15:25 +10:00
David Reid 13f50137b0 Optimization to ma_deinterleave_pcm_frames() for s32 and s24. 2026-02-15 14:13:45 +10:00
David Reid 65a0c1f83d Minor struct packing improvement. 2026-02-15 13:16:00 +10:00
David Reid d63deea939 Whitespace. 2026-02-15 13:15:31 +10:00
David Reid 37a7009b3d Merge branch 'dev' into dev-0.12 2026-02-15 08:18:36 +10:00
David Reid 1078dc292a Add a safety check to ma_data_source_read_pcm_frames_within_range().
Public issue https://github.com/mackron/miniaudio/pull/1095
2026-02-15 08:11:57 +10:00
David Reid b33eb2ea4f Win32: Fix a bug in ma_dlopen() with the UWP build.
Public issue https://github.com/mackron/miniaudio/pull/1095
2026-02-15 08:05:02 +10:00
David Reid a6a7a76e6f Update change history. 2026-02-15 07:54:42 +10:00
David Reid 20c9f7fe0a Try fixing some warnings with newer versions of Emscripten.
Public issue https://github.com/mackron/miniaudio/pull/1097
2026-02-15 07:47:36 +10:00
David Reid ce05296055 Remove a TODO. 2026-02-15 07:40:08 +10:00
David Reid 852e91b380 Make ma_device_post_init() private.
Backends should use `ma_device_update_descriptor()` instead.
2026-02-15 07:22:39 +10:00
David Reid d9590dcf6e Remove a TODO. 2026-02-15 07:20:07 +10:00
David Reid 9edf1a558c Fix some warnings. 2026-02-15 06:29:22 +10:00
David Reid f75cd3a784 Remove some now unnecessary warning silencers. 2026-02-15 06:24:38 +10:00
David Reid c8c11615e3 Try fixing the Emscripten build. 2026-02-14 20:55:02 +10:00
David Reid dbf391611d Add resampling test. 2026-02-14 20:26:20 +10:00
David Reid d286a97ab1 Fix some warnings with MSVC. 2026-02-14 20:24:52 +10:00
David Reid 5ffa29a80b Clear out an out of date test. 2026-02-14 20:20:28 +10:00
David Reid ec69cafef8 Fix a typo. 2026-02-14 17:08:26 +10:00
David Reid 6adcbf9034 API CHANGE: Remove some functions relating to resampling.
The following functions are removed:

    ma_linear_resampler_get_required_input_frame_count()
    ma_linear_resampler_get_expected_output_frame_count()
    ma_resampler_get_required_input_frame_count()
    ma_resampler_get_expected_output_frame_count()
    ma_data_converter_get_required_input_frame_count()
    ma_data_converter_get_expected_output_frame_count()

These functions were used for calculating the required number of input
frames given an output capacity, and the number of expected number of
output frames given an input frame count. In practice these have proven
to be extremely annoying and finicky to get right. I myself have had
trouble keeping this working consistently as I make changes to the
processing function and I have zero confidence custom resampling
backends will implement this correctly.

If you need this functionality, take a copy of the resampler from
miniaudio 0.11.x and maintain that yourself.
2026-02-14 17:08:11 +10:00
David Reid fd1369b3fc Resampler: Revert and earlier experiment. 2026-02-14 15:37:52 +10:00
David Reid a8dd56fbbe Remove some unused functions. 2026-02-14 15:01:01 +10:00
David Reid 0f1ead0873 Remove a TODO. 2026-02-14 14:56:49 +10:00
David Reid e2e6bb6334 Resampler: Optimization to the LPF > 0 path.
This moves the channel count checks outside of the loop.
2026-02-14 14:22:06 +10:00
David Reid 5ae52e1a0a Cleanup. 2026-02-14 13:52:23 +10:00
David Reid c39ace1604 Disable filtering for pitch shifting on sounds by design. 2026-02-14 13:29:27 +10:00
David Reid 0615ce28f1 Resampler: Optimization to the no-LPF path.
This moves some checks outside the loop. A bit more code duplication,
but does improve speed.
2026-02-14 13:22:42 +10:00
David Reid 0fe2f7effd Resampler: Remove some now well out of date code. 2026-02-14 08:58:33 +10:00
David Reid c456a2f432 Resampler: Experiment with some timer management optimizations.
The idea here is to only update the resampler object once at the end.
This improves speeds up the problematic s16 mono upsampling path with
Clang, but that same path with GCC is still slow somehow.
2026-02-14 08:54:13 +10:00
David Reid 6d20358df1 Resampler: More work on filter decoupling.
This makes the s16 mono upsampling path slower somehow. This seems to be
the problem code path for some reason. Other paths don't seem to be so
sensitive to seemingly harmless changes.
2026-02-14 08:21:56 +10:00