[ Launch: midistuff ] 7863273 by jocafa
-
-
Save jocafa/7863273 to your computer and use it in GitHub Desktop.
midistuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"description":"midistuff","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/w0P0lCg.png"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function log2(x) { | |
| return Math.log(x)/Math.LN2; | |
| } | |
| function midiToFreq(m) { | |
| return Math.pow(2, (m-69)/12) * 440; | |
| } | |
| function freqToMidi(f) { | |
| return 12*log2(f/440) + 69; | |
| } | |
| function midiToNote(m) { | |
| var notes = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#']; | |
| var octave = 4 + log2(midiToFreq(m)/440) | 0; | |
| return notes[((m-21)%12)] + octave; | |
| } | |
| function fretDistance(fret, scale) { | |
| return scale - (scale / Math.pow(2, fret/12)); | |
| } | |
| var note = 65; | |
| //console.log(midiToNote(note), midiToFreq(note)); | |
| console.log(fretDistance(4, 25)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment