summaryrefslogtreecommitdiff
path: root/sms
diff options
context:
space:
mode:
Diffstat (limited to 'sms')
-rw-r--r--sms/OOURA.h5
-rw-r--r--sms/analysis.c14
-rw-r--r--sms/cepstrum.c4
-rw-r--r--sms/filters.c4
-rw-r--r--sms/modify.c6
-rw-r--r--sms/sms.c42
-rw-r--r--sms/sms.h72
-rw-r--r--sms/sms.i126
-rw-r--r--sms/spectrum.c4
-rw-r--r--sms/stocAnalysis.c2
-rw-r--r--sms/synthesis.c2
-rw-r--r--sms/tables.c4
12 files changed, 126 insertions, 159 deletions
diff --git a/sms/OOURA.h b/sms/OOURA.h
index a1087cd..d7c60ad 100644
--- a/sms/OOURA.h
+++ b/sms/OOURA.h
@@ -1,11 +1,8 @@
#ifndef _OOURA_H
#define _OOURA_H
-#ifdef DOUBLE_PRECISION
#define sfloat double
-#else
-#define sfloat float
-#endif
+/*#define sfloat float*/
#define NMAX 8192
#define NMAXSQRT 64
diff --git a/sms/analysis.c b/sms/analysis.c
index 3f46e5f..678eb13 100644
--- a/sms/analysis.c
+++ b/sms/analysis.c
@@ -222,7 +222,7 @@ int sms_findPeaks(int sizeWaveform, sfloat *pWaveform, SMS_AnalParams *pAnalPara
pSpectralPeaks->nPeaksFound = pAnalParams->ppFrames[iCurrentFrame]->nPeaks;
pSpectralPeaks->nPeaks = pAnalParams->peakParams.iMaxPeaks;
pSpectralPeaks->pSpectralPeaks = pAnalParams->ppFrames[iCurrentFrame]->pSpectralPeaks;
- /* convert peak amps to mag */
+ /* convert peak amps to linear */
for(i = 0; i < pSpectralPeaks->nPeaksFound; i++)
{
pSpectralPeaks->pSpectralPeaks[i].fMag = sms_dBToMag(pSpectralPeaks->pSpectralPeaks[i].fMag);
@@ -235,8 +235,8 @@ int sms_findPeaks(int sizeWaveform, sfloat *pWaveform, SMS_AnalParams *pAnalPara
}
}
-void sms_setPeaks(SMS_AnalParams *pAnalParams, int numamps, float* amps,
- int numfreqs, float* freqs, int numphases, float* phases)
+void sms_setPeaks(SMS_AnalParams *pAnalParams, int numamps, sfloat* amps,
+ int numfreqs, sfloat* freqs, int numphases, sfloat* phases)
{
int i;
SMS_AnalFrame *tempFrame;
@@ -379,7 +379,7 @@ void sms_approxResidual(int sizeResidual, sfloat* pResidual,
// // (iSoundLoc - pAnalParams->soundBuffer.iMarker),
// // sizeResidual);
// int sizeData = sizeResidual;
-// if ((pFResidual = (sfloat *) calloc (sizeResidual, sizeof(float))) == NULL)
+// if ((pFResidual = (sfloat *) calloc (sizeResidual, sizeof(sfloat))) == NULL)
// {
// sms_error("sms_analyze: error allocating memory for pFResidual");
// return -1;
@@ -387,7 +387,7 @@ void sms_approxResidual(int sizeResidual, sfloat* pResidual,
// if (sizeWindowArray != sizeData)
// {
// if(sizeWindowArray != 0) free(pWindow);
-// if((pWindow = (sfloat *) calloc(sizeData, sizeof(float))) == NULL)
+// if((pWindow = (sfloat *) calloc(sizeData, sizeof(sfloat))) == NULL)
// {
// sms_error("sms_analyze: error allocating memory for pWindow");
// return -1;
@@ -550,7 +550,7 @@ int sms_analyze (int sizeWaveform, sfloat *pWaveform, SMS_Data *pSmsData, SMS_An
int sizeData = MIN(pAnalParams->soundBuffer.sizeBuffer -
(iSoundLoc - pAnalParams->soundBuffer.iMarker),
sizeResidual);
- if ((pFResidual = (sfloat *) calloc (sizeResidual, sizeof(float))) == NULL)
+ if ((pFResidual = (sfloat *) calloc (sizeResidual, sizeof(sfloat))) == NULL)
{
sms_error("sms_analyze: error allocating memory for pFResidual");
return -1;
@@ -558,7 +558,7 @@ int sms_analyze (int sizeWaveform, sfloat *pWaveform, SMS_Data *pSmsData, SMS_An
if (sizeWindowArray != sizeData)
{
if(sizeWindowArray != 0) free(pWindow);
- if((pWindow = (sfloat *) calloc(sizeData, sizeof(float))) == NULL)
+ if((pWindow = (sfloat *) calloc(sizeData, sizeof(sfloat))) == NULL)
{
sms_error("sms_analyze: error allocating memory for pWindow");
return -1;
diff --git a/sms/cepstrum.c b/sms/cepstrum.c
index 430f1c3..26af068 100644
--- a/sms/cepstrum.c
+++ b/sms/cepstrum.c
@@ -102,7 +102,7 @@ void sms_dCepstrum( int sizeCepstrum, sfloat *pCepstrum, int sizeFreq, sfloat *p
{
int i, k;
sfloat factor;
- sfloat fNorm = PI / (float)iMaxFreq; /* value to normalize frequencies to 0:0.5 */
+ sfloat fNorm = PI / (sfloat)iMaxFreq; /* value to normalize frequencies to 0:0.5 */
//static sizeCepstrumStatic
static CepstrumMatrices m;
//printf("nPoints: %d, nCoeff: %d \n", m.nPoints, m.nCoeff);
@@ -176,7 +176,7 @@ void sms_dCepstrumEnvelope(int sizeCepstrum, sfloat *pCepstrum, int sizeEnv, sfl
{
sms_error("bad fft size, incremented to power of 2");
}
- if ((pFftBuffer = (sfloat *) malloc(sizeFftArray * sizeof(float))) == NULL)
+ if ((pFftBuffer = (sfloat *) malloc(sizeFftArray * sizeof(sfloat))) == NULL)
{
sms_error("could not allocate memory for fft array");
return;
diff --git a/sms/filters.c b/sms/filters.c
index 98ab246..b1ca9fc 100644
--- a/sms/filters.c
+++ b/sms/filters.c
@@ -65,14 +65,14 @@ sfloat sms_deEmphasis(sfloat fInput, SMS_SynthParams *pSynthParams)
* \param fInput input sample
* \return value is the filtered sample
*/
-static sfloat ZeroPoleFilter (float *pFa, sfloat *pFb, int nCoeff, sfloat fInput )
+static sfloat ZeroPoleFilter (sfloat *pFa, sfloat *pFb, int nCoeff, sfloat fInput )
{
double fOut = 0;
int iSection;
/* static sfloat *pD = NULL; */
/* if (pD == NULL) */
-/* pD = (sfloat *) calloc(5, sizeof(float)); */
+/* pD = (sfloat *) calloc(5, sizeof(sfloat)); */
static sfloat pD[5] = {0, 0, 0, 0, 0};
pD[0] = fInput;
diff --git a/sms/modify.c b/sms/modify.c
index 4e520d1..1afdf82 100644
--- a/sms/modify.c
+++ b/sms/modify.c
@@ -80,7 +80,7 @@ void sms_freeModify(SMS_ModifyParams *params)
*
* The values in env2 are overwritten by the new interpolated envelope values.
*/
-void sms_interpEnvelopes(int sizeEnv, sfloat *env1, sfloat *env2, float interpFactor)
+void sms_interpEnvelopes(int sizeEnv, sfloat *env1, sfloat *env2, sfloat interpFactor)
{
if(sizeEnv <= 0)
{
@@ -88,7 +88,7 @@ void sms_interpEnvelopes(int sizeEnv, sfloat *env1, sfloat *env2, float interpFa
}
int i;
- float amp1, amp2;
+ sfloat amp1, amp2;
for(i = 0; i < sizeEnv; i++)
{
@@ -113,7 +113,7 @@ void sms_applyEnvelope(int numPeaks, sfloat *pFreqs, sfloat *pMags, int sizeEnv,
}
int i, envPos;
- float frac, binSize = (float)maxFreq / (float)sizeEnv;
+ sfloat frac, binSize = (sfloat)maxFreq / (sfloat)sizeEnv;
for(i = 0; i < numPeaks; i++)
{
diff --git a/sms/sms.c b/sms/sms.c
index c8a6803..7401827 100644
--- a/sms/sms.c
+++ b/sms/sms.c
@@ -201,7 +201,7 @@ int sms_initAnalysis(SMS_AnalParams *pAnalParams)
pAnalParams->sizeNextRead = (pAnalParams->iDefaultSizeWindow + 1) * 0.5; /* \todo REMOVE THIS from other files first */
/* sound buffer */
- if ((pSoundBuf->pFBuffer = (sfloat *) calloc(sizeBuffer, sizeof(float))) == NULL)
+ if ((pSoundBuf->pFBuffer = (sfloat *) calloc(sizeBuffer, sizeof(sfloat))) == NULL)
{
sms_error("could not allocate memory");
return(-1);
@@ -234,7 +234,7 @@ int sms_initAnalysis(SMS_AnalParams *pAnalParams)
/* deterministic synthesis buffer */
pSynthBuf->sizeBuffer = pAnalParams->sizeHop << 1;
- if((pSynthBuf->pFBuffer = (sfloat *)calloc(pSynthBuf->sizeBuffer, sizeof(float))) == NULL)
+ if((pSynthBuf->pFBuffer = (sfloat *)calloc(pSynthBuf->sizeBuffer, sizeof(sfloat))) == NULL)
{
sms_error("could not allocate memory");
return(-1);
@@ -267,19 +267,19 @@ int sms_initAnalysis(SMS_AnalParams *pAnalParams)
}
(pAnalParams->pFrames[i].deterministic).nTracks = pAnalParams->nGuides;
if (((pAnalParams->pFrames[i].deterministic).pFSinFreq =
- (sfloat *)calloc (pAnalParams->nGuides, sizeof(float))) == NULL)
+ (sfloat *)calloc (pAnalParams->nGuides, sizeof(sfloat))) == NULL)
{
sms_error("could not allocate memory");
return(-1);
}
if (((pAnalParams->pFrames[i].deterministic).pFSinAmp =
- (sfloat *)calloc (pAnalParams->nGuides, sizeof(float))) == NULL)
+ (sfloat *)calloc (pAnalParams->nGuides, sizeof(sfloat))) == NULL)
{
sms_error("could not allocate memory");
return(-1);
}
if (((pAnalParams->pFrames[i].deterministic).pFSinPha =
- (sfloat *) calloc (pAnalParams->nGuides, sizeof(float))) == NULL)
+ (sfloat *) calloc (pAnalParams->nGuides, sizeof(sfloat))) == NULL)
{
sms_error("could not allocate memory");
return(-1);
@@ -303,10 +303,10 @@ void sms_changeHopSize(int hopSize, SMS_AnalParams *pAnalParams)
pAnalParams->nStochasticCoeff = sms_power2(pAnalParams->sizeHop);
/* sound buffer */
- if ((pSoundBuf->pFBuffer = (sfloat *) calloc(sizeBuffer, sizeof(float))) == NULL)
+ if ((pSoundBuf->pFBuffer = (sfloat *) calloc(sizeBuffer, sizeof(sfloat))) == NULL)
{
sms_error("could not allocate memory");
- return(-1);
+ return;
}
pSoundBuf->iMarker = -sizeBuffer;
pSoundBuf->iFirstGood = sizeBuffer;
@@ -314,10 +314,10 @@ void sms_changeHopSize(int hopSize, SMS_AnalParams *pAnalParams)
/* deterministic synthesis buffer */
pSynthBuf->sizeBuffer = pAnalParams->sizeHop << 1;
- if((pSynthBuf->pFBuffer = (sfloat *)calloc(pSynthBuf->sizeBuffer, sizeof(float))) == NULL)
+ if((pSynthBuf->pFBuffer = (sfloat *)calloc(pSynthBuf->sizeBuffer, sizeof(sfloat))) == NULL)
{
sms_error("could not allocate memory");
- return(-1);
+ return;
}
pSynthBuf->iMarker = -sizeBuffer;
pSynthBuf->iMarker = pSynthBuf->sizeBuffer;
@@ -379,9 +379,9 @@ int sms_initSynth(SMS_SynthParams *pSynthParams)
}
sizeFft = sizeHop * 2;
- pSynthParams->pFStocWindow =(sfloat *) calloc(sizeFft, sizeof(float));
+ pSynthParams->pFStocWindow =(sfloat *) calloc(sizeFft, sizeof(sfloat));
sms_getWindow( sizeFft, pSynthParams->pFStocWindow, SMS_WIN_HANNING );
- pSynthParams->pFDetWindow = (sfloat *) calloc(sizeFft, sizeof(float));
+ pSynthParams->pFDetWindow = (sfloat *) calloc(sizeFft, sizeof(sfloat));
sms_getWindow( sizeFft, pSynthParams->pFDetWindow, SMS_WIN_IFFT );
/* allocate memory for analysis data - size of original hopsize */
@@ -391,10 +391,10 @@ int sms_initSynth(SMS_SynthParams *pSynthParams)
pSynthParams->nStochasticCoeff + 1, 1,
pSynthParams->iStochasticType, 0);
- pSynthParams->pSynthBuff = (sfloat *) calloc(sizeFft, sizeof(float));
- pSynthParams->pMagBuff = (sfloat *) calloc(sizeHop, sizeof(float));
- pSynthParams->pPhaseBuff = (sfloat *) calloc(sizeHop, sizeof(float));
- pSynthParams->pSpectra = (sfloat *) calloc(sizeFft, sizeof(float));
+ pSynthParams->pSynthBuff = (sfloat *) calloc(sizeFft, sizeof(sfloat));
+ pSynthParams->pMagBuff = (sfloat *) calloc(sizeHop, sizeof(sfloat));
+ pSynthParams->pPhaseBuff = (sfloat *) calloc(sizeHop, sizeof(sfloat));
+ pSynthParams->pSpectra = (sfloat *) calloc(sizeFft, sizeof(sfloat));
/* set/check modification parameters */
// pSynthParams->modParams.maxFreq = pSmsHeader->iMaxFreq;
@@ -406,15 +406,15 @@ int sms_changeSynthHop( SMS_SynthParams *pSynthParams, int sizeHop)
{
int sizeFft = sizeHop * 2;
- pSynthParams->pSynthBuff = (sfloat *) realloc(pSynthParams->pSynthBuff, sizeFft * sizeof(float));
- pSynthParams->pSpectra = (sfloat *) realloc(pSynthParams->pSpectra, sizeFft * sizeof(float));
- pSynthParams->pMagBuff = (sfloat *) realloc(pSynthParams->pMagBuff, sizeHop * sizeof(float));
- pSynthParams->pPhaseBuff = (sfloat *) realloc(pSynthParams->pPhaseBuff, sizeHop * sizeof(float));
+ pSynthParams->pSynthBuff = (sfloat *) realloc(pSynthParams->pSynthBuff, sizeFft * sizeof(sfloat));
+ pSynthParams->pSpectra = (sfloat *) realloc(pSynthParams->pSpectra, sizeFft * sizeof(sfloat));
+ pSynthParams->pMagBuff = (sfloat *) realloc(pSynthParams->pMagBuff, sizeHop * sizeof(sfloat));
+ pSynthParams->pPhaseBuff = (sfloat *) realloc(pSynthParams->pPhaseBuff, sizeHop * sizeof(sfloat));
pSynthParams->pFStocWindow =
- (sfloat *) realloc(pSynthParams->pFStocWindow, sizeFft * sizeof(float));
+ (sfloat *) realloc(pSynthParams->pFStocWindow, sizeFft * sizeof(sfloat));
sms_getWindow( sizeFft, pSynthParams->pFStocWindow, SMS_WIN_HANNING );
pSynthParams->pFDetWindow =
- (sfloat *) realloc(pSynthParams->pFDetWindow, sizeFft * sizeof(float));
+ (sfloat *) realloc(pSynthParams->pFDetWindow, sizeFft * sizeof(sfloat));
sms_getWindow( sizeFft, pSynthParams->pFDetWindow, SMS_WIN_IFFT );
pSynthParams->sizeHop = sizeHop;
diff --git a/sms/sms.h b/sms/sms.h
index 9c910be..265ee29 100644
--- a/sms/sms.h
+++ b/sms/sms.h
@@ -34,11 +34,8 @@
#define SMS_MAX_NPEAKS 400 /*!< \brief maximum number of peaks */
-#ifdef DOUBLE_PRECISION
#define sfloat double
-#else
-#define sfloat float
-#endif
+/*#define sfloat float*/
/*! \struct SMS_Header
* \brief structure for the header of an SMS file
@@ -573,12 +570,7 @@ sfloat sms_sine (sfloat fTheta);
sfloat sms_sinc (sfloat fTheta);
sfloat sms_random ( void );
int sms_power2(int n);
-//sfloat sms_temperedToFreq( float x ); /*!< raise frequency to the 12th root of 2 */
-//inline sfloat sms_temperedToFreq( float x ){ return(powf(1.0594630943592953, x)); }
-
-/*! \todo remove this define now that there is sms_scalerTempered */
-//#define TEMPERED_TO_FREQ( x ) (powf(1.0594630943592953, x)) /*!< raise frequency to the 12th root of 2 */
-sfloat sms_scalarTempered( float x);
+sfloat sms_scalarTempered( sfloat x);
void sms_arrayScalarTempered( int sizeArray, sfloat *pArray);
#ifndef MAX
@@ -592,8 +584,8 @@ void sms_arrayScalarTempered( int sizeArray, sfloat *pArray);
/*! \} */
/* function declarations */
-void sms_setPeaks(SMS_AnalParams *pAnalParams, int numamps, float* amps,
- int numfreqs, float* freqs, int numphases, float* phases);
+void sms_setPeaks(SMS_AnalParams *pAnalParams, int numamps, sfloat* amps,
+ int numfreqs, sfloat* freqs, int numphases, sfloat* phases);
int sms_findPeaks(int sizeWaveform, sfloat *pWaveform, SMS_AnalParams *pAnalParams, SMS_SpectralPeaks *pSpectralPeaks);
@@ -630,33 +622,33 @@ void sms_freeSynth( SMS_SynthParams *pSynthParams );
void sms_fillSoundBuffer (int sizeWaveform, sfloat *pWaveform, SMS_AnalParams *pAnalParams);
-void sms_windowCentered (int sizeWindow, sfloat *pWaveform, float *pWindow, int sizeFft, float *pFftBuffer);
+void sms_windowCentered (int sizeWindow, sfloat *pWaveform, sfloat *pWindow, int sizeFft, sfloat *pFftBuffer);
void sms_getWindow (int sizeWindow, sfloat *pWindow, int iWindowType);
void sms_scaleWindow (int sizeWindow, sfloat *pWindow);
-int sms_spectrum (int sizeWindow, sfloat *pWaveform, float *pWindow, int sizeMag,
- sfloat *pMag, float *pPhase);
+int sms_spectrum (int sizeWindow, sfloat *pWaveform, sfloat *pWindow, int sizeMag,
+ sfloat *pMag, sfloat *pPhase);
-int sms_invSpectrum (int sizeWaveform, sfloat *pWaveform, float *pWindow ,
- int sizeMag, sfloat *pMag, float *pPhase);
+int sms_invSpectrum (int sizeWaveform, sfloat *pWaveform, sfloat *pWindow ,
+ int sizeMag, sfloat *pMag, sfloat *pPhase);
/* \todo remove this once invSpectrum is completely implemented */
-int sms_invQuickSpectrumW (sfloat *pFMagSpectrum, float *pFPhaseSpectrum,
+int sms_invQuickSpectrumW (sfloat *pFMagSpectrum, sfloat *pFPhaseSpectrum,
int sizeFft, sfloat *pFWaveform, int sizeWave,
sfloat *pFWindow);
int sms_spectralApprox (sfloat *pSpec1, int sizeSpec1, int sizeSpec1Used,
sfloat *pSpec2, int sizeSpec2, int nCoefficients);
-int sms_spectrumMag (int sizeWindow, sfloat *pWaveform, float *pWindow,
+int sms_spectrumMag (int sizeWindow, sfloat *pWaveform, sfloat *pWindow,
int sizeMag, sfloat *pMag);
-void sms_dCepstrum( int sizeCepstrum, sfloat *pCepstrum, int sizeFreq, float *pFreq, float *pMag,
+void sms_dCepstrum( int sizeCepstrum, sfloat *pCepstrum, int sizeFreq, sfloat *pFreq, sfloat *pMag,
sfloat fLambda, int iSamplingRate);
-void sms_dCepstrumEnvelope (int sizeCepstrum, sfloat *pCepstrum, int sizeEnv, float *pEnv);
+void sms_dCepstrumEnvelope (int sizeCepstrum, sfloat *pCepstrum, int sizeEnv, sfloat *pEnv);
void sms_spectralEnvelope ( SMS_Data *pSmsData, SMS_SEnvParams *pSpecEnvParams);
@@ -664,7 +656,7 @@ int sms_sizeNextWindow (int iCurrentFrame, SMS_AnalParams *pAnalParams);
sfloat sms_fundDeviation (SMS_AnalParams *pAnalParams, int iCurrentFrame);
-int sms_detectPeaks (int sizeSpec, sfloat *pFMag, float *pPhase,
+int sms_detectPeaks (int sizeSpec, sfloat *pFMag, sfloat *pPhase,
SMS_Peak *pSpectralPeaks, SMS_PeakParams *pPeakParams);
//void sms_harmDetection (SMS_AnalFrame *pFrame, sfloat fRefFundamental,
@@ -682,7 +674,7 @@ sfloat sms_deEmphasis(sfloat fInput, SMS_SynthParams *pSynthParams);
void sms_cleanTracks (int iCurrentFrame, SMS_AnalParams *pAnalParams);
-void sms_scaleDet (sfloat *pSynthBuffer, float *pOriginalBuffer,
+void sms_scaleDet (sfloat *pSynthBuffer, sfloat *pOriginalBuffer,
sfloat *pSinAmp, SMS_AnalParams *pAnalParams, int nTracks);
int sms_prepSine (int nTableSize);
@@ -735,11 +727,11 @@ void sms_copyFrame (SMS_Data *pCopySmsFrame, SMS_Data *pOriginalSmsFrame);
int sms_frameSizeB (SMS_Header *pSmsHeader);
-int sms_residual (int sizeWindow, sfloat *pSynthesis, float *pOriginal, float *pResidual);
+int sms_residual (int sizeWindow, sfloat *pSynthesis, sfloat *pOriginal, sfloat *pResidual);
void sms_filterHighPass ( int sizeResidual, sfloat *pResidual, int iSamplingRate);
-int sms_stocAnalysis ( int sizeWindow, sfloat *pResidual, float *pWindow,
+int sms_stocAnalysis ( int sizeWindow, sfloat *pResidual, sfloat *pWindow,
SMS_Data *pSmsFrame);
void sms_interpolateFrames (SMS_Data *pSmsFrame1, SMS_Data *pSmsFrame2,
@@ -749,11 +741,11 @@ void sms_fft(int sizeFft, sfloat *pArray);
void sms_ifft(int sizeFft, sfloat *pArray);
-void sms_RectToPolar( int sizeSpec, sfloat *pReal, float *pMag, float *pPhase);
+void sms_RectToPolar( int sizeSpec, sfloat *pReal, sfloat *pMag, sfloat *pPhase);
-void sms_PolarToRect( int sizeSpec, sfloat *pReal, float *pMag, float *pPhase);
+void sms_PolarToRect( int sizeSpec, sfloat *pReal, sfloat *pMag, sfloat *pPhase);
-void sms_spectrumRMS( int sizeMag, sfloat *pReal, float *pMag);
+void sms_spectrumRMS( int sizeMag, sfloat *pReal, sfloat *pMag);
void sms_initModify(SMS_Header *header, SMS_ModifyParams *params);
@@ -768,7 +760,7 @@ void sms_modify(SMS_Data *frame, SMS_ModifyParams *params);
int sms_createDebugFile (SMS_AnalParams *pAnalParams);
-void sms_writeDebugData (sfloat *pBuffer1, float *pBuffer2,
+void sms_writeDebugData (sfloat *pBuffer1, sfloat *pBuffer2,
sfloat *pBuffer3, int sizeBuffer);
void sms_writeDebugFile ( void );
@@ -779,27 +771,5 @@ int sms_errorCheck( void );
char* sms_errorString( void );
-/***********************************************************************************/
-/************ things for hybrid program that are not currently used **********************/
-/* (this is because they were utilized with the MusicKit package that is out of date now) */
-
-/* /\*! \struct SMS_HybParams */
-/* * \brief structure for hybrid program */
-/* *\/ */
-/* typedef struct */
-/* { */
-/* int nCoefficients; */
-/* sfloat fGain; */
-/* sfloat fMagBalance; */
-/* int iSmoothOrder; */
-/* sfloat *pCompressionEnv; */
-/* int sizeCompressionEnv; */
-/* } SMS_HybParams; */
-
-/* void sms_hybridize (sfloat *pFWaveform1, int sizeWave1, float *pFWaveform2, */
-/* int sizeWave2, sfloat *pFWaveform, SMS_HybParams *pHybParams); */
-
-/* void sms_filterArray (sfloat *pFArray, int size1, int size2, float *pFOutArray); */
-
#endif /* _SMS_H */
diff --git a/sms/sms.i b/sms/sms.i
index 5a611c9..5474d80 100644
--- a/sms/sms.i
+++ b/sms/sms.i
@@ -23,34 +23,34 @@
}
/* apply all numpy typemaps to various names in sms.h */
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeWindow, float* pWindow)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeWaveform, float* pWaveform)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(long sizeSound, float* pSound)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeFft, float* pArray)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeFft, float* pFftBuffer)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeFreq, float* pFreq)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeAmp, float* pAmp)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeMag, float* pMag)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizePhase, float* pPhase)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeRes, float* pRes)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeCepstrum, float* pCepstrum)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeEnv, float* pEnv)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeTrack, float* pTrack)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeArray, float* pArray)};
-%apply (int DIM1, float* IN_ARRAY1) {(int sizeInArray, float* pInArray)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeOutArray, float* pOutArray)};
-%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeHop, float* pSynthesis)};
-%apply (int DIM1, float* IN_ARRAY1)
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeWindow, double* pWindow)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeWaveform, double* pWaveform)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(long sizeSound, double* pSound)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeFft, double* pArray)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeFft, double* pFftBuffer)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeFreq, double* pFreq)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeAmp, double* pAmp)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeMag, double* pMag)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizePhase, double* pPhase)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeRes, double* pRes)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeCepstrum, double* pCepstrum)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeEnv, double* pEnv)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeTrack, double* pTrack)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeArray, double* pArray)};
+%apply (int DIM1, double* IN_ARRAY1) {(int sizeInArray, double* pInArray)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeOutArray, double* pOutArray)};
+%apply (int DIM1, double* INPLACE_ARRAY1) {(int sizeHop, double* pSynthesis)};
+%apply (int DIM1, double* IN_ARRAY1)
{
- (int numamps, float* amps),
- (int numfreqs, float* freqs),
- (int numphases, float* phases)
+ (int numamps, double* amps),
+ (int numfreqs, double* freqs),
+ (int numphases, double* phases)
}
-%apply (int DIM1, float* IN_ARRAY1)
+%apply (int DIM1, double* IN_ARRAY1)
{
- (int sizeSynthesis, float* pSynthesis),
- (int sizeOriginal, float* pOriginal),
- (int sizeResidual, float* pResidual)
+ (int sizeSynthesis, double* pSynthesis),
+ (int sizeOriginal, double* pOriginal),
+ (int sizeResidual, double* pResidual)
}
%include "sms.h"
@@ -76,13 +76,13 @@
int allocated;
} SMS_File;
- void simplsms_dCepstrum( int sizeCepstrum, float *pCepstrum, int sizeFreq, float *pFreq, int sizeMag, float *pMag,
- float fLambda, int iSamplingRate)
+ void simplsms_dCepstrum( int sizeCepstrum, sfloat *pCepstrum, int sizeFreq, sfloat *pFreq, int sizeMag, sfloat *pMag,
+ sfloat fLambda, int iSamplingRate)
{
sms_dCepstrum(sizeCepstrum,pCepstrum, sizeFreq, pFreq, pMag,
fLambda, iSamplingRate);
}
- int simplsms_detectPeaks(int sizeMag, float *pMag, int sizePhase, float *pPhase,
+ int simplsms_detectPeaks(int sizeMag, sfloat *pMag, int sizePhase, sfloat *pPhase,
SMS_SpectralPeaks *pPeakStruct, SMS_PeakParams *pPeakParams)
{
if(sizeMag != sizePhase)
@@ -98,23 +98,23 @@
pPeakStruct->nPeaksFound = sms_detectPeaks(sizeMag, pMag, pPhase, pPeakStruct->pSpectralPeaks, pPeakParams);
return pPeakStruct->nPeaksFound;
}
- int simplsms_spectrum( int sizeWaveform, float *pWaveform, int sizeWindow, float *pWindow,
- int sizeMag, float *pMag, int sizePhase, float *pPhase)
+ int simplsms_spectrum( int sizeWaveform, sfloat *pWaveform, int sizeWindow, sfloat *pWindow,
+ int sizeMag, sfloat *pMag, int sizePhase, sfloat *pPhase)
{
return(sms_spectrum(sizeWindow, pWaveform, pWindow, sizeMag, pMag, pPhase));
}
- int simplsms_spectrumMag( int sizeWaveform, float *pWaveform, int sizeWindow, float *pWindow,
- int sizeMag, float *pMag)
+ int simplsms_spectrumMag( int sizeWaveform, sfloat *pWaveform, int sizeWindow, sfloat *pWindow,
+ int sizeMag, sfloat *pMag)
{
return(sms_spectrumMag(sizeWindow, pWaveform, pWindow, sizeMag, pMag));
}
- int simplsms_invSpectrum( int sizeWaveform, float *pWaveform, int sizeWindow, float *pWindow,
- int sizeMag, float *pMag, int sizePhase, float *pPhase)
+ int simplsms_invSpectrum( int sizeWaveform, sfloat *pWaveform, int sizeWindow, sfloat *pWindow,
+ int sizeMag, sfloat *pMag, int sizePhase, sfloat *pPhase)
{
return(sms_invSpectrum(sizeWaveform, pWaveform, pWindow, sizeMag, pMag, pPhase));
}
- void simplsms_windowCentered(int sizeWaveform, float *pWaveform, int sizeWindow,
- float *pWindow, int sizeFft, float *pFftBuffer)
+ void simplsms_windowCentered(int sizeWaveform, sfloat *pWaveform, int sizeWindow,
+ sfloat *pWindow, int sizeFft, sfloat *pFftBuffer)
{
if (sizeWaveform != sizeWindow)
{
@@ -123,7 +123,7 @@
}
sms_windowCentered(sizeWindow, pWaveform, pWindow, sizeFft, pFftBuffer);
}
- void simplsms_synthesize_wrapper(SMS_Data *pSmsData, int sizeHop, float *pSynthesis, SMS_SynthParams *pSynthParams)
+ void simplsms_synthesize_wrapper(SMS_Data *pSmsData, int sizeHop, sfloat *pSynthesis, SMS_SynthParams *pSynthParams)
{
if(sizeHop != pSynthParams->sizeHop)
{
@@ -181,8 +181,8 @@
}
frame = &$self->smsData[i];
}
- void getTrack(int track, int sizeFreq, float *pFreq, int sizeAmp,
- float *pAmp)
+ void getTrack(int track, int sizeFreq, sfloat *pFreq, int sizeAmp,
+ sfloat *pAmp)
{
/* fatal error protection first */
if(!$self->allocated)
@@ -210,8 +210,8 @@
}
}
// TODO turn into getTrackP - and check if phase exists
- void getTrack(int track, int sizeFreq, float *pFreq, int sizeAmp,
- float *pAmp, int sizePhase, float *pPhase)
+ void getTrack(int track, int sizeFreq, sfloat *pFreq, int sizeAmp,
+ sfloat *pAmp, int sizePhase, sfloat *pPhase)
{
/* fatal error protection first */
if(!$self->allocated)
@@ -249,7 +249,7 @@
return;
}
- void getFrameDet(int i, int sizeFreq, float *pFreq, int sizeAmp, float *pAmp)
+ void getFrameDet(int i, int sizeFreq, sfloat *pFreq, int sizeAmp, sfloat *pAmp)
{
if(!$self->allocated)
{
@@ -272,15 +272,15 @@
sms_error("freq and amp arrays are different in size");
return;
}
- memcpy(pFreq, $self->smsData[i].pFSinFreq, sizeof(float) * nTracks);
- memcpy(pAmp, $self->smsData[i].pFSinAmp, sizeof(float) * nTracks);
+ memcpy(pFreq, $self->smsData[i].pFSinFreq, sizeof(sfloat) * nTracks);
+ memcpy(pAmp, $self->smsData[i].pFSinAmp, sizeof(sfloat) * nTracks);
if($self->header->iFormat < SMS_FORMAT_HP) return;
return;
}
- void getFrameDetP(int i, int sizeFreq, float *pFreq, int sizeAmp,
- float *pAmp, int sizePhase, float *pPhase)
+ void getFrameDetP(int i, int sizeFreq, sfloat *pFreq, int sizeAmp,
+ sfloat *pAmp, int sizePhase, sfloat *pPhase)
{
if(!$self->allocated)
{
@@ -308,19 +308,19 @@
sms_error("freq and amp arrays are different in size");
return;
}
- memcpy(pFreq, $self->smsData[i].pFSinFreq, sizeof(float) * nTracks);
- memcpy(pAmp, $self->smsData[i].pFSinAmp, sizeof(float) * nTracks);
+ memcpy(pFreq, $self->smsData[i].pFSinFreq, sizeof(sfloat) * nTracks);
+ memcpy(pAmp, $self->smsData[i].pFSinAmp, sizeof(sfloat) * nTracks);
if(sizePhase != sizeFreq || sizePhase != sizeAmp)
{
sms_error("phase array and freq/amp arrays are different in size");
return;
}
- memcpy(pPhase, $self->smsData[i].pFSinPha, sizeof(float) * nTracks);
+ memcpy(pPhase, $self->smsData[i].pFSinPha, sizeof(sfloat) * nTracks);
return;
}
- void getFrameRes(int i, int sizeRes, float *pRes)
+ void getFrameRes(int i, int sizeRes, sfloat *pRes)
{
if(!$self->allocated)
@@ -337,10 +337,10 @@
if($self->header->nStochasticCoeff > sizeRes)
nCoeff = $self->header->nStochasticCoeff; // return what you can
- memcpy(pRes, $self->smsData[i].pFStocCoeff, sizeof(float) * nCoeff);
+ memcpy(pRes, $self->smsData[i].pFStocCoeff, sizeof(sfloat) * nCoeff);
return;
}
- void getFrameEnv(int i, int sizeEnv, float *pEnv)
+ void getFrameEnv(int i, int sizeEnv, sfloat *pEnv)
{
if(!$self->allocated)
@@ -397,7 +397,7 @@
s->nPeaksFound = 0;
return s;
}
- void getFreq( int sizeArray, float *pArray )
+ void getFreq( int sizeArray, sfloat *pArray )
{
if(sizeArray < $self->nPeaksFound)
{
@@ -409,7 +409,7 @@
pArray[i] = $self->pSpectralPeaks[i].fFreq;
}
- void getMag( int sizeArray, float *pArray )
+ void getMag( int sizeArray, sfloat *pArray )
{
if(sizeArray < $self->nPeaksFound)
{
@@ -420,7 +420,7 @@
for (i = 0; i < $self->nPeaksFound; i++)
pArray[i] = $self->pSpectralPeaks[i].fMag;
}
- void getPhase( int sizeArray, float *pArray )
+ void getPhase( int sizeArray, sfloat *pArray )
{
if(sizeArray < $self->nPeaksFound)
{
@@ -436,7 +436,7 @@
%extend SMS_Data
{
- void getSinAmp(int sizeArray, float *pArray)
+ void getSinAmp(int sizeArray, sfloat *pArray)
{
if(sizeArray < $self->nTracks)
{
@@ -447,7 +447,7 @@
for (i = 0; i < $self->nTracks; i++)
pArray[i] = $self->pFSinAmp[i];
}
- void getSinFreq(int sizeArray, float *pArray)
+ void getSinFreq(int sizeArray, sfloat *pArray)
{
if(sizeArray < $self->nTracks)
{
@@ -458,7 +458,7 @@
for (i = 0; i < $self->nTracks; i++)
pArray[i] = $self->pFSinFreq[i];
}
- void getSinPhase(int sizeArray, float *pArray)
+ void getSinPhase(int sizeArray, sfloat *pArray)
{
if(sizeArray < $self->nTracks)
{
@@ -469,7 +469,7 @@
for (i = 0; i < $self->nTracks; i++)
pArray[i] = $self->pFSinPha[i];
}
- void getSinEnv(int sizeArray, float *pArray)
+ void getSinEnv(int sizeArray, sfloat *pArray)
{
if(sizeArray < $self->nEnvCoeff)
{
@@ -480,7 +480,7 @@
for (i = 0; i < $self->nEnvCoeff; i++)
pArray[i] = $self->pSpecEnv[i];
}
- void setSinAmp(int sizeArray, float *pArray)
+ void setSinAmp(int sizeArray, sfloat *pArray)
{
if(sizeArray < $self->nTracks)
{
@@ -492,7 +492,7 @@
$self->pFSinAmp[i] = pArray[i];
}
- void setSinFreq(int sizeArray, float *pArray)
+ void setSinFreq(int sizeArray, sfloat *pArray)
{
if(sizeArray < $self->nTracks)
{
@@ -503,7 +503,7 @@
for (i = 0; i < $self->nTracks; i++)
$self->pFSinFreq[i] = pArray[i];
}
- void setSinPha(int sizeArray, float *pArray)
+ void setSinPha(int sizeArray, sfloat *pArray)
{
if(sizeArray < $self->nTracks)
{
@@ -519,7 +519,7 @@
%extend SMS_ModifyParams
{
/* no need to return an error code, if sms_error is called, it will throw an exception in python */
- void setSinEnv(int sizeArray, float *pArray)
+ void setSinEnv(int sizeArray, sfloat *pArray)
{
if(!$self->ready)
{
diff --git a/sms/spectrum.c b/sms/spectrum.c
index 8fc1077..c7d815a 100644
--- a/sms/spectrum.c
+++ b/sms/spectrum.c
@@ -312,14 +312,14 @@ void sms_spectrumRMS( int sizeMag, sfloat *pInRect, sfloat *pOutMag)
* sfloat *pFWaveform output waveform
* int sizeWave size of output waveform
*/
-/* int sms_invSpectrum (sfloat *pFMagSpectrum, float *pFPhaseSpectrum, */
+/* int sms_invSpectrum (sfloat *pFMagSpectrum, sfloat *pFPhaseSpectrum, */
/* int sizeFft, sfloat *pFWaveform, int sizeWave) */
/* { */
/* int sizeMag = sizeFft >> 1, i, it2; */
/* sfloat *pFBuffer, fPower; */
/* /\* allocate buffer *\/ */
-/* if ((pFBuffer = (sfloat *) calloc(sizeFft+1, sizeof(float))) == NULL) */
+/* if ((pFBuffer = (sfloat *) calloc(sizeFft+1, sizeof(sfloat))) == NULL) */
/* return -1; */
/* /\* convert from polar coordinates to rectangular *\/ */
diff --git a/sms/stocAnalysis.c b/sms/stocAnalysis.c
index 27d5e4b..d50df48 100644
--- a/sms/stocAnalysis.c
+++ b/sms/stocAnalysis.c
@@ -36,7 +36,7 @@ int sms_stocAnalysis ( int sizeWindow, sfloat *pResidual, sfloat *pWindow, SMS_D
{
int i;
sfloat fMag = 0.0;
- float fStocNorm;
+ sfloat fStocNorm;
static sfloat *pMagSpectrum;
static int sizeWindowStatic = 0;
diff --git a/sms/synthesis.c b/sms/synthesis.c
index fd882c3..bba506c 100644
--- a/sms/synthesis.c
+++ b/sms/synthesis.c
@@ -211,7 +211,7 @@ static int StocSynthApprox (SMS_Data *pSmsData, SMS_SynthParams *pSynthParams)
int sizeSpec1 = pSmsData->nCoeff;
int sizeSpec2 = pSynthParams->sizeHop;
int sizeFft = pSynthParams->sizeHop << 1; /* 50% overlap, so sizeFft is 2x sizeHop */
- float fStocGain;
+ sfloat fStocGain;
/* if no gain or no coefficients return */
if (*(pSmsData->pFStocGain) <= 0)
return 0;
diff --git a/sms/tables.c b/sms/tables.c
index 4366695..1802952 100644
--- a/sms/tables.c
+++ b/sms/tables.c
@@ -45,7 +45,7 @@ int sms_prepSine (int nTableSize)
register int i;
sfloat fTheta;
- if((sms_tab_sine = (sfloat *)malloc(nTableSize*sizeof(float))) == 0)
+ if((sms_tab_sine = (sfloat *)malloc(nTableSize*sizeof(sfloat))) == 0)
return (SMS_MALLOC);
fSineScale = (sfloat)(TWO_PI) / (sfloat)(nTableSize - 1);
fSineIncr = 1.0 / fSineScale;
@@ -110,7 +110,7 @@ int sms_prepSinc (int nTableSize)
sfloat fTheta = -4.0 * TWO_PI / N;
sfloat fThetaIncr = (8.0 * TWO_PI / N) / (nTableSize);
- if((sms_tab_sinc = (sfloat *) calloc (nTableSize, sizeof(float))) == 0)
+ if((sms_tab_sinc = (sfloat *) calloc (nTableSize, sizeof(sfloat))) == 0)
return (SMS_MALLOC);
for(i = 0; i < nTableSize; i++)