util

package
v0.0.0-...-d0979cb Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	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 MaxClicks = Clicks(math.MaxInt64)

MaxClicks is the high-possible value for Clicks

View Source
const UnfinishedDuration = math.MaxInt32 - 1

UnfinishedDuration is an 'unset' value for Duration

Variables

View Source
var DebugHub = DebugFlags{
	Realtime: true,
	Cursor:   true,
}

DebugHub controls debugging output

View Source
var DebugUtil = DebugFlags{}

DebugUtil controls debugging

View Source
var DefaultFragmentShader = `
#version 330

uniform sampler2D tex;
uniform vec2 tjt;

in vec2 fragTexCoord;
in vec4 finalcolor;
in vec2 finaldebug;
in vec2 finaltjt;

out vec4 outputColor;

void main() {
	outputColor = finalcolor;
	// if ( finaldebug.x < 0.5 ) {
	// 	outputColor = texture(tex, fragTexCoord);
	// } else if ( finaldebug.x > 0.5 ) {
		outputColor.r = 0.0;
		outputColor.g = 0.8;
		outputColor.b = 0.0;
	outputColor = texture(tex, fragTexCoord);
	outputColor.r = 1.0;
	// }
}
` + "\x00"

DefaultFragmentShader xxx

View Source
var DefaultVertexShader = `
#version 330

uniform mat4 projection;
uniform vec4 color;
uniform vec4 misc;
uniform vec2 debug;

in vec3 vert;
in vec2 vertTexCoord;

out vec2 fragTexCoord;
out vec4 finalcolor;
out vec4 finalvert;
out int finaltype;
out vec2 finaldebug;

vec3 hsl2rgb( in vec3 c )
{
    vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );

    return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0));
}

vec3 HueShift (in vec3 Color, in float Shift)
{
    vec3 P = vec3(0.55735)*dot(vec3(0.55735),Color);
    
    vec3 U = Color-P;
    
    vec3 V = cross(vec3(0.55735),U);    

    Color = U*cos(Shift*6.2832) + V*sin(Shift*6.2832) + P;
    
    return vec3(Color);
}

vec3 rgb2hsl( in vec3 c ){
  float h = 0.0;
	float s = 0.0;
	float l = 0.0;
	float r = c.r;
	float g = c.g;
	float b = c.b;
	float cMin = min( r, min( g, b ) );
	float cMax = max( r, max( g, b ) );

	l = ( cMax + cMin ) / 2.0;
	if ( cMax > cMin ) {
		float cDelta = cMax - cMin;
        
        //s = l < .05 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) ); Original
		s = l < .0 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) );
        
		if ( r == cMax ) {
			h = ( g - b ) / cDelta;
		} else if ( g == cMax ) {
			h = 2.0 + ( b - r ) / cDelta;
		} else {
			h = 4.0 + ( r - g ) / cDelta;
		}

		if ( h < 0.0) {
			h += 6.0;
		}
		h = h / 6.0;
	}
	return vec3( h, s, l );
}

vec3 rgb2hsv(vec3 c)
{
    vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
    vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
    vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));

    float d = q.x - min(q.w, q.y);
    float e = 1.0e-10;
    return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}

vec3 hsv2rgb(vec3 c)
{
    vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
    vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
    return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}

void main() {

	float angle = misc.x;
	float invsize = 1.0 / misc.y;
	float size = misc.y;
	float x = misc.z;
	float y = misc.w;

	fragTexCoord = vertTexCoord;
	finalvert = vec4(size*vert.x,size*vert.y,vert.z,1);
	if (angle != 0.0) {
		mat4 rotation = mat4(mat2(
			cos(angle), -sin(angle),
			sin(angle), cos(angle)));
		finalvert = finalvert * rotation;
	}
	finalvert.x += x;
	finalvert.y += y;

	gl_Position = projection * finalvert;

	vec4 mycolor = vec4(hsl2rgb(vec3(color.x,color.y,color.z)), color.a);
	finalcolor = mycolor;
	finaltype = 1;
	finaldebug = debug;
}
` + "\x00"

DefaultVertexShader xxx

View Source
var EffectsJSON map[string]interface{}

EffectsJSON is an unmarshalled version of the effects.json file

View Source
var FragmentShader2 = `
#version 330

uniform sampler2D tex;
uniform vec2 tjt;

in vec2 fragTexCoord;
in vec4 finalcolor;
in vec2 finaldebug;
in vec2 finaltjt;

out vec4 outputColor;

void main() {
	outputColor = finalcolor;
	// if ( finaldebug.x < 0.5 ) {
	// 	outputColor = texture(tex, fragTexCoord);
	// } else if ( finaldebug.x > 0.5 ) {
		outputColor.r = 0.0;
		outputColor.g = 0.0;
		outputColor.b = 0.8;
	outputColor = texture(tex, fragTexCoord);
	outputColor.g = 1.0;
	// }
}
` + "\x00"

FragmentShader2 xxx

View Source
var LineVerticesForLines = []float32{

	0.0, 0.0, 1.0, 0.0, 0.0,
	1.0, 0.0, 1.0, 1.0, 0.0,
}

LineVerticesForLines xxx

View Source
var LineVerticesForLines2 = []float32{

	0.0, 0.0, 1.0, 0.0, 0.0,
	1.0, 0.0, 1.0, 1.0, 0.0,
}

LineVerticesForLines2 xxx

View Source
var PadSettings = map[string]PadSetting{
	"A": {Sidmin: 11000, Sidmax: 12999},
}

PadSettings gives va;ies

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 Scales map[string]*Scale

Scales maps a name to a Scale

View Source
var SquareVerticesForLines = []float32{

	-1.0, -1.0, 1.0, 0.0, 0.0,
	1.0, -1.0, 1.0, 1.0, 0.0,

	1.0, -1.0, 1.0, 1.0, 0.0,
	1.0, 1.0, 1.0, 1.0, 1.0,

	1.0, 1.0, 1.0, 1.0, 1.0,
	-1.0, 1.0, 1.0, 0.0, 1.0,

	-1.0, 1.0, 1.0, 0.0, 1.0,
	-1.0, -1.0, 1.0, 0.0, 0.0,
}

SquareVerticesForLines xxx

View Source
var SquareVerticesForLines2 = []float32{

	-1.0, -1.0, 1.0, 0.0, 0.0,
	1.0, -1.0, 1.0, 1.0, 0.0,

	1.0, -1.0, 1.0, 1.0, 0.0,
	1.0, 1.0, 1.0, 1.0, 1.0,

	1.0, 1.0, 1.0, 1.0, 1.0,
	-1.0, 1.0, 1.0, 0.0, 1.0,

	-1.0, 1.0, 1.0, 0.0, 1.0,
	-1.0, -1.0, 1.0, 0.0, 0.0,
}

SquareVerticesForLines2 xxx

View Source
var SquareVerticiesForTriangles = []float32{

	-1.0, -1.0, 1.0, 1.0, 0.0,
	1.0, -1.0, 1.0, 0.0, 0.0,
	-1.0, 1.0, 1.0, 1.0, 1.0,
	1.0, -1.0, 1.0, 0.0, 0.0,
	1.0, 1.0, 1.0, 0.0, 1.0,
	-1.0, 1.0, 1.0, 1.0, 1.0,
}

SquareVerticiesForTriangles xxx

View Source
var SquareVerticiesForTriangles2 = []float32{

	-1.0, -1.0, 1.0, 1.0, 0.0,
	1.0, -1.0, 1.0, 0.0, 0.0,
	-1.0, 1.0, 1.0, 1.0, 1.0,
	1.0, -1.0, 1.0, 0.0, 0.0,
	1.0, 1.0, 1.0, 0.0, 1.0,
	-1.0, 1.0, 1.0, 1.0, 1.0,
}

SquareVerticiesForTriangles2 xxx

View Source
var VertexShader2 = `
#version 330

uniform mat4 projection;
uniform vec4 color;
uniform vec4 misc;
uniform vec2 debug;

in vec3 vert;
in vec2 vertTexCoord;

out vec2 fragTexCoord;
out vec4 finalcolor;
out vec4 finalvert;
out int finaltype;
out vec2 finaldebug;

vec3 hsl2rgb( in vec3 c )
{
    vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );

    return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0));
}

vec3 HueShift (in vec3 Color, in float Shift)
{
    vec3 P = vec3(0.55735)*dot(vec3(0.55735),Color);
    
    vec3 U = Color-P;
    
    vec3 V = cross(vec3(0.55735),U);    

    Color = U*cos(Shift*6.2832) + V*sin(Shift*6.2832) + P;
    
    return vec3(Color);
}

vec3 rgb2hsl( in vec3 c ){
  float h = 0.0;
	float s = 0.0;
	float l = 0.0;
	float r = c.r;
	float g = c.g;
	float b = c.b;
	float cMin = min( r, min( g, b ) );
	float cMax = max( r, max( g, b ) );

	l = ( cMax + cMin ) / 2.0;
	if ( cMax > cMin ) {
		float cDelta = cMax - cMin;
        
        //s = l < .05 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) ); Original
		s = l < .0 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) );
        
		if ( r == cMax ) {
			h = ( g - b ) / cDelta;
		} else if ( g == cMax ) {
			h = 2.0 + ( b - r ) / cDelta;
		} else {
			h = 4.0 + ( r - g ) / cDelta;
		}

		if ( h < 0.0) {
			h += 6.0;
		}
		h = h / 6.0;
	}
	return vec3( h, s, l );
}

vec3 rgb2hsv(vec3 c)
{
    vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
    vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
    vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));

    float d = q.x - min(q.w, q.y);
    float e = 1.0e-10;
    return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}

vec3 hsv2rgb(vec3 c)
{
    vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
    vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
    return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}

void main() {

	float angle = misc.x;
	float invsize = 1.0 / misc.y;
	float size = misc.y;
	float x = misc.z;
	float y = misc.w;

	fragTexCoord = vertTexCoord;
	finalvert = vec4(size*vert.x,size*vert.y,vert.z,1);
	if (angle != 0.0) {
		mat4 rotation = mat4(mat2(
			cos(angle), -sin(angle),
			sin(angle), cos(angle)));
		finalvert = finalvert * rotation;
	}
	finalvert.x += x;
	finalvert.y += y;

	gl_Position = projection * finalvert;

	vec4 mycolor = vec4(hsl2rgb(vec3(color.x,color.y,color.z)), color.a);
	finalcolor = mycolor;
	finaltype = 1;
	finaldebug = debug;
}
` + "\x00"

VertexShader2 xxx

Functions

func ClearExternalScale

func ClearExternalScale()

ClearExternalScale xxx

func ConfigValue

func ConfigValue(nm string) string

ConfigValue xxx

func CopyDir

func CopyDir(src, dest string) error

CopyDir xxx

func DataDir

func DataDir() string

DataDir xxx

func EngineDir

func EngineDir(engine string) string

EngineDir xxx

func EngineFilePath

func EngineFilePath(engine string, nm string) string

EngineFilePath xxx

func EnginePath

func EnginePath(engineName string, nm string) string

EnginePath xxx

func ErrorResponse

func ErrorResponse(err error, id string) string

ErrorResponse return a JSON 2.0 error response

func GetBool

func GetBool(paramvalues map[string]string, name string) (bool, error)

GetBool complains if a parameter is not there, but still returns false

func GetFloat

func GetFloat(paramvalues map[string]string, name string) (float32, error)

GetFloat returns an error if the parameter is not there

func GetInt

func GetInt(paramvalues map[string]string, name string) (int, error)

GetInt throws an error if the parameter is not there

func GetRequest

func GetRequest(conn *websocket.Conn) (method, params, id string, err error)

GetRequest reads a JSON request from a websocket

func GetString

func GetString(pmap map[string]string, name string) (string, error)

GetString complains if a parameter is not there, but still returns ""

func ISFFilePaths

func ISFFilePaths(venue string, nm string) (string, string)

ISFFilePaths xxx

func IsTrueValue

func IsTrueValue(value string) bool

IsTrueValue returns true if the value is some version of true

func ListenToMIDI

func ListenToMIDI()

ListenToMIDI publishes MIDI events

func LoadEffectsJSON

func LoadEffectsJSON(engineName string)

LoadEffectsJSON returns an unmarshalled version of the effects.json file

func LoadImage

func LoadImage(path string) (*image.NRGBA, error)

LoadImage reads an image file

func LoadParamDefs

func LoadParamDefs(engineName string) error

LoadParamDefs initializes the list of parameters

func LoadParamEnums

func LoadParamEnums(engineName string)

LoadParamEnums initializes the list of enumerated parameter values

func MidiFilePath

func MidiFilePath(venue string, nm string) string

MidiFilePath xxx

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 RecordingsPath

func RecordingsPath(venue string, nm string) string

RecordingsPath xxx

func ResultResponse

func ResultResponse(resultObj interface{}, id string) string

ResultResponse returns a JSON 2.0 result response

func RootBinPath

func RootBinPath(nm string) string

RootBinPath xxx

func RootConfigFilePath

func RootConfigFilePath(nm string) string

RootConfigFilePath xxx

func RootPath

func RootPath() string

RootPath is the root

func RootTemplatePath

func RootTemplatePath(nm string) string

RootTemplatePath xxx

func SendErrorResponse

func SendErrorResponse(conn *websocket.Conn, rpcerr error, id string) error

SendErrorResponse sends a JSON 2.0 response

func SendMail

func SendMail(recipient, subject, body string) error

SendMail xxx

func SendResponse

func SendResponse(conn *websocket.Conn, result interface{}, err error, id string) error

SendResponse sends a JSON 2.0 response

func SendResultResponse

func SendResultResponse(conn *websocket.Conn, result interface{}, id string) error

SendResultResponse sends a JSON 2.0 response

func SetExternalScale

func SetExternalScale(pitch int, on bool)

SetExternalScale xxx

func SetRootPath

func SetRootPath(path string)

SetRootPath xxx

func Spawn

func Spawn(executable string, stdout io.Writer, stderr io.Writer, args ...string) error

Spawn executes something in the background

func StartDeviceInput

func StartDeviceInput(stdout io.Writer, stderr io.Writer) error

StartDeviceInput starts anything needed to provide device inputs

func StartVizNats

func StartVizNats()

StartVizNats xxx

func StringMap

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

StringMap takes a JSON string and returns a map of elements

func StringParamOfAPI

func StringParamOfAPI(api string, pmap map[string]string, name string) (string, error)

StringParamOfAPI xxx

func VenueDir

func VenueDir(venue string) string

VenueDir xxx

func VenueFilePath

func VenueFilePath(venue string, nm string) string

VenueFilePath xxx

Types

type APIEvent

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

APIEvent is an API invocation

type APIHandler

type APIHandler func(method string, pmap map[string]string) error

APIHandler is an API execution func

type ActivePhrase

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

ActivePhrase is a currently active MIDI phrase

func NewActivePhrase

func NewActivePhrase(p *Phrase) *ActivePhrase

NewActivePhrase constructs a new ActivePhrase for a Phrase

type ActivePhrasesManager

type ActivePhrasesManager struct {
	ActivePhrasesMutex sync.RWMutex
	// contains filtered or unexported fields
}

ActivePhrasesManager manages ActivePhrases

func NewActivePhrasesManager

func NewActivePhrasesManager(midiOutput MidiDevice) *ActivePhrasesManager

NewActivePhrasesManager xxx

func (*ActivePhrasesManager) AdvanceActivePhrasesByOneStep

func (mgr *ActivePhrasesManager) AdvanceActivePhrasesByOneStep()

AdvanceActivePhrasesByOneStep xxx

func (*ActivePhrasesManager) CallbackOnOutput

func (mgr *ActivePhrasesManager) CallbackOnOutput(callback NoteOutputCallbackFunc) CallbackID

CallbackOnOutput xxx

func (*ActivePhrasesManager) StartPhrase

func (mgr *ActivePhrasesManager) StartPhrase(p *Phrase, cid string)

StartPhrase xxx NOTE: startPhrase assumes that the r.activePhrasesMutex is held for writing

func (*ActivePhrasesManager) StopPhrase

func (mgr *ActivePhrasesManager) StopPhrase(cid string, active *ActivePhrase, forceDelete bool)

StopPhrase xxx NOTE: stopPhrase assumes that the r.activePhrasesMutex is held for writing

func (*ActivePhrasesManager) UncallbackOnOutput

func (mgr *ActivePhrasesManager) UncallbackOnOutput(id CallbackID)

UncallbackOnOutput xxx

type Alg

type Alg interface {
	// Draw(pl *Pipeline)
	// ID() string
	// State() SpriteState
	// Params() *SpriteParams
	// AdjustForAge(secs float32)
	CanHandleCursor(ce *CursorEvent) bool
	ExecuteIncomingCursor(ce *CursorEvent)
}

Alg xxx

type AlgDefault

type AlgDefault struct {
	Alg
}

AlgDefault is an Alg that does nothing

type AlgMaze

type AlgMaze struct {
	Alg
}

AlgMaze is an Alg that manages a maze

type CallbackID

type CallbackID int

CallbackID xxx

type Clicks

type Clicks int64

Clicks is a time or duration value. It is NOT MIDI clock. NOTE: A Clicks value for a Note can be negative because it's relative to the starting time of a Phrase

type Command

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

Command is sent on the control channel of the Hub

type CursorEvent

type CursorEvent struct {
	ID         string // of the form {sessionid}@{IP}
	X          float32
	Y          float32
	Z          float32
	Downdragup string
	LoopsLeft  int
	Fresh      bool
	Quantized  bool
}

CursorEvent is a down, drag, or up event inside a loop step

type DebugFlags

type DebugFlags struct {
	MIDI     bool
	API      bool
	Loop     bool
	Gen      bool
	Realtime bool
	OSC      bool
	ISF      bool
	Cursor   bool
	Remote   bool
}

DebugFlags xxx

type Hub

type Hub struct {

	// OSCInput    chan oscDeviceEvent
	KillMe bool // set to true if Hub should be shutdown
	// contains filtered or unexported fields
}

Hub is a router for devices and engines

func NewHub

func NewHub() *Hub

NewHub xxx

func TheOneHub

func TheOneHub() *Hub

TheOneHub xxx

func (*Hub) AddVenue

func (hub *Hub) AddVenue(v *Venue) error

AddVenue xxx

func (*Hub) BootEngine

func (hub *Hub) BootEngine(engineName, hubAddr, engineAddr string) error

BootEngine xxx

func (*Hub) CreateVenue

func (hub *Hub) CreateVenue(vname string, ename string) (*Venue, error)

CreateVenue xxx

func (*Hub) GetVenue

func (hub *Hub) GetVenue(name string) *Venue

GetVenue xxx

func (*Hub) LoadConfig

func (hub *Hub) LoadConfig()

LoadConfig xxx

func (*Hub) LoadVenues

func (hub *Hub) LoadVenues() error

LoadVenues loads all the venues in the root/venues directory

func (*Hub) NumUsers

func (hub *Hub) NumUsers() int

NumUsers xxx

func (*Hub) NumVenues

func (hub *Hub) NumVenues() int

NumVenues xxx

func (*Hub) Start

func (hub *Hub) Start()

Start starts listeners, etc

func (*Hub) VenueCheckin

func (hub *Hub) VenueCheckin(venue *Venue, user *VizUser) error

VenueCheckin xxx

func (*Hub) Wait

func (hub *Hub) Wait()

Wait xxx

type LoopEvent

type LoopEvent struct {
	CursorEvent *CursorEvent
}

LoopEvent is what gets played back in a loop

type MIDIFile

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

MIDIFile lets you read a MIDI File

func NewMIDIFile

func NewMIDIFile(path string) (*MIDIFile, error)

NewMIDIFile creates a MIDIFile

func (*MIDIFile) Parse

func (m *MIDIFile) Parse() error

Parse reads the contents of a MIDIFile and creates Phrases for each track

func (*MIDIFile) Phrase

func (m *MIDIFile) Phrase() *Phrase

Phrase returns a single Phrase containing all tracks in the MIDIFile

type MidiDevice

type MidiDevice interface {
	Inputs() []string
	ListeningInputs() []string
	Outputs() []string
	SendNote(note *Note, debug bool, callbacks []*NoteOutputCallback)
	SendANO(outputName string) // lame
	ReadEvent(inputName string) (MidiDeviceEvent, error)
	Poll(inputName string) (bool, error)
	Listen(inputName string) error
	LoadSynths(path string) error
}

MidiDevice mediates all access to MIDI devices

func NewMidiDevice

func NewMidiDevice() (MidiDevice, error)

NewMidiDevice xxx

func NewNomidiDevice

func NewNomidiDevice() (MidiDevice, error)

NewNomidiDevice returns a MidiDevice interface for portmidi

type MidiDeviceEvent

type MidiDeviceEvent struct {
	Timestamp int64 // milliseconds
	Status    int64
	Data1     int64
	Data2     int64
}

MidiDeviceEvent is a single MIDI event

type MyWriter

type MyWriter struct {
	Source string
}

MyWriter xxx

func (*MyWriter) Write

func (w *MyWriter) Write(p []byte) (n int, err error)

type NomidiDevice

type NomidiDevice struct {
}

NomidiDevice is used when you don't want to do MIDI

func (*NomidiDevice) Inputs

func (m *NomidiDevice) Inputs() []string

Inputs returns a list of MIDI input names

func (*NomidiDevice) Listen

func (m *NomidiDevice) Listen(dev string) error

Listen for input on a particular MIDI device

func (*NomidiDevice) ListeningInputs

func (m *NomidiDevice) ListeningInputs() []string

ListeningInputs returns a list of MIDI input names that are open for listening

func (NomidiDevice) LoadSynths

func (m NomidiDevice) LoadSynths(path string) error

func (*NomidiDevice) Outputs

func (m *NomidiDevice) Outputs() []string

Outputs returns a list of MIDI output names

func (NomidiDevice) Poll

func (m NomidiDevice) Poll(inputName string) (bool, error)

Poll xxx

func (NomidiDevice) ReadEvent

func (m NomidiDevice) ReadEvent(inputName string) (MidiDeviceEvent, error)

ReadEvent xxx

func (*NomidiDevice) SendANO

func (m *NomidiDevice) SendANO(synth string)

SendANO sends all-notes-off

func (*NomidiDevice) SendNote

func (m *NomidiDevice) SendNote(n *Note, debug bool, callbacks []*NoteOutputCallback)

SendNote sends MIDI output for a Note

type NomidiEvent

type NomidiEvent struct {
}

NomidiEvent is a single MIDI input event XXX - since is local, PortmidiEvent should just be portmidi.Event

type Note

type Note struct {
	TypeOf   NoteType // NOTE, NOTEON, NOTEOFF, NOTEBYTES
	Clicks   Clicks   // nanoseconds
	Duration Clicks   // nanoseconds, when it's a NOTE
	// Channel  uint8    // MIDI Channel 1-based, 0 if not set?
	Pitch    uint8 // 0-127
	Velocity uint8 // 0-127
	Synth    string
	// contains filtered or unexported fields
}

Note is a single item in a Phrase

func NewNote

func NewNote(synth string, pitch uint8, velocity uint8, duration Clicks) *Note

NewNote creates a Note with a Duration

func NewNoteOff

func NewNoteOff(synth string, pitch uint8, velocity uint8) *Note

NewNoteOff creates a new NOTEOFF

func NewNoteOn

func NewNoteOn(synth string, pitch uint8, velocity uint8) *Note

NewNoteOn createx a new NOTEON

func (*Note) Compare

func (n *Note) Compare(n2 *Note) int

Compare is used to determine Note ordering

func (*Note) Copy

func (n *Note) Copy() *Note

Copy a Note. NOTE: the next value is cleared

func (*Note) EndOf

func (n *Note) EndOf() Clicks

EndOf returns the ending time of a note

func (*Note) Format

func (n *Note) Format(f fmt.State, c rune)

Format lets you conveniently print a Note with fmt functions

func (*Note) IsNote

func (n *Note) IsNote() bool

IsNote returns true if the note is a NOTE, NOTEON, or NOTEOFF

func (*Note) ReadablePitch

func (n *Note) ReadablePitch() string

ReadablePitch returns a readable string for a note pitch Note that it also includes a + or - if it's a NOTEON or NOTEOFF. If it's not a NOTE-type note, "" is returned

func (*Note) ToString

func (n *Note) ToString() string

ToString produces a human-readable version of a Note. Note that it includes the surrounding quotes that make it look like a Phrase

type NoteOutputCallback

type NoteOutputCallback struct {
	Callback func(n *Note)
	// contains filtered or unexported fields
}

NoteOutputCallback is a call

type NoteOutputCallbackFunc

type NoteOutputCallbackFunc func(n *Note)

NoteOutputCallbackFunc xxx

type NoteType

type NoteType int

NoteType is NOTE, NOTEON, NOTEOFF, or NOTEBYTES

const (
	// Values match keykit, make it easier to debug
	NOTE      NoteType = 2 // full note with duration
	NOTEON    NoteType = 4
	NOTEOFF   NoteType = 8
	NOTEBYTES NoteType = 1
)

These are the constant values of NoteType

type PadSetting

type PadSetting struct {
	Sidmin, Sidmax int
}

PadSetting specifies a range of sid (session IDs from TUIO)

type ParamCallback

type ParamCallback func(name string, value string) error

ParamCallback is the callback when setting parameter values

type ParamDef

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

ParamDef is a single parameter definition.

type ParamValue

type ParamValue interface{}

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

func NewParamValues

func NewParamValues() *ParamValues

NewParamValues creates a new ParamValues

func (*ParamValues) ParamBoolValue

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

ParamBoolValue xxx

func (*ParamValues) ParamFloatValue

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

ParamFloatValue xxx

func (*ParamValues) ParamIntValue

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

ParamIntValue xxx

func (*ParamValues) ParamStringValue

func (vals *ParamValues) ParamStringValue(name string) string

ParamStringValue xxx

func (*ParamValues) SetParamValue

