Commit Graph

271 Commits

Author SHA1 Message Date
David Reid 76640272be Rename some APIs for consistency with other APIs.
* ma_sound_set_fade_in_frames()       > ma_sound_set_fade_in_pcm_frames()
  * ma_sound_get_time_in_frames()       > ma_sound_get_time_in_pcm_frames()
  * ma_sound_set_start_time()           > ma_sound_set_start_time_in_pcm_frames()
  * ma_sound_set_stop_time()            > ma_sound_set_stop_time_in_pcm_frames()
  * ma_sound_group_set_fade_in_frames() > ma_sound_group_set_fade_in_pcm_frames()
  * ma_sound_group_get_time_in_frames() > ma_sound_group_get_time_in_pcm_frames()
  * ma_sound_group_set_start_time()     > ma_sound_group_set_start_time_in_pcm_frames()
  * ma_sound_group_set_stop_time()      > ma_sound_group_set_stop_time_in_pcm_frames()
2021-02-05 19:33:37 +10:00
David Reid cc2365b2b8 Fix a warning due to use of non-standard functionality. 2021-02-05 19:19:33 +10:00
David Reid 59db61d9f3 Add ma_sound_get_engine(). 2021-02-05 19:17:28 +10:00
David Reid fbb953ff01 Fix an unused variable warning. 2021-02-05 18:30:23 +10:00
David Reid 3265107cbd Fix a bug in ma_sound_is_playing().
This bug is due to the current time not being taken into account when
determining the node state.

Public issue https://github.com/mackron/miniaudio/issues/269
2021-02-05 17:16:30 +10:00
David Reid 1bd587e59f Fix the C++ build. 2021-01-31 19:52:35 +10:00
David Reid 626463a13e Fix a bug where a base node is being uninitialized twice. 2021-01-29 17:40:14 +10:00
David Reid 6281ed3165 Add some optimizations to inlined sounds. 2021-01-28 17:59:28 +10:00
David Reid 0f29839549 Remove the notification parameter from ma_sound_init_from_file().
This is buggy and unsafe. A complete rethink of the resource management
notification system needs to be done.
2021-01-28 17:46:09 +10:00
David Reid 8f6f72f188 Fix compilation error. 2021-01-27 18:12:58 +10:00
David Reid 8cd72f46a0 Temporary hack to fix some clicking glitches relating to resampling. 2021-01-26 17:21:31 +10:00
David Reid 243df7ebe0 Fix a copy/paste bug in ma_sound/group_set_positioning(). 2021-01-26 15:12:04 +10:00
David Reid a364b4ef96 Fix a bug with pitch shifting.
This bug results in the first period of samples being pitched at 1.0
regardless of whether or not ma_sound_set_pitch() had been called. What
happens is that the first period is processed at a rate of 1.0, and
then the pitch is applied after the fact. Then, the next period comes
along and resamples at the pitch set by ma_sound_set_pitch() which
results in a harsh sounding glitch.
2021-01-26 09:27:49 +10:00
David Reid 9fcb167476 Fix a bug relating to doppler pitching. 2021-01-26 08:20:51 +10:00
David Reid bd80a409d3 Remove some stale and misleading comments. 2021-01-25 16:04:53 +10:00
David Reid 78910a922a Simplify some APIs. 2021-01-25 15:39:42 +10:00
David Reid d571435566 Remove a debugging printf(). 2021-01-25 15:02:55 +10:00
David Reid cfff5f3192 Add support for angular attenuation to the spatializer. 2021-01-25 15:01:40 +10:00
David Reid 525dd7cb23 Add support for multiple listeners. 2021-01-25 11:38:18 +10:00
David Reid 33025bace2 Add support for doppler effect to the engine. 2021-01-25 10:12:05 +10:00
David Reid 4cdd892c54 Prep work in preparation for doppler effect. 2021-01-25 09:18:22 +10:00
David Reid 9677cdc1e9 Initial work on spatialization.
This does not yet support the following:

  * Cone based attenuation
  * Doppler effect
  * Multiple listeners
2021-01-24 21:06:15 +10:00
David Reid 8bd061b6c8 Add support for channel maps to ma_convert_pcm_frames_channels_f32(). 2021-01-24 16:54:33 +10:00
David Reid f040e3a1c1 Clean up in preparation for some spatialization work. 2021-01-24 09:03:32 +10:00
David Reid a389b65a75 Fix some bugs with notifications. 2021-01-20 19:43:18 +10:00
David Reid 776d7ddd91 Fix compilation errors with the C++ build. 2021-01-19 19:22:52 +10:00
David Reid ef9099a6f2 Bug fix an update documentation. 2021-01-18 21:42:56 +10:00
David Reid da42dfcd4b Add support for wide strings (wchar_t) to the engine. 2021-01-17 21:20:11 +10:00
David Reid 3eb0f400e6 Add support for wide strings (wchar_t) to the resource manager. 2021-01-17 21:11:21 +10:00
David Reid 30b55db681 Fix a bug with looping streaming sounds. 2021-01-17 18:38:17 +10:00
David Reid 13126b4ddf Fix a bug with the resource manager.
This was not setting the NON_BLOCKING flag correctly when NO_THREADING
is set.
2021-01-17 18:18:14 +10:00
David Reid dc0ca7072b Add support for running the resource manager without a job thread.
This is useful for platforms that do not have support for threading or
programs that do not want to use an extra thread for resource
management and would rather process jobs manually.

When configuring the resource manager to not use threading, the
MA_RESOURCE_MANAGER_FLAG_NO_THREADING flag must be set in the config.
This implicitly enables the MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING flag
because it requires programs to manually call
ma_resource_manager_process_next_job(), and since it's assumed that
won't ever be called from another thread, you'd never want that to be
blocking.

This sets up a framework for getting the resource manager working with
Emscripten.
2021-01-17 13:41:09 +10:00
David Reid 9e6042f698 Remove loop detection code for now.
This needs a rethink. My test is no longer looping. Needs further
investigation.
2021-01-17 10:29:09 +10:00
David Reid dd52456571 Start using the onGetRequiredInputFrameCount callback for nodes.
This is an optional callback and is used by miniaudio as a hint to help
it determine how many input frames to read at a time. Without this,
miniaudio needs to guess how many frames to read, and in certain
situations may end up overestimating. This callback is only useful for
nodes that process input and output frames at different rates, i.e.
nodes that perform resampling.
2021-01-17 09:10:38 +10:00
David Reid ec077e7974 Fix some warnings with GCC. 2021-01-16 21:15:38 +10:00
David Reid d3d98ee3a2 Add ma_audio_buffer_ref.
This is a data source whose backing data is an application-controlled
pointer. No data is copied. It's a way of efficiently wrapping a raw
buffer and using it as a data source.
2021-01-16 17:51:50 +10:00
David Reid aeb51a8eeb Simplify ma_node_config_init(). 2021-01-16 15:56:30 +10:00
David Reid 9a1885ebdc Revert the recent metadata functionality.
Change of mind on how this should work.
2021-01-16 15:05:26 +10:00
David Reid 9c7431ab91 Add support for metadata for nodes.
This is useful for retrieving information about some aspect of the
node. A good example is human readable names associated with the node
and it's input and output buses. This is useful for user interfaces
where a brief description of the node such as "Low Pass Filter" can be
drawn on the screen. It's also useful for buses to be named, such as
the source/carrier and excite/modulator on a vocoder effect which would
also need to be visible on a UI.
2021-01-16 14:06:24 +10:00
David Reid 85580a4c0a Minor grammar fix. 2021-01-15 22:48:35 +10:00
David Reid 0c435ae844 Add a TODO. 2021-01-15 22:47:23 +10:00
David Reid 13e03e4169 Some improvements to the processing of nodes.
The following flags can now be associated with nodes via the vtable:

  * MA_NODE_FLAG_PASSTHROUGH
  * MA_NODE_FLAG_CONTINUOUS_PROCESSING
  * MA_NODE_FLAG_ALLOW_NULL_INPUT
  * MA_NODE_FLAG_DIFFERENT_PROCESSING_RATES

See commit changes for a description of these flags.
2021-01-15 22:37:04 +10:00
David Reid 916c1b8a5f Changes to node processing callbacks.
* The simplified callback has been removed.
  * The `globalTime` parameter has been removed from the callback.
  * The order of input and output frames and counts has been swapped to
    be consistent with ma_data_converter_process_pcm_frames(), etc.
2021-01-15 19:44:36 +10:00
David Reid 88fc453f5f Add the MA_ATOMIC annotation.
Variables are marked with this annotation to make it clear that access
to the variable should be done through atomics.

I've also review the use of volatile in this commit.

Public issue https://github.com/mackron/miniaudio/issues/259
2021-01-14 19:05:10 +10:00
David Reid 687e9e5502 Fix a bug in the node graph relating to attaching and detaching nodes.
This was setting the previous pointer of newly attached nodes to NULL
instead of a pointer to the dummy head node. This then results in the
dummy head node never being updated when the node is detached which in
turn results in an uninitialized node being dereferenced.
2021-01-14 17:23:48 +10:00
David Reid 416ead6e35 Properly fix a bug with volume of output buses. 2021-01-14 17:08:14 +10:00
David Reid 63df16a2df Add some safety checks when reading from data sources. 2021-01-13 22:44:08 +10:00
David Reid 7a8ff122bc Fix a bug with the application of output bus volume. 2021-01-13 22:20:38 +10:00
David Reid fa416d323b Fix a bug when reading from a node with no attachments.
This would try reading from an uninitialized buffer thereby resulting
in a bad audio glitch. This does two things to fix the problem:

  1) When there are no input nodes attached to an input bus, nothing is
     read and 0 will be returned for the frames read variable.

  2) The buffer is silenced by default.

This fixes a bug with ma_engine where it would glitch in the moment
just after the engine is initialized and before a sound or group is
attached.
2021-01-13 22:03:09 +10:00
David Reid 14c5b35b8a Make the read counter for loop detection per output bus. 2021-01-13 21:18:07 +10:00