Tone.js icon indicating copy to clipboard operation
Tone.js copied to clipboard

mel scale for pitch linearRampToValue

Open kmjasmin opened this issue 7 years ago • 1 comments

Hi, I study auditory processing and it would be very useful to be able to use the linearRampToValue method for oscillator frequency on a "mel scale".

https://en.wikipedia.org/wiki/Mel_scale

This way, as the frequency changes it also appears perceptually even over time (rather than perceptually "faster" for lower frequencies and "slower" for higher frequencies). Since musical tones are spaced on a mel scale, I think this would be useful for other users of Tone.js.

I'm pasting the conversion formulas below. If this is not a feature you would want to add, please let me know (as I need this functionality for an auditory experiment and would need to code it myself).

Many thanks

Kyle

        function Mel2Freq(mel) {
            return 700 * ((Math.pow(10,(mel/2595))-1));
        }     
        
        function Freq2Mel(Hz) {
            return 2595  * Math.log10((1+(Hz/700));
        }  

kmjasmin avatar Dec 06 '18 09:12 kmjasmin

I'm open to this option. Seems pretty cool.

@kmjasmin if we include Mel, do we need to include Bark or any other perceptually-based scales? curious to know if there's any other music perception JS libraries out there which already offer these conversions.

tambien avatar Jan 10 '19 20:01 tambien