func (vals *ParamValues) SetParamValue(nm string, v ParamValue)

SetParamValue xxx

func (*ParamValues) SetParamValueWithString

func (vals *ParamValues) SetParamValueWithString(name, value string, callback ParamCallback) error

SetParamValueWithString xxx

type Phrase

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

Phrase is a time-ordered list of Notes which are MIDI messages and other realtime events).

func NewPhrase

func NewPhrase() *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) Append

func (p *Phrase) Append(n *Note)

Append appends a note to the end of a Phrase, assuming that the last note in the Phrase is before or at the same time as tne appended note.

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(n *Note) *Note

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

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) Format

func (p *Phrase) Format(f fmt.State, c rune)

Format lets you conveniently print a Phrase with fmt functions

func (*Phrase) InsertNoLock

func (p *Phrase) InsertNoLock(note *Note) *Phrase

InsertNoLock adds a Note to a Phrase

func (*Phrase) InsertNote

func (p *Phrase) InsertNote(nt *Note) *Phrase

InsertNote inserts a note into a Phrase NOTE: it's assumed that the Phrase is already locked for writing.

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) NumNotes

func (p *Phrase) NumNotes() int

NumNotes returns the number of notes in a Phrase

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) ToString

func (p *Phrase) ToString() string

ToString returns a human-readable version of a 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 PlaybackEvent

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

PlaybackEvent is a time-tagged cursor or API event

type Recording

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

Recording xxx

type Remote

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

Remote represents a remote Viz thing, either an engine or hub

func NewRemote

func NewRemote(addr string) *Remote

NewRemote returns a Remote for the given address

func (*Remote) CheckConnection

func (r *Remote) CheckConnection() bool

CheckConnection returns true if the connection is respondig

func (*Remote) Close

func (r *Remote) Close() error

Close xxx

func (*Remote) DoLogin

func (r *Remote) DoLogin(user, password string) (err error)

DoLogin logs in on a websocket connection

func (*Remote) InvokeAPI

func (r *Remote) InvokeAPI(method string, params string) (result interface{}, err error)

InvokeAPI does an API on an already-connected websocket

func (*Remote) SetUser

func (r *Remote) SetUser(user, password string)

SetUser sets login info for the connection

type Scale

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

Scale says whether a pitch is in a scale

func GetScale

func GetScale(name string) *Scale

GetScale xxx

func (*Scale) ClosestTo

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

ClosestTo xxx

type Step

type Step struct {
	Events []*LoopEvent
}

Step is one step of one loop in the looper

type StepLoop

type StepLoop struct {
	CurrentStep Clicks
	Length      Clicks
	Steps       []*Step
}

StepLoop is one loop

func NewLoop

func NewLoop(nclicks Clicks) *StepLoop

NewLoop allocates and adds a new steploop

func (*StepLoop) AddToStep

func (loop *StepLoop) AddToStep(ce *CursorEvent, stepnum Clicks, debug bool)

AddToStep adds a StepItem to the loop at the current step

func (*StepLoop) Clear

func (loop *StepLoop) Clear()

Clear removes everything from Loop

func (*StepLoop) ClearID

func (loop *StepLoop) ClearID(id string)

ClearID removes all cursorEvents with a given id

func (*StepLoop) SetLength

func (loop *StepLoop) SetLength(nclicks Clicks)

SetLength changesthe length of a loop

type TuioCursor

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

TuioCursor is a TUIO cursor, the main purpose being to know when it hasn't been seen for a while, to generate an UP event

type Venue

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

Venue xxx

func CreateVenue

func CreateVenue(vname string, ename string) (*Venue, error)

CreateVenue xxx

func LoadVenue

func LoadVenue(vname string) (*Venue, error)

LoadVenue xxx

func (*Venue) Dir

func (v *Venue) Dir() string

Dir xxx

func (*Venue) FeedMeEventsLive

func (v *Venue) FeedMeEventsLive(callback VenueEventCallback)

FeedMeEventsLive xxx

func (*Venue) Name

func (v *Venue) Name() string

Name xxx

type VenueEventCallback

type VenueEventCallback func(n *Note)

VenueEventCallback xxx

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 VizEvent

type VizEvent struct {
	// The EventSource is where the event originally came from
	EventSource string                 `json:"source"`
	EventType   string                 `json:"eventtype"`
	EventVal    map[string]interface{} `json:"eventval"`
}

VizEvent xxx

func NewCursorVizEvent

