SMS file input and output. More...
#include "sms.h"
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] |
SMS file input and output.
#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().
int sms_allocFrame | ( | SMS_Data * | pSmsFrame, | |
int | nTracks, | |||
int | nStochCoeff, | |||
int | iPhase, | |||
int | stochType, | |||
int | nEnvCoeff | |||
) |
allocate memory for a frame of SMS data
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 |
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().
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.
pSmsHeader | pointer to SMS header | |
pSmsFrame | pointer to SMS frame |
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.
void sms_clearFrame | ( | SMS_Data * | pSmsFrame | ) |
clear the SMS data structure
pSmsFrame | pointer to frame of SMS data |
References SMS_Data::pSmsData, and SMS_Data::sizeData.
Referenced by sms_analyze().
copy a frame of SMS_Data
pCopySmsData | copy of frame | |
pOriginalSmsData | original frame |
References MIN, SMS_Data::nCoeff, SMS_Data::nTracks, SMS_Data::pFSinAmp, SMS_Data::pFSinFreq, SMS_Data::pFSinPha, SMS_Data::pFStocCoeff, SMS_Data::pFStocGain, SMS_Data::pResPhase, SMS_Data::pSmsData, sfloat, and SMS_Data::sizeData.
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.
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.
int sms_frameSizeB | ( | SMS_Header * | pSmsHeader | ) |
get the size in bytes of the frame in a SMS file
pSmsHeader | pointer to SMS header |
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
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
pSmsFile | pointer to SMS file | |
pSmsHeader | pointer to SMS header | |
iFrame | frame number | |
pSmsFrame | pointer to SMS frame |
References SMS_Header::iFrameBSize, SMS_Header::iHeadBSize, SMS_Data::pSmsData, and sms_error().
int sms_getHeader | ( | char * | pChFileName, | |
SMS_Header ** | ppSmsHeader, | |||
FILE ** | ppSmsFile | |||
) |
function to read SMS header
pChFileName | file name for SMS file | |
ppSmsHeader | (double pointer to) SMS header | |
ppSmsFile | (double pointer to) inputfile |
References sms_error(), and SMS_MAGIC.
void sms_initHeader | ( | SMS_Header * | pSmsHeader | ) |
initialize the header structure of an SMS file
pSmsHeader | header for SMS file |
References SMS_Header::fResidualPerc, SMS_Header::iFormat, SMS_Header::iFrameBSize, SMS_Header::iFrameRate, SMS_Header::iHeadBSize, SMS_Header::iMaxFreq, SMS_Header::iSmsMagic, SMS_Header::iStochasticType, SMS_Header::nEnvCoeff, SMS_Header::nFrames, SMS_Header::nStochasticCoeff, SMS_Header::nTextCharacters, SMS_Header::nTracks, SMS_Header::pChTextCharacters, SMS_FORMAT_H, SMS_MAGIC, and SMS_STOC_APPROX.
Referenced by sms_fillHeader().
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
pSmsFrame1 | sms frame 1 | |
pSmsFrame2 | sms frame 2 | |
pSmsFrameOut | sms output frame | |
fInterpFactor | interpolation factor |
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
pSmsFile | pointer to SMS file | |
pSmsHeader | pointer to header for SMS file |
References SMS_Header::iHeadBSize, SMS_Header::nTextCharacters, and sms_error().
int sms_writeFrame | ( | FILE * | pSmsFile, | |
SMS_Header * | pSmsHeader, | |||
SMS_Data * | pSmsFrame | |||
) |
write SMS frame
pSmsFile | pointer to SMS file | |
pSmsHeader | pointer to SMS header | |
pSmsFrame | pointer to SMS data frame |
References SMS_Header::iFrameBSize, SMS_Data::pSmsData, and sms_error().
int sms_writeHeader | ( | char * | pChFileName, | |
SMS_Header * | pSmsHeader, | |||
FILE ** | ppSmsFile | |||
) |
write SMS header to file
pChFileName | file name for SMS file | |
pSmsHeader | header for SMS file | |
ppSmsFile | (double pointer to) file to be created |
References SMS_Header::iHeadBSize, SMS_Header::iSmsMagic, SMS_Header::nTextCharacters, sms_error(), and SMS_MAGIC.
char pChTextString[1000] [static] |
string to store analysis parameters in sms header
Referenced by sms_fillHeader().