Answer the question
In order to leave comments, you need to log in
How to process and filter the audio signal?
Hello. Your advice is very necessary. The university was asked to write a sound filtering program. (removal of noise and unnecessary harmonics). I took, translated and slightly changed the finished example from bass.dll as a basis.
Next, my plan is:
#define FREQ 44100 // частота дискретизации
#define BUFSTEP 200000 // блок распределения памяти
#define CHANS 1 // количество каналов
char *recbuf=NULL; // буфер записи
int reclen; // длина записи
HRECORD rchan=0; // канал записи
HSTREAM chan=0; // канал воспроизведения
BOOL CALLBACK RecordingCallback(HRECORD handle, const void *buffer, DWORD length, void *user) //вызывается каждые 100 мс.
{
if ((reclen%BUFSTEP)+length>=BUFSTEP) // увеличить размер буфера при необходимости
{
recbuf = (char *)realloc(recbuf,((reclen+length)/BUFSTEP+1)*BUFSTEP);
if (!recbuf)
{
rchan=0;
return FALSE; // стоп
}
}
memcpy(recbuf+reclen,buffer,length); // буфер данных
reclen+=length;
return TRUE; // продолжить запись
}
void StartRecording()
{
WAVEFORMATEX *wf;
if(recbuf)
{
BASS_StreamFree(chan); // освободить старый канал
chan=0;
free(recbuf);
recbuf=NULL;
BASS_Free();
}
recbuf=(char *)malloc(BUFSTEP); // выделить персональный буфер и освободить место для заголовка
reclen=44;
memcpy(recbuf,"RIFF\0\0\0\0WAVEfmt \20\0\0\0",20); // заполнить заголовок
memcpy(recbuf+36,"data\0\0\0\0",8);
wf=(WAVEFORMATEX*)(recbuf+20);
wf->wFormatTag=1; // тип аудио сигнала
wf->nChannels=CHANS; // количество каналов аудиоданных
wf->wBitsPerSample=16; // количество бит на сэмпл
wf->nSamplesPerSec=FREQ; // частота дискретизации
wf->nBlockAlign=wf->nChannels*wf->wBitsPerSample/8; // выравнивание блока в байтах
wf->nAvgBytesPerSec=wf->nSamplesPerSec*wf->nBlockAlign; // скорость передачи данных в байтах в секунду
rchan = BASS_RecordStart(FREQ,CHANS,0,RecordingCallback,0); // начать запись
}
Answer the question
In order to leave comments, you need to log in
What does the RecordingCallback function take as arguments?
I experimented with the DFT, driving a signal through it. I took 1024 samples and ran forward + reverse. The signal is restored, however, there is a jump at the junctions, so each window is separated by a click, in total, a constant click is heard in the received signal.
It is very interesting how to join the borders in order to avoid distortions?
jcmvbkbc : I understood from the help that the callback is called every 100 milliseconds. Each time this callback was called, I displayed the leght parameter. He was not static. Here is his output: 5512 11024 8268 8268 8268 11024 8268 and so on. Can it be changed and fixed somehow?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question