Skip to content

Commit

Permalink
Add ogg/flac versions
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Jun 19, 2017
1 parent ab0965c commit 3317c76
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 4 deletions.
5 changes: 5 additions & 0 deletions flac-base64.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions flac-datauri.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = 'data:audio/flac;base64,' + require('./flac-base64') + '';
6 changes: 6 additions & 0 deletions flac.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @module lena/flac.js
*/
'use strict';

module.exports = require('./decode')(require('./flac-base64'));
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ function lena (options) {
lena.wav = require('./wav')
lena.mp3 = require('./mp3')
lena.raw = require('./raw')
lena.ogg = require('./ogg')
lena.flac = require('./flac')

lena.wavDatauri = require('./wav-datauri')
lena.mp3Datauri = require('./mp3-datauri')
lena.rawDatauri = require('./raw-datauri')
lena.oggDatauri = require('./ogg-datauri')
lena.flacDatauri = require('./flac-datauri')

lena.wavBase64 = require('./wav-base64')
lena.mp3Base64 = require('./mp3-base64')
lena.rawBase64 = require('./raw-base64')
lena.oggBase64 = require('./ogg-base64')
lena.flacBase64 = require('./flac-base64')
Binary file added lena.flac
Binary file not shown.
Binary file added lena.ogg
Binary file not shown.
4 changes: 4 additions & 0 deletions ogg-base64.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions ogg-datauri.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = 'data:audio/ogg;base64,' + require('./ogg-base64') + '';
6 changes: 6 additions & 0 deletions ogg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @module lena/ogg.js
*/
'use strict';

module.exports = require('./decode')(require('./ogg-base64'));
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Appropriate for testing size (1Mb), length (~12s), noisy background, visible spe
| `wav size` | `1.03 Mb` |
| `mp3 size` | `192.8 Kb` |
| `bitRate` | `705kbps` |
| `artist` | `Lena Stolze` |
| `track title` | `Oh lad le` |
| `album title` | `Das schreckliche Mädchen` |
| `year` | `2014` |

## Usage

Expand Down Expand Up @@ -70,12 +74,15 @@ audio.src = mp3
| `audio-lena/raw` | _ArrayBuffer_ with float32 samples. |
| `audio-lena/mp3` | _ArrayBuffer_ with encoded mp3 data. |
| `audio-lena/wav` | _ArrayBuffer_ with encoded wav data. |
| `audio-lena/ogg` | _ArrayBuffer_ with encoded ogg data. |
| `audio-lena/raw-base64` | Base64 string with encoded float32 samples. |
| `audio-lena/mp3-base64` | Base64 string with encoded mp3 data. |
| `audio-lena/wav-base64` | Base64 string with encoded wav data. |
| `audio-lena/ogg-base64` | Base64 string with encoded ogg data. |
| `audio-lena/raw-datauri` | Data-URI string with encoded float32 samples. |
| `audio-lena/mp3-datauri` | Data-URI string with encoded mp3 data. |
| `audio-lena/wav-datauri` | Data-URI string with encoded wav data. |
| `audio-lena/ogg-datauri` | Data-URI string with encoded ogg data. |

### let result = lena({format: 'mp3', type: 'float'}?)

Expand Down
6 changes: 3 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ if (typeof document !== 'undefined') {
setTimeout(() => source.stop(), 500)


//mp3-datauri
var mp3 = require('./')({format: 'mp3', type: 'data-uri'})
//ogg-datauri
var ogg = require('./')({format: 'ogg', type: 'data-uri'})

var audio = new Audio()
audio.addEventListener('canplay', () => {
console.log("Can play!")
audio.play()
setTimeout(() => audio.pause(), 500)
})
audio.src = mp3
audio.src = ogg
}
2 changes: 1 addition & 1 deletion wav-datauri.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict';

module.exports = 'data:audio/mpeg;base64,' + require('./wav-base64') + '';
module.exports = 'data:audio/wav;base64,' + require('./wav-base64') + '';

0 comments on commit 3317c76

Please sign in to comment.