diff --git a/packages/webaudio/webaudio.mjs b/packages/webaudio/webaudio.mjs index 64d8672a..77d7e235 100644 --- a/packages/webaudio/webaudio.mjs +++ b/packages/webaudio/webaudio.mjs @@ -82,6 +82,14 @@ Pattern.prototype.out = function () { o.start(t); o.stop(t + hap.duration + release); chain.push(o); + // level down oscillators as they are really loud compared to samples i've tested + const g = ac.createGain(); + g.gain.value = 0.5; + chain.push(g); + // TODO: make adsr work with samples without pops + // envelope + const adsr = getADSR(attack, decay, sustain, release, 1, t, t + hap.duration); + chain.push(adsr); } else { // load sample const samples = getLoadedSamples(); @@ -111,19 +119,17 @@ Pattern.prototype.out = function () { } const src = ac.createBufferSource(); src.buffer = buffer; - let duration = src.buffer.duration; - const offset = begin * duration; - const sus = ((end - begin) * duration) / Math.abs(speed); src.playbackRate.value = Math.abs(speed); // TODO: nudge, unit, cut, loop - src.start(t, offset, sus); + + let duration = src.buffer.duration; + const offset = begin * duration; + duration = ((end - begin) * duration) / Math.abs(speed); + src.start(t, offset, duration); src.stop(t + duration); chain.push(src); } } - // envelope - const adsr = getADSR(attack, decay, sustain, release, 1, t, t + hap.duration); - chain.push(adsr); // filters cutoff !== undefined && chain.push(getFilter('lowpass', cutoff, resonance)); hcutoff !== undefined && chain.push(getFilter('highpass', hcutoff, hresonance)); diff --git a/repl/src/tunes.mjs b/repl/src/tunes.mjs index 61a55448..46a68255 100644 --- a/repl/src/tunes.mjs +++ b/repl/src/tunes.mjs @@ -865,3 +865,33 @@ export const bornagain = `stack( .jux(rev) .out() .stack(s("bd(3,8),hh*4,~ sd").webdirt())`; + +export const meltingsubmarine = `samples({ + clubkick: 'clubkick/2.wav', + sd: ['808sd/SD0010.WAV','808sd/SD0050.WAV'], + hh: 'hh/000_hh3closedhh.wav', + clak: 'clak/000_clak1.wav', + jvbass: ['jvbass/000_01.wav','jvbass/001_02.wav','jvbass/003_04.wav','jvbass/004_05.wav','jvbass/005_06.wav'] +}, 'https://raw.githubusercontent.com/tidalcycles/Dirt-Samples/master/'); +stack( + ",[~ ],hh(3,4)".s().n("<0 1 2>").speed(perlin.range(.7,.9)), + "" + .off(1/8,x=>x.add(12).degradeBy(.5)) + .add(perlin.range(0,.5)) + .n().decay(.15).sustain(0).s("sawtooth") + .superimpose(x=>x.add(.08)).gain(.4) + .cutoff(sine.slow(7).range(300,5000)), + ">".voicings().superimpose(x=>x.add(.04)) + .add(perlin.range(0,.5)) + .n().s('sawtooth') + .gain(.16) + .cutoff(500) + .attack(1), + "a4 c5 ".struct("x(5,8)") + .superimpose(x=>x.add(.04)) + .add(perlin.range(0,.5)).n() + .decay(.1).sustain(0).s('triangle') + .degradeBy(perlin.range(0,.5)).echoWith(4,.125,(x,n)=>x.gain(.15*1/(n+1))) +) + .out() + .slow(3/2)`;