mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-23 15:34:52 -04:00
feat(tracker): implement basic track display
This commit is contained in:
29
go4k/tracker/music.go
Normal file
29
go4k/tracker/music.go
Normal file
@ -0,0 +1,29 @@
|
||||
package tracker
|
||||
|
||||
import "fmt"
|
||||
|
||||
const baseNote = 20
|
||||
|
||||
var notes = []string{
|
||||
"C-",
|
||||
"C#",
|
||||
"D-",
|
||||
"D#",
|
||||
"E-",
|
||||
"F-",
|
||||
"F#",
|
||||
"G-",
|
||||
"G#",
|
||||
"A-",
|
||||
"A#",
|
||||
"B-",
|
||||
}
|
||||
|
||||
func valueAsNote(val byte) string {
|
||||
octave := (val - baseNote) / 12
|
||||
oNote := (val - baseNote) % 12
|
||||
if octave < 0 || oNote < 0 || octave > 10 {
|
||||
return "..."
|
||||
}
|
||||
return fmt.Sprintf("%s%d", notes[oNote], octave)
|
||||
}
|
Reference in New Issue
Block a user