From 0a9348e15acfaf0c87faaf6c6d5c1877fce7be86 Mon Sep 17 00:00:00 2001 From: Xavier Godart Date: Mon, 2 Dec 2024 20:53:57 +0100 Subject: [PATCH] add parameters help --- midi/midi.go | 5 +++++ ui/param/bank_cmd.go | 4 ++++ ui/param/cc.go | 17 +++++++++++++++++ ui/param/channel.go | 4 ++++ ui/param/clock_send.go | 4 ++++ ui/param/default_device.go | 4 ++++ ui/param/destination.go | 4 ++++ ui/param/direction.go | 4 ++++ ui/param/key.go | 4 ++++ ui/param/length.go | 4 ++++ ui/param/offset.go | 4 ++++ ui/param/param.go | 1 + ui/param/probability.go | 4 ++++ ui/param/root.go | 4 ++++ ui/param/root_cmd.go | 4 ++++ ui/param/scale.go | 4 ++++ ui/param/scale_cmd.go | 4 ++++ ui/param/steps.go | 4 ++++ ui/param/tempo_cmd.go | 4 ++++ ui/param/threshold.go | 4 ++++ ui/param/transport_send.go | 4 ++++ ui/param/triggers.go | 4 ++++ ui/param/velocity.go | 4 ++++ ui/ui.go | 9 ++++++++- 24 files changed, 111 insertions(+), 1 deletion(-) diff --git a/midi/midi.go b/midi/midi.go index 8548067..fc0df0e 100644 --- a/midi/midi.go +++ b/midi/midi.go @@ -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)) diff --git a/ui/param/bank_cmd.go b/ui/param/bank_cmd.go index db90010..5392237 100644 --- a/ui/param/bank_cmd.go +++ b/ui/param/bank_cmd.go @@ -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 "⨯" diff --git a/ui/param/cc.go b/ui/param/cc.go index 85dd6d9..c2c7d2a 100644 --- a/ui/param/cc.go +++ b/ui/param/cc.go @@ -3,9 +3,11 @@ package param import ( "fmt" "strconv" + "strings" "signls/core/common" "signls/core/music" + "signls/midi" "signls/ui/util" ) @@ -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 "⨯" diff --git a/ui/param/channel.go b/ui/param/channel.go index 3ca2be9..e2be5ef 100644 --- a/ui/param/channel.go +++ b/ui/param/channel.go @@ -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( diff --git a/ui/param/clock_send.go b/ui/param/clock_send.go index 7b12fda..17ea78c 100644 --- a/ui/param/clock_send.go +++ b/ui/param/clock_send.go @@ -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" diff --git a/ui/param/default_device.go b/ui/param/default_device.go index 9c63713..c373f10 100644 --- a/ui/param/default_device.go +++ b/ui/param/default_device.go @@ -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() } diff --git a/ui/param/destination.go b/ui/param/destination.go index 596c70e..9f789d6 100644 --- a/ui/param/destination.go +++ b/ui/param/destination.go @@ -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() diff --git a/ui/param/direction.go b/ui/param/direction.go index 2bcc486..f17b887 100644 --- a/ui/param/direction.go +++ b/ui/param/direction.go @@ -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() } diff --git a/ui/param/key.go b/ui/param/key.go index 5c6f98c..11ec7c8 100644 --- a/ui/param/key.go +++ b/ui/param/key.go @@ -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 "⨯" diff --git a/ui/param/length.go b/ui/param/length.go index 314b964..fdc10c8 100644 --- a/ui/param/length.go +++ b/ui/param/length.go @@ -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() diff --git a/ui/param/offset.go b/ui/param/offset.go index 80c0bc0..dad17f3 100644 --- a/ui/param/offset.go +++ b/ui/param/offset.go @@ -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( diff --git a/ui/param/param.go b/ui/param/param.go index c868f34..8e3dd06 100644 --- a/ui/param/param.go +++ b/ui/param/param.go @@ -14,6 +14,7 @@ const ( type Param interface { Name() string + Help() string Value() int AltValue() int Display() string diff --git a/ui/param/probability.go b/ui/param/probability.go index c88d11a..05ae2e5 100644 --- a/ui/param/probability.go +++ b/ui/param/probability.go @@ -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()) } diff --git a/ui/param/root.go b/ui/param/root.go index 330a1e3..6e26fb1 100644 --- a/ui/param/root.go +++ b/ui/param/root.go @@ -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() } diff --git a/ui/param/root_cmd.go b/ui/param/root_cmd.go index 9e8202d..390b8fc 100644 --- a/ui/param/root_cmd.go +++ b/ui/param/root_cmd.go @@ -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 "⨯" diff --git a/ui/param/scale.go b/ui/param/scale.go index 2891145..e29ba26 100644 --- a/ui/param/scale.go +++ b/ui/param/scale.go @@ -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() } diff --git a/ui/param/scale_cmd.go b/ui/param/scale_cmd.go index ae281e0..c5e1e61 100644 --- a/ui/param/scale_cmd.go +++ b/ui/param/scale_cmd.go @@ -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 "⨯" diff --git a/ui/param/steps.go b/ui/param/steps.go index 14f36ec..4e21ddd 100644 --- a/ui/param/steps.go +++ b/ui/param/steps.go @@ -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( diff --git a/ui/param/tempo_cmd.go b/ui/param/tempo_cmd.go index d028630..4f4f15e 100644 --- a/ui/param/tempo_cmd.go +++ b/ui/param/tempo_cmd.go @@ -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 "⨯" diff --git a/ui/param/threshold.go b/ui/param/threshold.go index 57cfd65..fce713d 100644 --- a/ui/param/threshold.go +++ b/ui/param/threshold.go @@ -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( diff --git a/ui/param/transport_send.go b/ui/param/transport_send.go index 228bf34..e517d7c 100644 --- a/ui/param/transport_send.go +++ b/ui/param/transport_send.go @@ -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" diff --git a/ui/param/triggers.go b/ui/param/triggers.go index fdd97d5..c89990d 100644 --- a/ui/param/triggers.go +++ b/ui/param/triggers.go @@ -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( diff --git a/ui/param/velocity.go b/ui/param/velocity.go index e72210f..41f09c1 100644 --- a/ui/param/velocity.go +++ b/ui/param/velocity.go @@ -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( diff --git a/ui/ui.go b/ui/ui.go index c141057..536a409 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -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, @@ -379,6 +385,7 @@ func (m mainModel) View() string { return lipgloss.JoinVertical( lipgloss.Left, m.renderGrid(), + paramHelp, help, ) }