Skip to content

Commit

Permalink
add midi cc node symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviergodart committed Nov 25, 2024
1 parent 57c52d3 commit bafb8e0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
14 changes: 0 additions & 14 deletions core/music/key_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,3 @@ func (p *KeyValue) IsSilent() bool {
func (p *KeyValue) SetSilent(silent bool) {
p.silent = silent
}

func (p *KeyValue) Name() string {
return "key"
}

func (p *KeyValue) Symbol() string {
if p.silent {
return "\u0353"
}
if p.amount != 0 {
return "\u033c"
}
return ""
}
18 changes: 18 additions & 0 deletions core/music/note.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package music

import (
"fmt"
"math/rand"
"time"

Expand Down Expand Up @@ -192,3 +193,20 @@ func (n *Note) SetChannel(channel uint8) {
func (n *Note) ClockDivision() (int, int) {
return common.PulsesPerStep, common.StepsPerQuarterNote
}

// Symbol returns the string symbol associated with the current note.
func (n *Note) Symbol() string {
var keySymbol, ccSymbol string
if n.Key.silent {
keySymbol = "\u0353"
} else if n.Key.amount != 0 {
keySymbol = "\u033c"
}
for _, c := range n.Controls {
if c.Type != SilentControlType {
ccSymbol = "\u0307"
break
}
}
return fmt.Sprintf("%s%s", keySymbol, ccSymbol)
}
4 changes: 2 additions & 2 deletions core/node/emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ func (e *Emitter) Symbol() string {
return fmt.Sprintf("%.2s", symbol)
}
if _, ok := e.behavior.(*PassEmitter); ok {
return fmt.Sprintf("%s%s%s", symbol, e.note.Key.Symbol(), "⇌")
return fmt.Sprintf("%s%s%s", symbol, e.note.Symbol(), "⇌")
}
if e.note == nil {
return fmt.Sprintf("%s%s", symbol, e.direction.Symbol())
}
return fmt.Sprintf("%s%s%s", symbol, e.note.Key.Symbol(), e.direction.Symbol())
return fmt.Sprintf("%s%s%s", symbol, e.note.Symbol(), e.direction.Symbol())
}

func (e *Emitter) Name() string {
Expand Down
2 changes: 1 addition & 1 deletion core/node/euclid.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (e *EuclidEmitter) SetDirection(dir common.Direction) {
}

func (e *EuclidEmitter) Symbol() string {
return fmt.Sprintf("%s%s%s", "E", e.note.Key.Symbol(), e.direction.Symbol())
return fmt.Sprintf("%s%s%s", "E", e.note.Symbol(), e.direction.Symbol())
}

func (e *EuclidEmitter) Name() string {
Expand Down
2 changes: 1 addition & 1 deletion ui/param/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Key struct {
}

func (k *Key) Name() string {
return k.nodes[0].(music.Audible).Note().Key.Name()
return "key"
}

func (k *Key) Display() string {
Expand Down
2 changes: 1 addition & 1 deletion ui/param/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (r Root) Name() string {
}

func (r Root) Display() string {
return r.grid.Key.Name()
return "key"
}

func (r Root) Value() int {
Expand Down

0 comments on commit bafb8e0

Please sign in to comment.