Coder Social home page Coder Social logo

Get it works with bpm.js about sox-stream HOT 11 CLOSED

artskydj avatar artskydj commented on May 27, 2024
Get it works with bpm.js

from sox-stream.

Comments (11)

ArtskydJ avatar ArtskydJ commented on May 27, 2024

@roccomuso does bpm.js work with your createAudioStream() function?

Please post a stack trace of the error you're getting.

from sox-stream.

roccomuso avatar roccomuso commented on May 27, 2024

@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)

from sox-stream.

ArtskydJ avatar ArtskydJ commented on May 27, 2024

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?

from sox-stream.

ArtskydJ avatar ArtskydJ commented on May 27, 2024

@roccomuso since I haven't heard from you, I'm gonna close this issue. @ reply if you have any questions.

from sox-stream.

roccomuso avatar roccomuso commented on May 27, 2024

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.

from sox-stream.

roccomuso avatar roccomuso commented on May 27, 2024

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

from sox-stream.

ArtskydJ avatar ArtskydJ commented on May 27, 2024

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.

from sox-stream.

roccomuso avatar roccomuso commented on May 27, 2024

It's exactly what i did Range Error: Index out of range.
It's some other issue.

from sox-stream.

ArtskydJ avatar ArtskydJ commented on May 27, 2024

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?

from sox-stream.

roccomuso avatar roccomuso commented on May 27, 2024

yes. I should try with different mp3..

from sox-stream.

ArtskydJ avatar ArtskydJ commented on May 27, 2024

Closing since this has been inactive for over half of a year. Reply or re-open if this is still an issue.

from sox-stream.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.