my lpc-10 c program works on an ".au" sound file but my aim is to run the program from a txt file where the sound samples are settled in the begining part of lines like that : 14183 12593 29486 25712 -9985 12288 16384 -5889 -12033 -22273 -30465 -9985 18432 12288 12288 20480 8192 4096 4096 -12033 ............... but i can't solve this problem, the .au file is opened that with that code infile = _topen(TEXT("16bit.au"),O_BINARY|O_RDONLY); and the sample reading part is below. *************************************************************** static int readSamples(int f, int type, short *buffer, int len) { int count; if(type == AU_PCM_16_BIT) { int i; /* no conversion needed, just swap */ count = read(f, buffer, sizeof(short) * len); count /= 2; swapSamples(buffer, count); return count; } else if(type == AU_PCM_8_BIT) { unsigned char temp[1000]; count = read(f, buffer, sizeof(short) * len); expandSamples(temp, buffer, count); return count; } else { unsigned char temp[1000]; /* convert the u-law samples to 16 bit */ count = read(f, temp, len); ulawDecode(temp, buffer, count); return count; } } ********************************************************************** i read the samples with placing that code after read command and i write the samples in a txt file which is pointed by f1, for(i=0;i<len;i++) fprintf(f1,"%d\n",buffer[i]); ************************************************************* now, how can i read the sound samples from that txt file ???? the original program is in http://www.hawksoft.com/cgi/philf/clickcount.pl?action=jump&URL=HawkVoiceDI091src.zip
reading sound samples from text for lpc-10 in c language ???
Started by ●August 7, 2006
Reply by ●August 8, 20062006-08-08
emperor84 wrote:> for(i=0;i<len;i++) > fprintf(f1,"%d\n",buffer[i]); > > ************************************************************* > now, how can i read the sound samples from that txt file ????fscanf?? -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (603) 226-0404 x536 Build a man a fire and he is warm for a day. Set a man on fire and he is warm for the rest of his life.