← Genuary 2023 Day 10 - Generative Music

Genuary 2023 Day 10 - Generative Music #20

by carson

Genuary 2023 Day 10 - Generative Music #20 static token preview
Full screen

Static preview.

Project

-- genuary #10 2023
-- generative music
-- by carson kompon

-- fxhash snippet
w=stat(6)s=1
for i=1,#w do
ch=ord(sub(w,i,i))s+=s*31+ch
end
srand(s)

-- init variables & palette
balls={}
size=8+rnd(20)
bounds={size,size,128-size,128-size}
pal({[0]=0,2,3,129,132,136,139,1,4,8,11,140,137,7},1)

-- create note
function make_note(inst,vol,pitch,effect)
b1=pitch+64*(inst%4)
b2=16effect+2vol+flr(inst/4)
return b1,b2
end

-- perc notes
function get_perc(p)
p=p%3
if p==0 then
-- kick
return make_note(0,7,0,3)
elseif p==1 then
-- snare
return make_note(6,7,0,3)
else
--hat
return make_note(6,7,0,5)
end
end

-- create all sfx procedurally
inst=rnd(6)\1
vol=6
effect=rnd({0,0,0,5,5,5,4,4,3})
rootnote=(rnd(12)\1)*(1+rnd(2)\1)
scale={0,2,4,5,7,9,11}
drumdens=2+rnd(8)
drum=0
for i=0,11 do
sfxa=0x3200+(8+i)*68
pitch=rootnote+rnd(scale)
b1,b2=make_note(inst,vol,pitch,effect)
if i%drumdens==0 then
b1,b2=get_perc(drum)
drum+=1
end
poke(sfxa,b1)
poke(sfxa+1,b2)
end

-- ball object
function spawn_ball(x,y,note)
add(balls,{
x=x,y=y,note=note,r=3,
col=9+rnd(4)\1,
hs=rnd(2)-1,
vs=rnd(2)-1,
update=function(self)
xto=self.x+self.hs
yto=self.y+self.vs
if xto<=bounds[1]+self.r then
self.hs=abs(self.hs)
xto+=self.hs
self:play()
elseif xto>=bounds[3]-self.r then
self.hs=-abs(self.hs)
xto+=self.hs
self:play()
end
if yto<=bounds[2]+self.r then
self.vs=abs(self.vs)
yto+=self.vs
self:play()
elseif yto>=bounds[4]-self.r then
self.vs=-abs(self.vs)
yto+=self.vs
self:play()
end
self.x=xto
self.y=yto
circfill(self.x,self.y,self.r,self.col)
end,
play=function(self)
sfx(8+self.note)
end
})
end

-- spawn balls
for i=1,8 do
spawn_ball(
63+rnd(32)-16,
63+rnd(32)-16,
i-1
)
end

cls()

::_::

-- burn the screen >:)
for i=1,200 do
	x=rnd(128)
	y=rnd(128)
	c=pget(x,y)
	if(c~=13)c=max(c-4)
	circfill(x,y,1,c)
end

-- update balls
for ball in all(balls) do
	ball:update()
end

-- draw box
color(13)
line(bounds[1],bounds[2],bounds[3],bounds[2])
line(bounds[3],bounds[2],bounds[3],bounds[4])
line(bounds[1],bounds[4],bounds[3],bounds[4])
line(bounds[1],bounds[2],bounds[1],bounds[4])

flip()

goto _

Price history

DateEventPriceMarket
2023-01-11Mint1 tezfxhash issuer v2
Last completed sales index sync
fx(params) mint tickets
Block 15305302
fxhash issuer v1 (first)
Block 15305302
fxhash issuer v1
Block 15305302
fxhash issuer v2
Block 15305302
fxhash issuer fx(params)
Block 15305302
fxhash marketplace v2
Block 15305302
fxhash marketplace v1
Block 15305302
objkt.com marketplace v1
Block 15305302
objkt.com English auctions v2
Block 15305302
objkt.com marketplace v2
Block 15305302
objkt.com English auctions v1
Block 15305302
objkt.com marketplace v3.2
Block 15305302
objkt.com collection offers
Block 15305302
objkt.com English auctions v3
Block 15305302
objkt.com marketplace v3.1
Block 15305302
objkt.com Dutch auctions v1
Block 15305302

Traits

Recorded features
Not yet indexed