(kemona_halftau)
just by phase-modulating a sine wave at frequency N by two other sine waves with frequencies which are multiples of N (i call those constants H_1 and H_2, H short for “harmonic”, the frequencies of the modulating waveforms are NH_1 and NH_2, i have H_1 set to 7 and H_2 set to 9) by a max angle of theta (i have theta set to 6*tau), you get this instrument:
(kemona_halftau)
fm synthesis is actually really easy to implement in code
suppose you have an oscillator in code:
for (int i=0; i<samples.Length; i++) {
theta+=freq/sampleRate;
theta%=1.0;
samples[i]=double.Sin(theta*TAU);
}you can turn that into fm synthesis just by doing this:
for (int i=0; i<samples.Length; i++) {
theta+=freq/sampleRate;
theta%=1.0;
samples[i]=double.Sin(
(theta*TAU)+
(double.Sin(theta*H_1*TAU)*T_1)
);
}where H_1 is the harmonic and T_1 is the theta constant
(kemona_halftau)
you do have to keep in mind that the theta constant is in radians, so youll need to multiply it by tau
(kemona_halftau)
@noisytoot i just read wikipedia for the most part, then attempt to imlement what i read into code
sometimes it works
(kemona_halftau)
@noisytoot for writing browser-based stuff using audiocontext theres this: https://developer.mozilla.org/en-US/docs/Web/API/AudioContext
im also writing my own dsp library from scratch but itll be a while before its usable