"Ritm box", a quicky
Posted: Sun Oct 25, 2015 9:33 pm
' ritm box (quicky)
' programmed by Michiel
' 24-10-2015
'
option base 0
True=1
False=0
notes tempo 300
ninstrument=4
dim instrument$(ninstrument),noot$(ninstrument)
data "bass drum", "b1"
data "snare drum", "d2"
data "closed hihat", "f#2"
data "ride cymbal", "d#3"
for i=0 to ninstrument-1
read instrument$(i),noot$(i)
next i
cellw=38
cellh=50
gridoffx=120
gridoffy=200
dim pattern(4,16)
def gridx(col)
gridx=.gridoffx+col*.cellw+5*floor(col/4)
end def
for row=0 to ninstrument-1
y=gridoffy+row*cellh
name$="f-"&str$(row)
field name$ text instrument$(row) at 10, y size 100,35 ro
for col=0 to 15
name$="b-"&str$(row)&"-"&str$(col)
button name$ text " " at gridx(col), y
next col
next row
poll:
slowdown
mutated=False
for row=0 to ninstrument-1
for col=0 to 15
name$="b-"&str$(row)&"-"&str$(col)
if button_pressed(name$) then
if pattern(row,col) then
button name$ text " "
pattern(row,col)=False
else
button name$ text " @ "
pattern(row,col)=True
end if
mutated=True
end if
next col
next row
if mutated then
drum$=""
for col=0 to 15
chord$="("
for row=0 to ninstrument-1
if pattern(row,col) then chord$&=noot$(row)
next row
chord$&=")"
if chord$="()" then chord$="r"
drum$&=chord$
next col
notes stop
notes set ,,,,,,,,,drum$ & drum$ & drum$ & drum$
notes play
end if
goto poll
' programmed by Michiel
' 24-10-2015
'
option base 0
True=1
False=0
notes tempo 300
ninstrument=4
dim instrument$(ninstrument),noot$(ninstrument)
data "bass drum", "b1"
data "snare drum", "d2"
data "closed hihat", "f#2"
data "ride cymbal", "d#3"
for i=0 to ninstrument-1
read instrument$(i),noot$(i)
next i
cellw=38
cellh=50
gridoffx=120
gridoffy=200
dim pattern(4,16)
def gridx(col)
gridx=.gridoffx+col*.cellw+5*floor(col/4)
end def
for row=0 to ninstrument-1
y=gridoffy+row*cellh
name$="f-"&str$(row)
field name$ text instrument$(row) at 10, y size 100,35 ro
for col=0 to 15
name$="b-"&str$(row)&"-"&str$(col)
button name$ text " " at gridx(col), y
next col
next row
poll:
slowdown
mutated=False
for row=0 to ninstrument-1
for col=0 to 15
name$="b-"&str$(row)&"-"&str$(col)
if button_pressed(name$) then
if pattern(row,col) then
button name$ text " "
pattern(row,col)=False
else
button name$ text " @ "
pattern(row,col)=True
end if
mutated=True
end if
next col
next row
if mutated then
drum$=""
for col=0 to 15
chord$="("
for row=0 to ninstrument-1
if pattern(row,col) then chord$&=noot$(row)
next row
chord$&=")"
if chord$="()" then chord$="r"
drum$&=chord$
next col
notes stop
notes set ,,,,,,,,,drum$ & drum$ & drum$ & drum$
notes play
end if
goto poll