-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaudio.js
More file actions
30 lines (24 loc) · 761 Bytes
/
Copy pathaudio.js
File metadata and controls
30 lines (24 loc) · 761 Bytes
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
var lame = require('lame');
// create the Encoder instance
var encoder = new lame.Encoder({
// input
channels: 1, // 2 channels (left and right)
bitDepth: 16, // 16-bit samples
sampleRate: 48000, // 44,100 Hz sample rate
// output
bitRate: 64,
outSampleRate: 48000,
mode: lame.MONO // STEREO (default), JOINTSTEREO, DUALCHANNEL or MONO
});
process.stdin.pipe(encoder);
// set up an express app
var express = require('express')
var app = express()
app.get('/stream.mp3', function (req, res) {
res.set({
'Content-Type': 'audio/mpeg3',
'Transfer-Encoding': 'chunked'
});
encoder.pipe(res);
});
var server = app.listen(3000, '127.0.0.1');