Skip to content

Commit

Permalink
work on midi settings
Browse files Browse the repository at this point in the history
  • Loading branch information
emicklei committed Sep 27, 2024
1 parent c158cb1 commit 6dc32e3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- play(loop(sequence('A B C D G'))) cannot be stopped
12 changes: 10 additions & 2 deletions midi/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,27 @@ func (r *DeviceRegistry) Command(args []string) notify.Message {
r.HandleSetting("echo", []interface{}{})
return nil
}
if len(args) == 1 && args[0] == "i" {
r.printInfo()
return nil
}
if len(args) == 1 && args[0] == "r" {
fmt.Println("Reset MIDI device configuration. Stopping all listeners")
r.Reset()
r.Close()
r.init()
}
r.printInfo()
r.printInfoVerbose()
return nil
}

func (r *DeviceRegistry) printInfo() {
r.streamRegistry.transport.PrintInfo(r.defaultInputID, r.defaultOutputID)

}
func (r *DeviceRegistry) printInfoVerbose() {
r.printInfo()

notify.PrintHighlighted("default settings:")
_, err := r.Input(r.defaultInputID)
if err == nil {
Expand All @@ -115,7 +123,7 @@ func (r *DeviceRegistry) printInfo() {
od, err := r.Output(r.defaultOutputID)
if err == nil {
fmt.Printf("output device = %d, channel = %d\n", r.defaultOutputID, od.defaultChannel)
fmt.Printf(" echo MIDI = %v\n", od.echo)
fmt.Printf(" echo MIDI = %v\n", od.echo)
} else {
fmt.Printf(" no output device (restart?)\n")
}
Expand Down
8 changes: 4 additions & 4 deletions midi/transport/rt_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func (t RtmidiTransporter) PrintInfo(defaultInID, defaultOutID int) {
}
isCurrent := ""
if i == defaultInID {
isCurrent = " (default)"
isCurrent = " (current)"
}
fmt.Printf(" set('midi.in',%d) --- set MIDI input from %s%s\n", i, name, isCurrent)
fmt.Printf(" set('midi.in',%d) --- set default MIDI input device to %s%s\n", i, name, isCurrent)
}
fmt.Println()

Expand All @@ -56,10 +56,10 @@ func (t RtmidiTransporter) PrintInfo(defaultInID, defaultOutID int) {
}
isCurrent := ""
if i == defaultInID {
isCurrent = " (default)"
isCurrent = " (current)"
}

fmt.Printf("set('midi.out',%d) --- set MIDI output to%s%s\n", i, name, isCurrent)
fmt.Printf("set('midi.out',%d) --- set default MIDI output device to %s%s\n", i, name, isCurrent)
}
}
fmt.Println()
Expand Down
1 change: 1 addition & 0 deletions ui/cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func setup(line *liner.State) {
func repl(line *liner.State, ctx core.Context) {
eval := dsl.NewEvaluator(ctx)
ctx.Control().Start()
ctx.Device().Command([]string{"i"}) // bit of a hack
for {
entry, err := line.Prompt(notify.Prompt())
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions ui/cli/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ func handleMIDISetting(ctx core.Context, args []string) notify.Message {

func handleBeatSetting(ctx core.Context, args []string) notify.Message {
l := ctx.Control()
fmt.Printf("[sequencer] beats per minute (BPM): %v\n", l.BPM())
fmt.Printf("[sequencer] beats in a bar (BIAB): %d\n", l.BIAB())
notify.PrintHighlighted("sequencer settings:")
fmt.Printf("beats per minute (BPM) = %v\n", l.BPM())
fmt.Printf("beats in a bar (BIAB) = %d\n", l.BIAB())
return nil
}

Expand Down

0 comments on commit 6dc32e3

Please sign in to comment.