XLTH
XLTH
h>
#include <stdlib.h>
#include <math.h>
#include <portaudio.h>
#include <windows.h>
#include <string.h>
#include <fftw3.h>
if (!filtersInitialized) {
// Allocate memory for filters
lowPassFilter = (float *)calloc(FILTER_SIZE, sizeof(float));
bassFilter = (float *)calloc(FILTER_SIZE, sizeof(float));
midFilter = (float *)calloc(FILTER_SIZE, sizeof(float));
trebleFilter = (float *)calloc(FILTER_SIZE, sizeof(float));
filtersInitialized = 1;
}
LeaveCriticalSection(&controlMutex);
// Mid filter
midSignal = 0;
for (int k = 0; k < FILTER_SIZE; k++) {
if (j - k >= 0) {
midSignal += lowPassedSignal[j - k] * midFilter[k];
}
}
// Treble filter
trebleSignal = 0;
for (int k = 0; k < FILTER_SIZE; k++) {
if (j - k >= 0) {
trebleSignal += lowPassedSignal[j - k] * trebleFilter[k];
}
}
return paContinue;
}
int choice;
float newGain;
scanf("%d", &choice);
EnterCriticalSection(&controlMutex);
switch (choice) {
case 1:
printf("Enter new Bass Gain: ");
scanf("%f", &newGain);
bassGain = newGain;
break;
case 2:
printf("Enter new Mid Gain: ");
scanf("%f", &newGain);
midGain = newGain;
break;
case 3:
printf("Enter new Treble Gain: ");
scanf("%f", &newGain);
trebleGain = newGain;
break;
case 4:
printf("Enter new Bass Frequency: ");
scanf("%f", &bassFreq);
break;
case 5:
printf("Enter new Mid Frequency: ");
scanf("%f", &midFreq);
break;
case 6:
printf("Enter new Treble Frequency: ");
scanf("%f", &trebleFreq);
break;
default:
printf("Invalid choice\n");
}
LeaveCriticalSection(&controlMutex);
}
return 0;
}
int main() {
PaError err;
// Initialize PortAudio
err = Pa_Initialize();
if (err != paNoError) {
fprintf(stderr, "PortAudio error: %s\n", Pa_GetErrorText(err));
return 1;
}