diff --git a/.vscode/.server-controller-port.log b/.vscode/.server-controller-port.log index 92acaf7..d49a3db 100644 --- a/.vscode/.server-controller-port.log +++ b/.vscode/.server-controller-port.log @@ -1,5 +1,5 @@ { "port": 13452, - "time": 1735839820567, + "time": 1735894326191, "version": "0.0.3" } \ No newline at end of file diff --git a/lib/oscillator.c b/lib/oscillator.c index 86e5e1e..57a2ac3 100644 --- a/lib/oscillator.c +++ b/lib/oscillator.c @@ -26,4 +26,11 @@ float get_oscillator_cos_sample(Oscillator *osc) { osc->phase -= M_2PI; } return sample; +} + +float get_oscillator_sin_multiplier_ni(Oscillator *osc, float multiplier) { + return sinf(osc->phase*multiplier) +} +float get_oscillator_cos_multiplier_ni(Oscillator *osc, float multiplier) { + return sinf(osc->phase*multiplier) } \ No newline at end of file diff --git a/lib/oscillator.h b/lib/oscillator.h index 0c7f727..c5db29a 100644 --- a/lib/oscillator.h +++ b/lib/oscillator.h @@ -11,3 +11,5 @@ void init_oscillator(Oscillator *osc, float frequency, float sample_rate); void change_oscillator_frequency(Oscillator *osc, float frequency); float get_oscillator_sin_sample(Oscillator *osc); float get_oscillator_cos_sample(Oscillator *osc); +float get_oscillator_sin_multiplier_ni(Oscillator *osc, float multiplier); +float get_oscillator_cos_multiplier_ni(Oscillator *osc, float multiplier); \ No newline at end of file diff --git a/src/ssb_stereo_coder.c b/src/ssb_stereo_coder.c index dbb4def..90e94b8 100644 --- a/src/ssb_stereo_coder.c +++ b/src/ssb_stereo_coder.c @@ -155,8 +155,8 @@ int main() { uninterleave(input, left, right, BUFFER_SIZE*2); for (int i = 0; i < BUFFER_SIZE; i++) { - float sin38 = sinf(pilot_osc.phase*2); - float cos38 = cosf(pilot_osc.phase*2); // Stereo carrier should be a harmonic of the pilot which is in phase, best way to generate the harmonic is to multiply the pilot's phase by two, so it is mathematically impossible for them to not be in phase + float sin38 = get_oscillator_sin_multiplier_ni(&pilot_osc, 2); + float cos38 = get_oscillator_cos_multiplier_ni(&pilot_osc, 2); // Stereo carrier should be a harmonic of the pilot which is in phase, best way to generate the harmonic is to multiply the pilot's phase by two, so it is mathematically impossible for them to not be in phase float pilot = get_oscillator_sin_sample(&pilot_osc); // This is after because if it was before then the stereo would be out of phase by one increment, so [GET STEREO] ([GET PILOT] [INCREMENT PHASE]) float l_in = left[i]; float r_in = right[i]; diff --git a/src/stereo_coder.c b/src/stereo_coder.c index 7d95859..fcd2d11 100644 --- a/src/stereo_coder.c +++ b/src/stereo_coder.c @@ -149,7 +149,7 @@ int main() { uninterleave(input, left, right, BUFFER_SIZE*2); for (int i = 0; i < BUFFER_SIZE; i++) { - float stereo_carrier = sinf(pilot_osc.phase*2); // Stereo carrier should be a harmonic of the pilot which is in phase, best way to generate the harmonic is to multiply the pilot's phase by two, so it is mathematically impossible for them to not be in phase + float stereo_carrier = get_oscillator_sin_multiplier_ni(&pilot_osc, 2); // Stereo carrier should be a harmonic of the pilot which is in phase, best way to generate the harmonic is to multiply the pilot's phase by two, so it is mathematically impossible for them to not be in phase float pilot = get_oscillator_sin_sample(&pilot_osc); // This is after because if it was before then the stereo would be out of phase by one increment, so [GET STEREO] ([GET PILOT] [INCREMENT PHASE]) float l_in = left[i]; float r_in = right[i];