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

fix exportPCM to return json data #1094

Merged
merged 1 commit into from
May 19, 2017
Merged

Conversation

entonbiba
Copy link
Contributor

@entonbiba entonbiba commented May 16, 2017

fixes #1083 - added default start parameter 0 to work with getPeaks method.

update docs for exportPCM #1101

exportPCM: function (length, accuracy, noWindow, start)

@thijstriemstra thijstriemstra merged commit 7778308 into master May 19, 2017
@entonbiba entonbiba deleted the entonbiba-patch-pcmexport branch May 19, 2017 21:59
@agamemnus
Copy link
Contributor

@entonbiba Is this right?

 wavesurfer.on ("ready", function () {
   var result = wavesurfer.exportPCM (1024, 10000, true, 0)
   console.log (result)
})

I just get a bunch of null values.

@entonbiba
Copy link
Contributor Author

@agamemnus what browser you using and can you post the audio file, I'll take a look.

@agamemnus
Copy link
Contributor

agamemnus commented Jun 3, 2017

Chrome. But let me play some more with this. The waveform does show up so I must be doing something wrong.

@davidteal
Copy link

@agamemnus did you get this working? i just get a blank array

@agamemnus
Copy link
Contributor

I was working on it last night, but fell asleep. The data is definitely being generated, but something is not quite right with the parameters, I think.

@davidteal
Copy link

Hmm not sure what I'm doing wrong. Everything I try, it just returns an empty array

@agamemnus
Copy link
Contributor

Do you have it actually creating a waveform?

@davidteal
Copy link

Yeah waveform is generated fine, I just need to export the peaks data so I can save and pre-render on the next load

@agamemnus
Copy link
Contributor

I was actually hoping to get this working with node.

@agamemnus
Copy link
Contributor

It seems my version did not have first = first || 0; last = last || length - 1; in getPeaks. I think it would make sense to have var peaks = this.backend.getPeaks(length, start, length - 1); anyway.

@neumanma
Copy link

Same issues here. Waveform gets generated fine but exportPCM just outputs an (almost) empty array - all values are null except the last two, which are 0. No matter which browser I use or which file I use (WAV, mp3, stereo, mono) - no matter which options I use to create the wavesurfer instance. I would really love to use the export of the peaks to use them once generated.

@agamemnus
Copy link
Contributor

agamemnus commented Jun 11, 2017 via email

@neumanma
Copy link

Thanks, but I'm not sure where I have to put your example line (if you are referring to: var peaks = this.backend.getPeaks(length, start, length - 1);) (I've started using wavesurfer a couple of hours ago...). Would I have to change the exportPCM method in wavesurfer.js or what? I'm using the cdn version //cdnjs.cloudflare.com/ajax/libs/wavesurfer.js/1.4.0/wavesurfer.min.js

thanks

@agamemnus
Copy link
Contributor

agamemnus commented Jun 11, 2017 via email

@neumanma
Copy link

Ok, so what do I have to do to use the most recent version? I have already downloaded the complete zip file and put the contents of the "src" folder in my local webserver's "js" directory and try to reference wavesurfer.js instead of the cdn version but that doesn't seem to work - it's missing utils stuff. The minified version in the "dist" folder is probably as old as the cdn version, right?

@agamemnus
Copy link
Contributor

One simple way is to use the un-minified version, just replace the relevant functions from the source... and then minify it. Or you can compile the source with grunt. (see readme under npm)...

@neumanma
Copy link

neumanma commented Jun 11, 2017

Alrighty! I have done all the npm... grunt stuff and built my own dist folder contents now containing the new minified version generated from the latest master and baaaam - it's working! :) Now I'm getting actual values when calling exportPCM instead of an (almost) empty array! Thanks a ton! Now I have to check how I can re-use those generated peak data! thanks again!

@agamemnus
Copy link
Contributor

If your audio data barely changes and/or if the audio files are really big, I would suggest storing on the server -- see #1082.

@neumanma
Copy link

thanks, yes I will store the peak data in a mySQL database. I'm creating a php/javascript website at the moment for selling my own royalty-free music ad sound fx. I will parse the peaks only once I upload my music etc. via an admin area and store all the peaks, metadata and description of my sound files in a database...

mspae pushed a commit to mspae/wavesurfer.js that referenced this pull request Aug 18, 2017
mspae pushed a commit that referenced this pull request Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

exportPCM no longer working.
6 participants