You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.2 KiB
Plaintext

// Define the bass synth
(
SynthDef(\boC_bass, {
arg freq = 440, detune = 1.001, amp = 0.4, cutoff = 1000, attack = 0.5, decay = 1;
var osc1, osc2, mix, filter, env;
// Two sawtooth oscillators detuned slightly
osc1 = Pulse.ar(freq, amp); // First oscillator, base frequency
osc2 = Pulse.ar(freq * detune, amp); // Second oscillator, slightly detuned
// Mix both oscillators
mix = osc1 + osc2;
// Apply a low-pass filter to smooth the high frequencies
filter = LPF.ar(mix, cutoff); // Low-pass filter with customizable cutoff
// Envelope for shaping the sound
env = EnvGen.kr(Env.perc(attack, decay), doneAction: 2); // Short attack and decay
// Apply envelope to the filter and mix the result
filter = filter * env;
// Output the final sound to both left and right channels
Out.ar(0, filter.dup);
}).add;
)
// Play the synth with default values
x = Synth(\boC_bass, [\freq, 30.midicps]);
// You can also play the synth with custom arguments
x = Synth(\boC_bass, [
\freq, 220, // Set frequency
\detune, 1.005, // Slightly different detune
\amp, 0.5, // Amp (volume)
\cutoff, 400, // Filter cutoff frequency
\attack, 0.05, // Attack time
\decay, 0.3 // Decay time
]);