Commit Graph

15 Commits

Author SHA1 Message Date
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 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 63df16a2df Add some safety checks when reading from data sources. 2021-01-13 22:44:08 +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 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 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 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 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 5e1f653efb Engine: Fix some bugs with effects. 2020-09-12 19:14:36 +10:00
David Reid d0bfcf0cc1 Rename ma_engine.h to miniaudio_engine.h. 2020-09-05 10:01:44 +10:00