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

43 lines
1.5 KiB
Plaintext

// Define the sine wave synth with non-ET tuning (just intonation)
// Define the sine wave synth with non-ET tuning and an envelope (Just Intonation)
(
SynthDef("sine_wave_non_et", {
arg freq, amp, tuningRatio, outBus;
// Set up tuning - Just Intonation scale (can use different tuning ratios)
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]; // Example ratios for the 8-note scale
// Calculate frequency based on tuning ratio
var tunedFreq = freq * tuning * tuningRatio;
// 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_non_et", // Synth name
\freq, Pseq([60, 61, 62, 63].midicps), // Sequence of frequencies (A4, E5, A5)
\amp, 0.3, //Constant amplitude
\tuningRatio, -4, // Tuning ratio for each frequency
\outBus, 0 // Output bus
).play;
)