-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·66 lines (56 loc) · 1.89 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env node
require('module-alias/register')
const { configuration } = require('@configuration')
process.title = configuration.package.name
const rythmus = require('@lib/rythmus')
const players = require('@lib/players')
const sound = require('@lib/sound')
const timeline = require('@lib/timeline')
const animations = require('@animations')({
modules: [
require('@animations/iddle'),
require('@animations/invitation')
],
variations: {
'player-1': require('@animations/player-sinus'),
'player-2': require('@animations/player-sinus'),
'player-3': require('@animations/player-sinus'),
'player-4': require('@animations/player-sinus'),
'player-5': require('@animations/player-sinus'),
'player-6': require('@animations/player-sinus')
}
}, { rythmus, players })
players.setHistorySize(rythmus.circumference / 2 + 1)
if (sound.enabled) {
sound.start()
players.forEach(player => player.heart.beat.on('start', () => {
if (!player.isActive) return
const { track, note } = player.note
sound.midi(track, note, 127)
}))
process.on('SIGINT', sound.kill)
process.on('SIGTERM', sound.kill)
}
rythmus.raf(players.update)
rythmus.raf(() => timeline.update(players.lifetimeTogether))
rythmus.raf(rythmus.clear)
rythmus.raf(frameCount => {
const emptyness = 1 - players.confidence
const modulations = timeline.properties
animations.iddle(frameCount, { weight: emptyness })
animations.invitation(frameCount, { weight: emptyness })
players.forEach(player => {
animations[player.animationName](frameCount, Object.assign({}, {
player,
weight: player.confidence
}, modulations))
})
if (sound.enabled) {
sound.mix(sound.tracks.iddle, emptyness)
sound.tracks.acts.forEach(trackNumber => {
const volume = (1 - emptyness) * modulations[`soundtrack-${trackNumber}-volume`]
sound.mix(trackNumber, volume)
})
}
})
rythmus.start()