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