Skip to content

Commit 4f3f4bd

Browse files
committed
Add section about reading wav files to README
1 parent 6979dbd commit 4f3f4bd

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Create, read and write wav files according to the specs.
2121
With **wavefile** you can:
2222

2323
- [Create wav files](#create-wave-files-from-scratch)
24-
- [Read wav files](#use)
24+
- [Read wav files](#read-wave-files)
2525
- [Change the bit depth of the audio](#change-the-bit-depth)
2626
- [Change the sample rate of the audio](#change-the-sample-rate)
2727
- [Read and write RIFF tags](#add-riff-tags-to-files)
@@ -149,6 +149,7 @@ let wavDataURI = wav.toDataURI();
149149
- [Use](#use)
150150
- [Operation Manual](#operation-manual)
151151
* [Create wave files from scratch](#create-wave-files-from-scratch)
152+
* [Read wave files](#read-wave-files)
152153
* [Add RIFF tags to files](#add-riff-tags-to-files)
153154
* [Add cue points to files](#add-cue-points-to-files)
154155
* [Create regions in files](#create-regions-in-files)
@@ -213,6 +214,18 @@ You can also use any bit depth between "8" and "53", like **"11", "12", "17", "2
213214
#### A word on bit depth
214215
Resolutions other than 4-bit, 8-bit, 16-bit, 24-bit, 32-bit (integer), 32-bit (fp) and 64-bit (fp) are implemented as WAVE_FORMAT_EXTENSIBLE and may not be supported by some players.
215216

217+
### Read wave files
218+
```javascript
219+
const WaveFile = require('wavefile').WaveFile;
220+
wav = new WaveFile();
221+
// Read a wav file from a buffer
222+
wav.fromBuffer(buffer);
223+
// Read a wav file from a base64 string
224+
wav.fromBase64(base64);
225+
// Read a wav file from a data URI
226+
wav.fromDataURI(dataURI);
227+
```
228+
216229
### Add RIFF tags to files
217230
You can create (or overwrite) tags on files with the **WaveFile.setTag()** method.
218231
```javascript

docs/index.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ <h2>Notice</h2>
7575
<p>With <strong>wavefile</strong> you can:</p>
7676
<ul>
7777
<li><a href="#create-wave-files-from-scratch">Create wav files</a></li>
78-
<li><a href="#use">Read wav files</a></li>
78+
<li><a href="#read-wave-files">Read wav files</a></li>
7979
<li><a href="#change-the-bit-depth">Change the bit depth of the audio</a></li>
8080
<li><a href="#change-the-sample-rate">Change the sample rate of the audio</a></li>
8181
<li><a href="#add-riff-tags-to-files">Read and write RIFF tags</a></li>
@@ -180,6 +180,7 @@ <h2>Table of Contents</h2>
180180
<li><a href="#operation-manual">Operation Manual</a>
181181
<ul>
182182
<li><a href="#create-wave-files-from-scratch">Create wave files from scratch</a></li>
183+
<li><a href="#read-wave-files">Read wave files</a></li>
183184
<li><a href="#add-riff-tags-to-files">Add RIFF tags to files</a></li>
184185
<li><a href="#add-cue-points-to-files">Add cue points to files</a></li>
185186
<li><a href="#create-regions-in-files">Create regions in files</a></li>
@@ -244,6 +245,16 @@ <h4>Stereo:</h4>
244245
<p>You can also use any bit depth between &quot;8&quot; and &quot;53&quot;, like <strong>&quot;11&quot;, &quot;12&quot;, &quot;17&quot;, &quot;20&quot; and so on</strong>.</p>
245246
<h4>A word on bit depth</h4>
246247
<p>Resolutions other than 4-bit, 8-bit, 16-bit, 24-bit, 32-bit (integer), 32-bit (fp) and 64-bit (fp) are implemented as WAVE_FORMAT_EXTENSIBLE and may not be supported by some players.</p>
248+
<h3>Read wave files</h3>
249+
<pre class="prettyprint source lang-javascript"><code>const WaveFile = require('wavefile').WaveFile;
250+
wav = new WaveFile();
251+
// Read a wav file from a buffer
252+
wav.fromBuffer(buffer);
253+
// Read a wav file from a base64 string
254+
wav.fromBase64(base64);
255+
// Read a wav file from a data URI
256+
wav.fromDataURI(dataURI);
257+
</code></pre>
247258
<h3>Add RIFF tags to files</h3>
248259
<p>You can create (or overwrite) tags on files with the <strong>WaveFile.setTag()</strong> method.</p>
249260
<pre class="prettyprint source lang-javascript"><code>// Write the ICMT tag with some comments to the file

0 commit comments

Comments
 (0)