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.
scd/sine_eikosany.scd

38 lines
1.3 KiB
Plaintext

// Define the sine wave synth with Eikosany tuning and an envelope (Just Intonation)
(
SynthDef("sine_wave_eikosany", {
arg freq, amp, tuningRatio, outBus;
// Eikosany tuning ratios from the .scl file
var tuning = [
33/32, 21/20, 11/10, 9/8, 7/6, 99/80, 77/60, 21/16,
11/8, 7/5, 231/160, 3/2, 63/40, 77/48, 33/20, 7/4,
9/5, 11/6, 77/40, 2/1
];
// Calculate frequency based on tuning ratio
var scaleIndex = freq % tuning.size; // Wrap the frequency to the scale size
var tunedFreq = freq * tuning[scaleIndex]; // Apply the tuning ratio
// Create an envelope (ADSR)
var env = EnvGen.kr(Env.perc(0.01, 0.2), gate: 1); // Short attack and release times
// Generate a sine wave oscillator with the tuned frequency and apply the envelope to the amplitude
var sig = SinOsc.ar(tunedFreq, 0, amp * env); // Sine wave at tuned frequency with envelope
// Send output to the specified bus
Out.ar(outBus, sig);
}).add;
)
(
// Use Pbind to bind parameters with patterns
Pbind(
\instrument, "sine_wave_eikosany", // Synth name
\freq, Pseq([60, 61, 62, 63].midicps), // Sequence of frequencies (e.g., A4, E5, A5)
\amp, 0.3, // Constant amplitude
\tuningRatio, 1, // Tuning ratio for each frequency
\outBus, 0 // Output bus
).play;
)