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

Suggested Improvement, Waveform magnification value. #944

Closed
jamiegau opened this issue Jan 29, 2017 · 2 comments
Closed

Suggested Improvement, Waveform magnification value. #944

jamiegau opened this issue Jan 29, 2017 · 2 comments

Comments

@jamiegau
Copy link

I made this change myself (It was trivial, but suggest it also be added.)
You can turn on the normalize flag so the waveform-height fills the window.
However, this is based on the amplitude of the audio you are pointing at.

I suggest you also add the ability to set a magnification constant as well.
Ie. I am showing a few different waveforms on the screen at once. But I want them to be relative to each other. However, they are quite low and do not produce a very detailed waveform.
So I added the ability to set the magnification (0 to 1) so I could for example.
Double all waveform height by setting to 0.5
This could be a percentage or whatever based on how its surfaced...

The ability to be able to set just how much the waveform is magnified, in general, is a good idea.

I did this myself by looking at the normalize parameter and simply added my own.

@mspae
Copy link
Contributor

mspae commented Jan 30, 2017

Can you post your Code? It's a bit easier to talk about. Thanks!

@jamiegau
Copy link
Author

Ok,

firstly I added the property
waveHeightScale, default 1...

var WaveSurfer = {
    defaultParams: {
        height        : 128,
        waveColor     : '#999',
        progressColor : '#555',
        cursorColor   : '#333',
        cursorWidth   : 1,
        skipLength    : 2,
        minPxPerSec   : 20,
        pixelRatio    : window.devicePixelRatio || screen.deviceXDPI / screen.logicalXDPI,
        fillParent    : true,
        scrollParent  : false,
        hideScrollbar : false,
        normalize     : false,
        waveHeightScale : 1,
        audioContext  : null,
        container     : null,
        dragSelection : true,
        loopSelection : true,
        audioRate     : 1,
        interact      : true,
        splitChannels : false,
        mediaContainer: null,
        mediaControls : false,
        renderer      : 'MultiCanvas',
        backend       : 'WebAudio',
        mediaType     : 'audio',
        autoCenter    : true,
        partialRender : false
    },

Then in the code base where it deals with the normalize parameter and inits the absmax variable default as 1, I change it to init it to the waveHeightScale parameter, about 3-4 spots.. I have replaced the following line....

        // var absmax = 1;
        var absmax = this.params.waveHeightScale;

About 5 lines of changed code.. But I hope that makes it clear now..
As I can set the parameter waveHeightScale to set a specific SCALE/Magnification.

Thanks,
James

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

No branches or pull requests

3 participants