Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 442ebeb

Browse files
committed
add more fixtures
1 parent 514c9dc commit 442ebeb

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

test/fixtures/kick.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Wavetable from './wavetable.js'
2+
import Lowpass from './lowpass.js'
3+
export default async c => {
4+
const lp = await Lowpass(c)
5+
const sin = await Wavetable(c, { osc: './sin.js' })
6+
return (c, {
7+
hz = 200,
8+
pitchDecay = 15,
9+
volDecay = 15,
10+
filter = .5
11+
}) => {
12+
if (c.p === 0) sin.setPhase(0)
13+
return lp({ x: sin(c, {
14+
hz: hz * Math.exp(-c.t * pitchDecay)
15+
}) * Math.exp(-c.t * volDecay) }, { a: filter })
16+
}
17+
}

test/fixtures/miss-judged.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
export default async c => {
2+
const [
3+
miss,
4+
drums,
5+
piano,
6+
] = await Promise.all([
7+
c.buf({id:'miss',len:c.br,ch:1}),
8+
c.buf({id:'drums',len:c.br*2,ch:1}),
9+
c.buf({id:'piano',len:c.br*2,ch:1}),
10+
])
11+
12+
const texture = await c.sample('freesound:263671')
13+
const fridge = await c.sample('freesound:478656')
14+
const bass = await c.sample('freesound:144114')
15+
16+
const missSrc = await c.src(
17+
'./miss-judged.js',{buffer:miss,d:16,s:32})
18+
19+
if (drums.createdNow)
20+
await c.src('./drums.js',{buffer:drums})
21+
22+
if (piano.createdNow)
23+
await c.src('./piano.js',{buffer:piano,hz:200,chord:[2/4,7/6]})
24+
25+
return c => c(
26+
c => { c.mix(c.zero(c.buffer),
27+
[miss, 1,1.3,c.n],
28+
[drums,1,1.3,c.n],
29+
[piano,1,1.5,c.n+c.br],
30+
[texture,1,.15,c.n],
31+
[fridge,1,1,c.n],
32+
[bass,1,7,c.n],
33+
) },
34+
c => { missSrc.update(c) },
35+
36+
// limiter
37+
c => [
38+
Math.tanh(c.input[0])*.8,
39+
Math.tanh(c.input[1])*.8
40+
]
41+
)
42+
}

0 commit comments

Comments
 (0)