Skip to content

Commit

Permalink
Add section about reading wav files to README
Browse files Browse the repository at this point in the history
  • Loading branch information
rochars committed Jan 22, 2020
1 parent 6979dbd commit 4f3f4bd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Create, read and write wav files according to the specs.
With **wavefile** you can:

- [Create wav files](#create-wave-files-from-scratch)
- [Read wav files](#use)
- [Read wav files](#read-wave-files)
- [Change the bit depth of the audio](#change-the-bit-depth)
- [Change the sample rate of the audio](#change-the-sample-rate)
- [Read and write RIFF tags](#add-riff-tags-to-files)
Expand Down Expand Up @@ -149,6 +149,7 @@ let wavDataURI = wav.toDataURI();
- [Use](#use)
- [Operation Manual](#operation-manual)
* [Create wave files from scratch](#create-wave-files-from-scratch)
* [Read wave files](#read-wave-files)
* [Add RIFF tags to files](#add-riff-tags-to-files)
* [Add cue points to files](#add-cue-points-to-files)
* [Create regions in files](#create-regions-in-files)
Expand Down Expand Up @@ -213,6 +214,18 @@ You can also use any bit depth between "8" and "53", like **"11", "12", "17", "2
#### A word on bit depth
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.

### Read wave files
```javascript
const WaveFile = require('wavefile').WaveFile;
wav = new WaveFile();
// Read a wav file from a buffer
wav.fromBuffer(buffer);
// Read a wav file from a base64 string
wav.fromBase64(base64);
// Read a wav file from a data URI
wav.fromDataURI(dataURI);
```

### Add RIFF tags to files
You can create (or overwrite) tags on files with the **WaveFile.setTag()** method.
```javascript
Expand Down
13 changes: 12 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h2>Notice</h2>
<p>With <strong>wavefile</strong> you can:</p>
<ul>
<li><a href="#create-wave-files-from-scratch">Create wav files</a></li>
<li><a href="#use">Read wav files</a></li>
<li><a href="#read-wave-files">Read wav files</a></li>
<li><a href="#change-the-bit-depth">Change the bit depth of the audio</a></li>
<li><a href="#change-the-sample-rate">Change the sample rate of the audio</a></li>
<li><a href="#add-riff-tags-to-files">Read and write RIFF tags</a></li>
Expand Down Expand Up @@ -180,6 +180,7 @@ <h2>Table of Contents</h2>
<li><a href="#operation-manual">Operation Manual</a>
<ul>
<li><a href="#create-wave-files-from-scratch">Create wave files from scratch</a></li>
<li><a href="#read-wave-files">Read wave files</a></li>
<li><a href="#add-riff-tags-to-files">Add RIFF tags to files</a></li>
<li><a href="#add-cue-points-to-files">Add cue points to files</a></li>
<li><a href="#create-regions-in-files">Create regions in files</a></li>
Expand Down Expand Up @@ -244,6 +245,16 @@ <h4>Stereo:</h4>
<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>
<h4>A word on bit depth</h4>
<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>
<h3>Read wave files</h3>
<pre class="prettyprint source lang-javascript"><code>const WaveFile = require('wavefile').WaveFile;
wav = new WaveFile();
// Read a wav file from a buffer
wav.fromBuffer(buffer);
// Read a wav file from a base64 string
wav.fromBase64(base64);
// Read a wav file from a data URI
wav.fromDataURI(dataURI);
</code></pre>
<h3>Add RIFF tags to files</h3>
<p>You can create (or overwrite) tags on files with the <strong>WaveFile.setTag()</strong> method.</p>
<pre class="prettyprint source lang-javascript"><code>// Write the ICMT tag with some comments to the file
Expand Down

0 comments on commit 4f3f4bd

Please sign in to comment.