@@ -136,8 +136,30 @@ The above method lets you create `BiquadFilterNode`.
136
136
137
137
#### Returns [ ` BiquadFilterNode ` ] ( /effects/biquad-filter-node ) .
138
138
139
+ :::caution
140
+ Supported file formats:
141
+ - mp3
142
+ - wav
143
+ - flac
144
+ :::
145
+
139
146
### ` decodeAudioData `
140
147
148
+ <details >
149
+ <summary >Example</summary >
150
+ ``` tsx
151
+ const url = ... // url to an audio
152
+
153
+ const buffer = await fetch (url )
154
+ .then ((response ) => response .arrayBuffer ())
155
+ .then ((arrayBuffer ) => this .audioContext .decodeAudioData (arrayBuffer ))
156
+ .catch ((error ) => {
157
+ console .error (' Error decoding audio data source:' , error );
158
+ return null ;
159
+ });
160
+ ```
161
+ </details >
162
+
141
163
The above method lets you decode audio data. It decodes with in memory audio data block.
142
164
143
165
| Parameters | Type | Description |
@@ -148,7 +170,23 @@ The above method lets you decode audio data. It decodes with in memory audio dat
148
170
149
171
### ` decodeAudioDataSource `
150
172
151
- The above method lets you decode audio data file. It saves file in the device file system.
173
+ <details >
174
+ <summary >Example using expo-asset library</summary >
175
+ ``` tsx
176
+ import { Asset } from ' expo-asset' ;
177
+
178
+ const buffer = await Asset .fromModule (require (' @/assets/music/example.mp3' ))
179
+ .downloadAsync ()
180
+ .then ((asset ) => {
181
+ if (! asset .localUri ) {
182
+ throw new Error (' Failed to load audio asset' );
183
+ }
184
+ return this .audioContext .decodeAudioDataSource (asset .localUri );
185
+ })
186
+ ```
187
+ </details >
188
+
189
+ The above method lets you decode audio data file.
152
190
153
191
| Parameters | Type | Description |
154
192
| :---: | :---: | :---- |
@@ -158,11 +196,20 @@ The above method lets you decode audio data file. It saves file in the device fi
158
196
159
197
### ` decodePCMInBase64Data ` <MobileOnly />
160
198
199
+ <details >
200
+ <summary >Example</summary >
201
+ ``` tsx
202
+ const data = ... // data encoded in base64 string
203
+ const buffer = await this .audioContext .decodePCMInBase64Data (data );
204
+ ```
205
+ </details >
206
+
161
207
The above method lets you decode audio data. It decodes with PCM data in Base64.
162
208
163
209
| Parameters | Type | Description |
164
210
| :---: | :---: | :---- |
165
211
| ` base64 ` | ` string ` | Base64 string with audio data. |
212
+ | ` playbackRate ` <Optional /> | ` number ` | Number that represents audio speed, which will be applied during decoding. |
166
213
167
214
#### Returns ` Promise<AudioBuffer> ` .
168
215
0 commit comments