diff options
Diffstat (limited to 'client/index.js')
| -rw-r--r-- | client/index.js | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/client/index.js b/client/index.js index 809220d..e08aab0 100644 --- a/client/index.js +++ b/client/index.js @@ -27,11 +27,13 @@ let samplers = {} let sampler requestAudioContext( () => { + // sampler = samplers.misc = new Sampler('samples/misc/glass.mp3', 2) // sampler = samplers.smash = new Sampler('samples/smash/g{}.mp3', 12) sampler = samplers.earth = new Sampler('samples/earth/earth{}.mp3', 20) // sampler = samplers.glass = new Sampler('samples/glass/0{}Particle.mp3', 20) - // sampler = samplers.bong = new Sampler('samples/bong/bong{}.mp3', 10) + // sampler = samplers.bubbles = new Sampler('samples/bubbles/bubbles{}.mp3', 10) // sampler = samplers.kalimba = new Sampler('samples/kalimba/380731__cabled-mess__sansula-08-c-raw.wav', 10) + samplers.choice = (m,n) => { const r = Math.random() if (r < m) return samplers.smash @@ -82,7 +84,7 @@ function manipulate(x, y, pcm, spec){ // let new_spec = spectrum.cloneSpectrum(spec) // new_spec = spectrum.rotatePhase(new_spec, x * Math.PI) - let new_spec = spectrum.rotateSpectrum(spec, x) + let new_spec = spectrum.rotateSpectrum(spec, (y + 0.5)%1) return new_spec } @@ -122,31 +124,39 @@ function trigger(x, y, t, source){ // const freq = notes[Math.floor(x * notes.length)] // const { speaker, player } = hall.play(source, y, freq, x, t) - const { pcm, spec } = source.getWaveAndSpectrum(y) + const { pcm, spec } = source.getWaveAndSpectrum(x) if (! pcm) return const new_spec = manipulate(x, y, pcm, spec) if (! new_spec) return - draw.clear() - // draw.waveform(pcm) - draw.spectrum(spec, 0, window.innerHeight/4 + 20) - const audioBuffer = spectrum.fromSpectrum(new_spec) - draw.waveform(audioBuffer.getChannelData(0)) - const player = new Tone.Player(audioBuffer) player.connect(output) player.start(Tone.now()) - // const new_spec = spectrum.toSpectrum(audioBuffer.getChannelData(0), sr) - draw.spectrum(new_spec, 0, window.innerHeight * 1/2 + 40) + draw.onFrame(() => { + // INIT DRAWING PHASE + draw.clear() - draw.triangle( - lerp(x, 0, 1) * window.innerWidth, - lerp(y, 0, 1) * window.innerHeight - 20, - 40 - ) + // DRAW INDIVIDUAL UI ELEMENTS + // draw.waveform(pcm) + // draw.spectrum(spec, 0, window.innerHeight/4 + 20) + + draw.waveform(audioBuffer.getChannelData(0)) + + // DRAW SPECTRUM + // const new_spec = spectrum.toSpectrum(audioBuffer.getChannelData(0), sr) + // draw.spectrum(new_spec, 0, window.innerHeight * 1/2 + 40) + draw.spectrum(new_spec, 0, window.innerHeight * 1/4 + 20, 0, window.innerHeight * 1/2) + + // DRAW FLAIR + draw.triangle( + lerp(x, 0, 1) * window.innerWidth, + lerp(y, 0, 1) * window.innerHeight - 20, + 40 + ) + }) } |