func NewCursorVizEvent(source string, ce *CursorEvent) VizEvent

NewCursorVizEvent xxx

func NewMidiInputVizEvent

func NewMidiInputVizEvent(source string, midievent MidiDeviceEvent) VizEvent

NewMidiInputVizEvent xxx

type VizNats

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

VizNats xxx

var TheVizNats *VizNats

TheVizNats is the only one

func NewVizNats

func NewVizNats() *VizNats

NewVizNats xxx

func (*VizNats) Connect

func (vn *VizNats) Connect() error

Connect xxx

func (*VizNats) Publish

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

Publish xxx

func (*VizNats) PublishRequest

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

PublishRequest xxx

func (*VizNats) Subscribe

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

Subscribe xxx

type VizOsc

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

VizOsc is a router for devices and engines

func NewVizOSC

func NewVizOSC() *VizOsc

NewVizOSC xxx

func (*VizOsc) Start

func (vo *VizOsc) Start()

Start xxx

func (*VizOsc) Time

func (vo *VizOsc) Time() time.Time

Time returns the current time

type VizUser

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

VizUser xxx

func (*VizUser) GetEmail

func (u *VizUser) GetEmail() string

GetEmail xxx

func (*VizUser) GetID

func (u *VizUser) GetID() interface{}

GetID xxx

func (*VizUser) GetPasswordHash

func (u *VizUser) GetPasswordHash() []byte

GetPasswordHash xxx

func (*VizUser) GetPasswordToken

func (u *VizUser) GetPasswordToken() (string, time.Time)

GetPasswordToken xxx

func (*VizUser) GetRoles

func (u *VizUser) GetRoles() []string

GetRoles xxx

func (*VizUser) GetState

func (u *VizUser) GetState() int

GetState xxx

func (*VizUser) GetVerificationID

func (u *VizUser) GetVerificationID() (string, time.Time)

GetVerificationID xxx

func (*VizUser) SetEmail

func (u *VizUser) SetEmail(email string)

SetEmail xxx

func (*VizUser) SetID

func (u *VizUser) SetID(id interface{})

SetID xxx

func (*VizUser) SetPasswordHash

func (u *VizUser) SetPasswordHash(hash []byte)

SetPasswordHash xxx

func (*VizUser) SetPasswordToken

func (u *VizUser) SetPasswordToken(id string, created time.Time)

SetPasswordToken xxx

func (*VizUser) SetState

func (u *VizUser) SetState(state int)

SetState xxx

func (*VizUser) SetVerificationID

func (u *VizUser) SetVerificationID(id string, created time.Time)

SetVerificationID xxx

type VizUsersDb

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

VizUsersDb xxx

func NewVizUsersDb

func NewVizUsersDb() (*VizUsersDb, error)

NewVizUsersDb xxx

func (*VizUsersDb) Num

func (vu *VizUsersDb) Num() int

Num is the number of users in the database

func (*VizUsersDb) Users

func (vu *VizUsersDb) Users() map[string]users.User

Users xxx

func (*VizUsersDb) VizLoadUserByEmail

func (vu *VizUsersDb) VizLoadUserByEmail(email string) (users.User, error)

VizLoadUserByEmail xxx

func (*VizUsersDb) VizLoadUserByPasswordToken

func (vu *VizUsersDb) VizLoadUserByPasswordToken(token string) (users.User, error)

VizLoadUserByPasswordToken xxx

func (*VizUsersDb) VizLoadUserByVerificationID

func (vu *VizUsersDb) VizLoadUserByVerificationID(id string) (users.User, error)

VizLoadUserByVerificationID xxx

func (*VizUsersDb) VizSaveNewUserAtomic

func (vu *VizUsersDb) VizSaveNewUserAtomic(user users.User) (users.User, error)

VizSaveNewUserAtomic xxx

func (*VizUsersDb) VizThrottleLogin

func (vu *VizUsersDb) VizThrottleLogin(email string)

VizThrottleLogin xxx

func (*VizUsersDb) VizThrottleVerification

func (vu *VizUsersDb) VizThrottleVerification()

VizThrottleVerification xxx

func (*VizUsersDb) VizUpdateUser

func (vu *VizUsersDb) VizUpdateUser(user users.User) error

VizUpdateUser xxx

func (*VizUsersDb) WriteUsers

func (vu *VizUsersDb) WriteUsers() error

WriteUsers writes out all users data. Assumes the caller has done the mutex.

Jump to

Keyboard shortcuts

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