mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 14:02:29 -05:00
Inline the interval to frequency function
This commit is contained in:
parent
66b4ae3795
commit
b7ff586ca1
1 changed files with 2 additions and 10 deletions
|
@ -49,16 +49,8 @@ class PitchEffect {
|
|||
* @returns {number} a playback ratio
|
||||
*/
|
||||
getRatio (val) {
|
||||
return this.intervalToFrequencyRatio(val / 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a musical interval to a frequency ratio.
|
||||
* With thanks to Tone.js: https://github.com/Tonejs/Tone.js
|
||||
* @param {number} interval - a musical interval, in semitones
|
||||
* @returns {number} a frequency ratio
|
||||
*/
|
||||
intervalToFrequencyRatio (interval) {
|
||||
const interval = val / 10;
|
||||
// Convert the musical interval in semitones to a frequency ratio
|
||||
return Math.pow(2, (interval / 12));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue