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

Pre-generated json peaks array not loading #715

Closed
mbordash opened this issue May 8, 2016 · 10 comments
Closed

Pre-generated json peaks array not loading #715

mbordash opened this issue May 8, 2016 · 10 comments
Labels

Comments

@mbordash
Copy link

mbordash commented May 8, 2016

Hi,

I'm trying out your library to replace my own homegrown player based on audiowaveform. Upon upload, I'm generating json via audiowaveform so that I can pre-load the peaks in your player. Unfortunately, wavesurfer doesn't seem to like the json array range generated by audiowaveform (or more likely, I'm doing something boneheaded).

The generated json looks like this (snip):
[0,0,-12,7,-12,8,-14,15,-16,10,-11,13,-15,11, ... ]
Here's a test page with the array loaded at runtime

http://www.internetdj.com/test.html

Any tips? Many thanks in advanced.

Michael

@mbordash
Copy link
Author

mbordash commented May 8, 2016

The problem was with the negative values generated by audiowaveform. I simply stripped them out of my peaks array and now we're in business.

Here's an example of wavesurfer in production:

http://www.internetdj.com/song/118198

@katspaugh
Copy link
Owner

katspaugh commented May 8, 2016

Great that you figured it out. I actually thought negative peaks were not a problem. I'll mark this as a bug to add a Math.abs to the drawing code.

@katspaugh katspaugh added the bug label May 8, 2016
@mbordash
Copy link
Author

mbordash commented May 9, 2016

Thanks for the confirmation. Love this library!

@thijstriemstra
Copy link
Contributor

Having a unit test for this would be nice!

@bekatom
Copy link

bekatom commented Jun 8, 2016

@mbordash how are you making to draw waveform with json data can you share some code ?

@katspaugh
Copy link
Owner

Perhaps something like audiowaveform -i some-file.mp3 --pixels-per-second 10 -b 8 -o some-file.json.

@bekatom
Copy link

bekatom commented Jun 8, 2016

@katspaugh Yeah i find it and i got file like this http://collabshot.com/show/0T3kzy but when I am loading it with wavesurfer I think it creates incorrectly, see : http://collabshot.com/show/CovV4L

wavesurfer.load('fifties_rock.mp3', result);
I tried also :
wavesurfer.load('fifties_rock.mp3', result.data);

@katspaugh
Copy link
Owner

katspaugh commented Jun 8, 2016

@btomashvili I guess you also need to filter out negative values like the OP did.
result.data.filter(function (val) { return val >= 0; })

Oh yeah, and you need the normalize: true option.

@bekatom
Copy link

bekatom commented Jun 8, 2016

thanks ;)

@mspae
Copy link
Contributor

mspae commented Sep 18, 2017

Closing: inactive

@mspae mspae closed this as completed Sep 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants