Sure:
-- KEY 3 trigger random note
-- with random velocity
--
engine.name = "Sampler"
local names = {}
local chord0 = {9, 40, 57, 16, 0, 45, 36, 24, 40, 33, 48} -- Abmin - ab1 eb4 ab5 eb2 b0 ab4 b3 b2 eb4 ab3 b4
local chord1 = {10, 40, 57, 17, 2, 46, 38, 26, 41, 34, 40} -- A_#11 - a1 eb4 ab5 e2 db1 a4 db4 db3 e4 a3 eb4
local chord2 = {2, 53, 57, 14, 17, -1, 21, 26, 38, 41, -1} -- Dbmin - db1 e5 ab5 db2 e2 - ab2 db3 db4 e4 -
local chord3 = {0, 53, 57, 19, 28, 46, 34, 38, 40, 29, 52} -- B0 E5 G#5 F#2 D#3 A4 A3 C#4 D#4 E3 D#5
-- B0 F#2 D#3 E3 A3 C#4 D#4 A4 D#5 E5 G#5 (in order of chord above, not sure what chord it is)
local chords = {chord0, chord1, chord2, chord3}
local screen_text = "Ready..."
local which_chord = 0
local prevnum = 0;
path = "/home/we/dust/audio/samples"
function redraw()
screen.clear()
screen.move(0,10)
screen.text(screen_text)
screen.update()
end
function init()
-- load all samples
dirname = path
f = io.popen('ls ' .. dirname)
i = 0;
for name in f:lines() do
print("loading: "..name.." "..i)
engine.load_sample(i,path..name)
names[i] = name
i=i+1
end
redraw()
end
function key(n,z)
if n == 3 then
if z == 1 then
-- choose a note from a chord
choose = math.random(1,11)
num = chords[1+which_chord][choose]
if num >= 0 then
engine.note_on(num, math.random(50,100), 1.0)
screen_text = "Chord "..which_chord.." Note "..names[num]
prevnum = num
else
engine.note_on(prevnum, math.random(50,100), 1.0)
screen_text = "no note here"
end
redraw()
end
end
if n == 2 then
if z == 1 then
which_chord = (which_chord+1)%4 -- since 4 chords right now
screen_text ="Switch Chord to: "..which_chord
redraw()
end
end
end
function enc(n,d)
if n==1 then mix:delta("output",d) end
end