I have this code
SNDFILE *sf;
SF_INFO info;
int num_channels;
int num, num_items;
int *buf;
int f,sr,c;
int i,j;
FILE *out;
/* Open the WAV file. */
info.format = (SF_FORMAT_RAW | SF_FORMAT_PCM_16);
info.samplerate = 44100;
info.channels = 2;
sf = sf_open("test.raw",SFM_READ,&info);
if (sf == NULL)
{
printf("Failed to open the file. ( %d )\n",sf_perror(sf));
exit(-1);
}
/* Print some of the info, and figure out how much data to read. */
f = info.frames;
sr = info.samplerate;
c = info.channels;
num_items = f*c;
/* Allocate space for the data to be read, then read it. */
buf = (int *) malloc(num_items*sizeof(int));
num = sf_read_int(sf,buf,num_items);
sf_close(sf);
printf("Read %d items\n",num);
/* Write the data to filedata.out. */
out = fopen("test.txt","w");
int links;
int rechts;
for (i = 0; i < num; i += c)
{
for (j = 0; j < c; ++j)
fprintf(out,"%d ",buf[i+j]);
fprintf(out,"\n");
}
fclose(out);
It's purpose is to read "test.raw", convert it to an array and write this into "test.txt". "test.raw" is a raw pcm created by
...
static const pa_sample_spec ss =
{
.format = PA_SAMPLE_S16LE,
.rate = 44100,
.channels = 2
};
pa_simple *s = NULL;
int ret = 1;
int error;
s = pa_simple_new(NULL,
"rec",
PA_STREAM_RECORD,
"bluez_source.00_00_00_00_00_00",
"rec",
&ss,
NULL,
NULL,
&error)
...
from the pulseaudio audio recording sample(download).
Thing is, I get something like
219676672 -131072
219676672 327680
219611136 655360
219217920 327680
218955776 -131072
219152384 -393216
218693632 -720896
in test.txt. I added headers, to get
SAMPLES: 365568
BITSPERSAMPLE: 16
CHANNELS: 2
SAMPLERATE: 44100
NORMALIZED: FALSE
219676672 -131072
219676672 327680
219611136 655360
219217920 327680
218955776 -131072
219152384 -393216
218693632 -720896
and imported into adobe audition as ascii file. I use 44100, 16 bit and stereo there aswell as the intel(also tried the motorola).
Each time I only get "bars" ie periods of constant volume. When reading "test.raw" in audition i see the data as it should be using the intel property.
What do I need to tweak for this to work?