You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/pins/audioout.md
+12-5Lines changed: 12 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# AudioOut
2
2
Copyright 2018 Moddable Tech, Inc.
3
3
4
-
Revised: February 23, 2018
4
+
Revised: March 19, 2018
5
5
6
6
**Warning**: These notes are preliminary. Omissions and errors are likely. If you encounter problems, please ask for assistance.
7
7
@@ -124,9 +124,15 @@ The enqueue function has several different functions, all related to the audio q
124
124
All invocations of the `enqueue` function include the first parameter, the target stream number, a value from 0 to one less than the number of streams configured using the constructor.
125
125
126
126
#### Enqueuing audio samples
127
-
To `enqueue`audio samples call enqueue with a buffer of samples:
127
+
Audio samples to play may be provided either as a MAUD audio resource or as raw audio samples. In both cases, the samples must be in the same format as the audio output (e.g. have the same sample rate, bits per sample, and number of channels).
128
128
129
-
audio.enqueue(0, buffer);
129
+
To `enqueue` audio samples with a Moddable Audio header (MAUD), call enqueue with a buffer of samples:
130
+
131
+
audio.enqueue(0, AuioOut.Samples, buffer);
132
+
133
+
To `enqueue` a buffer of audio samples with no header call enqueue with a buffer of samples:
134
+
135
+
audio.enqueue(0, AudioOut.RawSamples, buffer);
130
136
131
137
To play the buffer several times, specify the optional `repeat` count. The repeat count is either a positive integer or `Infinity`.
132
138
@@ -159,9 +165,9 @@ To change the volume, enqueue a `Volume` command on a stream. The volume command
159
165
Values for the volume command range from 0 for silent, to 256 for full volume.
160
166
161
167
## MAUD format
162
-
The `maud` format, "Moddable Audio", is a trivial uncompressed audio format intended to be compact and trivially parsed. The `enqueue` function of `AudioOut` class accepts only samples in the `maud` format.
168
+
The `maud` format, "Moddable Audio", is a simple uncompressed audio format intended to be compact and trivially parsed. The `enqueue` function of `AudioOut` class accepts samples in the `maud` format. The `wav2maud` tool in the Moddable SDK converts WAV files to `maud` resources.
163
169
164
-
The format has a simple twelve byte header followed by samples.
170
+
The format has a twelve byte header followed immediately by audio samples.
165
171
166
172
- offset 0 -- ASCII 'm'
167
173
- offset 1 -- ASCII 'a'
@@ -187,6 +193,7 @@ The `audioOut` module is be configured at build time.
187
193
-`MODDEF_AUDIOOUT_I2S_BCK_PIN` -- The I2S clock pin. The default is 26.
188
194
-`MODDEF_AUDIOOUT_I2S_LR_PIN` -- The I2S LR pin. The default is 25.
189
195
-`MODDEF_AUDIOOUT_I2S_DATAOUT_PIN` -- The I2S data pin. The default is 22.
196
+
-`MODDEF_AUDIOOUT_I2S_BITSPERSAMPLE` - Number of bits per sample to transmit over I2S, either 16 or 32. Default is 16.
190
197
191
198
### Defines for ESP8266
192
199
-`MODDEF_AUDIOOUT_I2S_PDM` -- If zero, PCM samples are transmitted over I2S. If non-zero, samples are transmitted using PDM. Set to 32 for no oversampling, 64 for 2x oversampling, and 128 for 4x oversampling. Default is 0.
0 commit comments