Simulator first commit
This commit is contained in:
10
node_modules/lame/examples/floatpcm2mp3.js
generated
vendored
Normal file
10
node_modules/lame/examples/floatpcm2mp3.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
var fs = require('fs');
|
||||
var lame = require('../');
|
||||
var path = require('path');
|
||||
|
||||
fs.createReadStream(process.argv[2] || path.resolve(__dirname, 'sample.float.pcm'))
|
||||
.pipe(new lame.Encoder({ channels: 2, bitDepth: 32, float: true }))
|
||||
.pipe(fs.createWriteStream(path.resolve(__dirname, 'sample_pcm.mp3')))
|
||||
.on('close', function () {
|
||||
console.error('done!');
|
||||
});
|
55
node_modules/lame/examples/mp32wav.js
generated
vendored
Normal file
55
node_modules/lame/examples/mp32wav.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
/**
|
||||
* An example using node-lame and node-wav to decode an MP3 file and save it into
|
||||
* a WAVE file.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
var lame = require('../');
|
||||
var wav = require('wav');
|
||||
var filename = process.argv[2];
|
||||
|
||||
if (process.stdin.isTTY && !filename) {
|
||||
// print help
|
||||
console.error('usage:');
|
||||
console.error(' decode an mp3 file:');
|
||||
console.error(' $ %s <infile.mp3> <outfile.wav>', process.argv.join(' '));
|
||||
console.error(' or decode mp3 data from stdin:');
|
||||
console.error(' $ cat song.mp3 | %s | ffplay -', process.argv.join(' '));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// first figure out if we're decoding from a filename, or from stdin
|
||||
var input;
|
||||
var output;
|
||||
if (filename) {
|
||||
var outfile = process.argv[3];
|
||||
if (!outfile) {
|
||||
console.error('FATAL: must specify an output .wav file!');
|
||||
process.exit(1);
|
||||
}
|
||||
console.error('encoding %j', filename);
|
||||
console.error('to %j', outfile);
|
||||
input = fs.createReadStream(filename);
|
||||
output = fs.createWriteStream(outfile);
|
||||
} else {
|
||||
input = process.stdin;
|
||||
output = process.stdout;
|
||||
}
|
||||
|
||||
// start reading the MP3 file from the input
|
||||
var decoder = new lame.Decoder();
|
||||
|
||||
// we have to wait for the "format" event before we can start encoding
|
||||
decoder.on('format', onFormat);
|
||||
|
||||
// and start transferring the data
|
||||
input.pipe(decoder);
|
||||
|
||||
function onFormat (format) {
|
||||
console.error('MP3 format: %j', format);
|
||||
|
||||
// write the decoded MP3 data into a WAV file
|
||||
var writer = new wav.Writer(format);
|
||||
decoder.pipe(writer).pipe(output);
|
||||
}
|
8
node_modules/lame/examples/mp3player.js
generated
vendored
Normal file
8
node_modules/lame/examples/mp3player.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var fs = require('fs');
|
||||
var lame = require('../');
|
||||
var Speaker = require('speaker');
|
||||
|
||||
fs.createReadStream(process.argv[2])
|
||||
.pipe(new lame.Decoder)
|
||||
.on('format', console.log)
|
||||
.pipe(new Speaker);
|
BIN
node_modules/lame/examples/sample.float.pcm
generated
vendored
Normal file
BIN
node_modules/lame/examples/sample.float.pcm
generated
vendored
Normal file
Binary file not shown.
55
node_modules/lame/examples/wav2mp3.js
generated
vendored
Normal file
55
node_modules/lame/examples/wav2mp3.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
/**
|
||||
* Here's a clone of the popular "wav2mp3" program, but using node-lame and
|
||||
* node-wav.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
var lame = require('../');
|
||||
var wav = require('wav');
|
||||
var filename = process.argv[2];
|
||||
|
||||
if (process.stdin.isTTY && !filename) {
|
||||
// print help
|
||||
console.error('usage:');
|
||||
console.error(' encode a wav file:');
|
||||
console.error(' $ %s <infile.wav> <outfile.mp3>', process.argv.join(' '));
|
||||
console.error(' or encode a wav from stdin:');
|
||||
console.error(' $ cat song.wav | %s | mpg123 -', process.argv.join(' '));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// first figure out if we're encoding from a filename, or from stdin
|
||||
var input;
|
||||
var output;
|
||||
if (filename) {
|
||||
var outfile = process.argv[3];
|
||||
if (!outfile) {
|
||||
console.error('FATAL: must specify an output mp3 file!');
|
||||
process.exit(1);
|
||||
}
|
||||
console.error('encoding %j', filename);
|
||||
console.error('to %j', outfile);
|
||||
input = fs.createReadStream(filename);
|
||||
output = fs.createWriteStream(outfile);
|
||||
} else {
|
||||
input = process.stdin;
|
||||
output = process.stdout;
|
||||
}
|
||||
|
||||
// start reading the WAV file from the input
|
||||
var reader = new wav.Reader();
|
||||
|
||||
// we have to wait for the "format" event before we can start encoding
|
||||
reader.on('format', onFormat);
|
||||
|
||||
// and start transferring the data
|
||||
input.pipe(reader);
|
||||
|
||||
function onFormat (format) {
|
||||
console.error('WAV format: %j', format);
|
||||
|
||||
// encoding the wave file into an MP3 is as simple as calling pipe()
|
||||
var encoder = new lame.Encoder(format);
|
||||
reader.pipe(encoder).pipe(output);
|
||||
}
|
Reference in New Issue
Block a user