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

Waveform clarity #16

Open
phawk opened this issue Nov 15, 2014 · 2 comments
Open

Waveform clarity #16

phawk opened this issue Nov 15, 2014 · 2 comments

Comments

@phawk
Copy link

phawk commented Nov 15, 2014

Hey, this isn’t an issue per-say, but a request. Would love it if you could point me in the right direction.

I have this gem working great and am able to generate waveforms, however the design for the audio player I have been given requires less clarity in the image, basically each peak needs to be ~3px wide and flat on the top, with 1px in between each peak. Not sure if you have any suggestions for how to accomplish this?

Audio player design:
messages image 760783981

How I have got on so far with some CSS background images:
screen shot 2014-11-15 at 21 03 44

@benalavi
Copy link
Owner

Interesting use case, off the top of my head I can't think of way to accomplish it with any CSS or layering. The code itself will always output 1-pixel-width per sampled frame (so each peak value from the audio maps to a 1px wide line). I think to make this what would need to be added is a way to set the output width per frame, so say map each sample to 10px or something, and then use a CSS overlay to cut them "in half" showing 5px and hiding the other 5px, making a clean 5px bar for each sample.

I'm a little indisposed right now, and admittedly it's been a while since I touched the code, but I think the relevant line of code to edit would be https://github.com/benalavi/waveform/blob/master/lib/waveform.rb#L172. If you wanted to just hack it real quick you could probably set the line width and tweak things from there.

If you do figure it out feel free to send a pull request and I'll check it out and add a front-end option to set the line width, or if you're feeling ambitious you could add that too :)

If not I'll try to get to it in the next day or so, seems like a useful feature.

Nice looking player, btw.

@phawk
Copy link
Author

phawk commented Nov 16, 2014

Thanks sir, I shall get looking at this early next week. I think an option for taking an average of x frames, and then rounding the last 3 samples to all be the same value might work.

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

2 participants