Closed roccomuso closed 5 years ago
@roccomuso does bpm.js work with your createAudioStream()
function?
Please post a stack trace of the error you're getting.
@ArtskydJ it works with the createAudioStream()
function.
The code I'm trying to execute is this:
var sox = require('sox-stream')
var fs = require('fs')
var src = fs.createReadStream('hellberg.mp3')
var transcode = sox({
input: {
type: 'mp3',
encoding: 'float',
rate: 44100,
channels: 1
},
output: {
type: 'mp3'
}
})
src.pipe(transcode)
and returns this error:
events.js:160
throw er; // Unhandled 'error' event
^
Error: sox WARN formats: can't set 1 channels; using 2
at Socket.<anonymous> (/tmp/hello/node_modules/sox-stream/index.js:33:23)
Changing channel to 2 apparently i got a valid stream.
But when piped to bpm.js
after a while you get this:
/tmp/bpm.js/index.js:0
RangeError: Index out of range
at checkOffset (buffer.js:830:11)
at Buffer.readFloatLE (buffer.js:1007:5)
at bufRead (/tmp/bpm.js/index.js:129:14)
at DestroyableTransform.write [as _transform] (/tmp/bpm.js/index.js:148:15)
at DestroyableTransform.Transform._read (/tmp/bpm.js/node_modules/readable-stream/lib/_stream_transform.js:182:10)
at DestroyableTransform.Transform._write (/tmp/bpm.js/node_modules/readable-stream/lib/_stream_transform.js:170:83)
at doWrite (/tmp/bpm.js/node_modules/readable-stream/lib/_stream_writable.js:406:64)
at writeOrBuffer (/tmp/bpm.js/node_modules/readable-stream/lib/_stream_writable.js:395:5)
at DestroyableTransform.Writable.write (/tmp/bpm.js/node_modules/readable-stream/lib/_stream_writable.js:322:11)
at Stream.ondata (stream.js:31:26)
If you use sox-stream with 2 channels, and pipe it to fs.createWriteStream('mynewfile.mp3')
, and then run your bpm code with fs.createReadStream('mynewfile.mp3')
, then does bpm.js accept it?
My guess is that sox doesn't like mono audio, and bpm.js doesn't like stereo?
@roccomuso since I haven't heard from you, I'm gonna close this issue. @ reply if you have any questions.
Sorry, 've been busy lately.
I did what you said. bpm.js
keeps saying "Range Error: Index out of range".
NB. mynewfile.mp3
is 725159 bytes. The original mp3 is 725240. We have 81 bytes of difference.
With the original sox
from CLI (using this cmd: sox wave.mp3 -t raw -r 44100 -e float -c 2 out.mp3
), the output file size is: 15980544.
With the cli tool I'm also able to set -c 1, with sox-stream it throws: Error: sox WARN formats: can't set 1 channels; using 2
I looked at bpm.js
code, and this line return arr.readFloatLE(i*4);
appears to be erroring.
Maybe run the mp3 through sox-stream
, and then write it to the file system. Then read it from the file system and pipe it through bpm.js
? If that works, then it is an issue with the interface of sox-stream and bpm.js aren't compatible. (Which would be weird since they're both streams.) But if that's the case, you might just want to use sox.js
instead of sox-stream
.
It's exactly what i did Range Error: Index out of range
.
It's some other issue.
So if you run the file through sox using the command line using the same options you used with sox-stream
, and then you read the file using bpm.js, are you getting the Range Error: Index out of range
error then too?
Maybe try an assortment of mp3s?
yes. I should try with different mp3..
Closing since this has been inactive for over half of a year. Reply or re-open if this is still an issue.
Can you take a look at this? https://github.com/monstercat/bpm.js/issues/5
I'm trying to make this module works with bpm.js.
I'm trying to do with sox-stream the equivalent of this: