Commit Graph

210 Commits

Author SHA1 Message Date
David Reid 3c68efb333 Fix a bug in the stereo panner effect. 2020-10-11 15:40:58 +10:00
David Reid d8aa619250 Add some experimental fading APIs to the engine API.
This is a simplified and somewhat more intuitive way of handling fades.
With these APIs, fades are applied immediately, whereas with the old
fading APIs the fades were scheduled. The old APIs still exist, but may
be removed.

The ma_sound_set_fade_in_frames/milliseconds() API sets the fade which
will be applied immediately. If the starting volume is negative, the
fade will start from the current fade volume. This will also overwrite
any existing fade that is already happening.

The ma_sound_get_current_fade_volume() API allows you to retrieve the
current volume of the fade.

The fade is layered on top of the normal volume parameter. I.e. they
are configured and applied to the signal interdependently.

Currently, all fades are applied linearly.
2020-10-11 14:41:08 +10:00
David Reid 4f63069984 Engine: Fix a bug where sounds groups are not initialized properly.
This is happening due to the hierarchy not being constructed properly.
2020-10-11 09:40:57 +10:00
David Reid 742bccff4d Remove an unnecessary member from ma_engine_config. 2020-10-01 20:24:52 +10:00
David Reid e951e7ee61 Fix compilation errors when compiling as C++. 2020-10-01 20:12:17 +10:00
David Reid 5effa71e94 Minor refactor. 2020-09-15 17:39:15 +10:00
David Reid 0a73233877 Try fixing a bug where a sound is never unmarked as mixing.
This should fix a deadlock when uninitializing a sound after it's
reached the end.
2020-09-14 19:51:21 +10:00
David Reid 5e1f653efb Engine: Fix some bugs with effects. 2020-09-12 19:14:36 +10:00
David Reid 8d64b597f8 Fix a typo. 2020-09-12 12:56:57 +10:00
David Reid b0736de6b1 Add support for initializing an engine using a pre-initialized device. 2020-09-09 19:15:40 +10:00
David Reid 0c4fc08759 Minor documentation updates. 2020-09-05 13:45:22 +10:00
David Reid 9535551f3c Add a new resource manager example and simplify the old one. 2020-09-05 10:49:57 +10:00
David Reid e6392c0ba7 Add hello world example for engine. 2020-09-05 10:24:31 +10:00
David Reid acf4284aa9 Fix a crash when passing in NULL for the engine config. 2020-09-05 10:12:27 +10:00
David Reid d0bfcf0cc1 Rename ma_engine.h to miniaudio_engine.h. 2020-09-05 10:01:44 +10:00
David Reid 3c734f936f Merge ma_mixing into ma_engine. 2020-09-05 09:49:01 +10:00
David Reid 2012c93cc9 Add support for customizing the VFS for ma_engine. 2020-08-29 20:47:43 +10:00
David Reid 35d8f093ec Only set the isPlaying flag when the audio has finished playing. 2020-08-29 18:05:45 +10:00
David Reid 3a347e04ed Fix a bug where a sound is never marked as not playing. 2020-08-29 17:24:11 +10:00
David Reid f156baafca Use a default instead of blank channel map by default.
This commit fixes an issue where the optimized mono expansion path is
never hit.
2020-08-29 09:18:50 +10:00
David Reid 3b840235f9 Resource Manager: Fix a looping bug.
This is happening because the data buffer is incorrectly being reported
as busy (still loading) which is used to indicate to the engine that no
data is available and therefore nothing can be played.
2020-08-28 20:31:45 +10:00
David Reid c20b26208b Revert an experimental change. 2020-08-28 19:21:30 +10:00
David Reid 31793a3f45 Experiment with fixing a looping bug. 2020-08-25 21:12:10 +10:00
David Reid 19c52c98f9 Resource Manager: Fix a data buffer bug. 2020-08-25 20:45:51 +10:00
David Reid 07ae0be2ad Resource Manager: Fix a bug when reusing an already-loaded data buffer. 2020-08-25 18:05:08 +10:00
David Reid 89a3df2bb5 Try fixing a mixing crash. 2020-08-24 20:05:22 +10:00
David Reid d6f664e19a Add support for configuring automatic resetting of fade points.
This is useful for enabling or disabling fading around loop
transitions.
2020-08-23 16:55:58 +10:00
David Reid 8ad73fa4da Clean up. 2020-08-23 14:18:42 +10:00
David Reid 49a9e2a2bf Minor refactor for getting load notifications working for sounds.
With this commit, you can now pass in a notification object which is
fired when an asynchronous sound has finished loading.
2020-08-23 14:08:22 +10:00
David Reid 96a60c069e Remove the pEngine parameter from all ma_sound_group_*() APIs.
Previously you could set the group to NULL in which case the master
group would be used, but this has now changed and the group parameter
can never be NULL. Use ma_engine_get_master_sound_group() to retrieve
the master sound group.
2020-08-23 10:51:04 +10:00
David Reid 0c410b0fdc Remove the pEngine parameter from all ma_sound_*() APIs. 2020-08-23 10:18:03 +10:00
David Reid fd1ca85219 Rename some APIs.
* ma_engine_sound_*() renamed to ma_sound_*().
  * ma_engine_sound_group_*() renamed to ma_sound_group_*().
2020-08-23 10:02:45 +10:00
David Reid dcb2b0ba1f Minor restructure. 2020-08-23 09:58:14 +10:00
David Reid 1f89b003c5 Changes to fading and delays.
* Removed ma_engine_sound_set_fade_in/out()
  * Add ma_engine_sound_set_fade_point_in_frames()
  * Add ma_engine_sound_set_fade_point_in_milliseconds()
  * Add ma_engine_sound_set_stop_delay()
  * Add ma_engine_sound_get_time_in_frames()
  * Removed ma_engine_sound_group_set_fade_in/out()
  * Add ma_engine_sound_group_set_fade_point_in_frames()
  * Add ma_engine_sound_group_set_fade_point_in_milliseconds()
  * Add ma_engine_sound_group_set_stop_delay()
  * Add ma_engine_sound_group_get_time_in_frames()

The fade in/out system has been replaced with something more general
and flexible which allows for up to two fade points to be configured
per sound or group, with arbitrary time periods and volumes.

This commit also includes the addition of a placeholder parameter for
ma_engine_sound_init_from_file() which is used to notify the caller
when an asynchronously loaded sound has finished loading.
2020-08-22 21:58:03 +10:00
David Reid 4873584058 Add support for fading out to sound groups. 2020-08-16 21:30:35 +10:00
David Reid 3de7f5caf5 Add support for start delays to sound groups. 2020-08-16 17:16:50 +10:00
David Reid 56dbcb529c Add support for fading in to sound groups. 2020-08-16 16:57:53 +10:00
David Reid 1baf3e941a Update documentation for ma_mixer_end(). 2020-08-16 15:23:20 +10:00
David Reid 22a785d72b Add support for setting the pitch on sound groups. 2020-08-16 15:20:35 +10:00
David Reid 41198b9b75 Add support for offsetting mixing output. 2020-08-16 15:10:16 +10:00
David Reid 042e1b95b1 Add support for panning to sound groups. 2020-08-16 11:34:13 +10:00
David Reid 340dbcc37b Fix a mixing bug when applying an effect. 2020-08-16 11:32:07 +10:00
David Reid 96ee8242f4 Add support for start delays for engine sounds. 2020-08-15 11:53:37 +10:00
David Reid fea2cba24b Add support for offsets to the low-level mixing API. 2020-08-15 11:48:40 +10:00
David Reid fe85a13214 Add ma_decoder_get_cursor_in_pcm_frames(). 2020-08-15 10:09:19 +10:00
David Reid 6d1a1ccd05 Engine: Improve support for fading in and out of sounds.
Fading is now set using these APIs:

  * ma_engine_sound_set_fade_in()
  * ma_engine_sound_set_fade_out()

When a sound is stopped, either by naturally reaching the end, or
explicitly with ma_engine_sound_stop(), the fade out will be applied.
Fading will also be applied around loop transitions.

Note that when a sound is stopped implicitly by it reaching the end,
fading out will not work when the length of the sound is not know (that
is, when ma_data_source_get_length_in_pcm_frames() returns 0).
2020-08-14 13:25:47 +10:00
David Reid 775c624e66 Add some APIs to data sources:
* ma_data_source_get_cursor_in_pcm_frames()
  * ma_data_source_get_length_in_pcm_frames()

When the data source has no notion of a cursor or length, these return
MA_NOT_IMPLEMENTED to let the caller know about it. This is returned
when a custom data source leaves these functions unimplemented.

ma_decoder, ma_audio_buffer, ma_waveform and ma_noise have all been
updated to support these new functions.
2020-08-09 22:29:11 +10:00
David Reid 78ff206095 Fix bug in ma_resource_manager_data_buffer_get_available_frames(). 2020-08-09 18:49:48 +10:00
David Reid ab38bf91aa Add ma_engine_sound_get_data_format().
This function is used for retrieving the sample format, channel count
and sample rate of the sound.
2020-08-09 17:17:52 +10:00
David Reid 6e32cc22ff Add ma_engine_sound_set_fade_in/out().
As of this commit, ma_engine_sound_set_fade_out() is not fully
implemented pending the writing of some additional infrastructure.
2020-08-09 17:01:18 +10:00