Commit Graph

1777 Commits

Author SHA1 Message Date
David Reid 5f766acf8e Update revision history. 2020-06-08 17:15:35 +10:00
David Reid 13c7a0389f Add custom semaphore implementation for POSIX platforms.
This is needing to be done manually because Apple has decided to
deprecate anonymous semaphores from semaphore.h which we're going to
need.
2020-06-08 17:10:44 +10:00
David Reid ebf0826b17 Simplify the ma_thread structure. 2020-06-08 16:58:31 +10:00
David Reid 66e7518ef3 Simplify the ma_event structure. 2020-06-08 16:47:38 +10:00
David Reid ad7084030e Remove dependency on ma_context from the event API. 2020-06-08 16:42:06 +10:00
David Reid fc1a6930d3 Remove dependency on ma_context from the thread API. 2020-06-08 16:31:17 +10:00
David Reid d54b9efc07 Remove the dependency on ma_context from the semaphore API. 2020-06-08 16:24:01 +10:00
David Reid b819a0800f Rearrange some threading code to decouple it from device IO. 2020-06-08 16:18:38 +10:00
David Reid 2efe1ab81a Simplify mutex API by removing the ma_context parameter. 2020-06-08 16:06:13 +10:00
David Reid 95ded1d57c Fix sound uninitialization. 2020-06-07 15:33:49 +10:00
David Reid ce4d4b359f More work on the new high level API:
* Implement the notion of a virtual file system (VFS) which is used
    by the resource manager for loading sound files. The idea is that
    the application can implement these to support loading from custom
    packages, archives, etc.
  * Add a helper API for decoding a file from a VFS and a file name.
  * Add some symbols representing allocation types. These are not
    currently used, but I've added them in preparation for changes to
    the allocation callbacks. The idea is that an allocation type will
    be passed to the callbacks to give the allocator better intel as to
    what it's allocating which will give it a chance to optimize.
  * Add some placeholders for flags for controlling how to load a data
    source. Currently only MA_DATA_SOURCE_FLAG_DECODE is implemented
    which is used to indicate to the resource manager that it should
    store the decoded contents of the sound file in memory rather than
    the raw (encoded) file data.
  * Support has been added to the resource manager to load audio data
    into memory rather than naively reading straight from disk. This
    eliminates file IO from the audio thread, but comes at the expense
    of extra memory usage. Support for streaming is not implemented as
    of this commit. Early (largely untested) work has been implemented
    to avoid loading sound files multiple times. This is a simple ref
    count system for now, with hashed files paths being used for the
    key into a binary search tree. The BST is not fully tested and
    likely has bugs which will be ironed out in future commits.
  * Support has been added for configuring the stereo pan effect. Most
    audio engines use a simple balancing technique to implement the
    pan effect, but a true pan should "move" one side to the other
    rather than just simply making one side quieter. With this commit,
    the ma_panner effect can support both modes. The default mode will
    be set to ma_pan_mode_balance which is just a simple balancing and
    is consistent with most other audio engines. A true pan can be used
    by setting the mode to ma_pan_mode_pan.
2020-06-07 12:09:39 +10:00
David Reid 99fea233e8 Fix a bug when mixing a data source using mmap mode.
This was causing mmaped data sources to not loop if they coincidentally
reached the end at the same time as the final output frame was written.
2020-06-07 11:51:59 +10:00
David Reid 0be72c02dd Add ma_seek_origin_end in preparation for future work. 2020-06-07 11:50:42 +10:00
David Reid bc23d565e7 Minor optimization to ma_copy_pcm_frames() and update to documentation.
This changes makes ma_copy_pcm_frames() a no-op when the input and
output buffers are both set to the same pointer. This is useful for
some in-place no-ops for effects and filters.
2020-06-06 18:16:45 +10:00
David Reid b287d94fe8 Rename some functions for consistency. 2020-06-03 21:25:57 +10:00
David Reid fe06814325 Don't do filtering when pitch shifting for now.
This may be changed back to a first order LPF later on.
2020-06-03 20:50:44 +10:00
David Reid 5b1b160c62 Fix compilation errors with MA_NO_DEVICE_IO. 2020-06-03 20:01:36 +10:00
David Reid 31f08287da Have decoders use their native channel count in the high level API.
This is required so we can do different spatialization logic depending
on the channel count of the audio source.
2020-06-03 17:01:39 +10:00
David Reid c0ebf41633 Minor renaming. 2020-06-03 16:52:05 +10:00
David Reid 766420eb2b Update revision history. 2020-06-01 21:20:36 +10:00
David Reid cc8201738b Optimization to stereo panner. 2020-06-01 20:47:34 +10:00
David Reid 4d5433ae58 Use first order LPF for pitch shifting by default.
There is a bug that's causing glitches which appears to be something to
do with the second order LPF.
2020-06-01 20:38:37 +10:00
David Reid fefde682e3 Don't support such extreme resampling ratios.
This was affecting the stability of the internal low pass filters.
2020-06-01 20:20:43 +10:00
David Reid 54adbc3dfc Fix a possible infinite loop. 2020-06-01 18:03:43 +10:00
David Reid 352a776b52 Fix a bug in the linear resampler when changing rates.
This bug is happening due to the internal timer not being adjusted to
match the new sample rate.
2020-06-01 17:11:23 +10:00
David Reid 32e240d4ec Fix a bug when mixing a data source. 2020-06-01 01:05:01 +10:00
David Reid bf63ed17b9 Enable mmap mode for ma_audio_buffer data sources. 2020-06-01 00:09:03 +10:00
David Reid 1c26893930 Add initial implementation of stereo panning to the ma_engine API.
This currently only supports f32, but support for more formats will be
coming soon.
2020-05-31 23:54:29 +10:00
David Reid f4b0b271cd More work on the new engine API.
* Initial work on infrastructure for spatialization, panning and
    pitch shifting.
  * Add ma_engine_sound_set_pitch()

Spatialization and panning is not yet implemented, but pitch shifting
should now be working.
2020-05-31 23:14:59 +10:00
David Reid 3a62d44959 Work on changes to the effect API. 2020-05-31 07:03:14 +10:00
David Reid 105d016e69 Updates to the new ma_engine API.
* The engine will now auto-start by default. This can be changed in
    the config by setting `noAutoStart` to true.

  * Initial implementation of ma_engine_play_sound() which can be used
    for fire-and-forget playback of sounds.

  * Add ma_engine_sound_at_end() for querying whether or not a sound
    has reached the end. The at-end flag is set atomically and
    locklessly in the mixing thread.
2020-05-30 13:56:41 +10:00
David Reid 8254324a5e Update release notes. 2020-05-30 13:40:30 +10:00
David Reid e2b37b5d6d Fix some warnings reported by GCC. 2020-05-30 13:40:02 +10:00
David Reid 9718ac2d64 Fix some warnings with GCC and -std=c89. 2020-05-30 13:34:23 +10:00
David Reid 3fcef2fc7e Add atomic compare and swap. 2020-05-30 13:25:02 +10:00
David Reid fda0c07626 Update ma_mixer_mix_data_source() return value.
This change makes it so MA_AT_END is returned when a non-looping data
source reaches the end. This is how the caller can know to do clean up
or whatnot.
2020-05-30 13:01:56 +10:00
David Reid 29641e08dc Add documentation for log levels. 2020-05-30 09:49:01 +10:00
David Reid 803cd284bc Shorten a comment for easier viewing. 2020-05-29 19:51:37 +10:00
David Reid 967174368e Add looping example. 2020-05-29 19:50:04 +10:00
David Reid 8de49326d4 Add support for looping when reading data from data sources.
Updated APIs:
  * ma_data_source_read_pcm_frames()
  * ma_data_source_seek_pcm_frames()
2020-05-29 19:49:38 +10:00
David Reid 69253921de Update dr_wav in preparation for some new work. 2020-05-29 19:20:24 +10:00
David Reid 1cec172623 Add ma_data_source_seek_pcm_frames().
This commit also explicitly defines ma_data_source_read_pcm_frames() as
supporting an output buffer of NULL in which case a forward seek should
be performed.
2020-05-29 18:00:48 +10:00
David Reid aec20ea98c Add support for passing in NULL for output buffer when decoding.
This will cause a forward seek to occur instead of a read when calling
ma_decoder_read_pcm_frames() with the output buffer set to NULL.
2020-05-29 17:57:01 +10:00
David Reid 077ae13157 Clarify some wording. 2020-05-28 22:36:34 +10:00
David Reid 046bc0d7c6 Add initial experimental work on the ma_engine API. 2020-05-28 21:25:39 +10:00
David Reid 0d691012d6 Add support for effects when mixing memory mapped data sources. 2020-05-28 16:18:16 +10:00
David Reid 783aef728e Updates to the mixer API.
* Add support for volume control to ma_mixer_mix_*().
  * Add support for specifying an effect to apply before mixing.
  * Add optimized pipeline for memory mappable data sources.
  * Remove some unnecessary functions:
    - ma_mixer_mix_pcm_frames_ex()
    - ma_mixer_mix_callbacks()
    - ma_mixer_mix_decoder()
    - ma_mixer_mix_audio_buffer()
    - ma_mixer_mix_waveform()
    - ma_mixer_mix_noise()
    - ma_mixer_mix_rb_ex()
2020-05-27 22:58:22 +10:00
David Reid c2aa044335 Have ma_audio_buffer_unmap to return MA_AT_END when the end is reached. 2020-05-27 21:19:16 +10:00
David Reid df9906a11e Add support for memory mapping to ma_data_source. 2020-05-27 21:13:06 +10:00
David Reid f572ac8709 Change pDeviceID to constant pointers in ma_device_config. 2020-05-27 17:44:41 +10:00