-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (31 loc) · 941 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var fs = require('fs');
var lame = require('lame');
var stream = require('stream');
var parser = new stream.Transform({objectMode: true});
var totalsamples = 0;
parser._transform = function(chunk, encoding, done){
console.log(chunk.length);
for (var j = 0; j < chunk.length; j = j+4){
var firstSample = chunk.readInt16BE(j, true);
// this.push(totalsamples+','+firstSample+'\n');
this.push(new Buffer(firstSample));
totalsamples++;
}
done();
}
var writer = fs.createWriteStream('text.txt')
.on('finish', function(){console.log('finished writing')});
var pcmWriter = fs.createWriteStream('raw.pcm')
.on('finish', function(){console.log('finished raw dump')});
var decoded = fs.createReadStream('heyyou.mp3')
.on('end', function(){
console.log("Finished reading");
})
.pipe(new lame.Decoder())
.pipe(pcmWriter);
// decoded
// .pipe(parser)
// .pipe(pcmWriter);
// decoded
// .pipe(parser);
// .pipe(writer);