Skip to content

Commit

Permalink
put windows paths in windows.go, integrate keykit
Browse files Browse the repository at this point in the history
  • Loading branch information
vizicist committed Feb 4, 2023
1 parent 805a07e commit d319d18
Show file tree
Hide file tree
Showing 26 changed files with 323 additions and 100 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ _Current.json
_Current_*.json
CurrentSnapshot.*
CurrentQuad.*
last.kp
*.pyc
*.suo
default/logs/*.log
Expand Down
13 changes: 12 additions & 1 deletion build/windows/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ mkdir %ship%\bin
mkdir %ship%\bin\mmtt_kinect
mkdir %ship%\html
mkdir %ship%\ffgl
mkdir %ship%\keykit
mkdir %ship%\keykit\bin
mkdir %ship%\keykit\lib

echo ================ Upgrading Python
python -m pip install pip | grep -v "already.*satisfied"
Expand Down Expand Up @@ -96,6 +99,11 @@ copy %PALETTESOURCE%\binaries\nats\nats-sub.exe %bin% >nul
copy %PALETTESOURCE%\binaries\nircmdc.exe %bin% >nul
copy %PALETTESOURCE%\binaries\tail.exe %bin% >nul

echo ================ Copying keykit things
copy %PALETTESOURCE%\keykit\bin\key.exe %ship%\keykit\bin >nul
copy %PALETTESOURCE%\keykit\bin\keylib.exe %ship%\keykit\bin >nul
copy %PALETTESOURCE%\keykit\lib\*.* %ship%\keykit\lib >nul

echo ================ Copying scripts
pushd %PALETTESOURCE%\scripts
copy palettetasks.bat %bin% >nul
Expand All @@ -114,6 +122,8 @@ for %%X in (data_omnisphere) DO (
mkdir %ship%\%%X\config
mkdir %ship%\%%X\midifiles
mkdir %ship%\%%X\saved
mkdir %ship%\%%X\keykit
mkdir %ship%\%%X\keykit\liblocal
copy %PALETTESOURCE%\%%X\config\homepage.json %ship%\%%X\config >nul
copy %PALETTESOURCE%\%%X\config\ffgl.json %ship%\%%X\config >nul
copy %PALETTESOURCE%\%%X\config\param*.json %ship%\%%X\config >nul
Expand All @@ -132,7 +142,8 @@ for %%X in (data_omnisphere) DO (
copy %PALETTESOURCE%\%%X\config\palette.ico %ship%\%%X\config >nul
copy %PALETTESOURCE%\%%X\config\*.bidule %ship%\%%X\config >nul
copy %PALETTESOURCE%\%%X\midifiles\*.* %ship%\%%X\midifiles >nul
xcopy /e /y %PALETTESOURCE%\%%X\saved %ship%\%%X\saved > nul
xcopy /e /y %PALETTESOURCE%\%%X\saved %ship%\%%X\saved >nul
xcopy /e /y %PALETTESOURCE%\%%X\keykit\liblocal %ship%\%%X\keykit\liblocal >nul
)

echo ================ Copying windows-specific things
Expand Down
1 change: 1 addition & 0 deletions build/windows/palette_win_setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Source: "ship\bin\pyinstalled\*"; DestDir: "{app}\bin\pyinstalled"; Flags: ignor
Source: "ship\bin\mmtt_kinect\*"; DestDir: "{app}\bin\mmtt_kinect"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "ship\ffgl\*"; DestDir: "{app}\ffgl"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "ship\html\*"; DestDir: "{app}\html"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "ship\keykit\*"; DestDir: "{app}\keykit"; Flags: ignoreversion recursesubdirs createallsubdirs

; NOTE - all data_* files go in CommonProgramFiles\Palette
Source: "ship\data_omnisphere\*"; DestDir: "{commoncf64}\{#MyAppName}\data_omnisphere"; Flags: comparetimestamp ignoreversion recursesubdirs createallsubdirs
Expand Down
6 changes: 6 additions & 0 deletions cmd/palette/palette.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func CliCommand(args []string) string {
case "resolume":
return doApi("quadpro.startprocess", "process", "resolume")

case "keykit":
return doApi("quadpro.startprocess", "process", "keykit")

case "", "all":
s1 := doStartEngine()
s2 := doApi("quadpro.startprocess", "process", "all")
Expand Down Expand Up @@ -132,6 +135,9 @@ func CliCommand(args []string) string {
case "resolume":
return doApi("quadpro.stopprocess", "process", "resolume")

case "keykit":
return doApi("quadpro.stopprocess", "process", "keykit")

default:
return usage()
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/palette_engine/palette_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {
os.Exit(0)
}()

if engine.EngineParamBool("twinsys") {
if e.ParamBool("engine.twinsys") {
twinsys.Run()
} else {
select {}
Expand Down
1 change: 1 addition & 0 deletions data_omnisphere/config/paramdefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"engine.attractidleminutes": {"valuetype":"int", "min":"0", "max":"60", "init":"0", "comment":"# Attract timeout, 0 to disable" },
"engine.autostart": {"valuetype":"string", "min":"autostart", "max":"autostart", "init":"bidule,resolume", "comment":"# Plugins to start" },
"engine.bidule": {"valuetype":"string", "min":"bidule", "max":"bidule", "init":"C:/Program Files/Plogue/Bidule/Bidule.exe", "comment":"# Bidule executable path" },
"engine.midiinput": {"valuetype":"string", "min":"midiinput", "max":"midiinput", "init":"", "comment":"# Bidule executable path" },
"engine.guiresize": {"valuetype":"string", "min":"guiresize", "max":"bidule", "init":"100,100,800,1280", "comment":"# GUI resize" },

"visual.noisevertex": {"valuetype":"float", "min":"0.0", "max":"1.0", "randmin":"0.0", "randmax":"0.0", "init":"0.0", "comment":"# 0-1" },
Expand Down
1 change: 1 addition & 0 deletions data_omnisphere/config/paramenums.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"quantstyle": [ "none", "frets", "fixed", "pressure" ],
"volstyle": [ "fixed", "pressure" ],
"shape": [ "line", "triangle", "square", "circle" ],
"midiinput": [ "" ],
"movedir": [ "cursor", "left", "right", "up", "down", "random", "random90", "updown", "leftright" ],
"rotangdir": [ "right", "left", "random" ],
"mirror": [ "none", "vertical", "horizontal", "four" ],
Expand Down
8 changes: 8 additions & 0 deletions data_omnisphere/keykit/liblocal/keylib.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#library keylocal.k keylocal
#library keylocal.k localprerc
#library keylocal.k localpostrc
#library palette.k palette_kill
#library palette.k palette_listen
#library palette.k palette_listen_task
#library palette.k palette_send
#library palette.k palette_test
30 changes: 30 additions & 0 deletions data_omnisphere/keykit/liblocal/keylocal.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# To control your local configuration, you can create a file
# named c:\keylocal.k (ie. in the root directory of the drive you
# are running keykit from), and put a function keylocal() in it.
# That function will be executed when keykit starts, and you
# can set things like the default MIDI input/output ports, etc.
#
# This is a sample. You should copy this file to c:\keylocal.k
# and then edit it as needed. The Contribdir, if set, is where things
# like GeoMaestro will be located.

function keylocal() {

Contribdir = "c:\\contrib"

# You can add (multiple) things to be executed at the beginning and
# end of the boot process, by using addprerc and addpostrc, like this:
addprerc(global(localprerc))
addpostrc(global(localpostrc))

# Inittask = remotecons(4444) # would start remote console on port 4444
# Inittask = palette_listen()
}

function localprerc() {
# This would get executed at the beginning of keyrc()
}

function localpostrc() {
# This would get executed at the end of keyrc()
}
51 changes: 51 additions & 0 deletions data_omnisphere/keykit/liblocal/palette.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# These are routines used by the Space Palette

PaletteListenAddress = "[email protected]"
PaletteListenConnection = 0
PaletteSendAddress = "[email protected]"
PaletteSendConnection = 0
PaletteListenTask = 0

function palette_kill() {
print("Killing listen task")
kill(PaletteListenTask)
PaletteListenTask = 0
}

function palette_listen() {
if ( PaletteListenTask != 0 ) {
print("Palette listener already running.")
return()
}
PaletteListenTask = task palette_listen_task()
}

function palette_listen_task() {
if ( PaletteListenConnection == 0 ) {
PaletteListenConnection = open(PaletteListenAddress,"rA","osc_listen")
if ( PaletteListenConnection < 0 ) {
print("Palette: unable to open ",PaletteListenAddress)
print("Palette: perhaps another process is listening on ",PaletteListenAddress)
return()
}
}
while ( (d = get(PaletteListenConnection)) != Eof ) {
print("Palette sent to keykit:",string(d))
}
}

function palette_send(msg) {
if ( PaletteSendConnection == 0 ) {
print("Opening connection to Palette: ",PaletteSendAddress)
PaletteSendConnection = open(PaletteSendAddress,"wb","osc_send")
}
print("Sending to Palette:",msg)
mdep("osc","send",PaletteSendConnection,msg)
}

function palette_test() {
msg = [0="/api",1="{\"api\":\"engine.sprite\",\"x\":\"0.3\",\"y\":\"0.4\",\"z\":\"0.5\"}"]
palette_send(msg)
}


14 changes: 5 additions & 9 deletions engine/bidule.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package engine

import (
"strings"
"path/filepath"
"sync"
"time"

Expand Down Expand Up @@ -40,21 +40,17 @@ func (b *Bidule) Activate() {
}

func (b *Bidule) ProcessInfo() *ProcessInfo {
bidulePath := EngineParam("bidule")
bidulePath := TheEngine.Get("engine.bidule")
if bidulePath == "" {
bidulePath = "C:/Program Files/Plogue/Bidule/Bidule.exe"
bidulePath = BiduleDefaultPath
LogWarn("No bidule value in settings, using default", "path", bidulePath)
}
if !FileExists(bidulePath) {
LogWarn("No bidule found, looking for", "path", bidulePath)
return nil
}
exe := bidulePath
lastslash := strings.LastIndex(exe, "\\")
if lastslash > 0 {
exe = exe[lastslash+1:]
}
bidulefile := EngineParam("bidulefile")
exe := filepath.Base(bidulePath)
bidulefile := TheEngine.Get("engine.bidulefile")
if bidulefile == "" {
bidulefile = "default.bidule"
}
Expand Down
11 changes: 7 additions & 4 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Engine struct {
params *ParamValues
Router *Router
Scheduler *Scheduler
CursorManager *CursorManager
CursorManager *CursorManager
ProcessManager *ProcessManager
// CursorManager *CursorManager
done chan bool
Expand Down Expand Up @@ -44,10 +44,13 @@ func NewEngine() *Engine {
params: NewParamValues(),
Scheduler: NewScheduler(),
Router: router,
CursorManager: cm,
CursorManager: cm,
ProcessManager: NewProcessManager(),
done: make(chan bool),
}

TheEngine.ProcessManager.AddProcessBuiltIn("keykit")

TheEngine.ResetLogTypes(os.Getenv("PALETTE_LOG"))
LogInfo("Engine InitLog ==============================================")
TheEngine.SetDefaultValues()
Expand Down Expand Up @@ -104,7 +107,7 @@ func (e *Engine) Start() {
go e.Scheduler.Start()
go e.Router.Start()

if EngineParamBool("depth") {
if e.ParamBool("mmtt.depth") {
go DepthRunForever()
}
}
Expand Down Expand Up @@ -213,7 +216,7 @@ func (e *Engine) StartHTTP(port int) {
default:
response = ErrorResponse(fmt.Errorf("HTTP server unable to handle method=%s", req.Method))
}
})
})

source := fmt.Sprintf("127.0.0.1:%d", port)
err := http.ListenAndServe(source, nil)
Expand Down
62 changes: 59 additions & 3 deletions engine/engineapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package engine
import (
"fmt"
"os"
"strconv"
"strings"
"time"
)
Expand Down Expand Up @@ -112,6 +113,26 @@ func (e *Engine) executeEngineAPI(api string, apiargs map[string]string) (result
}
return e.Get(name), nil

case "startprocess":
process, ok := apiargs["process"]
if !ok {
return "", fmt.Errorf("executeEngineAPI: missing process parameter")
}
err := e.ProcessManager.StartRunning(process)
if err != nil {
return "", err
}
err = e.ProcessManager.Activate(process)
return "", err

case "stopprocess":
process, ok := apiargs["process"]
if !ok {
return "", fmt.Errorf("executeEngineAPI: missing process parameter")
}
err := e.ProcessManager.StopRunning(process)
return "", err

case "save":
filename, ok := apiargs["filename"]
if !ok {
Expand Down Expand Up @@ -278,9 +299,7 @@ func (e *Engine) Set(name string, value string) error {
}

func (e *Engine) Get(name string) string {
value := e.params.Get(name)
// LogInfo("Engine.Get", "name", name, "value", value)
return value
return e.params.Get(name)
}

func (e *Engine) GetWithDefault(nm string, dflt string) string {
Expand All @@ -291,6 +310,43 @@ func (e *Engine) GetWithDefault(nm string, dflt string) string {
}
}

// ParamBool returns bool value of nm, or false if nm not set
func (e *Engine) ParamBool(nm string) bool {
v := e.Get(nm)
if v == "" {
return false
}
return IsTrueValue(v)
}

func (e *Engine) EngineParamIntWithDefault(nm string, dflt int) int {
s := e.Get(nm)
if s == "" {
return dflt
}
var val int
nfound, err := fmt.Sscanf(s, "%d", &val)
if nfound == 0 || err != nil {
LogError(err)
return dflt
}
return val
}

func (e *Engine) EngineParamFloatWithDefault(nm string, dflt float64) float64 {
s := e.Get(nm)
if s == "" {
return dflt
}
var f float64
f, err := strconv.ParseFloat(s, 32)
if err != nil {
LogError(err)
return dflt
}
return f
}

func (e *Engine) executeSavedAPI(api string, apiargs map[string]string) (result string, err error) {

switch api {
Expand Down
8 changes: 6 additions & 2 deletions engine/midi.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func InitMIDI() {
inports := midi.GetInPorts()
outports := midi.GetOutPorts()

midiInputName := EngineParam("midiinput")
midiInputName := TheEngine.Get("engine.midiinput")

// device names is done with strings.Contain // Note: name matching of MIDI s
// beause gomidi/midi appends an index value to the strings
Expand Down Expand Up @@ -132,9 +132,13 @@ func InitMIDI() {

type MidiHandlerFunc func(midi.Message, int32)

func (m *MIDIIO) handleMidiError(err error) {
LogError(err)
}

func (m *MIDIIO) Start(inChan chan MidiEvent) {
m.midiInputChan = inChan
stop, err := midi.ListenTo(m.midiInput, m.handleMidiInput, midi.UseSysEx())
stop, err := midi.ListenTo(m.midiInput, m.handleMidiInput, midi.UseSysEx(), midi.HandleError(m.handleMidiError))
if err != nil {
LogWarn("midi.ListenTo", "err", err)
return
Expand Down
Loading

0 comments on commit d319d18

Please sign in to comment.