kit

package module
v0.0.0-...-e6c1bf1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2023 License: MIT Imports: 26 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// NoteOn
	NoteOnStatus       byte = 0x90
	NoteOffStatus      byte = 0x80
	PressureStatus     byte = 0xa0
	ControllerStatus   byte = 0xb0
	ProgramStatus      byte = 0xc0
	ChanPressureStatus byte = 0xd0
	PitchbendStatus    byte = 0xe0
)

These are the values of MIDI status bytes

View Source
const EventCursor = 0x04
View Source
const EventMidiInput = 0x01

Bits for Events

View Source
const EventNoteOutput = 0x02
View Source
const PatchNameSeparator = "-"

In a quad file, the parameter names are of the form: {patchName}-{parametername}.

Variables

View Source
var BugFixWarningCount = 0
View Source
var EighthNote = Clicks(12)
View Source
var FirstTime = true
View Source
var HalfNote = Clicks(48)
View Source
var LogEnabled = map[string]bool{
	"*":              false,
	"advance":        false,
	"api":            false,
	"attract":        false,
	"bidule":         false,
	"config":         false,
	"cursor":         false,
	"drawing":        false,
	"erae":           false,
	"exec":           false,
	"ffgl":           false,
	"freeframe":      false,
	"gensound":       false,
	"genvisual":      false,
	"gesture":        false,
	"go":             false,
	"goroutine":      false,
	"info":           false,
	"patch":          false,
	"process":        false,
	"keykit":         false,
	"layerapi":       false,
	"listeners":      false,
	"load":           false,
	"loop":           false,
	"midi":           false,
	"midicontroller": false,
	"midiports":      false,
	"mmtt":           false,
	"morph":          false,
	"mouse":          false,
	"nats":           false,
	"note":           false,
	"notify":         false,
	"osc":            false,
	"params":         false,
	"phrase":         false,
	"plugin":         false,
	"quant":          false,
	"saved":          false,
	"realtime":       false,
	"resolume":       false,
	"remote":         false,
	"router":         false,
	"scale":          false,
	"scheduler":      false,
	"task":           false,
	"transpose":      false,
	"value":          false,
}
View Source
var LogMutex sync.Mutex
View Source
var MaxClicks = Clicks(math.MaxInt64)

MaxClicks is the high-possible value for Clicks

View Source
var MidiNumDown int
View Source
var MidiOctaveShift int
View Source
var MidiThruScadjust bool
View Source
var Midisetexternalscale bool
View Source
var Midithru bool
View Source
var OneBeatMutex sync.RWMutex
View Source
var OscOutput = true
View Source
var PaletteAPISubject = "palette.api"

PaletteAPISubject xxx

View Source
var ParamDefs map[string]ParamDef

ParamDefs is the set of all parameter definitions

View Source
var ParamEnums map[string][]string

ParamEnums contains the lists of enumerated values for string parameters

View Source
var Patchs = map[string]*Patch{}
View Source
var PitchSets = map[string][]uint8{
	"stylusrmx": {36, 37, 38, 39, 42, 43, 51, 49},
}
View Source
var PointZero image.Point = image.Point{0, 0}
View Source
var QuarterNote = Clicks(24)
View Source
var SixteenthNote = Clicks(6)
View Source
var Synths map[string]*Synth
View Source
var TempoFactor = float64(1.0)

TempoFactor xxx

View Source
var ThirtySecondNote = Clicks(3)
View Source
var Time0 = time.Time{}
View Source
var TwitchParams map[string]string
View Source
var WholeNote = Clicks(96)

Functions

func AppendExtraValues

func AppendExtraValues(keysAndValues []any) []any

func ArchiveLogs

func ArchiveLogs() error

func ArgToFloat

func ArgToFloat(nm string, args map[string]string) float32

func ArgToInt

func ArgToInt(nm string, args map[string]string) int

func BoundAndScaleController

func BoundAndScaleController(v, vmin, vmax float32, cmin, cmax int) int

func BoundAndScaleFloat

func BoundAndScaleFloat(v, vmin, vmax, outmin, outmax float32) float32

func BoundValueZeroToOne

func BoundValueZeroToOne(v float64) float64

func ChangeClicksPerSecond

func ChangeClicksPerSecond(factor float64)

ChangeClicksPerSecond is what you use to change the tempo

func ClearExternalScale

func ClearExternalScale()

func Clicks2Seconds

func Clicks2Seconds(clk Clicks) float64

Clicks2Seconds converts Clicks to Time (seconds), relative

func CopyDir

func CopyDir(src, dest string) error

CopyDir xxx

func CurrentMilli

func CurrentMilli() int64

func CurrentMilliOffset

func CurrentMilliOffset() int64

func CursorToOscMsg

func CursorToOscMsg(ce CursorEvent) *osc.Message

func EngineApi

func EngineApi(api string, apiargs ...string) (map[string]string, error)

func EraeBitize7chksum

func EraeBitize7chksum(in []byte) (out []byte, chksum byte)

7-bitize an array of bytes and get the resulting checksum Algorithm taken from Erae documentation. Return value is the output bytes and checksum

func EraeUnbitize7chksum

func EraeUnbitize7chksum(in []byte) ([]byte, byte)

7-unbitize an array of bytes and get the incomming checksum Algorithm taken from Erae documentation. Return value is the output bytes and checksum

func ErrorResponse

func ErrorResponse(err error) string

ErrorResponse return an error response

func ErrorResult

func ErrorResult(err string) string

ErrorResult xxx

func ExecuteApi

func ExecuteApi(api string, apiargs map[string]string) (result string, err error)

ExecuteApi xxx

func ExecuteApiFromJson

func ExecuteApiFromJson(rawjson string) (string, error)

handleRawJsonApi takes raw JSON (as a string of the form "{...}"") as an API and returns raw JSON

func ExecuteEngineApi

func ExecuteEngineApi(api string, apiargs map[string]string) (result string, err error)

func ExecuteSavedApi

func ExecuteSavedApi(api string, apiargs map[string]string) (result string, err error)

func ExtractAndRemoveValueOf

func ExtractAndRemoveValueOf(valName string, argsmap map[string]string) string

ExtractAndRemoveValueOf removes a named value from a map and returns it. If the value doesn't exist, "" is returned.

func FileExists

func FileExists(path string) bool

func Float32bytes

func Float32bytes(float float32) []byte

func Float32frombytes

func Float32frombytes(bytes []byte) float32

func GetArgsXYZ

func GetArgsXYZ(args map[string]string) (x, y, z float32, err error)

func GetFloat

func GetFloat(value string, f *float64) bool

func GetFloat32

func GetFloat32(value string, f *float32) bool

func GetInt

func GetInt(value string, i *int64) bool

func GetNUID

func GetNUID() string

GetNUID xxx

func GetNameValue

func GetNameValue(apiargs map[string]string) (name string, value string, err error)

func GetParam

func GetParam(nm string) (string, error)

func GetParamBool

func GetParamBool(nm string) (bool, error)

func GetParamFloat

func GetParamFloat(nm string) (float64, error)

func GetParamInt

func GetParamInt(nm string) (int, error)

func GoroutineID

func GoroutineID() uint64

func HandleMidiEvent

func HandleMidiEvent(me MidiEvent)

func HumanReadableApiOutput

func HumanReadableApiOutput(apiOutput map[string]string) string

humanReadableApiOutput takes the result of an API invocation and produces what will appear in visible output from a CLI command.

func Init

func Init() error

func InitParamDefs

func InitParamDefs()

func InitSynths

func InitSynths()

func InitializeClicksPerSecond

func InitializeClicksPerSecond(clkpersec Clicks)

InitializeClicksPerSecond initializes

func IsLogging

func IsLogging(logtype string) bool

func IsPatchCategory

func IsPatchCategory(category string) bool

func IsPerPatchParam

func IsPerPatchParam(name string) bool

func IsTrueValue

func IsTrueValue(value string) bool

IsTrueValue returns true if the value is some version of true, and false otherwise.

func JsonObject

func JsonObject(args ...string) string

func JsonString

func JsonString(args ...string) string

func LoadEngineParams

func LoadEngineParams(fname string)

func LoadParamDefs

func LoadParamDefs() error

LoadParamDefs initializes the list of parameters

func LoadParamEnums

func LoadParamEnums() error

LoadParamEnums initializes the list of enumerated parameter values

func LogError

func LogError(err error, keysAndValues ...any)

func LogIfError

func LogIfError(err error, keysAndValues ...any)

func LogInfo

func LogInfo(msg string, keysAndValues ...any)

func LogOfType

func LogOfType(logtypes string, msg string, keysAndValues ...any)

func LogWarn

func LogWarn(msg string, keysAndValues ...any)

func MapString

func MapString(amap map[string]string) string

func MidiToOscMsg

func MidiToOscMsg(me MidiEvent) *osc.Message

func MmttApi

func MmttApi(api string) (map[string]string, error)

func MyNUID

func MyNUID() string

MyNUID xxx

func NatsHandler

func NatsHandler(msg *nats.Msg)

func NeedBoolArg

func NeedBoolArg(nm string, api string, args map[string]string) (bool, error)

func NeedFloatArg

func NeedFloatArg(nm string, api string, args map[string]string) (float32, error)

func NeedStringArg

func NeedStringArg(nm string, api string, args map[string]string) (string, error)

func NewClickMsg

func NewClickMsg(click Clicks) string

NewClickMsg xxx

func NewSetParamMsg

func NewSetParamMsg(name string, value string) string

func OkResult

func OkResult() string

ErrorResult xxx

func OptionalStringArg

func OptionalStringArg(nm string, args map[string]string, dflt string) string

func ParseBool

func ParseBool(s string, name string) (bool, error)

ParseBool xxx

func ParseFloat32

func ParseFloat32(s string, name string) (float32, error)

ParseFloat32 xxx

func ParseInt

func ParseInt(s string, name string) (int, error)

ParseInt xxx

func PatchNames

func PatchNames() []string

func PublishCursorEvent

func PublishCursorEvent(ce CursorEvent)

PublishCursorEvent xxx

func PublishMIDIDeviceEvent

func PublishMIDIDeviceEvent(me MidiEvent)

PublishMIDIDeviceEvent xxx

func PublishSpriteEvent

func PublishSpriteEvent(x, y, z float32)

PublishSpriteEvent xxx

func RegisterAndInit

func RegisterAndInit(h Host) error

func RegisterHost

func RegisterHost(h Host)

func RemoteEngineApi

func RemoteEngineApi(api string, data string) (string, error)

func ResultResponse

func ResultResponse(resultObj any) string

ResultResponse returns a JSON 2.0 result response

func SavedList

func SavedList(apiargs map[string]string) (string, error)

func SavedNameSplit

func SavedNameSplit(saved string) (string, string)

func ScheduleAt

func ScheduleAt(atClick Clicks, tag string, value any)

func ScheduleCursorEvent

func ScheduleCursorEvent(ce CursorEvent)

func SendToOscClients

func SendToOscClients(msg *osc.Message)

func SetClicksPerSecond

func SetClicksPerSecond(cps Clicks)

func SetCurrentClick

func SetCurrentClick(click Clicks)

func SetCurrentClickOffset

func SetCurrentClickOffset(click Clicks)

func SetCurrentMilli

func SetCurrentMilli(milli int64)

func SetCurrentMilliOffset

func SetCurrentMilliOffset(milli int64)

func SetEngineParam

func SetEngineParam(name string, value string) error

func SetExternalScale

func SetExternalScale(pitch uint8, on bool)

func SetLogTypeEnabled

func SetLogTypeEnabled(dtype string, b bool)

func SetLogTypes

func SetLogTypes(logtypes string)

func StartEngine

func StartEngine()

func StartTwitch

func StartTwitch()

func String

func String(arg any) string

String xxx

func StringMap

func StringMap(params string) (map[string]string, error)

StringMap takes a JSON string and returns a map of elements

func ToBool

func ToBool(arg any) bool

ToBool xxx

func TwitchLoadParams

func TwitchLoadParams() error

TwitchLoadParams

func Uptime

func Uptime() float64

Uptime returns the number of seconds since the program started.

Types

type ActiveCursor

type ActiveCursor struct {
	Current     CursorEvent
	Previous    CursorEvent
	NoteOn      *NoteOn
	NoteOnClick Clicks
	NoteOnY     float32
	NoteOnZ     float32
	Patch       *Patch
	Button      string
	// contains filtered or unexported fields
}

OscEvent is an OSC message

func NewActiveCursor

func NewActiveCursor(ce CursorEvent) *ActiveCursor

NewActiveCursor - create a new ActiveCursor for a CursorEvent An ActiveCursor can be for a Button or a Patch area.

type AttractManager

type AttractManager struct {

	// externally controlled things
	AttractCheckSecs       float64
	AttractChangeInterval  float64
	AttractGestureInterval float64
	AttractIdleSecs        float64
	// contains filtered or unexported fields
}
var TheAttractManager *AttractManager

func NewAttractManager

func NewAttractManager() *AttractManager

func (*AttractManager) AttractModeIsOn

func (am *AttractManager) AttractModeIsOn() bool

func (*AttractManager) SetAttractEnabled

func (am *AttractManager) SetAttractEnabled(b bool)

func (*AttractManager) SetAttractMode

func (am *AttractManager) SetAttractMode(onoff bool)

type ChanPressure

type ChanPressure struct {
	Channel  uint8
	Pressure uint8
}

func NewChanPressure

func NewChanPressure(channel, pressure uint8) *ChanPressure

func (*ChanPressure) String

func (n *ChanPressure) String() string

type ClickEvent

type ClickEvent struct {
	Click  Clicks
	Uptime float64
}

type Clicks

type Clicks int64

Clicks is a time or duration value. NOTE: A Clicks value can be negative because it's sometimes relative to the starting time of a Phrase. XXX - possiblycould have a type to distinguish Clicks that are XXX - used as absolute time versus Clicks that are step numbers

var OneBeat Clicks

func ClicksPerSecond

func ClicksPerSecond() Clicks

func CurrentClick

func CurrentClick() Clicks

func CurrentClickOffset

func CurrentClickOffset() Clicks

func Seconds2Clicks

func Seconds2Clicks(tm float64) Clicks

Seconds2Clicks converts a Time value (elapsed seconds) to Clicks

type Cmd

type Cmd struct {
	Subj   string
	Values map[string]string
}

func NewSimpleCmd

func NewSimpleCmd(subj string) Cmd

func (Cmd) ValuesBool

func (cmd Cmd) ValuesBool(name string, dflt bool) bool

func (Cmd) ValuesColor

func (cmd Cmd) ValuesColor(dflt color.RGBA) color.RGBA

func (Cmd) ValuesFloat

func (cmd Cmd) ValuesFloat(name string, dflt float32) float32

func (Cmd) ValuesInt

func (cmd Cmd) ValuesInt(name string, dflt int) int

func (Cmd) ValuesPos

func (cmd Cmd) ValuesPos(dflt image.Point) image.Point

func (Cmd) ValuesRect

func (cmd Cmd) ValuesRect(dflt image.Rectangle) image.Rectangle

func (Cmd) ValuesSetPos

func (cmd Cmd) ValuesSetPos(pos image.Point)

func (Cmd) ValuesSetXY

func (cmd Cmd) ValuesSetXY(key string, pos image.Point)

func (Cmd) ValuesSetXY0

func (cmd Cmd) ValuesSetXY0(pos image.Point)

func (Cmd) ValuesSetXY1

func (cmd Cmd) ValuesSetXY1(pos image.Point)

func (Cmd) ValuesSize

func (cmd Cmd) ValuesSize(dflt image.Point) image.Point

func (Cmd) ValuesString

func (cmd Cmd) ValuesString(name string, dflt string) string

func (Cmd) ValuesToString

func (cmd Cmd) ValuesToString() string

func (Cmd) ValuesUint8

func (cmd Cmd) ValuesUint8(name string, dflt uint8) uint8

func (Cmd) ValuesXY

func (cmd Cmd) ValuesXY(xyname string, dflt image.Point) image.Point

ValuesXY is used to get any 2-valued int value (ie. pos or size)

func (Cmd) ValuesXY0

func (cmd Cmd) ValuesXY0(dflt image.Point) image.Point

func (Cmd) ValuesXY1

func (cmd Cmd) ValuesXY1(dflt image.Point) image.Point

func (Cmd) VerifyValues

func (cmd Cmd) VerifyValues(names ...string) bool

type Command

type Command struct {
	Action string // e.g. "addmidi"
	Arg    any
}

type Controller

type Controller struct {
	Controller uint8
	Value      uint8
	Channel    uint8
}

func NewController

func NewController(channel, controller, value uint8) *Controller

NewController create a new noteoff

func (*Controller) String

func (n *Controller) String() string

type CursorCallbackFunc

type CursorCallbackFunc func(e CursorEvent)

CursorDeviceCallbackFunc xxx

type CursorEvent

type CursorEvent struct {
	// Named CClick to catch everyone that accesses it
	CClick Clicks `json:"Click"`
	Gid    int    `json:"Gid"`
	Tag    string `json:"Tag"`
	// Source string
	Ddu  string    `json:"Ddu"` // "down", "drag", "up" (sometimes "clear")
	Pos  CursorPos `json:"Pos"`
	Area float32   `json:"Area"`
}

CursorEvent is a single Cursor event. NOTE: it's assumed that we can copy a CursorEvent by copying the value. Do note add pointers to this struct.

func CursorEventFromString

func CursorEventFromString(s string) (ce CursorEvent, err error)

func NewCursorClearEvent

func NewCursorClearEvent(tag string) CursorEvent

func NewCursorEvent

func NewCursorEvent(gid int, tag string, ddu string, pos CursorPos) CursorEvent

func (CursorEvent) GetClick

func (ce CursorEvent) GetClick() Clicks

func (CursorEvent) IsAttractGenerated

func (ce CursorEvent) IsAttractGenerated() bool

func (CursorEvent) Marshal

func (ce CursorEvent) Marshal() (bytes []byte, err error)

XXX - can this make use of generics? (across all the Event types)

func (*CursorEvent) SetClick

func (ce *CursorEvent) SetClick(click Clicks)

func (*CursorEvent) Source

func (ce *CursorEvent) Source() string

type CursorHandler

type CursorHandler interface {
	// contains filtered or unexported methods
}

type CursorManager

type CursorManager struct {
	ClickMutex sync.RWMutex

	GidToLoopedGidMutex sync.RWMutex
	GidToLoopedGid      map[int]int

	LoopThreshold float32
	// contains filtered or unexported fields
}
var TheCursorManager *CursorManager

func NewCursorManager

func NewCursorManager() *CursorManager

func (*CursorManager) AddCursorHandler

func (cm *CursorManager) AddCursorHandler(name string, handler CursorHandler, sources ...string)

func (*CursorManager) CheckAutoCursorUp

func (cm *CursorManager) CheckAutoCursorUp()

func (*CursorManager) ClearAllActiveCursors

func (cm *CursorManager) ClearAllActiveCursors(tag string)

func (*CursorManager) DeleteActiveCursor

func (cm *CursorManager) DeleteActiveCursor(gid int)

func (*CursorManager) DeleteActiveCursorIfZLessThan

func (cm *CursorManager) DeleteActiveCursorIfZLessThan(gid int, threshold float32)

DeleteActiveCursorIfZLessThan deletes the ActiveCursor if its Z value is less than threshold.

func (*CursorManager) DeleteActiveCursorsForTag

func (cm *CursorManager) DeleteActiveCursorsForTag(tag string)

func (*CursorManager) ExecuteCursorEvent

func (cm *CursorManager) ExecuteCursorEvent(ce CursorEvent)

func (*CursorManager) GenerateGesture

func (cm *CursorManager) GenerateGesture(tag string, numsteps int, dur time.Duration, pos0 CursorPos, pos1 CursorPos)

func (*CursorManager) GenerateRandomGesture

func (cm *CursorManager) GenerateRandomGesture(tag string, numsteps int, dur time.Duration)

func (*CursorManager) LoopCursorEvent

func (cm *CursorManager) LoopCursorEvent(ac *ActiveCursor) *SchedElement

func (*CursorManager) LoopedGidFor

func (cm *CursorManager) LoopedGidFor(ce CursorEvent, warn bool) int

Keep track of names attached to each cursor "down", and use those names on subsequent "drag" and "up" events.

func (*CursorManager) PlayCursor

func (cm *CursorManager) PlayCursor(tag string, dur time.Duration, pos CursorPos)

func (*CursorManager) UniqueGid

func (cm *CursorManager) UniqueGid() int

type CursorPos

type CursorPos struct {
	X, Y, Z float32
}

type Erae

type Erae struct {
	Output any
	// contains filtered or unexported fields
}
var TheErae *Erae

func NewErae

func NewErae() *Erae

func (*Erae) EraeApiModeDisable

func (erae *Erae) EraeApiModeDisable()

func (*Erae) EraeApiModeEnable

func (erae *Erae) EraeApiModeEnable()

func (*Erae) EraeFingerIndicator

func (erae *Erae) EraeFingerIndicator(zone, x, y byte)

func (*Erae) EraeWriteSysEx

func (erae *Erae) EraeWriteSysEx(bytes []byte)

func (*Erae) EraeZoneBoundaryRequest

func (erae *Erae) EraeZoneBoundaryRequest(zone byte)

func (*Erae) EraeZoneClearDisplay

func (erae *Erae) EraeZoneClearDisplay(zone byte)

func (*Erae) EraeZoneClearPixel

func (erae *Erae) EraeZoneClearPixel(zone, x, y, r, g, b byte)

func (*Erae) EraeZoneRectangle

func (erae *Erae) EraeZoneRectangle(zone, x, y, w, h, r, g, b byte)

func (*Erae) Start

func (erae *Erae) Start()

type Event

type Event any

type Host

type Host interface {
	Init() error
	Start()
	SayDone()

	LogWarn(msg string, keysAndValues ...any)
	LogError(err error, keysAndValues ...any)
	LogInfo(msg string, keysAndValues ...any)
	// IsLogging(name string) bool
	// LogOfType(logtypes string, msg string, keysAndValues ...any)
	ArchiveLogs() error

	EngineHttpApi(api string, args ...string) (map[string]string, error)
	MmttHttpApi(api string) (map[string]string, error)
	HandleIncomingMidiEvent(me MidiEvent)
	ResetAudio()
	ActivateAudio()
	FileExists(path string) bool
	SendToOscClients(msg *osc.Message)
	GenerateVisualsFromCursor(ce CursorEvent, patchName string)
	InputEventLock()
	InputEventUnlock()
	OpenFakeChannelOutput(port string, channel int) *MIDIPortChannelState
	OpenChannelOutput(PortChannel) *MIDIPortChannelState
	GetPortChannelState(PortChannel) (*MIDIPortChannelState, error)
	SendMIDI(output any, bytes []byte) error
	StartRunning(process string) error
	KillProcess(process string) error
	SetMidiInput(name string) error
	ShowClip(clipNum int)

	GetConfigFileData(filename string) ([]byte, error)
	SavedFileList(category string) ([]string, error)
	SaveDataInFile(data []byte, category string, filename string) error
	GetSavedData(category string, filename string) ([]byte, error)

	EveryTick()

	ToFreeFramePlugin(patchName string, msg *osc.Message)
	SendEffectParam(patchName string, name string, value string)
	PortAndLayerNumForPatch(patchName string) (portnum int, layernum int)
	ShowText(msg string)
}
var TheHost Host

type Kval

type Kval struct {
	// contains filtered or unexported fields
}

func NewPhraseVal

func NewPhraseVal(s string) Kval

func Ternary

func Ternary(a Kval, b Kval, c Kval) Kval

type MIDIEventHandler

type MIDIEventHandler func(MidiEvent)

type MIDIPortChannelState

type MIDIPortChannelState struct {
	Channel  int    // 1-based, 1-16
	Bank     int    // 1-based, 1-whatever
	Program  int    // 1-based, 1-128
	PortName string // MIDI output port
	Output   any    // was drivers.Out
	Isopen   bool
	Mutex    sync.Mutex
}

MIDIChannelOutput is used to remember the last bank and program values for a particular output, so they're only sent out when they've changed.

func (*MIDIPortChannelState) UpdateBankProgram

func (state *MIDIPortChannelState) UpdateBankProgram(synth *Synth)

type MidiEvent

type MidiEvent struct {
	Click Clicks
	Tag   string
	Msg   midi.Message
}

func NewMidiEvent

func NewMidiEvent(click Clicks, tag string, msg midi.Message) MidiEvent

func (MidiEvent) Data1

func (me MidiEvent) Data1() uint8

func (MidiEvent) HasPitch

func (me MidiEvent) HasPitch() bool

func (MidiEvent) Marshal

func (e MidiEvent) Marshal() (bytes []byte, err error)

func (MidiEvent) Pitch

func (me MidiEvent) Pitch() uint8

func (MidiEvent) Status

func (me MidiEvent) Status() uint8

func (MidiEvent) String

func (e MidiEvent) String() string

type NoteBytes

type NoteBytes struct {
	// contains filtered or unexported fields
}

func NewNoteBytes

func NewNoteBytes(bytes []byte) *NoteBytes

func (*NoteBytes) String

func (n *NoteBytes) String() string

type NoteFull

type NoteFull struct {
	// Channel  uint8
	Synth     *Synth
	Duration  Clicks
	SynthName string
	Pitch     uint8
	Velocity  uint8
}

NoteFull has a duration, i.e. it's a combination of a NoteOn and NoteOff

func NewNoteFull

func NewNoteFull(synth *Synth, pitch, velocity uint8, duration Clicks) *NoteFull

func (*NoteFull) String

func (n *NoteFull) String() string

type NoteOff

type NoteOff struct {
	// Channel  uint8
	Synth    *Synth
	Pitch    uint8
	Velocity uint8
}

func NewNoteOff

func NewNoteOff(synth *Synth, pitch, velocity uint8) *NoteOff

NewNoteOff create a new noteoff

func NewNoteOffFromNoteOn

func NewNoteOffFromNoteOn(nt *NoteOn) *NoteOff

NewNoteOff create a new NoteOff from a NoteOn

func (NoteOff) String

func (n NoteOff) String() string

type NoteOn

type NoteOn struct {
	// Channel  uint8
	Synth    *Synth
	Pitch    uint8
	Velocity uint8
}

func NewNoteOn

func NewNoteOn(synth *Synth, pitch, velocity uint8) *NoteOn

NewNoteOn create a new noteon

func (*NoteOn) String

func (n *NoteOn) String() string

type NoteSystem

type NoteSystem struct {
	// contains filtered or unexported fields
}

func NewNoteSystem

func NewNoteSystem(system byte) *NoteSystem

func (*NoteSystem) String

func (n *NoteSystem) String() string

type OscEvent

type OscEvent struct {
	Click  Clicks       `json:"Click"`
	Msg    *osc.Message `json:"Msg"`
	Source string       `json:"Source"`
}

func (OscEvent) Marshal

func (e OscEvent) Marshal() (bytes []byte, err error)

func (OscEvent) String

func (e OscEvent) String() string

type ParamDef

type ParamDef struct {
	TypedParamDef any
	Category      string
	Init          string
	// contains filtered or unexported fields
}

ParamDef is a single parameter definition.

type ParamDefBool

type ParamDefBool struct {
}

type ParamDefFloat

type ParamDefFloat struct {
	Init string
	// contains filtered or unexported fields
}

type ParamDefInt

type ParamDefInt struct {
	// contains filtered or unexported fields
}

type ParamDefString

type ParamDefString struct {
	// contains filtered or unexported fields
}

type ParamValue

type ParamValue any

ParamValue is a single parameter value which could be any of the param*Value types

type ParamValues

type ParamValues struct {
	// contains filtered or unexported fields
}

ParamValues is the set of all parameter values

var EngineParams *ParamValues

These EngineParams are global to the kit package

func NewParamValues

func NewParamValues() *ParamValues

func (*ParamValues) ApplyValuesFromMap

func (params *ParamValues) ApplyValuesFromMap(category string, paramsmap map[string]any, setfunc func(string, string) error)

Currently, no errors are ever returned, but log messages are generated.

func (*ParamValues) DoForAllParams

func (vals *ParamValues) DoForAllParams(f func(string, ParamValue))

func (*ParamValues) Exists

func (vals *ParamValues) Exists(name string) bool

func (*ParamValues) Get

func (vals *ParamValues) Get(name string) (string, error)

returns "" if parameter doesn't exist

func (*ParamValues) GetBoolValue

func (vals *ParamValues) GetBoolValue(name string) bool

func (*ParamValues) GetFloatValue

func (vals *ParamValues) GetFloatValue(name string) float32

func (*ParamValues) GetIntValue

func (vals *ParamValues) GetIntValue(name string) int

func (*ParamValues) GetStringValue

func (vals *ParamValues) GetStringValue(name string, def string) string

func (*ParamValues) JsonValues

func (vals *ParamValues) JsonValues() string

func (*ParamValues) ParamNames

func (vals *ParamValues) ParamNames() []string

func (*ParamValues) Save

func (vals *ParamValues) Save(category string, filename string) error

Save parameters values to a file. If filename doesn't have a .json suffix, it's added.

func (*ParamValues) Set

func (vals *ParamValues) Set(name, value string) error

func (*ParamValues) SetParamValueWithString

func (vals *ParamValues) SetParamValueWithString(origname, value string) (err error)

type ParamsMap

type ParamsMap map[string]any
var CursorSourceToQuadPreset ParamsMap

func LoadParamsMap

func LoadParamsMap(bytes []byte) (ParamsMap, error)

func OverrideMap

func OverrideMap() ParamsMap

type Patch

type Patch struct {
	// contains filtered or unexported fields
}

func GetPatch

func GetPatch(patchName string) *Patch

func NewPatch

func NewPatch(patchName string) *Patch

func (*Patch) Api

func (patch *Patch) Api(api string, apiargs map[string]string) (string, error)

func (*Patch) ApplyPatchValuesFromQuadMap

func (patch *Patch) ApplyPatchValuesFromQuadMap(paramsmap map[string]any) error

func (*Patch) CursorToQuant

func (patch *Patch) CursorToQuant(ce CursorEvent) Clicks

func (*Patch) Get

func (patch *Patch) Get(paramName string) string

If no such parameter, return ""

func (*Patch) GetBool

func (patch *Patch) GetBool(paramName string) bool

func (*Patch) GetFloat

func (patch *Patch) GetFloat(paramName string) float32

func (*Patch) GetInt

func (patch *Patch) GetInt(paramName string) int

func (*Patch) Load

func (patch *Patch) Load(category string, filename string) error

func (*Patch) MIDIChannel

func (patch *Patch) MIDIChannel() uint8

func (*Patch) Name

func (patch *Patch) Name() string

func (*Patch) ParamNames

func (patch *Patch) ParamNames() []string

func (*Patch) RefreshAllIfPortnumMatches

func (patch *Patch) RefreshAllIfPortnumMatches(ffglportnum int)

func (*Patch) RefreshAllPatchValues

func (patch *Patch) RefreshAllPatchValues()

func (*Patch) SaveAndAlert

func (patch *Patch) SaveAndAlert(category string, filename string) error

func (*Patch) SaveQuadAndAlert

func (patch *Patch) SaveQuadAndAlert() error

func (*Patch) SetDefaultValues

func (patch *Patch) SetDefaultValues()

SetDefaultValues xxx

func (*Patch) Status

func (patch *Patch) Status() string

func (*Patch) Synth

func (patch *Patch) Synth() *Synth

type PatchLogic

type PatchLogic struct {
	// contains filtered or unexported fields
}

func NewPatchLogic

func NewPatchLogic(patch *Patch) *PatchLogic

type Phrase

type Phrase struct {
	Source      string
	Destination string
	Length      Clicks
	// contains filtered or unexported fields
}

Phrase is a time-ordered list of *PhraseElements

func NewPhrase

func NewPhrase(vals ...string) *Phrase

NewPhrase returns a new Phrase

func (*Phrase) AdjustTimes

func (p *Phrase) AdjustTimes(shift Clicks) *Phrase

AdjustTimes returns a new Phrase shifted by shift Clicks

func (*Phrase) Arpeggio

func (p *Phrase) Arpeggio() *Phrase

Arpeggio returns an arpeggiated version of the phrase. One way of describing is that all the notes have been separated and then put back together, back-to-back.

func (*Phrase) AtTime

func (p *Phrase) AtTime(tm Clicks) *Phrase

AtTime returns those notes in the specified phrase that are sounding at the specified time. If a note ends exactly at the specified time, it is not included.

func (*Phrase) Copy

func (p *Phrase) Copy() *Phrase

Copy returns a copy of a Phrase

func (*Phrase) CopyAndAppend

func (p *Phrase) CopyAndAppend(elem *PhraseElement) *PhraseElement

CopyAndAppend makes a copy of a Note and appends it to the Phrase

func (*Phrase) CutSound

func (p *Phrase) CutSound(sound string) *Phrase

CutSound creates a new Phrase with notes for a given sound

func (*Phrase) CutTime

func (p *Phrase) CutTime(fromclick, toclick Clicks) *Phrase

CutTime creates a new Phrase with notes in a given time range

func (*Phrase) InsertElement

func (p *Phrase) InsertElement(item *PhraseElement) *Phrase

InsertNote inserts a note into a Phrase

func (*Phrase) InsertNoLock

func (p *Phrase) InsertNoLock(pe *PhraseElement) *Phrase

InsertNoLock adds a Note to a Phrase

func (*Phrase) Legato

func (p *Phrase) Legato() *Phrase

Legato extends the duration of each note to abutt the start of the next note. Doesn't modify the duration of the last note.

func (*Phrase) Lock

func (p *Phrase) Lock()

Lock for writing

func (*Phrase) LowestPitch

func (p *Phrase) LowestPitch(delta int) uint8

LowestPitch returns the lowest pitch in a Phrase

func (*Phrase) Merge

func (p *Phrase) Merge(fromPhrase *Phrase) *Phrase

Merge merges a second Phrase into a Phrase NOTE: we get a Write lock on the Phrase, since we're actually changing it.

func (*Phrase) NextTime

func (p *Phrase) NextTime(st Clicks) Clicks

NextTime returns the time of the next note AFTER time st. If there are no notes after it, returns -1.

func (*Phrase) RLock

func (p *Phrase) RLock()

RLock for reading

func (*Phrase) RUnlock

func (p *Phrase) RUnlock()

RUnlock for reading

func (*Phrase) ResetLengthNoLock

func (p *Phrase) ResetLengthNoLock()

ResetLengthNoLock sets the length of a Phrase to the end of the lastnote

func (*Phrase) Step

func (p *Phrase) Step(stepsize Clicks) *Phrase

Step returns a stepped version of the Phrase.

func (*Phrase) Transpose

func (p *Phrase) Transpose(delta int) *Phrase

Transpose returns a Phrase whose pitch is transposed.

func (*Phrase) Unlock

func (p *Phrase) Unlock()

Unlock for writing

type PhraseElement

type PhraseElement struct {
	AtClick Clicks
	Value   any // things like *NoteFull, *NoteOn, *NoteOff, etc
}

func (*PhraseElement) Copy

func (pe *PhraseElement) Copy() *PhraseElement

func (*PhraseElement) EndOf

func (pe *PhraseElement) EndOf() Clicks

func (*PhraseElement) Format

func (pi *PhraseElement) Format(f fmt.State, c rune)

Format xxx

func (*PhraseElement) IsNote

func (pe *PhraseElement) IsNote() bool

type PhraseScanner

type PhraseScanner struct {
	// contains filtered or unexported fields
}

PhraseScanner represents a lexical scanner for phrase constants

func NewPhraseScanner

func NewPhraseScanner(r io.Reader) *PhraseScanner

NewScanner returns a new instance of Scanner.

func (*PhraseScanner) ScanChar

func (s *PhraseScanner) ScanChar() string

func (*PhraseScanner) ScanNumber

func (s *PhraseScanner) ScanNumber() (int, error)

func (*PhraseScanner) ScanWord

func (s *PhraseScanner) ScanWord() (tok Token, lit string)

Scan returns the next token and literal value.

type PitchBend

type PitchBend struct {
	// contains filtered or unexported fields
}

func NewPitchBend

func NewPitchBend(data0, data1, data2 uint8) *PitchBend

func (*PitchBend) String

func (n *PitchBend) String() string

type PlaybackEvent

type PlaybackEvent struct {
	Click     Clicks `json:"Click"`
	IsRunning bool   `json:"IsRunning"`
}

PlaybackEvent is for start/stop

type PortChannel

type PortChannel struct {
	Port    string // as used by Portmidi
	Channel int    // 0-15 for MIDI channels 1-16
}

type ProgramChange

type ProgramChange struct {
	Channel uint8
	Program uint8
}

func NewProgramChange

func NewProgramChange(channel, program uint8) *ProgramChange

func (*ProgramChange) String

func (n *ProgramChange) String() string

type QuadPro

type QuadPro struct {
	// contains filtered or unexported fields
}
var TheQuadPro *QuadPro

func NewQuadPro

func NewQuadPro() *QuadPro

func (*QuadPro) Api

func (quadpro *QuadPro) Api(api string, apiargs map[string]string) (result string, err error)

func (*QuadPro) Load

func (quadpro *QuadPro) Load(bytes []byte, category string, filename string) error

func (*QuadPro) OnClientRestart

func (quadpro *QuadPro) OnClientRestart(portnum int)

func (*QuadPro) PatchForCursorEvent

func (quadpro *QuadPro) PatchForCursorEvent(ce CursorEvent) (patch *Patch, button string)

func (*QuadPro) Start

func (quadpro *QuadPro) Start()

func (*QuadPro) Status

func (quadpro *QuadPro) Status(source string) string

func (*QuadPro) Stop

func (quadpro *QuadPro) Stop()

type RecordingEvent

type RecordingEvent struct {
	Event string
	Value any
}

type Scale

type Scale struct {
	HasNote [128]bool
}

Scale says whether a pitch is in a scale

func GetScale

func GetScale(name string) *Scale

GetScale xxx

func MakeScale

func MakeScale(pitches ...int) *Scale

func (*Scale) ClosestTo

func (s *Scale) ClosestTo(pitch uint8) uint8

ClosestTo xxx

type SchedElement

type SchedElement struct {
	// patch             *Patch
	AAtClick Clicks
	Tag      string
	Value    any
}

func NewSchedElement

func NewSchedElement(atclick Clicks, tag string, value any) *SchedElement

func SchedElementFromString

func SchedElementFromString(s string) (se *SchedElement, err error)

func (SchedElement) GetClick

func (se SchedElement) GetClick() Clicks

func (*SchedElement) SetClick

func (se *SchedElement) SetClick(click Clicks)

NOTE: a pointer is used so se.SetClick() can modify the value

type Scheduler

type Scheduler struct {
	AutoTransposeOn bool
	// contains filtered or unexported fields
}
var TheScheduler *Scheduler

func NewScheduler

func NewScheduler() *Scheduler

func (*Scheduler) CountEventsWithTag

func (sched *Scheduler) CountEventsWithTag(tag string) int

func (*Scheduler) DeleteCursorEventsWhoseGidIs

func (sched *Scheduler) DeleteCursorEventsWhoseGidIs(gid int)

func (*Scheduler) DeleteEventsWithTag

func (sched *Scheduler) DeleteEventsWithTag(tag string)

func (*Scheduler) Format

func (sched *Scheduler) Format(f fmt.State, c rune)

func (*Scheduler) PendingToString

func (sched *Scheduler) PendingToString() string

func (*Scheduler) SetAutoTransposeBeats

func (sched *Scheduler) SetAutoTransposeBeats(beats int)

func (*Scheduler) SetTranspose

func (sched *Scheduler) SetTranspose(i int)

func (*Scheduler) Start

func (sched *Scheduler) Start()

Start runs the scheduler and never returns

func (*Scheduler) ToString

func (sched *Scheduler) ToString() string

type Synth

type Synth struct {
	// contains filtered or unexported fields
}

func GetSynth

func GetSynth(synthName string) *Synth

func NewSynth

func NewSynth(name string, port string, channel int, bank int, program int) *Synth

func (*Synth) Channel

func (synth *Synth) Channel() uint8

func (*Synth) ClearNoteDowns

func (synth *Synth) ClearNoteDowns()

func (*Synth) SendANO

func (synth *Synth) SendANO()

SendANO sends all-notes-off

func (*Synth) SendBytes

func (synth *Synth) SendBytes(bytes []byte) error

func (*Synth) SendBytesToMidiOutput

func (synth *Synth) SendBytesToMidiOutput(bytes []byte)

SendBytesToMidiOutput

func (*Synth) SendController

func (synth *Synth) SendController(cnum uint8, cval uint8)

func (*Synth) SendNoteToMidiOutput

func (synth *Synth) SendNoteToMidiOutput(value any)

func (*Synth) UpdateBankProgram

func (synth *Synth) UpdateBankProgram()

type Token

type Token int

Token is something returned by the PhraseScanner

const (
	EOF Token = iota
	WORD
	NUMBER
	MINUS
	PLUS
	COMMA
	SINGLEQUOTE
	SPACE
	UNKNOWN
)

type VizColor

type VizColor struct {
	// contains filtered or unexported fields
}

VizColor xxx

func ColorFromHLS

func ColorFromHLS(hue, luminance, saturation float32) VizColor

ColorFromHLS creates a color from hue, luminance, and saturation

func ColorFromRGB

func ColorFromRGB(red, green, blue float32) VizColor

ColorFromRGB creates a VizColor from red, green, blue

type VizNats

type VizNats struct {
	// contains filtered or unexported fields
}

VizNats xxx

var TheNats *VizNats

TheNats is the only one

func NewVizNats

func NewVizNats() *VizNats

NewVizNats xxx

func (*VizNats) Connect

func (vn *VizNats) Connect(user string, password string) error

Connect xxx

func (*VizNats) Publish

func (vn *VizNats) Publish(subj string, msg string) error

Publish xxx

func (*VizNats) Request

func (vn *VizNats) Request(subj, data string, timeout time.Duration) (retdata string, err error)

Request is used for APIs - it blocks waiting for a response and returns the response

func (*VizNats) Subscribe

func (vn *VizNats) Subscribe(subj string, callback nats.MsgHandler) error

Subscribe xxx

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL