Unify custom instruments and regular ones
This commit is contained in:
parent
da41c77dad
commit
89aa2a0efb
@ -1,9 +1,8 @@
|
||||
nflags=klass()
|
||||
function nflags:init(o)
|
||||
self.c = o.c or 0 -- custom
|
||||
self.e = o.e or 0 -- effect
|
||||
self.v = o.v or 0 -- volume
|
||||
self.w = o.w or 0 -- waveform
|
||||
self.w = o.w or 0 -- waveform and custom
|
||||
self.p = o.p or 0 -- pitch
|
||||
|
||||
self:validate()
|
||||
@ -14,32 +13,33 @@ function nflags:clone()
|
||||
end
|
||||
|
||||
function nflags:validate()
|
||||
local c,e,v,w,p
|
||||
=self.c,self.e,self.v,self.w,self.p
|
||||
local e,v,w,p
|
||||
=self.e,self.v,self.w,self.p
|
||||
|
||||
assert_range(c,0,2,"custom")
|
||||
assert_range(e,0,8,"effect")
|
||||
assert_range(v,0,8,"volume")
|
||||
assert_range(w,0,8,"waveform")
|
||||
assert_range(w,0,16,"waveform")
|
||||
assert_range(p,0,64,"pitch")
|
||||
end
|
||||
|
||||
function nflags:encode()
|
||||
self:validate()
|
||||
local c,e,v,w,p
|
||||
=self.c,self.e,self.v,self.w,self.p
|
||||
local e,v,w,p
|
||||
=self.e,self.v,self.w,self.p
|
||||
|
||||
c &= 0xffff
|
||||
e &= 0xffff
|
||||
v &= 0xffff
|
||||
w &= 0xffff
|
||||
p &= 0xffff
|
||||
|
||||
local wlow = w&7;
|
||||
local whi = (w&8)>>3;
|
||||
|
||||
return (
|
||||
(c << 15) |
|
||||
(whi << 15) |
|
||||
(e << 12) |
|
||||
(v << 9) |
|
||||
(w << 6) |
|
||||
(wlow << 6) |
|
||||
(p)
|
||||
)
|
||||
end
|
16
unique.lua
16
unique.lua
@ -23,8 +23,8 @@ function build_bgm()
|
||||
bgm:add(32)
|
||||
bgm:add(32)
|
||||
|
||||
local bassline=instrument:new(devil(0,2,5,5))
|
||||
local yowler=instrument:new(devil(1,2,5,3))
|
||||
local bassline=instrument:new(devil(8,2,5,5))
|
||||
local yowler=instrument:new(devil(9,2,5,3))
|
||||
local p0=performer:new(bgm,0,bassline,0,{12-2})
|
||||
local p1=performer:new(bgm,1,yowler,0,{24-2})
|
||||
|
||||
@ -113,7 +113,7 @@ function devil(w,e,v0,v1)
|
||||
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}
|
||||
out[i]=nflags:new{p=pitch,v=v,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
|
||||
@ -125,14 +125,14 @@ 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=10,v=7,w=8,e=0},
|
||||
-- nflags:new{p=0,v=5,w=8,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}
|
||||
nflags:new{p=19,v=7,w=10,e=0},
|
||||
-- nflags:new{p=12,v=5,w=2,e=0}
|
||||
}
|
||||
end
|
||||
if (verbs.snare) return {nflags:new{p=30,v=7,c=0,w=6,e=3}}
|
||||
if (verbs.snare) return {nflags:new{p=30,v=7,w=6,e=3}}
|
||||
|
||||
return {}
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user