diff --git a/docs/examples/index.html b/docs/examples/index.html index 7d7ab909..32c6a0ca 100644 --- a/docs/examples/index.html +++ b/docs/examples/index.html @@ -247,7 +247,7 @@ a.doc-navigation-l4 {
Documentation HomeProgramming ManualExamplesFixed Size CallbackSimple CaptureSimple DuplexSimple EnumerationSimple LoopbackSimple LoopingSimple MixingSimple PlaybackSimple Playback SineAPI Reference
Examples
Programming Manual - API Reference - Source Code
-
Fixed Size CallbackShows one way to implement a data callback that is called with a fixed frame count.
Simple CaptureDemonstrates how to capture data from a microphone using the low-level API.
Simple DuplexDemonstrates duplex mode which is where data is captured from a microphone and then output to a device.
Simple EnumerationDemonstrates how to enumerate over devices.
Simple LoopbackDemonstrates how to implement loopback recording.
Simple LoopingShows one way to handle looping of a sound.
Simple MixingDemonstrates one way to load multiple files and play them all back at the same time.
Simple PlaybackDemonstrates how to load a sound file and play it back using the low-level API.
Simple Playback SineDemonstrates playback of a sine wave.
+
Fixed Size CallbackShows one way to implement a data callback that is called with a fixed frame count.
Simple CaptureDemonstrates how to capture data from a microphone using the low-level API.
Simple DuplexDemonstrates duplex mode which is where data is captured from a microphone and then output to a speaker device.
Simple EnumerationDemonstrates how to enumerate over devices.
Simple LoopbackDemonstrates how to implement loopback recording.
Simple LoopingShows one way to handle looping of a sound.
Simple MixingDemonstrates one way to load multiple files and play them all back at the same time.
Simple PlaybackDemonstrates how to load a sound file and play it back using the low-level API.
Simple Playback SineDemonstrates playback of a sine wave.
diff --git a/docs/examples/simple_duplex.html b/docs/examples/simple_duplex.html index ed7dc16f..b45f09b7 100644 --- a/docs/examples/simple_duplex.html +++ b/docs/examples/simple_duplex.html @@ -247,7 +247,7 @@ a.doc-navigation-l4 { @@ -1554,7 +1621,7 @@ sndio channel map. http://www.sndio.org/tips.html

ma_standard_channel_map_webaudio

Documentation HomeProgramming ManualExamplesFixed Size CallbackSimple CaptureSimple DuplexSimple EnumerationSimple LoopbackSimple LoopingSimple MixingSimple PlaybackSimple Playback SineAPI Reference

Simple Duplex

-Demonstrates duplex mode which is where data is captured from a microphone and then output to a device. +Demonstrates duplex mode which is where data is captured from a microphone and then output to a speaker device.

diff --git a/docs/manual/index.html b/docs/manual/index.html index fa2f1537..6e35088c 100644 --- a/docs/manual/index.html +++ b/docs/manual/index.html @@ -262,7 +262,7 @@ miniaudio is a single file library for audio playback and capture. To use it, do #include "miniaudio.h"

-You can do #include miniaudio.h in other parts of the program just like any other header. +You can do #include "miniaudio.h" in other parts of the program just like any other header.

@@ -537,22 +537,22 @@ backends and enumerating devices. The example below shows how to enumerate devic // Error. } -ma_device_info* pPlaybackDeviceInfos; -ma_uint32 playbackDeviceCount; -ma_device_info* pCaptureDeviceInfos; -ma_uint32 captureDeviceCount; -if (ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount) != MA_SUCCESS) { +ma_device_info* pPlaybackInfos; +ma_uint32 playbackCount; +ma_device_info* pCaptureInfos; +ma_uint32 captureCount; +if (ma_context_get_devices(&context, &pPlaybackInfos, &playbackCount, &pCaptureInfos, &captureCount) != MA_SUCCESS) { // Error. } -// Loop over each device info and do something with it. Here we just print the name with their index. You may want to give the user the -// opportunity to choose which device they'd prefer. -for (ma_uint32 iDevice = 0; iDevice < playbackDeviceCount; iDevice += 1) { - printf("%d - %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name); +// Loop over each device info and do something with it. Here we just print the name with their index. You may want +// to give the user the opportunity to choose which device they'd prefer. +for (ma_uint32 iDevice = 0; iDevice < playbackCount; iDevice += 1) { + printf("%d - %s\n", iDevice, pPlaybackInfos[iDevice].name); } ma_device_config config = ma_device_config_init(ma_device_type_playback); -config.playback.pDeviceID = &pPlaybackDeviceInfos[chosenPlaybackDeviceIndex].id; +config.playback.pDeviceID = &pPlaybackInfos[chosenPlaybackDeviceIndex].id; config.playback.format = MY_FORMAT; config.playback.channels = MY_CHANNEL_COUNT; config.sampleRate = MY_SAMPLE_RATE; @@ -1098,8 +1098,68 @@ All formats are native-endian.

4. Decoding

-The ma_decoder API is used for reading audio files. Built in support is included for WAV, FLAC and MP3. Support for Vorbis is enabled via stb_vorbis which -can be enabled by including the header section before the implementation of miniaudio, like the following: +The ma_decoder API is used for reading audio files. The following formats are supported: +

+

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + +

+Format

+

+Decoding Backend

+

+Built-In

+

+WAV

+

+dr_wav

+

+Yes

+

+MP3

+

+dr_mp3

+

+Yes

+

+FLAC

+

+dr_flac

+

+Yes

+

+Vorbis

+

+stb_vorbis

+

+No

+

+Vorbis is supported via stb_vorbis which can be enabled by including the header section before the implementation of miniaudio, like the following:

@@ -1120,19 +1180,19 @@ A copy of stb_vorbis is included in the "extras" folder in the miniaud

-Built-in decoders are implemented via dr_wav, dr_flac and dr_mp3. These are amalgamated into the implementation section of miniaudio. You can disable the -built-in decoders by specifying one or more of the following options before the miniaudio implementation: +Built-in decoders are amalgamated into the implementation section of miniaudio. You can disable the built-in decoders by specifying one or more of the +following options before the miniaudio implementation:

 #define MA_NO_WAV
-#define MA_NO_FLAC
 #define MA_NO_MP3
+#define MA_NO_FLAC
 

-Disabling built-in versions of dr_wav, dr_flac and dr_mp3 is useful if you use these libraries independantly of the ma_decoder API. +Disabling built-in decoding libraries is useful if you use these libraries independantly of the ma_decoder API.

@@ -1404,7 +1464,14 @@ conversion. Below is an example of initializing a simple channel converter which

-ma_channel_converter_config config = ma_channel_converter_config_init(ma_format, 1, NULL, 2, NULL, ma_channel_mix_mode_default, NULL);
+ma_channel_converter_config config = ma_channel_converter_config_init(
+    ma_format,                      // Sample format
+    1,                              // Input channels
+    NULL,                           // Input channel map
+    2,                              // Output channels
+    NULL,                           // Output channel map
+    ma_channel_mix_mode_default);   // The mixing algorithm to use when combining channels.
+
 result = ma_channel_converter_init(&config, &converter);
 if (result != MA_SUCCESS) {
     // Error.
@@ -1442,7 +1509,7 @@ Input and output PCM frames are always interleaved. Deinterleaved layouts are no
 

6.2.1. Channel Mapping

-In addition to converting from one channel count to another, like the example above, The channel converter can also be used to rearrange channels. When +In addition to converting from one channel count to another, like the example above, the channel converter can also be used to rearrange channels. When initializing the channel converter, you can optionally pass in channel maps for both the input and output frames. If the channel counts are the same, and each channel map contains the same channel positions with the exception that they're in a different order, a simple shuffling of the channels will be performed. If, however, there is not a 1:1 mapping of channel positions, or the channel counts differ, the input channels will be mixed based on a mixing mode which is @@ -1546,7 +1613,7 @@ FreeBSD's sound(4).

ma_standard_channel_map_sndio

-sndio channel map. http://www.sndio.org/tips.html

+sndio channel map. http://www.sndio.org/tips.html.

-https://webaudio.github.io/web-audio-api/#ChannelOrdering

+https://webaudio.github.io/web-audio-api/#ChannelOrdering

@@ -1735,7 +1802,13 @@ Resampling is achieved with the ma_resample

-ma_resampler_config config = ma_resampler_config_init(ma_format_s16, channels, sampleRateIn, sampleRateOut, ma_resample_algorithm_linear);
+ma_resampler_config config = ma_resampler_config_init(
+    ma_format_s16,
+    channels,
+    sampleRateIn,
+    sampleRateOut,
+    ma_resample_algorithm_linear);
+
 ma_resampler resampler;
 ma_result result = ma_resampler_init(&config, &resampler);
 if (result != MA_SUCCESS) {
@@ -2429,7 +2502,13 @@ miniaudio supports generation of sine, square, triangle and sawtooth waveforms.
 
 

-ma_waveform_config config = ma_waveform_config_init(FORMAT, CHANNELS, SAMPLE_RATE, ma_waveform_type_sine, amplitude, frequency);
+ma_waveform_config config = ma_waveform_config_init(
+    FORMAT,
+    CHANNELS,
+    SAMPLE_RATE,
+    ma_waveform_type_sine,
+    amplitude,
+    frequency);
 
 ma_waveform waveform;
 ma_result result = ma_waveform_init(&config, &waveform);
@@ -2447,7 +2526,7 @@ The amplitude, frequency and sample rate can be changed dynamically with 
 

-You can reverse the waveform by setting the amplitude to a negative value. You can use this to control whether or not a sawtooth has a positive or negative +You can invert the waveform by setting the amplitude to a negative value. You can use this to control whether or not a sawtooth has a positive or negative ramp, for example.

@@ -2496,7 +2575,12 @@ miniaudio supports generation of white, pink and Brownian noise via the

-ma_noise_config config = ma_noise_config_init(FORMAT, CHANNELS, ma_noise_type_white, SEED, amplitude);
+ma_noise_config config = ma_noise_config_init(
+    FORMAT,
+    CHANNELS,
+    ma_noise_type_white,
+    SEED,
+    amplitude);
 
 ma_noise noise;
 ma_result result = ma_noise_init(&config, &noise);
@@ -2557,8 +2641,8 @@ ma_noise_type_brownian

9. Audio Buffers

-miniaudio supports reading from a buffer of raw audio data via the ma_audio_buffer API. This can read from both memory that's managed by the application, but -can also handle the memory management for you internally. The way memory is managed is flexible and should support most use cases. +miniaudio supports reading from a buffer of raw audio data via the ma_audio_buffer API. This can read from memory that's managed by the application, but +can also handle the memory management for you internally. Memory management is flexible and should support most use cases.

@@ -2568,7 +2652,13 @@ Audio buffers are initialised using the standard configuration system used every

-ma_audio_buffer_config config = ma_audio_buffer_config_init(format, channels, sizeInFrames, pExistingData, &allocationCallbacks);
+ma_audio_buffer_config config = ma_audio_buffer_config_init(
+    format,
+    channels,
+    sizeInFrames,
+    pExistingData,
+    &allocationCallbacks);
+
 ma_audio_buffer buffer;
 result = ma_audio_buffer_init(&config, &buffer);
 if (result != MA_SUCCESS) {
@@ -2580,8 +2670,8 @@ result = ma_audio_buffer_init(&config, &buffer);
 ma_audio_buffer_uninit(&buffer);
 

-In the example above, the memory pointed to by pExistingData will _not_ be copied which is how an application can handle memory allocations themselves. If -you would rather make a copy of the data, use ma_audio_buffer_init_copy(). To uninitialize the buffer, use ma_audio_buffer_uninit(). +In the example above, the memory pointed to by pExistingData will _not_ be copied and is how an application can do self-managed memory allocation. If you +would rather make a copy of the data, use ma_audio_buffer_init_copy(). To uninitialize the buffer, use ma_audio_buffer_uninit().

@@ -2592,7 +2682,13 @@ the raw audio data will be located immediately after the

-ma_audio_buffer_config config = ma_audio_buffer_config_init(format, channels, sizeInFrames, pExistingData, &allocationCallbacks);
+ma_audio_buffer_config config = ma_audio_buffer_config_init(
+    format,
+    channels,
+    sizeInFrames,
+    pExistingData,
+    &allocationCallbacks);
+
 ma_audio_buffer* pBuffer
 result = ma_audio_buffer_alloc_and_init(&config, &pBuffer);
 if (result != MA_SUCCESS) {
@@ -2691,8 +2787,8 @@ routines. Passing in NULL for this r
 

-Use ma_pcm_rb_init_ex() if you need a deinterleaved buffer. The data for each sub-buffer is offset from each other based on the stride. To manage your sub- -buffers you can use ma_pcm_rb_get_subbuffer_stride(), ma_pcm_rb_get_subbuffer_offset() and ma_pcm_rb_get_subbuffer_ptr(). +Use ma_pcm_rb_init_ex() if you need a deinterleaved buffer. The data for each sub-buffer is offset from each other based on the stride. To manage your +sub-buffers you can use ma_pcm_rb_get_subbuffer_stride(), ma_pcm_rb_get_subbuffer_offset() and ma_pcm_rb_get_subbuffer_ptr().

@@ -2717,7 +2813,7 @@ there is too little space between the pointers, move the write pointer forward.

You can use a ring buffer at the byte level instead of the PCM frame level by using the ma_rb API. This is exactly the same, only you will use the ma_rb -functions instead of ma_pcm_rb and instead of frame counts pass around byte counts. +functions instead of ma_pcm_rb and instead of frame counts you will pass around byte counts.