saner vibrato default

This commit is contained in:
Raphael Forment 2023-09-05 11:24:21 +02:00
parent 3ba195c2d9
commit fc9525e7d8
2 changed files with 16 additions and 13 deletions

View File

@ -393,6 +393,8 @@ const generic_params = [
*/ */
// currently an alias of 'hcutoff' https://github.com/tidalcycles/strudel/issues/496 // currently an alias of 'hcutoff' https://github.com/tidalcycles/strudel/issues/496
// ['hpf'], // ['hpf'],
[['vib'], 'vib'],
[['vibmod'], 'vibmod'],
[['hcutoff', 'hresonance'], 'hpf', 'hp'], [['hcutoff', 'hresonance'], 'hpf', 'hp'],
/** /**
* Controls the **h**igh-**p**ass **q**-value. * Controls the **h**igh-**p**ass **q**-value.

View File

@ -40,10 +40,10 @@ export function registerSynthSounds() {
fmrelease: fmRelease, fmrelease: fmRelease,
fmvelocity: fmVelocity, fmvelocity: fmVelocity,
fmwave: fmWaveform = 'sine', fmwave: fmWaveform = 'sine',
vibrato = 0, vib = 0,
vdepth = 100, vibmod = 1,
slide, slide,
slidespeed = 1, slide_speed = 1,
} = value; } = value;
let { n, note, freq } = value; let { n, note, freq } = value;
// with synths, n and note are the same thing // with synths, n and note are the same thing
@ -61,10 +61,10 @@ export function registerSynthSounds() {
t, t,
s: wave, s: wave,
freq, freq,
vibrato, vib,
vdepth, vibmod,
slide: slide * freq, slide: slide * freq,
slidespeed: sustain / slidespeed, slide_speed: sustain / slide_speed,
partials: n, partials: n,
}); });
@ -150,11 +150,11 @@ export function waveformN(partials, type) {
return osc; return osc;
} }
export function getOscillator({ s, freq, t, vibrato, vdepth, slide, slidespeed, partials }) { export function getOscillator({ s, freq, t, vib, vibmod, slide, slide_speed, partials }) {
// Additional oscillator for vibrato effect // Additional oscillator for vibrato effect
if (vibrato > 0) { if (vib > 0) {
var vibrato_oscillator = getAudioContext().createOscillator(); var vibrato_oscillator = getAudioContext().createOscillator();
vibrato_oscillator.frequency.value = vibrato; vibrato_oscillator.frequency.value = vib;
} }
// Make oscillator with partial count // Make oscillator with partial count
@ -166,11 +166,12 @@ export function getOscillator({ s, freq, t, vibrato, vdepth, slide, slidespeed,
o = waveformN(partials, s); o = waveformN(partials, s);
} }
if (vibrato > 0) { if (vib > 0) {
o.frequency.value = Number(freq); o.frequency.value = Number(freq);
slide > 0 && o.frequency.linearRampToValueAtTime(freq + slide, t + slidespeed); slide > 0 && o.frequency.linearRampToValueAtTime(freq + slide, t + slide_speed);
var gain = getAudioContext().createGain(); var gain = getAudioContext().createGain();
gain.gain.value = vdepth * 100; // Vibmod is the amount of vibrato, in semitones
gain.gain.value = vibmod * freq;
vibrato_oscillator.connect(gain); vibrato_oscillator.connect(gain);
gain.connect(o.detune); gain.connect(o.detune);
vibrato_oscillator.start(t); vibrato_oscillator.start(t);
@ -185,7 +186,7 @@ export function getOscillator({ s, freq, t, vibrato, vdepth, slide, slidespeed,
} else { } else {
// Normal operation, without vibrato // Normal operation, without vibrato
o.frequency.value = Number(freq); o.frequency.value = Number(freq);
slide > 0 && o.frequency.linearRampToValueAtTime(freq + slide, t + slidespeed); slide > 0 && o.frequency.linearRampToValueAtTime(freq + slide, t + slide_speed);
o.start(t); o.start(t);
const stop = (time) => o.stop(time); const stop = (time) => o.stop(time);
return { node: o, stop }; return { node: o, stop };