Comments (6)
I think it's a problem with the stream implementation.
Because of the way the metadata of these chiptune files work, libopenmpt needs to receive the whole file before it's able to properly convert it.
The duplex stream implementation reads and buffers the whole stream before starting to write data, and that seems pretty broken at the moment.
You can try reading the whole request stream first to a buffer and then creating a chiptune readable stream from it (something similar to the speaker example), that should work as expected.
from node-chiptune.
Yah even when passing in buffered data into the chiptune decoder, it still outputted choppy audio
Current Code:
var buffer = fs.readFileSync("{path to mod file}")
var chiptuneDecoder = chiptune(buffer, {
channels: 2, // 2 channels (stereo)
sampleRate: 48000 // 48,000 Hz sample rate
});
var lameEncoder = new lame.Encoder({
// input
channels: 2,
bitDepth: 16,
sampleRate: 48000,
// output
bitRate: 128,
outSampleRate: 48000,
mode: lame.STEREO
});
var outputStream = fs.createWriteStream('out.mp3');
chiptuneDecoder.pipe(lameEncoder);
lameEncoder.pipe(outputStream);
from node-chiptune.
I also tried exactly what your example did by just using fs.readfile, and it still output the same laggy audio. If you want a preview of what it sounds like I will attach the output
out.zip
from node-chiptune.
I even tried just outputting the raw PCM data to a file, and it is still choppy, so it isn't anything wrong with the conversion from PCM to mp3 nor just adding the WAVE header with wav.
from node-chiptune.
Ok so even more testing shows that if I set node-chiptune to process 4 channels, it works without issue and produces clean audio
from node-chiptune.
Ok so here is the code I have now. I can now output a clean mp3 using lame, but you still need to fix this issue as it's very weird that it does this.
//This is the example code using fs.readFile, this can be replaced with request to grab the data
fs.readFile("{input file}", function(err, data) {
var chiptuneDecoder = chiptune(data, {
channels: 4, // 2 channels (stereo)
sampleRate: 48000 // 48,000 Hz sample rate
});
var lameEncoder = new lame.Encoder({
// input
channels: 2,
bitDepth: 16,
sampleRate: 96000,
// output
bitRate: 128,
outSampleRate: 48000,
mode: lame.STEREO
});
var outputStream = fs.createWriteStream('out.mp3');
chiptuneDecoder.pipe(lameEncoder);
lameEncoder.pipe(outputStream);
});
from node-chiptune.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-chiptune.