Other Sampling Rates #6

pedromtavares opened this Issue Nov 15, 2012 · 7 comments


None yet
3 participants

Yo Nate! :)

So I'm back to working on my radio website that I've talked to you about in the past, but fortunately my question today is quite small!

The issue is that I'm streaming mp3 files from all over the internet, and thus, they don't come in a same pretty pattern, they all have completely different bit rates and sampling rates. The bit rate problem I managed to solve, but the sampling rates problem sort of depends on this lib, hehe.


This array only allows those sampling rates, and when a file comes with a sampling rate of say 22050 (I'm spawning a process of ffprobe to figure out this info on a track), then it bugs everything and doesn't run, haha.

To make a big story short, is adding new sampling rates as easy as adding numbers to that array? Or is the issue deeper than that?

By the way, I'll be writing a huge blog post about the part 2 of the radio website and you can expect another big thank you in there :P



TooTallNate commented Nov 15, 2012

Hey @pedromtavares! Long time!

So basically I've been hard at work on node-lame recently, mainly implementing the Decoder. But you should check out the https://github.com/TooTallNate/node-lame/tree/gyp gyp branch. I'll be merging it into master soon for a v1.0 release. But the Parser class that I wrote I've removed, and am planning on moving it to another repo probably. It doesn't belong in node-lame.

However, the rewritten Encoder class supports both sampleRate and outSampleRate iirc, so it does some basic resampling. You should check it out!

Hmmmm cool! I guess I'll wait for that then since I'm guessing it's not production ready yet :)

If it's not asking too much, could you post here when it's ready? This way I'll get the notification on my e-mail immediately and test it out!


TooTallNate commented Dec 8, 2012

Hey @pedromtavares. Just wanted to pop in and say that I published lame@v1.0.0 just now. There's still lots of work to be done on it, but at least now there's a Decoder class as well as lame's built-in support for sample rate resampling, which is what you are originally asking for here.

Give it a shot and open new issues if/when you find any. Cheers!

@TooTallNate TooTallNate closed this Dec 8, 2012

Hey Nate,

Just got some time to mess with this stuff again, and my first question is: how should I handle the mp3 parsing now on v1.0? Does the Encoder on 1.0 already return a perfectly parsed mp3 file?


TooTallNate commented Dec 22, 2012

@pedromtavares Ya the Encoder outputs a valid MP3 file. I'll add better docs soon, check out the wav2mp3 example for now: https://github.com/TooTallNate/node-lame/blob/master/examples/wav2mp3.js

Just as an FYI, the resampling doesn't work. Tested it with the first track I found on ex.fm which was had a sample rate of 48000 to output as 44100 and the sound came back distorted. This was the track I tested with: http://a.tumblr.com/tumblr_mawppqiHDe1qe21l5o1.mp3 (it's quite easy to see the difference because the female voice gets much deeper on a failed resample).

I'm getting by currently by spawning a lame process and calling --resample on it directly, but if you ever feel like fixing this resampling bit (I realize it's quite a superficial feature to the module), give a heads up :)

I'll try to find other tracks with different sample rates (like 32000 or 22500) and paste links here if it makes it easier for you.

Edit: here's one that's 22500: http://themusicninja.net/uploadedmp3s/Madeon%20-%20Finale%20%28Dillon%20Francis%20Remix%29.mp3

darkyen commented May 21, 2016

For anyone messing with sample rates there exists node-resampler (libresample) and node-samplerate (libsamplerate) both are backed by incredibly well maintained and performant native modules. I would recommend using them if you are still having a resample issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment