Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mp3 playback speed is slowed down and it starts in the middle of the track #19

Open
LorenzKahl opened this issue Nov 24, 2018 · 15 comments

Comments

@LorenzKahl
Copy link

I'm on Mac OS (10.13.6) using nodejs (10.13). When I'm trying to play an mp3 file the playback speed is slowed down and it starts in the middle of the track.

I've tried multiple mp3 files from different sources - mostly all with the same outcome.
This is an example which is not working for me when I download it and try to play it locally.

The only file I actually could get to play as expected was a random test I downloaded here.

Unfortunately I don't know how to determine which audio library is being used to decode the mp3 files to provide further information.

@gregoryjjb
Copy link

Hey, did you find a solution? I have the exact same issue, Windows 10.

@derhuerst
Copy link
Member

Unfortunately I don't know how to determine which audio library is being used to decode the mp3 files [...].

It currently uses speaker underneath, which in turn uses mpg123.

@gregoryjjb
Copy link

Interestingly, even if I specifically install speaker, I get the message 'speaker' package not found, using 'audio-sink' instead. I don't know if that's related or not.

@derhuerst
Copy link
Member

Which version of audio-play do you use? It would be best if you run npm ls to get the tree of dependencies.

@gregoryjjb
Copy link

audio-play version is 2.2.1.

The ls of my dependencies looks like:

audio-test@1.0.0 C:\Development\temp\audio-test
+-- audio-loader@1.0.3
| +-- audio-context@1.0.3
| +-- audio-decode@1.4.0
| | +-- audio-buffer-from@1.1.1
| | | +-- audio-buffer@4.0.4 deduped
| | | +-- audio-context@1.0.3 deduped
| | | +-- audio-format@2.3.2
| | | | +-- is-audio-buffer@1.1.0 deduped
| | | | +-- is-buffer@1.1.6 deduped
| | | | +-- is-plain-obj@1.1.0 deduped
| | | | +-- pick-by-alias@1.2.0 deduped
| | | | `-- sample-rate@2.0.1
| | | +-- is-audio-buffer@1.1.0 deduped
| | | +-- is-plain-obj@1.1.0
| | | +-- pcm-convert@1.6.5
| | | | +-- audio-format@2.3.2 deduped
| | | | +-- is-audio-buffer@1.1.0 deduped
| | | | +-- is-buffer@1.1.6 deduped
| | | | `-- object-assign@4.1.1 deduped
| | | +-- pick-by-alias@1.2.0
| | | `-- string-to-arraybuffer@1.0.2
| | |   +-- atob-lite@2.0.0
| | |   `-- is-base64@0.1.0
| | +-- audio-context@1.0.3 deduped
| | +-- audio-type@1.0.2
| | | +-- is-flac@1.1.2
| | | +-- is-m4a@1.1.0
| | | +-- is-mp3@1.1.3
| | | +-- is-ogg@1.1.2
| | | +-- is-wav@1.1.2
| | | `-- read-chunk@2.1.0
| | |   +-- pify@3.0.0
| | |   `-- safe-buffer@5.1.2 deduped
| | +-- av@0.4.9
| | | +-- coffeeify@0.6.0
| | | | +-- coffee-script@1.7.1
| | | | | `-- mkdirp@0.3.5
| | | | +-- convert-source-map@0.3.5
| | | | `-- through@2.3.8
| | | `-- speaker@0.3.1 deduped
| | +-- is-buffer@1.1.6 deduped
| | +-- mp3@0.1.0
| | +-- to-array-buffer@2.2.2
| | | +-- flatten-vertex-data@1.0.2
| | | | `-- dtype@2.0.0
| | | +-- is-blob@2.0.1
| | | `-- string-to-arraybuffer@1.0.2 deduped
| | +-- typedarray-to-buffer@3.1.5
| | | `-- is-typedarray@1.0.0 deduped
| | `-- wav-decoder@1.3.0
| +-- is-absolute@0.2.6
| | +-- is-relative@0.2.1 deduped
| | `-- is-windows@0.2.0
| +-- is-audio-buffer@1.1.0
| +-- is-buffer@1.1.6
| +-- is-relative@0.2.1
| | `-- is-unc-path@0.1.2
| |   `-- unc-path-regex@0.1.2
| +-- is-url@1.2.4
| +-- object-assign@4.1.1
| `-- request@2.88.0
|   +-- aws-sign2@0.7.0
|   +-- aws4@1.8.0
|   +-- caseless@0.12.0
|   +-- combined-stream@1.0.7
|   | `-- delayed-stream@1.0.0
|   +-- extend@3.0.2
|   +-- forever-agent@0.6.1
|   +-- form-data@2.3.3
|   | +-- asynckit@0.4.0
|   | +-- combined-stream@1.0.7 deduped
|   | `-- mime-types@2.1.21 deduped
|   +-- har-validator@5.1.3
|   | +-- ajv@6.6.1
|   | | +-- fast-deep-equal@2.0.1
|   | | +-- fast-json-stable-stringify@2.0.0
|   | | +-- json-schema-traverse@0.4.1
|   | | `-- uri-js@4.2.2
|   | |   `-- punycode@2.1.1
|   | `-- har-schema@2.0.0
|   +-- http-signature@1.2.0
|   | +-- assert-plus@1.0.0
|   | +-- jsprim@1.4.1
|   | | +-- assert-plus@1.0.0 deduped
|   | | +-- extsprintf@1.3.0
|   | | +-- json-schema@0.2.3
|   | | `-- verror@1.10.0
|   | |   +-- assert-plus@1.0.0 deduped
|   | |   +-- core-util-is@1.0.2 deduped
|   | |   `-- extsprintf@1.3.0 deduped
|   | `-- sshpk@1.15.2
|   |   +-- asn1@0.2.4
|   |   | `-- safer-buffer@2.1.2 deduped
|   |   +-- assert-plus@1.0.0 deduped
|   |   +-- bcrypt-pbkdf@1.0.2
|   |   | `-- tweetnacl@0.14.5 deduped
|   |   +-- dashdash@1.14.1
|   |   | `-- assert-plus@1.0.0 deduped
|   |   +-- ecc-jsbn@0.1.2
|   |   | +-- jsbn@0.1.1 deduped
|   |   | `-- safer-buffer@2.1.2 deduped
|   |   +-- getpass@0.1.7
|   |   | `-- assert-plus@1.0.0 deduped
|   |   +-- jsbn@0.1.1
|   |   +-- safer-buffer@2.1.2
|   |   `-- tweetnacl@0.14.5
|   +-- is-typedarray@1.0.0
|   +-- isstream@0.1.2
|   +-- json-stringify-safe@5.0.1
|   +-- mime-types@2.1.21
|   | `-- mime-db@1.37.0
|   +-- oauth-sign@0.9.0
|   +-- performance-now@2.1.0
|   +-- qs@6.5.2
|   +-- safe-buffer@5.1.2
|   +-- tough-cookie@2.4.3
|   | +-- psl@1.1.29
|   | `-- punycode@1.4.1
|   +-- tunnel-agent@0.6.0
|   | `-- safe-buffer@5.1.2 deduped
|   `-- uuid@3.3.2
`-- audio-play@2.2.1
  +-- audio-buffer@4.0.4
  | `-- audio-context@1.0.3 deduped
  +-- audio-context@1.0.3 deduped
  +-- audio-source@1.1.1
  | +-- audio-buffer@2.4.6
  | | +-- audio-context@1.0.3
  | | +-- buffer-to-arraybuffer@0.0.5
  | | +-- is-audio-buffer@1.1.0 deduped
  | | +-- is-browser@2.1.0
  | | `-- is-buffer@1.1.6 deduped
  | +-- audio-through@2.2.3
  | | +-- audio-buffer@3.2.1
  | | | +-- audio-context@1.0.3 deduped
  | | | +-- buffer-to-arraybuffer@0.0.5 deduped
  | | | +-- is-audio-buffer@1.1.0 deduped
  | | | +-- is-browser@2.1.0 deduped
  | | | +-- is-buffer@1.1.6 deduped
  | | | `-- is-plain-obj@1.1.0 deduped
  | | +-- audio-context@1.0.3 deduped
  | | +-- inherits@2.0.3 deduped
  | | +-- is-audio-buffer@1.1.0 deduped
  | | +-- is-promise@2.1.0
  | | +-- object-assign@4.1.1 deduped
  | | +-- pcm-util@2.1.0 deduped
  | | `-- performance-now@2.1.0 deduped
  | +-- inherits@2.0.3
  | +-- is-audio-buffer@1.1.0 deduped
  | `-- pull-stream@3.6.9
  +-- audio-speaker@1.5.0
  | +-- audio-sink@1.1.6
  | | +-- inherits@2.0.3 deduped
  | | `-- xtend@4.0.1
  | +-- audio-through@2.2.3 deduped
  | +-- inherits@2.0.3 deduped
  | +-- is-audio-buffer@1.1.0 deduped
  | +-- object-assign@4.1.1 deduped
  | +-- pcm-util@2.1.0
  | | +-- audio-buffer@3.2.1
  | | | +-- audio-context@1.0.3 deduped
  | | | +-- buffer-to-arraybuffer@0.0.5 deduped
  | | | +-- is-audio-buffer@1.1.0 deduped
  | | | +-- is-browser@2.1.0 deduped
  | | | +-- is-buffer@1.1.6 deduped
  | | | `-- is-plain-obj@1.1.0 deduped
  | | +-- is-audio-buffer@1.1.0 deduped
  | | +-- is-buffer@1.1.6 deduped
  | | `-- to-array-buffer@1.2.4
  | |   +-- atob-lite@1.0.0
  | |   +-- is-audio-buffer@1.1.0 deduped
  | |   `-- is-data-uri@0.1.0
  | |     `-- data-uri-regex@0.1.4
  | +-- pull-stream@3.6.9 deduped
  | +-- speaker@0.3.1
  | | +-- bindings@1.3.1
  | | +-- debug@2.6.9
  | | | `-- ms@2.0.0
  | | +-- nan@2.11.1
  | | `-- readable-stream@2.3.6
  | |   +-- core-util-is@1.0.2
  | |   +-- inherits@2.0.3 deduped
  | |   +-- isarray@1.0.0
  | |   +-- process-nextick-args@2.0.0
  | |   +-- safe-buffer@5.1.2 deduped
  | |   +-- string_decoder@1.1.1
  | |   | `-- safe-buffer@5.1.2 deduped
  | |   `-- util-deprecate@1.0.2
  | `-- web-audio-stream@3.0.1
  |   +-- audio-buffer-list@2.0.7
  |   | +-- audio-buffer@3.2.1
  |   | | +-- audio-context@1.0.3 deduped
  |   | | +-- buffer-to-arraybuffer@0.0.5 deduped
  |   | | +-- is-audio-buffer@1.1.0 deduped
  |   | | +-- is-browser@2.1.0 deduped
  |   | | +-- is-buffer@1.1.6 deduped
  |   | | `-- is-plain-obj@1.1.0 deduped
  |   | +-- audio-buffer-utils@4.3.2 deduped
  |   | +-- inherits@2.0.3 deduped
  |   | +-- is-audio-buffer@1.1.0 deduped
  |   | +-- is-plain-obj@1.1.0 deduped
  |   | +-- negative-index@1.0.3 deduped
  |   | `-- object-assign@4.1.1 deduped
  |   +-- audio-buffer-utils@4.3.2
  |   | +-- audio-buffer@3.2.1
  |   | | +-- audio-context@1.0.3 deduped
  |   | | +-- buffer-to-arraybuffer@0.0.5 deduped
  |   | | +-- is-audio-buffer@1.1.0 deduped
  |   | | +-- is-browser@2.1.0 deduped
  |   | | +-- is-buffer@1.1.6 deduped
  |   | | `-- is-plain-obj@1.1.0 deduped
  |   | +-- audio-context@1.0.3 deduped
  |   | +-- clamp@1.0.1
  |   | +-- is-audio-buffer@1.1.0 deduped
  |   | +-- is-browser@2.1.0 deduped
  |   | +-- negative-index@1.0.3 deduped
  |   | `-- typedarray-methods@1.0.1
  |   +-- audio-context@1.0.3 deduped
  |   +-- inherits@2.0.3 deduped
  |   +-- is-audio-buffer@1.1.0 deduped
  |   +-- is-plain-obj@1.1.0 deduped
  |   +-- object-assign@4.1.1 deduped
  |   +-- pcm-util@2.1.0 deduped
  |   `-- pull-stream@3.6.9 deduped
  +-- is-audio-buffer@1.1.0 deduped
  `-- negative-index@1.0.3
    `-- negative-zero@2.0.0

I'm thinking of moving my audio playing workload to an external python script or something right now, it seems like the most viable option.

@LorenzKahl
Copy link
Author

Hey, did you find a solution? I have the exact same issue, Windows 10.

Hi, I gave up and resorted to using play-sound.
I'm developing on a Mac but the target platform is a Raspberry Pi - play-sound works just fine on both platforms which is a huge plus for me.

@gregoryjjb
Copy link

I looked at play-sound and got it working but I need the ability to start playing exactly when I want to, not have it load and play in the same function call since that adds some lag. As far as I can tell this is the only Node package that can do that.

@dy

This comment has been minimized.

@LorenzKahl
Copy link
Author

@dy much appreciated - but sure I hope you won't be spending your whole weekend on it. Cheers!

@gregoryjjb
Copy link

@dy same, it's no rush, I can work around it. Thanks!

@prmichaelsen
Copy link

I have the same issue. At first, I was delighted, because it was very fun to hear "what's new pussycat" in such a demonic form.

Ultimately, I'm going to have to try a different library, though.

@BradTotaro
Copy link

@gregoryjjb with play-sound, which back-end are you using, it seems that there is a preferred player for certain media types.

I'm testing on a thinkpad and a raspberry pi.

When playing MP3 with this library I hear the weird demonic version of the song, after transcode to WAV the first second is distorted, then the audio seems fine.

with play-sound on mpg123 i see inconsistent play volumes and sometimes files do not play.

@gregoryjjb
Copy link

@BradTotaro I never did use play-sound, as I needed the ability to load the audio into memory separately from starting playback so I could start playback instantly. I ended up writing my audio playing functionality in Python and later Rust.

@fusionstream
Copy link

@gregoryjjb Did you consider preconverting to wav (which seems to play fine) and then using that? I ask because I'm getting the same weirdness

@gregoryjjb
Copy link

@fusionstream I just revisited this problem a couple days ago and I used node-speaker and node-lame and got it to do what I wanted. If I run into issues with this setup I might try converting to WAV!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants