Opus M. Version 2 (iPone 3GS and up)
Posted: Fri Oct 16, 2015 12:24 pm
A somewhat controllable "music" generator.
Default start is same as previous version without control.
Select an instrument group from the scrollable list and assign that group to one of three channels by pressing the corresponding button. That channel will then make random selections from that instrument group. After assignment, the list will be deselected.
Pressing a channel button while the list is deselected will mute that channel.
Drums are not yet implemented (however, the percussion groups can be selected).
Default start is same as previous version without control.
Select an instrument group from the scrollable list and assign that group to one of three channels by pressing the corresponding button. That channel will then make random selections from that instrument group. After assignment, the list will be deselected.
Pressing a channel button while the list is deselected will mute that channel.
Drums are not yet implemented (however, the percussion groups can be selected).
Code: Select all
dim grp$(16)
app_init
new_song: notes set n1$,n2$,n3$ ! notes play
n1$=notes_gen$(g1) ! n2$=notes_gen$(g2) ! n3$=notes_gen$(g3)
go_on: slowdown
k=list_selected("1") ! if k>=0 then g_nr=k
if button_pressed("c1") then
if g_nr=-1 then ! g1=-1
else ! g1=g_nr ! g_nr=-1 ! list "1" select -1
end if
n1$=notes_gen$(g1) ! goto new_song
end if
if button_pressed("c2") then
if g_nr=-1 then ! g2=-1
else ! g2=g_nr ! g_nr=-1 ! list "1" select -1
end if
n2$=notes_gen$(g2) ! goto new_song
end if
if button_pressed("c3") then
if g_nr=-1 then ! g3=-1
else ! g3=g_nr ! g_nr=-1 ! list "1" select -1
end if
n3$=notes_gen$(g3) ! goto new_song
end if
if notes_time()<notes_length() then go_on else new_song
end
def app_init
randomize ! set underground on
graphics ! graphics clear ! draw color 0,0,0 ! fill color .8,.8,.8
for i=0 to 15 ! read .grp$(i) ! next i
data "Piano","Percussion","Organ","Guitar","Bass","Strings 1"
data "Strings 2","Brass","Reed","Pipe","Synth Lead","Synth Pad"
data "Synth Effects","Ethnic","Percussive","All"
for i=1 to 7 ! for j=1 to 7 ! .t$&=chr$(96+j) ! next j ! next i
.note=23 ! .speed$="WHHQQQQIIISST"
.g1=16 ! .g2=16 ! .g3=16 ! .g_nr=-1
c_list("1"," Groups",.grp$,15,10,10,160,400)
button "c1" title "channel 1" at 180,40 size 100,30
button "c2" title "channel 2" at 180,100 size 100,30
button "c3" title "channel 3" at 180,160 size 100,30
button "dr" title "drums" at 180,370 size 100,30
end def
def notes_gen$(g)
a$=""
if g<0 then return a$
for i=1 to 200
if i=1 or rnd(1)<.05 then
if g=16 then a$&=" "&rnd(119)&":" else a$&=" "&(8*g+rnd(8))&":"
end if
if rnd(1)<.5 then a$&=mid$(.speed$,rnd(13),1)
if rnd(1)<.1 then a$&="V"&(48+rnd(80))
dn=rnd(7)-3 ! a$&=tone_mut$(dn)
next i
return a$
end def
def tone_mut$(dt)
.note+=dt ! .note=max(0,.note) ! .note=min(41,.note)
n$=mid$(.t$,.note,1) & str$(floor(.note/7)+1)
return n$
end def
def c_list(id$,title$,cont$(),size,xt,yt,xb,yb)
dim temp$(size+1)
for i=0 to size ! temp$(i)=cont$(i) ! next i
list id$ text temp$ at xt+2,yt+32 size xb-xt-4,yb-yt-34
draw size 3
draw rect xt,yt to xb,yb ! draw line xt,yt+30 to xb,yt+30
fill rect xt+2,yt+2 to xb-2,yt+28
draw color 0,0,1 ! draw text title$ at xt+5,yt+5
draw color 0,0,0
end def