Commit Graph

4561 Commits

Author SHA1 Message Date
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
David Reid 459fc19304 Resampler: Decouple the filtering step from the main resampler object.
The idea here is to have a more clearly defined data dependency
separation between the resampler and the filtering state which I'm
hoping might open up more optimization opportunities. The problem with
this theory, is that this commit makes the GCC build slower on the s16
mono upsampling path. It appears to be slightly fast with Clang though.
2026-02-14 07:10:34 +10:00
David Reid d4382ce478 Resampler: Optimization to the filtering stage.
This seems to trigger a fast optimization strategy when compiling with
GCC. With this change the filtered s16 mono path is almost 2x faster.
2026-02-14 06:20:37 +10:00
David Reid b3340e629a Remove a TODO.
I tried addressing this, but upon doing so the build was slower. It was
especially bad with Clang where is was 2x slower(!), and just slightly
slower with GCC.

Not sure exactly what's going on here, but I guess the compiler is
hitting some edge case that's prevent efficient optimization. What's
weirder, is the slowness only affects the mono s16 code path. Other
code paths are totally fine.
2026-02-13 20:54:38 +10:00
David Reid 9d0f4a4103 Rename a macro. 2026-02-13 19:10:53 +10:00
David Reid db1bc8c4b7 Resampler: Remove dependency on ma_lpf.
This makes the resampler a bit more self-contained and allows us to do
some resampler-specific optimizations to the filtering process. It also
reduces the size of the `ma_linear_resampler` struct.
2026-02-13 18:54:32 +10:00
David Reid cbbe317adc Resampler: Miscellaneous optimizations to the linear resampler. 2026-02-13 18:33:29 +10:00
David Reid 172f8beae6 Resampler: Optimization for floating point stereo.
This applies only to the f32 no-LPF code path. Other code paths will be
integrated later.
2026-02-08 22:01:23 +10:00
David Reid cd02ebe39c Resampler: A loop unrolling optimization experiment.
My idea here is to make it easier to for the compiler to SIMD-ify some
of the interpolation code. I have not confirmed that it is actually
being SIMD-ified by the compiler, but it is still significantly faster
in both debug and release builds.

There is a mono specialization here which further improves performance.
I have not yet experimented with a stereo specialization, but if it
works it'll be added in a future commit.

This applies only to the f32 no-LPF code path. Other paths will come
later once I'm done with this round of experiments.
2026-02-08 20:12:57 +10:00
David Reid 20180b0ae5 Resampler: For LPF orders to be a multiple of 2.
This is in preparation for an implementation simplification for the
purpose of some upcoming optimizations.
2026-02-08 19:21:10 +10:00
David Reid a04f300821 Stop encouraging the use of some resampling functions.
These functions are not reliably implemented by all backends and as such
I'd rather not encourage these use of these. These might be removed in
the future.
2026-02-07 17:09:51 +10:00
David Reid 2ea55eaeaf Resampler: Optimization to f32, no LPF code path. 2026-02-07 15:40:10 +10:00
David Reid c0b57c3aea Resampler: Optimization to s16, no LPF code path. 2026-02-07 11:26:05 +10:00
David Reid 4b8eb8588d Resampler: Stop allowing NULL input and output buffers. 2026-02-07 10:48:42 +10:00