Improved element documentation

This commit is contained in:
Sasha Koshka
2023-02-09 14:50:24 -05:00
parent c7bebabed5
commit 2cd670f4cd
7 changed files with 34 additions and 1 deletions

3
elements/fun/doc.go Normal file
View File

@@ -0,0 +1,3 @@
// Package fun provides "fun" elements that have few actual use cases, but serve
// as good demos of what Tomo is capable of.
package fun

View File

@@ -15,6 +15,7 @@ type pianoKey struct {
music.Note
}
// Piano is an element that can be used to input midi notes.
type Piano struct {
*core.Core
core core.CoreControl
@@ -32,7 +33,15 @@ type Piano struct {
onRelease func (music.Note)
}
// NewPiano returns a new piano element with a lowest and highest octave,
// inclusive. If low is greater than high, they will be swapped.
func NewPiano (low, high music.Octave) (element *Piano) {
if low > high {
temp := low
low = high
high = temp
}
element = &Piano {
low: low,
high: high,