FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-08-2006, 02:44 AM
emperor84
Guest
 
Posts: n/a
Default reading sound samples from text for lpc-10 in c language ???

my lpc-10 c program works on an ".au" sound file but my aim is to run th
program from a txt file where the sound samples are settled in th
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 cod

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 writ
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 i
http://www.hawksoft.com/cgi/philf/cl...ceDI091src.zip


Reply With Quote
  #2 (permalink)  
Old 08-08-2006, 03:45 PM
Jim Thomas
Guest
 
Posts: n/a
Default Re: reading sound samples from text for lpc-10 in c language ???

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
[email protected] 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.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading non-text files Tricky VHDL 6 09-11-2007 11:33 AM
Reading text files. [email protected] Verilog 4 07-23-2007 03:05 PM
software to sing text (combine text and pitch) [email protected] DSP 7 02-10-2006 08:08 PM
How to go from sound analysis to sound synthesis? [email protected] DSP 2 08-23-2005 06:12 AM
Creating raw sound data from IFFT - how to append sound chunks louis DSP 3 06-24-2005 04:45 AM


All times are GMT +1. The time now is 03:22 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved