# Spherical Harmonics as audio

I asked http://claude.ai to make a patch that took the concept of Spherical Harmonics from the Boost special functions and make something that makes music. It created some tremolo effect I think. Im terrible at math. So I wouldn’t know if it did it right. I am genuinely curious though how it did.

``````(
// Define our synth
SynthDef(\pseudoSphericalTremolo, {
arg freq=440, l=1, m=0, tremoloSpeed=4, amp=0.5, pan=0, out=0;
var sig, tremolo, theta, phi, env;

// Create our base signal - a simple sine wave
sig = SinOsc.ar(freq);

// Create a pseudo-spherical harmonic effect
theta = LFSaw.kr(tremoloSpeed).range(0, 2*pi);
phi = pi/2;

tremolo = SinOsc.kr(l * theta) * (cos(m * phi) ** l.abs);

// Scale the tremolo to range 0 to 1 and apply it
tremolo = tremolo.range(0, 1);
sig = sig * tremolo;

// Apply envelope and amplitude
env = EnvGen.kr(Env.perc(0.01, 1), doneAction: 2);
sig = sig * env * amp;

// Output the sound
Out.ar(out, Pan2.ar(sig, pan));

// Play a sequence of notes
(
Pbind(
\instrument, \pseudoSphericalTremolo,
\degree, Pseq([10, 5, 3, 5, 5.3, 6.5, 7, 2.3, 3.8], inf),
\dur, 0.5,
\l, Pseq([1, 2, 3, 4], inf),
\m, Prand([0, 1, -1], inf),
\tremoloSpeed, Pwhite(2, 8),
\amp, 0.2,
\pan, Pwhite(-0.5, 0.5)
).play;
)
)
``````

I think this output is just unrelated or random. But the tremolo is kind of cool if you use it more.

Only thing I added was the melody. That is human