[prev in list] [next in list] [prev in thread] [next in thread]
List: nas
Subject: Playing only parts of a file
From: Eric Wehr <eswehr () csti ! nosc ! mil>
Date: 1996-04-03 17:21:08
[Download RAW message or body]
> And even if I would, I
>couldn't figure out, how the for the starting to the ending time are
>computed if you have some time values for start and end.
Since I've only worked with the low level functions, that's the only place I
can help. My application has called for reading out file data and sending
it to a remote D/A. I simply search into the file so many bytes to get to
the point I want. The following two functions do all of my conversion.
Minor modification will be needed to make them more generic.
/* Using 16 bit signed linear at 8kHz */
#define SAMPLE_RATE 8000 /* 8k samples per second */
#define SAMPLE_SIZE 2 /* 2 bytes per sample */
/********************************************************************/
/* Function: long int SecondsToBytes(int seconds);
/* Description: Converts a time given in seconds to a number of bytes
/* of audio data based on #define values
/********************************************************************/
long int SecondsToBytes(int seconds)
{
long int RetVal;
RetVal = (long int) seconds * (long int) SAMPLE_RATE * (long int)
SAMPLE_SIZE;
return( RetVal );
}
/********************************************************************/
/* Function: int BytesToSeconds(long int bytes);
/* Description: Converts a number of bytes of audio data to a time
/* in seconds based on #define values
/********************************************************************/
int BytesToSeconds(long int bytes)
{
long int RetVal;
RetVal = bytes / (long int) SAMPLE_RATE / (long int) SAMPLE_SIZE;
return( (int) RetVal );
}
Hope this helps if you need to go to the low level API calls.
Eric
Eric S. Wehr | Hey folks, this is
Communication Systems Technology, Inc. | me, not CSTI, not
Charleston, SC Office: | the Navy, not
Naval Weapons Station South Annex | _anyone_ else!
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic