ojack / hydra-standalone

Standalone version of hydra running in Electron
GNU Affero General Public License v3.0
26 stars 12 forks source link

Clock #1

Closed diegovdc closed 5 years ago

diegovdc commented 5 years ago

A small class that creates a clock.

const a = new Clock({onTick: val => console.log(`count at ${val}`)})
setTimeout(() => console.log('value should be 4', a.val()), 5000)
setTimeout(() => a.stop(), 5000)

Usage in hydra:

const b = new Clock({interval: 2000}) // two seconds
osc(() => b.val()) // value will increase on every tick

This clock would work really nice with sclang inspired functions such as:

foldAt, foldBetween and warpAt, which would allow the values to either oscillante between to values.

i.e.

foldAt(5, clock.val())  // for clock values 0-9: [0, 1, 2, 3, 4, 5, 4, 3, 2, 1]