dervisakyuz
asked on
reading wav files into array
hello all;
please help me about his subject.I want to read a wav file into a double array.No time to learn.just quick help.
thanks.
please help me about his subject.I want to read a wav file into a double array.No time to learn.just quick help.
thanks.
Which parts of it?
You can read the file to bytes array, not to double array. You'll have to apply some kind of conversion or at least a type cast later.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW, this is a duplicate of the already posted question:
https://www.experts-exchange.com/questions/21821007/reading-writing-wav-files-in-java.html
https://www.experts-exchange.com/questions/21821007/reading-writing-wav-files-in-java.html
ASKER
this are good but i am very new about java.
this is a code in c++ what i want..but i need it in java??
any excelllent expert can do it??
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "aec.h"
#define TAPS (80*8)
typedef signed short MONO;
typedef struct {
signed short l;
signed short r;
} STEREO;
float dB2q(float dB)
{
/* Dezibel to Ratio */
return powf(10.0f, dB / 20.0f);
}
float q2dB(float q)
{
/* Ratio to Dezibel */
return 20.0f * log10f(q);
}
/* Read a raw audio file (8KHz sample frequency, 16bit PCM, stereo)
* from stdin, echo cancel it and write it to stdout
*/
int main(int argc, char *argv[])
{
STEREO inbuf[TAPS], outbuf[TAPS];
fprintf(stderr, "usage: aec_test [ambient in dB] <in.raw >out.raw\n");
AEC aec;
if (argc >= 2) {
aec.setambient(MAXPCM*dB2q (atof(argv [1])));
}
int taps;
while (taps = fread(inbuf, sizeof(STEREO), TAPS, stdin)) {
int i;
for (i = 0; i < taps; ++i) {
int s0 = inbuf[i].l; /* left channel microphone */
int s1 = inbuf[i].r; /* right channel speaker */
/* and do NLMS */
s0 = aec.doAEC(s0, s1);
/* copy back */
outbuf[i].l = 0; /* left channel silence */
outbuf[i].r = s0; /* right channel echo cancelled mic */
}
fwrite(outbuf, sizeof(STEREO), taps, stdout);
}
float ambient = aec.getambient();
float ambientdB = q2dB(ambient / 32767.0f);
fprintf(stderr, "Ambient = %2.0f dB\n", ambientdB);
fflush(NULL);
return 0;
}
this is a code in c++ what i want..but i need it in java??
any excelllent expert can do it??
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "aec.h"
#define TAPS (80*8)
typedef signed short MONO;
typedef struct {
signed short l;
signed short r;
} STEREO;
float dB2q(float dB)
{
/* Dezibel to Ratio */
return powf(10.0f, dB / 20.0f);
}
float q2dB(float q)
{
/* Ratio to Dezibel */
return 20.0f * log10f(q);
}
/* Read a raw audio file (8KHz sample frequency, 16bit PCM, stereo)
* from stdin, echo cancel it and write it to stdout
*/
int main(int argc, char *argv[])
{
STEREO inbuf[TAPS], outbuf[TAPS];
fprintf(stderr, "usage: aec_test [ambient in dB] <in.raw >out.raw\n");
AEC aec;
if (argc >= 2) {
aec.setambient(MAXPCM*dB2q
}
int taps;
while (taps = fread(inbuf, sizeof(STEREO), TAPS, stdin)) {
int i;
for (i = 0; i < taps; ++i) {
int s0 = inbuf[i].l; /* left channel microphone */
int s1 = inbuf[i].r; /* right channel speaker */
/* and do NLMS */
s0 = aec.doAEC(s0, s1);
/* copy back */
outbuf[i].l = 0; /* left channel silence */
outbuf[i].r = s0; /* right channel echo cancelled mic */
}
fwrite(outbuf, sizeof(STEREO), taps, stdout);
}
float ambient = aec.getambient();
float ambientdB = q2dB(ambient / 32767.0f);
fprintf(stderr, "Ambient = %2.0f dB\n", ambientdB);
fflush(NULL);
return 0;
}
Pls don't post on this duplicate question anymore. Let's continue the discussion on the original one (the link I posted).
:-)