Skip to content

Instantly share code, notes, and snippets.

@trentgill
Last active June 24, 2021 14:48
Show Gist options
  • Save trentgill/71da8b6854be5f31de8d7d837dacf5f4 to your computer and use it in GitHub Desktop.
Save trentgill/71da8b6854be5f31de8d7d837dacf5f4 to your computer and use it in GitHub Desktop.
crow v3 syntax
--- crow syntax reference
-- many libs have multiple access styles
-- i think we need to be more explicit about the idiomatic choices
-- all examples / bowery / tutorials should use *the* way
--- input
_ = input[n].volts --> returns current voltage
input[n].query() --> sends voltage to the stream handler
input[n].mode('mode' [, args]) -- function style
input[n]{ mode = 'mode' [, args]} -- table initialization
input[n].mode = 'mode' -- uses defaults
input[n].mode_name = event_handler -- assign event handler per input mode
--- output
output[n].volts = 2
output[n].slew = 0.1
output[n].shape = 'sine'
output[n].scale = {0,3,6,9}
output[n].action = my_asl
output[n]:action(my_asl)
output[n](my_asl)
_ = output[n].volts() --> returns current output voltage
output[n].scale(notes [, divs, scaling])
output[n]:clock(division)
--- metro
metro[n]:start( [time, count, stage] )
metro[n].time = _
metro[n].count = _
metro[n].init_stage = _
metro[n]:stop()
_ = metro[n].id
_ = metro[n].count
_ = metro[n].time
_ = metro[n].init_stage
named_metro = metro.init(event, time, count)
named_metro = metro.init{event=fn, time=_, count=_}
-- all above 'metro[n]' can be replaced with 'named_metro'
-- clock
_ = clock.run(fn [, args])
clock.cancel(coro_id)
clock.sleep(seconds)
clock.sync(beats)
_ = clock.get_beats
_ = clock.get_beat_sec
clock.start( [beat] )
clock.stop()
clock.transport.start = start_handler
clock.transport.stop = stop_handler
clock.tempo = _
_ = clock.tempo
-- asl
to( [volts, time, shape] )
loop(myasl)
held(myasl)
lock(myasl)
times(count, myasl)
asl._if(pred, myasl)
asl._while(pred, myasl)
dyn{name = init_value}
mutable(init_value)
mutable{name = init_value}
-- calibrate
cal.save()
cal.source(chan)
_ = cal.input[n].offset
_ = cal.input[n].scale
cal.input[n].offset = _
cal.input[n].scale = _
-- same syntax for cal.output[n] as cal.input[n]
-- ii
ii.help()
ii.pullup(state)
ii.raw(addr, bytes, rx_len)
ii.self.event_name = event_handler
ii.event_raw = raw_handler
ii.mydevice.help()
ii.mydevice.myparam( [args] )
ii.mydevice.get('myparam' [, args])
ii.mydevice.event = mydevice_handler
-- public
public(name, init_value [, type_limits] [, action])
-- potential method style
pubvar = public{name = init_value}
pubvar:range(min, max)
pubvar:options{...}
pubvar:type(str)
pubvar:action(fn)
-- potential table-style
public{ name = _
, default = _
, range = _
, options = _
, type = _
, action = _
}
-- actions upon public params
public.name = _
_ = public.name
-- cv i/o viewers
public.view.all( [state] )
public.view.input[n]( [state] )
public.view.output[n]( [state] )
-- remote fns (called by remote host, from library, not userspace)
public.discover()
public.update(name, value [, subkey])
-- sequins
myseq = sequins{1,2,3,4}
myseq:reset()
myseq:step(n)
myseq:select(n)
myseq:cond(pred)
myseq:condr(pred)
myseq:every(n)
myseq:times(n)
myseq:count(n)
myseq:all()
myseq:once()
myseq:settable(new_table)
myseq()
myseq[n] = _
myseq.n = _
-- crowlib
crow.tell(event [, args])
delay(action, time [, repeats])
quotes(str)
justvolts(fraction [, offset])
just12(fraction [, offset])
hztovolts(freq [, reference])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment