Skip to content

Commit

Permalink
add parameters help
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviergodart committed Dec 2, 2024
1 parent fd56b76 commit 0a9348e
Show file tree
Hide file tree
Showing 24 changed files with 111 additions and 1 deletion.
5 changes: 5 additions & 0 deletions midi/midi.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func Note(note uint8) string {
return gomidi.Note(note).String()
}

// CC retruns the string representation of a cc message
func CC(controller uint8) string {
return gomidi.ControlChangeName[controller]
}

func (m *midi) start() {
var wg sync.WaitGroup
wg.Add(len(m.devices))
Expand Down
4 changes: 4 additions & 0 deletions ui/param/bank_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func (b BankCmd) Name() string {
return "bank"
}

func (b BankCmd) Help() string {
return ""
}

func (b BankCmd) Display() string {
if !b.nodes[0].(music.Audible).Note().MetaCommands[bankCmdIndex].Active() {
return "⨯"
Expand Down
17 changes: 17 additions & 0 deletions ui/param/cc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package param
import (
"fmt"
"strconv"
"strings"

"signls/core/common"
"signls/core/music"
"signls/midi"
"signls/ui/util"
)

Expand All @@ -29,6 +31,21 @@ func (c CC) Name() string {
}
}

func (c CC) Help() string {
switch c.nodes[0].(music.Audible).Note().Controls[c.index].Type {
case music.ControlChangeControlType:
return strings.ToLower(midi.CC(c.nodes[0].(music.Audible).Note().Controls[c.index].Controller))
case music.AfterTouchControlType:
return "after touch"
case music.PitchBendControlType:
return "pitch bend"
case music.ProgramChangeControlType:
return "program change"
default:
return ""
}
}

func (c CC) Display() string {
if c.nodes[0].(music.Audible).Note().Controls[c.index].Type == music.SilentControlType {
return "⨯"
Expand Down
4 changes: 4 additions & 0 deletions ui/param/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func (c Channel) Name() string {
return "cha"
}

func (c Channel) Help() string {
return ""
}

func (c Channel) Display() string {
if c.nodes[0].(music.Audible).Note().Channel.RandomAmount() != 0 {
return util.Normalize(
Expand Down
4 changes: 4 additions & 0 deletions ui/param/clock_send.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ func (c ClockSend) Name() string {
return "clock"
}

func (c ClockSend) Help() string {
return ""
}

func (c ClockSend) Display() string {
if c.grid.SendClock {
return "on"
Expand Down
4 changes: 4 additions & 0 deletions ui/param/default_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ func (d DefaultDevice) Name() string {
return "device"
}

func (d DefaultDevice) Help() string {
return ""
}

func (d DefaultDevice) Display() string {
return d.grid.MidiDevice()
}
Expand Down
4 changes: 4 additions & 0 deletions ui/param/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func (d Destination) Name() string {
return "dest"
}

func (s Destination) Help() string {
return ""
}

func (d Destination) Display() string {
x, y := d.nodes[0].(*node.HoleEmitter).Destination()
amountX, amountY := d.nodes[0].(*node.HoleEmitter).DestinationAmount()
Expand Down
4 changes: 4 additions & 0 deletions ui/param/direction.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func (d Direction) Name() string {
return "direction"
}

func (d Direction) Help() string {
return ""
}

func (d Direction) Display() string {
return d.nodes[0].Direction().Symbol()
}
Expand Down
4 changes: 4 additions & 0 deletions ui/param/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func (k *Key) Name() string {
return "key"
}

func (k *Key) Help() string {
return ""
}

func (k *Key) Display() string {
if k.mode == KeyModeSilent {
return "⨯"
Expand Down
4 changes: 4 additions & 0 deletions ui/param/length.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func (l Length) Name() string {
return "len"
}

func (l Length) Help() string {
return ""
}

func (l Length) Display() string {
length := int(l.nodes[0].(music.Audible).Note().Length.Value())
pulsesPerStep, stepsPerQuarterNote := l.nodes[0].(music.Audible).Note().ClockDivision()
Expand Down
4 changes: 4 additions & 0 deletions ui/param/offset.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func (o Offset) Name() string {
return "off"
}

func (o Offset) Help() string {
return ""
}

func (o Offset) Display() string {
if o.nodes[0].(*node.EuclidEmitter).Offset.RandomAmount() != 0 {
return util.Normalize(
Expand Down
1 change: 1 addition & 0 deletions ui/param/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (

type Param interface {
Name() string
Help() string
Value() int
AltValue() int
Display() string
Expand Down
4 changes: 4 additions & 0 deletions ui/param/probability.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func (p Probability) Name() string {
return "prb"
}

func (p Probability) Help() string {
return ""
}

func (p Probability) Display() string {
return fmt.Sprintf("%d", p.Value())
}
Expand Down
4 changes: 4 additions & 0 deletions ui/param/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func (r Root) Name() string {
return "root"
}

func (r Root) Help() string {
return ""
}

func (r Root) Display() string {
return r.grid.Key.Name()
}
Expand Down
4 changes: 4 additions & 0 deletions ui/param/root_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func (r RootCmd) Name() string {
return "root"
}

func (r RootCmd) Help() string {
return ""
}

func (r RootCmd) Display() string {
if !r.nodes[0].(music.Audible).Note().MetaCommands[rootCmdIndex].Active() {
return "⨯"
Expand Down
4 changes: 4 additions & 0 deletions ui/param/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ func (s Scale) Name() string {
return "scale"
}

func (s Scale) Help() string {
return ""
}

func (s Scale) Display() string {
return s.grid.Scale.Name()
}
Expand Down
4 changes: 4 additions & 0 deletions ui/param/scale_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func (s ScaleCmd) Name() string {
return "scale"
}

func (s ScaleCmd) Help() string {
return ""
}

func (s ScaleCmd) Display() string {
if !s.nodes[0].(music.Audible).Note().MetaCommands[scaleCmdIndex].Active() {
return "⨯"
Expand Down
4 changes: 4 additions & 0 deletions ui/param/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func (s Steps) Name() string {
return "stp"
}

func (s Steps) Help() string {
return ""
}

func (s Steps) Display() string {
if s.nodes[0].(*node.EuclidEmitter).Steps.RandomAmount() != 0 {
return util.Normalize(
Expand Down
4 changes: 4 additions & 0 deletions ui/param/tempo_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func (t TempoCmd) Name() string {
return "tempo"
}

func (t TempoCmd) Help() string {
return ""
}

func (t TempoCmd) Display() string {
if !t.nodes[0].(music.Audible).Note().MetaCommands[tempoCmdIndex].Active() {
return "⨯"
Expand Down
4 changes: 4 additions & 0 deletions ui/param/threshold.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func (t Threshold) Name() string {
return "thd"
}

func (t Threshold) Help() string {
return ""
}

func (t Threshold) Display() string {
if t.control().RandomAmount() != 0 {
return util.Normalize(
Expand Down
4 changes: 4 additions & 0 deletions ui/param/transport_send.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ func (t TransportSend) Name() string {
return "transport"
}

func (t TransportSend) Help() string {
return ""
}

func (t TransportSend) Display() string {
if t.grid.SendTransport {
return "on"
Expand Down
4 changes: 4 additions & 0 deletions ui/param/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func (t Triggers) Name() string {
return "trg"
}

func (t Triggers) Help() string {
return ""
}

func (t Triggers) Display() string {
if t.nodes[0].(*node.EuclidEmitter).Triggers.RandomAmount() != 0 {
return util.Normalize(
Expand Down
4 changes: 4 additions & 0 deletions ui/param/velocity.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func (v Velocity) Name() string {
return "vel"
}

func (v Velocity) Help() string {
return ""
}

func (v Velocity) Display() string {
if v.nodes[0].(music.Audible).Note().Velocity.RandomAmount() != 0 {
return util.Normalize(
Expand Down
9 changes: 8 additions & 1 deletion ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,15 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (m mainModel) View() string {
help := lipgloss.NewStyle().
MarginLeft(2).
MarginTop(1).
Render(m.help.View(m.keymap))

paramHelp := ""
if m.mode == EDIT {
paramHelp = m.help.Styles.ShortDesc.
MarginLeft(16).
Render(m.activeParam().Help())
}

if m.help.ShowAll {
return lipgloss.JoinVertical(
lipgloss.Left,
Expand All @@ -379,6 +385,7 @@ func (m mainModel) View() string {
return lipgloss.JoinVertical(
lipgloss.Left,
m.renderGrid(),
paramHelp,
help,
)
}
Expand Down

0 comments on commit 0a9348e

Please sign in to comment.