Click here to Skip to main content
15,899,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: thread update data? Pin
John M. Drescher24-Oct-05 16:55
John M. Drescher24-Oct-05 16:55 
AnswerRe: thread update data? Pin
Anonymous24-Oct-05 19:52
Anonymous24-Oct-05 19:52 
QuestionUsing c++ to write c++ Pin
Jordan C. Atlas24-Oct-05 15:09
Jordan C. Atlas24-Oct-05 15:09 
AnswerRe: Using c++ to write c++ Pin
User 58385224-Oct-05 15:51
User 58385224-Oct-05 15:51 
AnswerRe: Using c++ to write c++ Pin
Bob Stanneveld24-Oct-05 23:25
Bob Stanneveld24-Oct-05 23:25 
GeneralRe: Using c++ to write c++ Pin
Jordan C. Atlas25-Oct-05 5:06
Jordan C. Atlas25-Oct-05 5:06 
GeneralRe: Using c++ to write c++ Pin
Bob Stanneveld25-Oct-05 6:39
Bob Stanneveld25-Oct-05 6:39 
QuestionHelp needed for speech capture project! Pin
student_eng24-Oct-05 14:57
student_eng24-Oct-05 14:57 
Hi,
I have a project which i am unable to do myself.It is not a very long project but because of the time constraint,I would like it to be completed at most by the 7th of November.

The specifications of the project are as follows:

I actually am developing a hearing aid and now the problem is in real time implementation of it.

1. I have to capture speech coming in through "mic in" port of the computer.

2. The captured speech would pass through a module(consisting of filters and Fourier transforms)..which i have written below.

3. The output through my module has to be played back out through the "mic out" port of the computer.


Code is :
#include <stdio.h>
#include <math.h>
#include <string.h>

double wdata[13]; //required for the FFT
double datafft[8192]; //length required is twice the inverse FFT
double x[295000]; //input data vector,maximum,length
int expo = 12; //required for the FFT

int main ()
{

double pi,ex,temp,theta1,coefa,coefb,G;
double X2,W1,bf,phikb,phia,phib;
double phi[1260],XR[4096],XI[4096],X[4096],XM[4096];
double w[512]; // vector of hamming window values
double ret[4096]; // vector of the inverse FFT returned data
double x1[512],x2[512],f[512];
double G1;

int a,i,j,k,m,n,FL,NW,L,l,q1,q2,kb,ks,ke;
double sr = 25000.0; // sampling rate
int CF = 15; // compression factor,CF:1
int hfru = 10500; // high frequency range upper limit
int hfrl = 4400; // high frequency range lower limit
int N = 2048; // number of frequency samples,top half
int ND = 512; // length of input data
int M = 4096; // length of inverse FFT

FILE *fp;
fp = fopen("ELPHRG01.WAV","r+b");

i = 0;

*/
while((fscanf(fp,"%f/n",&x[i++])) != EOF);
fclose(fp);

FL = i;
pi = 4.0 * atan(1.0);
ex = exp(1.0);
NW = 512;
W1 = 0.5;
l = 0;
L = 1;
for (n=0; n < NW; n++) {
theta1 = (2 * pi * n) / (NW - 1);
w[n] = W1 - (W1 * cos(theta1));
}

for (n = 0; n < NW; n++) {
x2[n] = 0.0;
}

bf = sr / (2 * CF); // break frequency
phikb = (pi * bf) / (sr / 2); // angle of break frequency
kb = N / CF; // number of samples from DC to break
phia = (hfrl / (sr /2 )) * pi; // high frequency region starting angle
phib = (hfru / (sr /2 )) *pi; // high frequency region ending angle
coefa = 0.00799;
coefb = -0.3722072;

//1. Obtain a windowed Segment of the input data
for (a = 1; a < 2 * FL / NW + 1; a++) {
for (m = 0, n = 1; m < NW; m++, n++) {
f[m] = w[m] * x[n];
}
}

//2. Obtain Nonlinearly Compressed and Transpossed frequency samples
for (k = 0; k < 150; k++) {

temp = coefa * k;
phi[k] = pow(ex, temp) + coefb;
G = pow(ex, temp);
G1 = G * sqrt(G) + 6;
XR[k] = 0.0;
XI[k] = 0.0;

for (n = 0; n < ND; n++) {

XR[k] = XR[k] + f[n] * cos(phi[k] * n);
XI[k] = XI[k] + f[n] * sin(phi[k]*n);
}

XR[k] = G1 * XR[k];
XI[k] = G1 * XI[k];
}

//3. Pad zeros in the center of the Spectrum
for (k = 150; k < M - 150; k++) {
XR[k] = 0.0;
XI[k] = 0.0;
}

//4. Form the Complex conjugate part of the spectrum
for (k = M - 150 + 1; k < M + 1; k++) {
XR[k] = XR[M-k];
XI[k] = -XI[M-k];
}

//5. Convert from Polar to rectangular for the inverse FT
for (i = 0; i < M; i++) {
j = 2 * i;
k = j + 1;
datafft[j] = XR[i];
datafft[k] = XI[i];
}


//6. Call the FFT
f_init(); //I need to implement this FFT function in C++ rather than Foxpro
MAIN_();

//7. Obtain the inverse FFT from the FFT call
ret[0] = datafft[0] / M;
for (i = 2244; i < 2756; i++) {

j = 2 * i;
k = 2 *M - j;
ret[i+1] = datafft[k] / M;
}

for (k = 0; k < 512; k++) {
ret[k] = ret[k+2244];
}

// Multiply by the hamming
q1 = a / 2;
q2 = q1 * 2;

if (q2 == a) {

for (i = 0; i < 256; i++) {
X2 = ret[i] * w[i] + x1[i + 256];
printf("%f\n",X2);
}

for (i = 256; i < 512; i++) {
x2[i] = ret[i] * w[i];
}
} else {

for (i = 0; i < 256; i++) {
X2 = ret[i] * w[i] + x2[i + 256];
printf("%f\n",X2);
}

for (i = 256; i < 512; i++) {
x1[i] = ret[i] * w[i];
}
}

l = (NW * L / 2);
L = L+1;

return 0;

}




