You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From the Maps stream, I came up with some fun functions that allow for a more streamlined approach to building basic arpeggiators and such. They would likely be great additions to the crow (and norns) standard libraries.
Below is the example in question, particularly useful for generating arpeggios and basic sequences, but it could be expanded into slightly more of a library such that the 'scales' could be updated on the fly (at present they are captured & owned by the arp). Naming could be improved as there are likely implications beyond simple arpeggiators.
--- the userspace function call stylemyskal= {3,6,9,15,18,21,-6}
myarp2=run_arp( function(v) ii.wsyn.play_note(v,3) end-- what to do at each note of the arp
, make_sequence( myskal, 'next' ) -- a generator to return the next arp note
, 4/3-- a timing in 'clock' module style
)
-- takes an action, a generator, and a timingfunctionrun_arp( fn, seq, sync )
returnclock.run(
function()
whiletruedoclock.sync( sync )
fn( seq() )
endend)
end-- generator that takes a table & a behaviour, returning a function that will give the next step-- arg1: scale table eg{0,2,4,7,9}-- arg2: behaviour enum:{'next','prev',rand','drunk'} -- n as next#-- retv: function that generates the next notefunctionmake_sequence( skal, behaviour )
skix=1returnfunction() -- was 'new_note'ifbehaviour=='next' thenskix=skix+1elseifbehaviour=='prev' thenskix=skix-1elseifbehaviour=='rand' thenskix=math.random(#skal)
elseifbehaviour=='drunk' thenskix=skix+math.random(-1,1)
end-- clamp to skal sizewhileskix<1doskix=skix+#skalendwhileskix>#skaldoskix=skix-#skalend-- scale 12TET notes to v8returnskal[skix] /12endend
Also, there is the possibility of using the clock library for (re)implementing ASL style constructs where the output is a control-rate destination. Particularly useful for ii destinations where we can't & don't need audio rate ASL generation. Instead, generating each 'frame' in lua is fine. Would be nice to provide versions of the the asllib.lua functions which are applied to a generic function at a given framerate. Could be useful for dynamic sample-rate reduction (read sample&hold) of the functions.
-- userspace callmylfo=fn_lfo(
function(v)
ii.wsyn.fm_index(v)
output[1].volts=vend)
functionfn_lfo( fn, duration, min, max, fps )
-- set defaultsduration, min, max, fps=durationor1
, minor0
, maxor5
, fpsor30localphase=0localrange=max-minreturnclock.run(
function()
whiletruedophase=phase+1/(duration*fps)
whilephase>=1dophase=phase-1end-- wrap-- TODO add 'shapes' here. currently just triangle. ramp/sawtooth is even easierlocalo=phase*2-- triangleo= (o>1) and1-ooro-- triangleo=o*range+min-- maps to [min,max]fn( o )
clock.sleep(1/fps)
endend)
end
The text was updated successfully, but these errors were encountered:
This reminds me a fair amount of SuperCollider's (stream-based, event-generating) pattern library, which you may already be familiar with. For example, this is a rough translation of myarp from the first code block (NB velocity of 3 is very loud in SC-land!): Pbind(\note, Pseq([3,6,9,15,18,21,-6], inf), \amp, 3, \dur, 4/3).play;
I have been thinking about translating some of these pattern constructs into lua within crow/norns, so it is encouraging to see a simple implementation above. These could be building blocks for a basic composition/synthesis environment (which may or may not jibe with current design goals).
trentgill
changed the title
Add musical structure utilities
Sequins.lua - musical structure utilities
Apr 20, 2021
From the Maps stream, I came up with some fun functions that allow for a more streamlined approach to building basic arpeggiators and such. They would likely be great additions to the crow (and norns) standard libraries.
Below is the example in question, particularly useful for generating arpeggios and basic sequences, but it could be expanded into slightly more of a library such that the 'scales' could be updated on the fly (at present they are captured & owned by the arp). Naming could be improved as there are likely implications beyond simple arpeggiators.
Also, there is the possibility of using the clock library for (re)implementing ASL style constructs where the output is a control-rate destination. Particularly useful for
ii
destinations where we can't & don't need audio rate ASL generation. Instead, generating each 'frame' in lua is fine. Would be nice to provide versions of the the asllib.lua functions which are applied to a generic function at a given framerate. Could be useful for dynamic sample-rate reduction (read sample&hold) of the functions.The text was updated successfully, but these errors were encountered: