Skip to content
Snippets Groups Projects
Commit c2d1a21b authored by Marc Rene Arns's avatar Marc Rene Arns
Browse files

fix everything

parent 4ebd1be3
No related branches found
Tags v0.1.0
No related merge requests found
......@@ -2,11 +2,11 @@ package main
import (
"fmt"
"os"
"time"
"gitlab.com/gomidi/midi"
_ "gitlab.com/gomidi/midi/reader"
_ "gitlab.com/gomidi/midi/writer"
"gitlab.com/gomidi/midi/writer"
driver "gitlab.com/gomidi/midicatdrv"
// when using portmidi, replace the line above with
// driver gitlab.com/gomidi/portmididrv
......@@ -28,17 +28,36 @@ func main() {
// make sure to close all open ports at the end
defer drv.Close()
ins, err := drv.Ins()
outs, err := drv.Outs()
must(err)
outs, err := drv.Outs()
printOutPorts(outs)
//fmt.Printf("%#v\n", outs)
/*
ins, err := drv.Ins()
must(err)
outs, err := drv.Outs()
must(err)
if len(os.Args) == 2 && os.Args[1] == "list" {
printInPorts(ins)
printOutPorts(outs)
return
}
*/
out := outs[1]
err = out.Open()
must(err)
if len(os.Args) == 2 && os.Args[1] == "list" {
printInPorts(ins)
printOutPorts(outs)
return
}
wr := writer.New(outs[1])
writer.NoteOn(wr, 60, 120)
time.Sleep(time.Second)
writer.NoteOff(wr, 60)
time.Sleep(time.Second)
/*
in, out := ins[0], outs[0]
......
......@@ -3,18 +3,30 @@
package midicatdrv
import (
"fmt"
"os/exec"
"syscall"
)
func execCommand(c string) *exec.Cmd {
func _execCommand(c string) *exec.Cmd {
return exec.Command("/bin/sh", "-c", "exec "+c)
}
func midiCatOutCmd(index int) *exec.Cmd {
cmd := exec.Command("midicat", "out", fmt.Sprintf("--index=%v", index))
// cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
return cmd
}
func midiCatInCmd(index int) *exec.Cmd {
cmd := exec.Command("midicat", "in", fmt.Sprintf("--index=%v", index))
// cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
return cmd
}
func midiCatCmd(args string) *exec.Cmd {
cmd := execCommand("midicat " + args)
cmd := _execCommand("midicat " + args)
// important! prevents that signals such as interrupt send to the main program gets passed
// to midicat (which would not allow us to shutdown properly, e.g. stop hanging notes)
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
//cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
return cmd
}
......@@ -3,15 +3,32 @@
package midicatdrv
import (
"fmt"
"os/exec"
"strings"
)
/*
func execCommand(c string) *exec.Cmd {
//return exec.Command("powershell.exe", "/Command", `$Process = [Diagnostics.Process]::Start("` + c + `") ; echo $Process.Id `)
//return exec.Command("powershell.exe", "/Command", `$Process = [Diagnostics.Process]::Start("fluidsynth.exe", "-i -q -n $_file") ; echo $Process.Id `)
fmt.Println(c)
return exec.Command("cmd.exe", "/C", c)
}
*/
func midiCatOutCmd(index int) *exec.Cmd {
return exec.Command("midicat.exe", "out", fmt.Sprintf("--index=%v", index))
}
func midiCatInCmd(index int) *exec.Cmd {
return exec.Command("midicat.exe", "in", fmt.Sprintf("--index=%v", index))
}
func midiCatCmd(args string) *exec.Cmd {
return execCommand("midicat.exe " + args)
//return execCommand("midicat.exe " + args)
//fmt.Println("midicat.exe " + args)
a := strings.Split(args, " ")
return exec.Command("midicat.exe", a...)
}
......@@ -2,6 +2,4 @@ module gitlab.com/gomidi/midicatdrv
go 1.14
require (
gitlab.com/gomidi/midi v1.22.3
)
require gitlab.com/gomidi/midi v1.23.0
......@@ -62,7 +62,8 @@ func (o *in) fireCmd() error {
o.hasProc = true
o.Unlock()
go func(shouldStopListening <-chan bool, didStopListening chan<- bool, shouldKill <-chan bool, wasKilled chan<- bool) {
cmd := midiCatCmd(fmt.Sprintf("in --index=%v --name='%s'", o.number, o.name))
cmd := midiCatInCmd(o.number)
//cmd := midiCatCmd(fmt.Sprintf("in --index=%v --name='%s'", o.number, o.name))
rd, wr := io.Pipe()
cmd.Stdout = wr
err := cmd.Start()
......
......@@ -30,7 +30,10 @@ func (o *out) fireCmd() error {
if o.cmd != nil {
return fmt.Errorf("already running")
}
o.cmd = midiCatCmd(fmt.Sprintf("out --index=%v --name='%s'", o.number, o.name))
//o.cmd = midiCatCmd(fmt.Sprintf("out --index=%v --name=%q", o.number, o.name))
o.cmd = midiCatOutCmd(o.number)
//o.cmd = midiCatCmd(fmt.Sprintf("out --index=%v", o.number))
o.rd, o.wr = io.Pipe()
o.cmd.Stdin = o.rd
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment