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