Conversation

fm synthesis is neat

1
0
0

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:

1
0
0
bad code, more confusing words
Show content

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

2
0
0

you do have to keep in mind that the theta constant is in radians, so youll need to multiply it by tau

0
0
0
re: bad code, more confusing words
Show content
@kemona_halftau where do I learn more about audio processing? I want to understand what this does
1
0
0

@noisytoot i just read wikipedia for the most part, then attempt to imlement what i read into code

sometimes it works

1
0
1

@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

0
0
1