| -- looper | |
| -- key 2 rec / overdub | |
| -- key 3 stop | |
| -- enc 2 length | |
| -- enc 3 rate | |
| -- todo - mask click; double / half loop; multiple loops | |
| engine.name = 'SoftCut' | |
| function init() | |
| engine.loop_start(1,0) | |
| engine.loop_on(1,0) | |
| engine.pre(1,1) --- pre sets the amount of feedback every loop | |
| engine.amp(1,1) | |
| engine.rec_on(1,1) | |
| engine.rec(1,1) | |
| engine.adc_rec(1,1,1) | |
| engine.adc_rec(1,2,1) | |
| engine.play_dac(1,1,1) | |
| engine.play_dac(1,2,1) | |
| engine.rate(1,0) | |
| engine.reset(1) | |
| engine.stop(1) | |
| playing = 0 | |
| recording = 0 | |
| first_loop = 0 | |
| length = 0 | |
| rate = 0 | |
| active_loop = 1 | |
| p = poll.set("phase_quant_1") | |
| p.callback = function(val) phase(val) end | |
| p:start() | |
| loop_pos=0 | |
| end | |
| phase = function(val) | |
| loop_pos = val | |
| redraw() | |
| end | |
| function redraw() | |
| screen.clear() | |
| screen.level(recording == 1 and 15 or 2) | |
| screen.line_width(recording == 1 and 2 or 1) | |
| screen.rect(0,0,(loop_pos/length)*120,60) | |
| screen.stroke() | |
| screen.move(30,30) | |
| screen.text("length: ") | |
| screen.text(length) | |
| screen.move(30,40) | |
| screen.text("position: ") | |
| screen.text(loop_pos) | |
| screen.move(30,50) | |
| screen.text(playing) | |
| screen.text(recording) | |
| screen.update() | |
| end | |
| function key(n,z) | |
| if z==1 then | |
| if n==2 then | |
| if playing == 0 and recording == 0 then | |
| playing = 1 | |
| engine.start(1) | |
| engine.rate(1,1) | |
| first_loop = 1 | |
| recording = 1 | |
| elseif | |
| playing == 1 and first_loop == 1 then | |
| engine.loop_end(1,loop_pos) | |
| engine.loop_on(1,1) | |
| length = loop_pos | |
| first_loop = 0 | |
| end | |
| if playing == 1 and first_loop == 0 then | |
| recording = 1 - recording | |
| end | |
| engine.rec(1,recording == 1 and 1 or 0) | |
| end | |
| end | |
| if n==3 then | |
| playing = 0 | |
| recording = 0 | |
| engine.stop(1) | |
| length = 0 | |
| loop_pos = 0 | |
| first_loop = 0 | |
| engine.loop_on(1,0) | |
| engine.loop_end(1,100) | |
| engine.reset(1) | |
| end | |
| redraw() | |
| end | |
| function enc(n,z) | |
| if n == 3 then | |
| length = length + (z/10) | |
| engine.loop_end(1,length) | |
| end | |
| if n == 2 then | |
| rate = rate + (z/100) | |
| engine.rate(1,rate) | |
| end | |
| if n == 1 then | |
| active_loop = (active_loop + z)%6 | |
| print(active_loop+1) | |
| end | |
| redraw() | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment