Skip to content

Commit

Permalink
select the output bit depth when decoding compressed audio
Browse files Browse the repository at this point in the history
  • Loading branch information
rochars committed May 6, 2018
1 parent 62ab074 commit d927b7b
Show file tree
Hide file tree
Showing 17 changed files with 548 additions and 96 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## version 6.3.0 (2018-05-06)
- fromIMAADPCM, fromALaw and fromMuLaw can receive an optional parameter: the bit depth of the output. If ommited, defaults to "16".
- Fix: argument validation in fromScratch

## version 6.2.0 (2018-05-04)
- Limited support of RF64. Need to be tested with files > 4gb in size.

Expand Down
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ To decode 4-bit IMA-ADPCM as 16-bit linear PCM:
wav.fromIMAADPCM();
```

Decoding always result in 16-bit audio.
Decoding always result in 16-bit audio. To decode to another bit depth:
```javascript
// Decode 4-bit IMA-ADPCM as 24-bit:
wav.fromIMAADPCM("24");
```

### A-Law
16-bit wave files (mono or stereo) can be encoded as A-Law:
Expand All @@ -212,8 +216,11 @@ To decode 8-bit A-Law as 16-bit linear PCM:
wav.fromALaw();
```

Decoding always result in 16-bit audio.

Decoding always result in 16-bit audio. To decode to another bit depth:
```javascript
// Decode 8-bit A-Law as 24-bit:
wav.fromALaw("24");
```
### mu-Law
16-bit wave files (mono or stereo) can be encoded as mu-Law:
```javascript
Expand All @@ -229,7 +236,11 @@ To decode 8-bit mu-Law as 16-bit linear PCM:
wav.fromMuLaw();
```

Decoding always result in 16-bit audio.
Decoding always result in 16-bit audio. To decode to another bit depth:
```javascript
// Decode 8-bit mu-Law as 24-bit:
wav.fromMuLaw("24");
```

### Change the bit depth
You **can't** change to and from 4-bit ADPCM, 8-bit A-Law and 8-bit mu-Law. To encode/decode files as ADPCM, A-Law and mu-Law you must use the *toIMAADPCM()*, *fromIMAADPCM()*, *toALaw()*, *fromALaw()*, *toMuLaw()* and *fromMuLaw()* methods.
Expand Down
15 changes: 12 additions & 3 deletions compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
const WaveFile = require("./index.js");

/*
WaveFile.prototype["container"] = WaveFile.prototype.container;
WaveFile.prototype["chunkSize"] = WaveFile.prototype.chunkSize;
WaveFile.prototype["format"] = WaveFile.prototype.format;
WaveFile.prototype["fromScratch"] = WaveFile.prototype.fromScratch;
WaveFile.prototype["fromBuffer"] = WaveFile.prototype.fromBuffer;
WaveFile.prototype["toBuffer"] = WaveFile.prototype.toBuffer;
Expand All @@ -24,6 +21,18 @@ WaveFile.prototype["toALaw"] = WaveFile.prototype.toALaw;
WaveFile.prototype["fromALaw"] = WaveFile.prototype.fromALaw;
WaveFile.prototype["toMuLaw"] = WaveFile.prototype.toMuLaw;
WaveFile.prototype["fromMuLaw"] = WaveFile.prototype.fromMuLaw;
WaveFile.prototype["container"] = WaveFile.prototype.container;
WaveFile.prototype["chunkSize"] = WaveFile.prototype.chunkSize;
WaveFile.prototype["format"] = WaveFile.prototype.format;
WaveFile.prototype["fmt"] = WaveFile.prototype.fmt;
WaveFile.prototype["fact"] = WaveFile.prototype.fact;
WaveFile.prototype["bext"] = WaveFile.prototype.bext;
WaveFile.prototype["ds64"] = WaveFile.prototype.ds64;
WaveFile.prototype["cue"] = WaveFile.prototype.cue;
WaveFile.prototype["data"] = WaveFile.prototype.data;
WaveFile.prototype["isInterleaved"] = WaveFile.prototype.isInterleaved;
WaveFile.prototype["bitDepth"] = WaveFile.prototype.bitDepth;
*/

window["WaveFile"] = WaveFile;
104 changes: 52 additions & 52 deletions dist/wavefile-min.js

Large diffs are not rendered by default.

Loading

0 comments on commit d927b7b

Please sign in to comment.