Generate EDM (but the code is bad)
This commit is contained in:
parent
fa282184a9
commit
da41c77dad
72
pulsar.p8
72
pulsar.p8
@ -17,11 +17,73 @@ __gfx__
|
|||||||
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
__sfx__
|
__sfx__
|
||||||
010f20001e2241e2201e22525224252202522523224232222322521224202241e2241c2241c2251a2241a22519224192201922023224232202322022224222222222222225000001c2241e224202242122423224
|
010fa0001ab741211512115101040e1740e1740e1740e174101050412404135161250806034a433cb5736b273eb5338a4338a3336a331ab7522b362ab7630b2736b473ab573ab1732b37069231c012280622e847
|
||||||
010f2000252242522523224232252a2242a2252c2242c2252d2242d2252f2242d2242c2242c2252a2242a22528224282252a22428224262242622528224262242522425220252202522500000000000000000000
|
090a20001837018341183411834118341183411834118341183411834118341183411834118341183411834118341183411834118341183411834118341183411834118341183411834118341183411834118341
|
||||||
010f200000000000000e0401a04015045110322a03036030310352d02200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
010120002667126361233610e3610e3610a3610636103361013600036301363013630135000350003500035002350023500235002550025400254001540004400000000000000000000000000000000000000000
|
||||||
010f200000000000000000015040210401c04518032310203d0203802534012000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
010f200000000000000000015040210401c04518032310203d0203802534012000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
010f20000a8522285114852168520a8522285114852168520a8520a853148520a8520a85314852198521b852168522e8512085222852168522e85120852228521685216853208521685216853208522585227852
|
||||||
|
010f200013a700a95314952169521e6730a953149521695213a700a953149520a9531e67314952199531b95213a701d95327952299521e6731d953279522995213a701d953279521d9531e673279522c9532e952
|
||||||
|
010f2000293252932529345293652932529325293452936529325293252934529365293252932533345333653132531345313653136531345313453136531365303453034530365303652c3652c365303652c365
|
||||||
|
010f2000228523a8512c8522e852228523a8512c8522e85222852228532c85222852228532c852318523385227852278532085227852278532085227852278532085227852278532085219852188521985218852
|
||||||
|
010f200013a702995333952359521e67329953339523595213a702995333952299531e67333952389533a95213a703795313a70379531e6733095213a703795313a70379531e6733095213a702b95213a701f952
|
||||||
|
010f20002932529325293452936529325293252934529365293252932529345293652932529325333453336500000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
002000001885000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
__music__
|
__music__
|
||||||
00 00404040
|
00 08090a40
|
||||||
00 01404040
|
00 0b0c0d40
|
||||||
|
00 40404040
|
||||||
|
00 40404040
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ function performer:init(track,channel,instrument,time,roots)
|
|||||||
self.time=time
|
self.time=time
|
||||||
self.roots=roots
|
self.roots=roots
|
||||||
self.selected_root=1
|
self.selected_root=1
|
||||||
|
self.offset=0
|
||||||
end
|
end
|
||||||
|
|
||||||
function performer:root(root)
|
function performer:root(root)
|
||||||
@ -16,7 +17,7 @@ function performer:root(root)
|
|||||||
end
|
end
|
||||||
function performer:play(duration,note,verbs)
|
function performer:play(duration,note,verbs)
|
||||||
local base=self.roots[self.selected_root]
|
local base=self.roots[self.selected_root]
|
||||||
local note=base+note
|
local note=base+note+self.offset
|
||||||
local t0=self.time
|
local t0=self.time
|
||||||
local t1=t0+duration
|
local t1=t0+duration
|
||||||
self.time+=duration
|
self.time+=duration
|
||||||
|
160
unique.lua
160
unique.lua
@ -1,7 +1,7 @@
|
|||||||
function _init()
|
function _init()
|
||||||
local bgm=build_bgm()
|
local bgm=build_bgm()
|
||||||
local free_patterns={}
|
local free_patterns={}
|
||||||
for i=0,63 do add(free_patterns,i) end
|
for i=8,63 do add(free_patterns,i) end
|
||||||
|
|
||||||
bgm:build(free_patterns,0)
|
bgm:build(free_patterns,0)
|
||||||
|
|
||||||
@ -18,60 +18,132 @@ end
|
|||||||
function build_bgm()
|
function build_bgm()
|
||||||
local bgm=track:new()
|
local bgm=track:new()
|
||||||
|
|
||||||
|
bgm:add(32)
|
||||||
|
bgm:add(32)
|
||||||
bgm:add(32)
|
bgm:add(32)
|
||||||
bgm:add(32)
|
bgm:add(32)
|
||||||
|
|
||||||
trumpet=instrument:new(play_trumpet)
|
local bassline=instrument:new(devil(0,2,5,5))
|
||||||
local perf=performer:new(bgm,0,trumpet,0,{30})
|
local yowler=instrument:new(devil(1,2,5,3))
|
||||||
perf:play(3,0)
|
local p0=performer:new(bgm,0,bassline,0,{12-2})
|
||||||
perf:play(3,7)
|
local p1=performer:new(bgm,1,yowler,0,{24-2})
|
||||||
perf:play(3,5,"warb")
|
|
||||||
perf:play(1,3)
|
|
||||||
perf:play(1,2)
|
|
||||||
perf:play(1,0)
|
|
||||||
perf:play(2,-2)
|
|
||||||
perf:play(2,-4)
|
|
||||||
perf:play(3,-5,"hold")
|
|
||||||
perf:play(3,5,"hold")
|
|
||||||
perf:play(4,4,"warb")
|
|
||||||
perf:rest(1)
|
|
||||||
perf:play(1,-2)
|
|
||||||
perf:play(1,0)
|
|
||||||
perf:play(1,2)
|
|
||||||
perf:play(1,3)
|
|
||||||
perf:play(1,5)
|
|
||||||
|
|
||||||
perf:play(2,7)
|
function generators(r,a,b,c,d)
|
||||||
perf:play(2,5)
|
a+=r b+=r c+=r d+=r
|
||||||
perf:play(2,12)
|
local oct=12
|
||||||
perf:play(2,14)
|
if (b < a) oct=-12
|
||||||
perf:play(2,15)
|
local e=a+oct
|
||||||
perf:play(1,17)
|
local f=b+oct
|
||||||
perf:play(1,15)
|
local g=c+oct
|
||||||
perf:play(2,14)
|
local t={
|
||||||
perf:play(2,12)
|
gen4=function()
|
||||||
perf:play(2,10)
|
p0:play(1,a) p0:play(1,a+24,"slide") p0:play(1,d) p0:play(1,e)
|
||||||
perf:play(1,12)
|
p1:play(1,a,"chop") p1:play(1,a,"chop") p1:play(1,d) p1:play(1,e)
|
||||||
perf:play(1,10)
|
end,
|
||||||
perf:play(2,8)
|
|
||||||
perf:play(1,10)
|
gen3=function()
|
||||||
perf:play(1,8)
|
p0:play(1,a) p0:play(1,a,"chop") p0:play(1,d)
|
||||||
perf:play(4,7)
|
p1:play(1,a,"chop") p1:play(1,a,"chop") p1:play(1,d)
|
||||||
perf:rest(4)
|
end,
|
||||||
|
|
||||||
|
gen2=function(off)
|
||||||
|
off = off or 0
|
||||||
|
p0:play(1,f+off) p0:play(1,g+off)
|
||||||
|
p1:play(1,f+off,"chop") p1:play(1,g+off)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
t.gen16=function()
|
||||||
|
t.gen4() t.gen4() t.gen3() t.gen3() t.gen2()
|
||||||
|
end
|
||||||
|
t.gen12=function()
|
||||||
|
t.gen3() t.gen3() t.gen3() t.gen3()
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
p1.offset=-12
|
||||||
|
generators(0,0,3,5,10).gen16()
|
||||||
|
p1.offset=-5
|
||||||
|
generators(12,0,3,5,10).gen16()
|
||||||
|
generators(24,0,3,5,10).gen16()
|
||||||
|
p1.offset=4
|
||||||
|
generators(29,0,-2,-3,-7).gen12()
|
||||||
|
p1.offset=7
|
||||||
|
generators(29,0,-2,-3,-7).gen2()
|
||||||
|
p1.offset=-5
|
||||||
|
generators(29,0,-2,-3,-7).gen2()
|
||||||
|
|
||||||
|
local drums=instrument:new(drums)
|
||||||
|
local pd=performer:new(bgm,1,drums,0,{0})
|
||||||
|
|
||||||
|
for i=0,5 do
|
||||||
|
pd:play(1,0,"kick")
|
||||||
|
pd:rest(3)
|
||||||
|
pd:play(1,0,"snare")
|
||||||
|
pd:rest(3)
|
||||||
|
end
|
||||||
|
pd:play(1,0,"kick") pd:rest(1) pd:play(1,0,"kick") pd:rest(1) pd:play(1,0,"snare") pd:rest(1)
|
||||||
|
pd:play(1,0,"kick") pd:rest(1) pd:play(1,0,"kick") pd:rest(1) pd:play(1,0,"snare") pd:rest(1)
|
||||||
|
pd:play(1,0,"kick") pd:rest(1) pd:play(1,0,"kick") pd:rest(1)
|
||||||
|
|
||||||
|
local melo1=instrument:new(melo1)
|
||||||
|
local pm=performer:new(bgm,2,melo1,0,{48-2})
|
||||||
|
|
||||||
|
local function generate_ostinato(a,b,c,d,e,stophalf)
|
||||||
|
pm:play(1,a,"qq") pm:play(1,a,"qq") pm:play(1,a,"q") pm:play(1,a)
|
||||||
|
pm:play(1,a,"qq") pm:play(1,a,"qq") pm:play(1,a,"q") pm:play(1,a)
|
||||||
|
pm:play(1,a,"qq") pm:play(1,a,"qq") pm:play(1,a,"q") pm:play(1,a)
|
||||||
|
pm:play(1,a,"qq") pm:play(1,a,"qq") pm:play(1,e,"q") pm:play(1,e)
|
||||||
|
if (stophalf) return
|
||||||
|
pm:play(1,d,"qq") pm:play(1,d,"q") pm:play(1,d) pm:play(1,d)
|
||||||
|
pm:play(1,d,"q") pm:play(1,d,"q") pm:play(1,d) pm:play(1,d)
|
||||||
|
pm:play(1,c,"q") pm:play(1,c,"q") pm:play(1,c) pm:play(1,c)
|
||||||
|
pm:play(1,b) pm:play(1,b) pm:play(1,c) pm:play(1,b)
|
||||||
|
end
|
||||||
|
|
||||||
|
generate_ostinato(-5,-2,2,3,5)
|
||||||
|
generate_ostinato(-5,-2,2,3,5,true)
|
||||||
|
pm:rest(16)
|
||||||
|
|
||||||
return bgm
|
return bgm
|
||||||
end
|
end
|
||||||
|
|
||||||
function play_trumpet(duration,pitch,verbs)
|
function devil(w,e,v0,v1)
|
||||||
local e=0
|
return function(duration,pitch,verbs)
|
||||||
if (verbs.slide) e=1
|
local out={}
|
||||||
if (verbs.warb) e=2
|
for i=1,duration do
|
||||||
|
local v=v1
|
||||||
|
if (i == 1) v=v0
|
||||||
|
out[i]=nflags:new{p=pitch,v=v,c=1,w=w,e=e}
|
||||||
|
end
|
||||||
|
if (verbs.slide and #out>0) out[1].e=1
|
||||||
|
if (verbs.chop and #out>0) out[1].e=3
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function drums(duration,pitch,verbs)
|
||||||
|
if verbs.kick then
|
||||||
|
return {
|
||||||
|
-- kind of a cool sidechained bass effect, but not useful here
|
||||||
|
-- nflags:new{p=10,v=7,c=1,w=0,e=0},
|
||||||
|
-- nflags:new{p=0,v=5,c=1,w=0,e=1}
|
||||||
|
|
||||||
|
nflags:new{p=19,v=7,c=1,w=2,e=0},
|
||||||
|
-- nflags:new{p=12,v=5,c=1,w=2,e=0}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
if (verbs.snare) return {nflags:new{p=30,v=7,c=0,w=6,e=3}}
|
||||||
|
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function melo1(duration,pitch,verbs)
|
||||||
|
local v=6
|
||||||
|
if (verbs.q) v=4
|
||||||
|
if (verbs.qq) v=2
|
||||||
local out={}
|
local out={}
|
||||||
for i=1,duration do
|
for i=1,duration do
|
||||||
out[i]=nflags:new{p=pitch,v=2,w=2,e=e}
|
out[i]=nflags:new{p=pitch,w=3,v=v,e=5}
|
||||||
end
|
end
|
||||||
if (not verbs.slide) out[1].e=4
|
|
||||||
if (not verbs.hold and #out>1) out[#out].e=5
|
|
||||||
return out
|
return out
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user