Copyright (C) Kevin Larke 2009-2020

This file is part of libcm.

libcm is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

libcm is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See the GNU General Public License distributed with the libcm package or look here: .

cmProcObj : Base class for all 'proc' objects.

// constants
  // semitones per octave (length of the chroma feature vector)
  kStPerOctave      = 12,  
  // count of bands in the equal loudness contour table
  // used for sone calc. (length of the sones feature vector)  
  kEqualLoudBandCnt = 15,
  kTonalSpaceDimCnt = 6

struct cmCtx_str; enum { kDynObjFl = 0x01 }; typedef struct { unsigned flags; cmErr_t err; struct cmCtx_str* ctx; } cmObj; void* _cmObjAlloc( void* p, const char* label, struct cmCtx_str* c, unsigned objByteCnt ); void _cmObjFree( void** pp, cmObj* op ); // Allocate, zero, and setup the embedded cmObj field for an empty object. #define cmObjAlloc( type, ctx, p ) (type*)(_cmObjAlloc(p,#type,ctx,sizeof(type))) // if pp is non-NULL then *pp is NULL on return //#define cmObjFree( pp ) _cmObjFree((void**)pp, pp==NULL ? NULL : (cmObj*)(*pp) ) #define cmObjFree( pp ) _cmObjFree( (void**)(pp), (cmObj*)(*(pp)) ) #define cmArgAssertRC (0x80000001) #define cmSystemErrorRC (0x80000002) // use strerror() to get the system error #define cmEofRC (0x80000003) #define cmSingularMtxRC (0x80000004) #define cmSubSysFailRC (0x80000005) #define cmInvalidArgRC (0x80000006)
// Macro to allow embedded objects to be freed without having to explicitely // define a pointer.
#define cmObjFreeStatic( func, type, ref ) do{ type* __p=&(ref); func(&__p); }while(0)
typedef struct cmCtx_str { cmObj obj; cmLHeapH_t lhH; cmSymTblH_t stH; } cmCtx; struct cmFeatFile; // set p to NULL to dynamically allocate the object cmCtx* cmCtxAlloc( cmCtx* p, cmRpt_t* rpt, cmLHeapH_t lhH, cmSymTblH_t stH ); cmRC_t cmCtxFree( cmCtx** pp ); cmRC_t cmCtxInit( cmCtx* c, cmRpt_t* rpt, cmLHeapH_t lhH, cmSymTblH_t stH ); cmRC_t cmCtxFinal( cmCtx* c ); cmRC_t cmCtxPrint( cmCtx* c, const char* fmt, ... ); // a runtime resource aquisition failed (e.g. file open failed, read failed, ... ) cmRC_t cmCtxRtCondition( cmObj* p, unsigned code, const char* fmt, ... ); // a cmRC_t cmCtxRtAssertFailed( cmObj* p, unsigned code, const char* fmt, ... );
typedef struct cmMtxFile { cmObj obj; cmChar_t* fn; FILE* fp; } cmMtxFile; // Create a text file and write a row of values on each call to cmMtxFileXXXExec(). cmMtxFile* cmMtxFileAlloc(cmCtx* c, cmMtxFile* p, const char* fn ); cmRC_t cmMtxFileFree( cmMtxFile** p ); cmRC_t cmMtxFileCreate( cmMtxFile* p, const char* fn ); cmRC_t cmMtxFileClose( cmMtxFile* p ); cmRC_t cmMtxFileFloatExec( cmMtxFile* p, const float* inPtr, unsigned inCnt, unsigned inStride ); cmRC_t cmMtxFileDoubleExec( cmMtxFile* p, const double* inPtr, unsigned inCnt, unsigned inStride ); cmRC_t cmMtxFileComplexExec( cmMtxFile* p, const cmComplexR_t* inPtr, unsigned inCnt, unsigned inStride ); #if CM_FLOAT_SMP==1 #define cmMtxFileSmpExec(f,p,n) cmMtxFileFloatExec((f),(p),(n),1) #define cmMtxFileSmpExecN(f,p,n,s) cmMtxFileFloatExec((f),(p),(n),(s)) #else #define cmMtxFileSmpExec(f,p,n) cmMtxFileDoubleExec((f),(p),(n),1) #define cmMtxFileSmpExecN(f,p,n,s) cmMtxFileDoubleExec((f),(p),(n),(s)) #endif #if CM_FLOAT_REAL==1 #define cmMtxFileRealExec(f,p,n) cmMtxFileFloatExec((f),(p),(n),1) #define cmMtxFileRealExecN(f,p,n,s) cmMtxFileFloatExec((f),(p),(n),(s)) #else #define cmMtxFileRealExec(f,p,n) cmMtxFileDoubleExec((f),(p),(n),1) #define cmMtxFileRealExecN(f,p,n,s) cmMtxFileDoubleExec((f),(p),(n),(s)) #endif