Commit Graph

2315 Commits

Author SHA1 Message Date
David Reid 6c4bdaf7e0 Add vocoder node and duplex example. 2021-01-16 19:48:12 +10:00
David Reid 7c22845925 Rename ma_audio_buffer_ref_reset() to ma_audio_buffer_ref_set_data(). 2021-01-16 18:28:08 +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 2b761c3c7f Update revision history. 2021-01-14 20:24:07 +10:00
David Reid 1ac06d44b3 Fix documentation on new backend enabling macros.
Public issue https://github.com/mackron/miniaudio/issues/260
2021-01-14 19:57:26 +10:00
David Reid 422ef79240 Add support for enabling only specific backends at compile time.
This enables the ability to explicitly enable only the backends a
program is interested in. Essentially it's the reverse of the pre-
existing method whereby instead of disabling backends, all backends are
disabled by default, and then specific backends are enabled. Example:

    #define MA_ENABLE_ONLY_SPECIFIC_BACKENDS
    #define MA_ENABLE_WASAPI /* Only care about WASAPI on Windows. */
    #define MA_ENABLE_ALSA   /* Only care about ALSA on Linux. */

Note that even if MA_ENABLE_* is used, the backend will still only be
enabled if the compilation environment and target platform actually
supports it. You can therefore use the MA_ENABLE_* options without
needing to worry about platform detection.

Public issue https://github.com/mackron/miniaudio/issues/260
2021-01-14 19:54:12 +10:00
David Reid b16f74bf6b Update revision history. 2021-01-14 19:06:35 +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
David Reid e6c2e4441b No longer force fixed sized updates from ma_engine.
This is no longer necessary and just introduces unnecessary latency and
inefficiency due to extra data movement.
2021-01-12 22:16:49 +10:00
David Reid 3f7cf70619 Reimplement ma_engine_play_sound(). 2021-01-12 21:37:45 +10:00
David Reid 2209234af8 Remove ma_effect. 2021-01-12 20:39:08 +10:00
David Reid 0e8a19eef2 Decouple fader, spatializer and panner from ma_effect. 2021-01-12 20:35:30 +10:00
David Reid 56e0e62497 Add support for disabling pitching.
This provides an optimization by allowing processing to bypass the
resampler. Audio data needs to pass through the resampler even for the
case where pitch=1 because it needs to update internal buffers which if
it didn't do, would result in a glitch when moving away from 1.

In practice most sounds won't require individual pitch control, however
in the interest in being consistent with miniaudio's philosophy of
things "Just Working", pitching is enabled by default. Pitching can be
disabled with MA_SOUND_FLAG_DISABLE_PITCH in ma_sound_init_*() and
ma_sound_group_init().
2021-01-12 20:33:53 +10:00
David Reid b5c0f6f6d3 Remove ma_engine_effect.
This is the first step towards decoupling the ma_effect API from the
engine for the eventual removal.

This also fixes bugs regarding channel conversion when processing an
engine node.
2021-01-12 20:09:05 +10:00
David Reid 1afec17bdb Make some functions const correct. 2021-01-12 20:03:56 +10:00
David Reid ff22dc3c87 Fix a bug when trying to play a sound with inconsistent channel counts.
This bug happens when the channel count of the data source does not
match the channel count of the engine.
2021-01-12 17:22:44 +10:00
David Reid 400aaf582d Rename ma_sound_set_start/stop_delay() to ma_sound_set_start/stop_time()
This is mainly for consistency with the node API, but also because it
more clearly indicates that it's an absolute time rather than a delay
which sounds more like a relative time.
2021-01-12 16:23:27 +10:00
David Reid d5b25502c1 Migrate start and stop delays to the node graph system.
This changes ma_sound_set_start/stop_delay() to take an absolute time
in frames based on the global clock. Previously these took a relative
time in milliseconds. To use a relative time, add it to the value
returned by ma_engine_get_time(). To use milliseconds, use a standard
sample rate to milliseconds conversion.
2021-01-12 12:40:22 +10:00
David Reid a6cd93401d Version 0.10.30 2021-01-10 22:42:17 +10:00
David Reid 369fb6fd8f Some small improvements to the resource manager.
These changes are in preparation for fixing some issues relating to
retrieval of channel counts from data sources. The problem relates to
the asynchronous nature of the resource manager and how data sources
may be in the middle of loading when trying to initialize a sound which
results in the channel count not yet being available. The channel count
is necessary in order for the engine to be able to convert the data
source to the channel count of the final output.
2021-01-10 22:38:00 +10:00
David Reid 085728fdcd Remove ma_mixer. 2021-01-10 20:47:22 +10:00
David Reid 66a20f0a87 Remove the old mixing code from ma_engine. 2021-01-10 20:39:36 +10:00
David Reid d72b6f1dca Begin work on integrating the engine with the routing system.
This commit has known issues which will be fixed in the next commits.
2021-01-10 19:48:24 +10:00
David Reid 67863c48f3 Fix a crash in ma_audio_buffer_read_pcm_frames(). 2021-01-10 17:18:21 +10:00
David Reid 8da4b4fa8b Add support for timing operations to the node graph system.
This is needed for scheduling frame-exact starting and stopping of
nodes, in addition to any kind of time-based effects required by custom
nodes, such as fading.
2021-01-10 10:56:44 +10:00
David Reid 554c505f9c Work in progress on integrating ma_engine with the routing system.
This is not fully functional as of this commit.
2021-01-09 15:18:46 +10:00
David Reid 3e8a9ec040 Remove the ability to configure the engine's sample format.
The sample format is now always 32-bit floating point. This was done
for simplicity and practicality.
2021-01-09 09:15:26 +10:00
David Reid 72bc5bc043 Update ma_node_output_bus_set_volume() to allow amplification. 2021-01-07 20:44:38 +10:00
David Reid c394348d9a Remove ma_sound_set_effect() and ma_sound_group_set_effect().
Effects will now be implemented by plugging effect nodes into the node
graph at the appropriate location.
2021-01-07 20:43:31 +10:00
David Reid afcb46dbb1 Fix a typo. 2021-01-06 22:11:02 +10:00
David Reid d580e3043f Remove some unnecessary atomics. 2021-01-06 22:06:25 +10:00
David Reid 9f62d69669 Update documentation. 2021-01-06 22:04:39 +10:00
David Reid 79845b5ec6 Update documentation. 2021-01-06 21:27:41 +10:00
David Reid fb1e61cb06 Add ma_node_detach_all_output_buses(). 2021-01-06 21:19:55 +10:00
David Reid fb336f54e3 Make ma_node_detach() private and rename to ma_node_detach_full(). 2021-01-06 21:17:02 +10:00
David Reid bb0e486d95 Simplify node attachment APIs.
With this change, attachment and detachment of a node's output bus is
now consistent:

  * ma_node_attach_output_bus()
  * ma_node_detach_output_bus()

The old function that allowed you to attach the other way around has
been removed as the caller can easily do that themselves by swapping
the order of parameters.
2021-01-06 21:10:42 +10:00
David Reid 4f96309cbf Add experimental loop detection to the routing system. 2021-01-06 19:06:39 +10:00