/Users/richardeakin/projects/libsms/trunk/src/fileIO.c File Reference

SMS file input and output. More...

#include "sms.h"
Include dependency graph for fileIO.c:

Defines

#define SMS_MAGIC   767
 file identification constant

Functions

void sms_initHeader (SMS_Header *pSmsHeader)
 initialize the header structure of an SMS file
void sms_fillHeader (SMS_Header *pSmsHeader, SMS_AnalParams *pAnalParams, char *pProgramString)
 fill an SMS header with necessary information for storage
int sms_writeHeader (char *pChFileName, SMS_Header *pSmsHeader, FILE **ppSmsFile)
 write SMS header to file
int sms_writeFile (FILE *pSmsFile, SMS_Header *pSmsHeader)
 rewrite SMS header and close file
int sms_writeFrame (FILE *pSmsFile, SMS_Header *pSmsHeader, SMS_Data *pSmsFrame)
 write SMS frame
int sms_frameSizeB (SMS_Header *pSmsHeader)
 get the size in bytes of the frame in a SMS file
int sms_getHeader (char *pChFileName, SMS_Header **ppSmsHeader, FILE **ppSmsFile)
 function to read SMS header
int sms_getFrame (FILE *pSmsFile, SMS_Header *pSmsHeader, int iFrame, SMS_Data *pSmsFrame)
 read an SMS data frame
int sms_allocFrame (SMS_Data *pSmsFrame, int nTracks, int nStochCoeff, int iPhase, int stochType, int nEnvCoeff)
 allocate memory for a frame of SMS data
int sms_allocFrameH (SMS_Header *pSmsHeader, SMS_Data *pSmsFrame)
 function to allocate an SMS data frame using an SMS_Header
void sms_freeFrame (SMS_Data *pSmsFrame)
 free the SMS data structure
void sms_clearFrame (SMS_Data *pSmsFrame)
 clear the SMS data structure
void sms_copyFrame (SMS_Data *pCopySmsData, SMS_Data *pOriginalSmsData)
 copy a frame of SMS_Data
void sms_interpolateFrames (SMS_Data *pSmsFrame1, SMS_Data *pSmsFrame2, SMS_Data *pSmsFrameOut, sfloat fInterpFactor)
 function to interpolate two SMS frames

Variables

static char pChTextString [1000]

Detailed Description

SMS file input and output.


Define Documentation

#define SMS_MAGIC   767

file identification constant

constant number that is first within SMS_Header, in order to correctly identify an SMS file when read.

Referenced by sms_getHeader(), sms_initHeader(), and sms_writeHeader().


Function Documentation

int sms_allocFrame ( SMS_Data pSmsFrame,
int  nTracks,
int  nStochCoeff,
int  iPhase,
int  stochType,
int  nEnvCoeff 
)

allocate memory for a frame of SMS data

Parameters:
pSmsFrame pointer to a frame of SMS data
nTracks number of sinusoidal tracks in frame
nStochCoeff number of stochastic coefficients in frame
iPhase whether phase information is in the frame
stochType stochastic resynthesis type
nStochCoeff number of envelope coefficients in frame
nEnvCoeff number of envelope coefficients in frame
Returns:
0 on success, -1 on error

References SMS_Data::nCoeff, SMS_Data::nEnvCoeff, SMS_Data::nTracks, SMS_Data::pFSinAmp, SMS_Data::pFSinFreq, SMS_Data::pFSinPha, SMS_Data::pFStocCoeff, SMS_Data::pFStocGain, SMS_Data::pResPhase, SMS_Data::pSmsData, SMS_Data::pSpecEnv, sfloat, SMS_Data::sizeData, sms_error(), SMS_STOC_APPROX, and SMS_STOC_IFFT.

Referenced by sms_allocFrameH(), sms_initAnalysis(), and sms_initSynth().

Here is the call graph for this function:

int sms_allocFrameH ( SMS_Header pSmsHeader,
SMS_Data pSmsFrame 
)

function to allocate an SMS data frame using an SMS_Header

this one is used when you have only read the header, such as after opening a file.

Parameters:
pSmsHeader pointer to SMS header
pSmsFrame pointer to SMS frame
Returns:
0 on success, -1 on error

References SMS_Header::iFormat, SMS_Header::iStochasticType, SMS_Header::nEnvCoeff, SMS_Header::nStochasticCoeff, SMS_Header::nTracks, sms_allocFrame(), SMS_FORMAT_HP, and SMS_FORMAT_IHP.

Here is the call graph for this function:

void sms_clearFrame ( SMS_Data pSmsFrame  ) 

clear the SMS data structure

Parameters:
pSmsFrame pointer to frame of SMS data

References SMS_Data::pSmsData, and SMS_Data::sizeData.

Referenced by sms_analyze().

void sms_copyFrame ( SMS_Data pCopySmsData,
SMS_Data pOriginalSmsData 
)
void sms_fillHeader ( SMS_Header pSmsHeader,
SMS_AnalParams pAnalParams,
char *  pProgramString 
)

fill an SMS header with necessary information for storage

copies parameters from SMS_AnalParams, along with other values so an SMS file can be stored and correctly synthesized at a later time. This is somewhat of a convenience function.

sms_initAnal() should be done first to properly set everything.

Parameters:
pSmsHeader header for SMS file (to be stored)
pAnalParams structure of analysis parameters
pProgramString pointer to a string containing the name of the program that made the analysis data

References SMS_AnalParams::fDefaultFundamental, SMS_AnalParams::fFreqDeviation, SMS_AnalParams::fFundContToGuide, SMS_AnalParams::fHighestFreq, SMS_AnalParams::fHighestFundamental, SMS_AnalParams::fLowestFundamental, SMS_AnalParams::fMinPeakMag, SMS_AnalParams::fMinRefHarmMag, SMS_AnalParams::fPeakContToGuide, SMS_AnalParams::fRefHarmMagDiffFromMax, SMS_AnalParams::fSizeWindow, SMS_AnalParams::iAnalysisDirection, SMS_AnalParams::iCleanTracks, SMS_Header::iEnvType, SMS_AnalParams::iFormat, SMS_Header::iFormat, SMS_Header::iFrameBSize, SMS_AnalParams::iFrameRate, SMS_Header::iFrameRate, SMS_Header::iMaxFreq, SMS_AnalParams::iMaxSleepingTime, SMS_AnalParams::iMinTrackLength, SMS_AnalParams::iRefHarmonic, SMS_AnalParams::iSamplingRate, SMS_Header::iSamplingRate, SMS_AnalParams::iSoundType, SMS_AnalParams::iStochasticType, SMS_Header::iStochasticType, SMS_SEnvParams::iType, SMS_AnalParams::iWindowType, SMS_SEnvParams::nCoeff, SMS_Header::nEnvCoeff, SMS_AnalParams::nFrames, SMS_Header::nFrames, SMS_AnalParams::nGuides, SMS_AnalParams::nStochasticCoeff, SMS_Header::nStochasticCoeff, SMS_Header::nTextCharacters, SMS_AnalParams::nTracks, SMS_Header::nTracks, SMS_Header::pChTextCharacters, pChTextString, sms_frameSizeB(), sms_initHeader(), SMS_STOC_NONE, and SMS_AnalParams::specEnvParams.

Here is the call graph for this function:

int sms_frameSizeB ( SMS_Header pSmsHeader  ) 

get the size in bytes of the frame in a SMS file

Parameters:
pSmsHeader pointer to SMS header
Returns:
the size in bytes of the frame

References SMS_Header::iFormat, SMS_Header::iStochasticType, SMS_Header::nEnvCoeff, SMS_Header::nStochasticCoeff, SMS_Header::nTracks, sfloat, SMS_FORMAT_H, SMS_FORMAT_IH, SMS_STOC_APPROX, and SMS_STOC_IFFT.

Referenced by sms_fillHeader().

void sms_freeFrame ( SMS_Data pSmsFrame  ) 

free the SMS data structure

Parameters:
pSmsFrame pointer to frame of SMS data

References SMS_Data::nCoeff, SMS_Data::nTracks, SMS_Data::pFSinAmp, SMS_Data::pFSinFreq, SMS_Data::pFStocCoeff, SMS_Data::pFStocGain, SMS_Data::pResPhase, SMS_Data::pSmsData, and SMS_Data::sizeData.

Referenced by sms_freeAnalysis(), and sms_freeSynth().

int sms_getFrame ( FILE *  pSmsFile,
SMS_Header pSmsHeader,
int  iFrame,
SMS_Data pSmsFrame 
)

read an SMS data frame

Parameters:
pSmsFile pointer to SMS file
pSmsHeader pointer to SMS header
iFrame frame number
pSmsFrame pointer to SMS frame
Returns:
0 on sucess, -1 on error

References SMS_Header::iFrameBSize, SMS_Header::iHeadBSize, SMS_Data::pSmsData, and sms_error().

Here is the call graph for this function:

int sms_getHeader ( char *  pChFileName,
SMS_Header **  ppSmsHeader,
FILE **  ppSmsFile 
)

function to read SMS header

Parameters:
pChFileName file name for SMS file
ppSmsHeader (double pointer to) SMS header
ppSmsFile (double pointer to) inputfile
Returns:
error code
See also:
SMS_ERRORS

References sms_error(), and SMS_MAGIC.

Here is the call graph for this function:

void sms_initHeader ( SMS_Header pSmsHeader  ) 
void sms_interpolateFrames ( SMS_Data pSmsFrame1,
SMS_Data pSmsFrame2,
SMS_Data pSmsFrameOut,
sfloat  fInterpFactor 
)

function to interpolate two SMS frames

this assumes that the two frames are of the same size

Parameters:
pSmsFrame1 sms frame 1
pSmsFrame2 sms frame 2
pSmsFrameOut sms output frame
fInterpFactor interpolation factor

Todo:
how to interpolate residual phase spectrum

References SMS_Data::nCoeff, SMS_Data::nEnvCoeff, SMS_Data::nTracks, SMS_Data::pFSinAmp, SMS_Data::pFSinFreq, SMS_Data::pFStocCoeff, SMS_Data::pFStocGain, SMS_Data::pSpecEnv, and sfloat.

int sms_writeFile ( FILE *  pSmsFile,
SMS_Header pSmsHeader 
)

rewrite SMS header and close file

Parameters:
pSmsFile pointer to SMS file
pSmsHeader pointer to header for SMS file
Returns:
error code
See also:
SMS_WRERR in SMS_ERRORS

References SMS_Header::iHeadBSize, SMS_Header::nTextCharacters, and sms_error().

Here is the call graph for this function:

int sms_writeFrame ( FILE *  pSmsFile,
SMS_Header pSmsHeader,
SMS_Data pSmsFrame 
)

write SMS frame

Parameters:
pSmsFile pointer to SMS file
pSmsHeader pointer to SMS header
pSmsFrame pointer to SMS data frame
Returns:
0 on success, -1 on failure

References SMS_Header::iFrameBSize, SMS_Data::pSmsData, and sms_error().

Here is the call graph for this function:

int sms_writeHeader ( char *  pChFileName,
SMS_Header pSmsHeader,
FILE **  ppSmsFile 
)

write SMS header to file

Parameters:
pChFileName file name for SMS file
pSmsHeader header for SMS file
ppSmsFile (double pointer to) file to be created
Returns:
error code
See also:
SMS_WRERR in SMS_ERRORS

References SMS_Header::iHeadBSize, SMS_Header::iSmsMagic, SMS_Header::nTextCharacters, sms_error(), and SMS_MAGIC.

Here is the call graph for this function:


Variable Documentation

char pChTextString[1000] [static]

string to store analysis parameters in sms header

Referenced by sms_fillHeader().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on Thu Oct 29 04:08:06 2009 for libsms by  doxygen 1.6.1