MAIN_()
{ //This is again using Fox Pro but i am not sure
fft2c_(datafft,&expo,wdata);
return 0;
}

So,in all i just need code development in C++ to capture speech and play it back and a slight modification in my module to make it compatible.
If somebody can please help me out,I am even willing to pay for the project.

Thanks,
Student



-- modified at 21:21 Monday 24th October, 2005
AnswerRe: Help needed for speech capture project! Pin
Christian Graus24-Oct-05 15:28
protectorChristian Graus24-Oct-05 15:28 
GeneralRe: Help needed for speech capture project! Pin
student_eng24-Oct-05 15:31
student_eng24-Oct-05 15:31 
GeneralRe: Help needed for speech capture project! Pin
Christian Graus24-Oct-05 15:37
protectorChristian Graus24-Oct-05 15:37 
AnswerRe: Help needed for speech capture project! Pin
normanS24-Oct-05 20:24
normanS24-Oct-05 20:24 
QuestionChunk data trasmfer between two thread. Pin
LeeeNN24-Oct-05 13:39
LeeeNN24-Oct-05 13:39 
AnswerRe: Chunk data trasmfer between two thread. Pin
PJ Arends24-Oct-05 15:17
professionalPJ Arends24-Oct-05 15:17 
GeneralRe: Chunk data trasmfer between two thread. Pin
LeeeNN24-Oct-05 15:51
LeeeNN24-Oct-05 15:51 
AnswerRe: Chunk data trasmfer between two thread. Pin
John R. Shaw24-Oct-05 18:32
John R. Shaw24-Oct-05 18:32 
GeneralRe: Chunk data trasmfer between two thread. Pin
LeeeNN25-Oct-05 8:01
LeeeNN25-Oct-05 8:01 
QuestionEvent Handling Pin
suezzz0024-Oct-05 12:42
suezzz0024-Oct-05 12:42 
AnswerRe: Event Handling Pin
khan++24-Oct-05 19:36
khan++24-Oct-05 19:36 
GeneralRe: Event Handling Pin
S. Senthil Kumar24-Oct-05 20:08
S. Senthil Kumar24-Oct-05 20:08 
GeneralRe: Event Handling Pin
khan++24-Oct-05 20:36
khan++24-Oct-05 20:36 
AnswerRe: Event Handling Pin
S. Senthil Kumar24-Oct-05 21:09
S. Senthil Kumar24-Oct-05 21:09 
Questiondrawing on mouse move Pin
Ann6624-Oct-05 11:37
sussAnn6624-Oct-05 11:37 
AnswerRe: drawing on mouse move Pin
Christian Graus24-Oct-05 12:42
protectorChristian Graus24-Oct-05 12:42 
AnswerRe: drawing on mouse move Pin
vikas amin24-Oct-05 19:53
vikas amin24-Oct-05 19:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.