瀏覽代碼

extend max pvoc fft size to 32768

richarddobson 2 月之前
父節點
當前提交
1cebee869b
共有 5 個文件被更改,包括 50 次插入6 次删除
  1. 1 1
      dev/cdparams_other/cdparams_other.c
  2. 1 1
      dev/include/pvoc.h
  3. 1 1
      dev/include/science.h
  4. 25 2
      dev/new/spectrum.c
  5. 22 1
      dev/science/specanal.c

+ 1 - 1
dev/cdparams_other/cdparams_other.c

@@ -7004,7 +7004,7 @@ int filetype,int linecnt,double duration,aplptr ap)
     case(SPEKLINE):
         if(mode == 0) {
             ap->lo[SPEKPOINTS]  = 2;
-            ap->hi[SPEKPOINTS]  = 16380;
+            ap->hi[SPEKPOINTS]  = 32768;  //RWD 2025 was 16380
             ap->lo[SPEKHARMS]   = 0;
             ap->hi[SPEKHARMS]   = 64;
             ap->lo[SPEKBRITE]   = -96;

+ 1 - 1
dev/include/pvoc.h

@@ -31,7 +31,7 @@
 #define DEFAULT_PVOC_CHANS      (1024)
 #define DEFAULT_WIN_OVERLAP     (3)
 #define VERY_BIG_INT            (100000000)
-#define MAX_PVOC_CHANS          (16380)
+#define MAX_PVOC_CHANS          (32768)   //RWD 2025 was 16380 
 #define PVOC_CONSTANT_A         (8.0)
 #define SAMP_TIME_STEP          (2000)
 

+ 1 - 1
dev/include/science.h

@@ -119,7 +119,7 @@
 
 #define PA_DEFAULT_PVOC_CHANS   (1024)
 #define PA_VERY_BIG_INT         (100000000)
-#define PA_MAX_PVOC_CHANS       (16380)
+#define PA_MAX_PVOC_CHANS       (32768)    //RWD 2025 was 16380
 #define PA_PVOC_CONSTANT_A      (8.0)
 
 #define FILTR_DUR   (0)

+ 25 - 2
dev/new/spectrum.c

@@ -154,6 +154,8 @@ static int speclines(dataptr dz);
 static int get_the_mode_from_cmdline(char *str,dataptr dz);
 static int speclinesfilt(dataptr dz);
 
+//RWD 2025 zero error checking - will already have been done!
+static int checkchans4format(int chans, const char* fname);
 /**************************************** MAIN *********************************************/
 
 int main(int argc,char *argv[])
@@ -784,12 +786,12 @@ int setup_spectrum_param_ranges_and_defaults(dataptr dz)
     // get_param_ranges()
     if(dz->process != SPEKLINE || dz->mode != 0) {
         ap->lo[SPEKPOINTS]    = 2;
-        ap->hi[SPEKPOINTS]    = 16380;        // CHANNEL CNT
+        ap->hi[SPEKPOINTS]    = 32768;        // CHANNEL CNT  // RWD 2025 was 16380
         ap->default_val[SPEKPOINTS]    = 2048;
     }
     if(dz->process == SPEKLINE && dz->mode == 0) {
         ap->lo[SPEKPOINTS]    = 2;
-        ap->hi[SPEKPOINTS]    = 16380;        // CHANNEL CNT
+        ap->hi[SPEKPOINTS]    = 32768;        // CHANNEL CNT  //RWD as above
         ap->default_val[SPEKPOINTS]    = 2048;
     }
     ap->lo[SPEKSRATE]    = 44100;
@@ -1394,6 +1396,13 @@ int check_spectrum_param_validity_and_consistency(int **perm,dataptr dz)
         sprintf(errstr,"ANALYSIS POINTS PARAMETER MUST BE A POWER OF TWO.\n");
         return(DATA_ERROR);
     }
+    //RWD 2025
+    if(checkchans4format(k,dz->outfilename) == 0) {
+        sprintf(errstr,"Requested analysis channel count %d > 8192: too large for .ana format\n",k);
+        return DATA_ERROR;
+    }
+    
+    
     if(dz->iparam[1] < 44100 || BAD_SR(dz->iparam[1])) {
         sprintf(errstr,"INVALID SAMPLE RATE ENTERED (44100,48000,88200,96000 only).\n");
         return(DATA_ERROR);
@@ -3067,3 +3076,17 @@ int speclinesfilt(dataptr dz)
     }
     return FINISHED;
 }
+//RWD 2025 zero error checking - will already have been done!
+static int checkchans4format(int chans, const char* fname)
+{
+    char *lastdot;
+    
+    lastdot = strrchr(fname,'.');
+    if(chans > 8192){
+        if((_stricmp(lastdot,".wav")==0)
+           || (_stricmp(lastdot,".ana")==0))
+            return 0;
+    }
+    
+    return 1;
+}

+ 22 - 1
dev/science/specanal.c

@@ -163,6 +163,8 @@ static int check_specanal_param_validity_and_consistency2(dataptr dz);
 static int get_tempered_hf(float *averages, float *averages2, float *averages3, dataptr dz);
 static int smooth_and_output_varying_hf(dataptr dz);
 static int rerange_outofrange_pitch(int strandindex,int eventindex,dataptr dz);
+//RWD 2025 trap oversize channel count for .ana format
+static int checkchans4format(int chans, const char* fname);
 
 /**************************************** MAIN *********************************************/
 
@@ -1137,6 +1139,11 @@ int check_specanal_param_validity_and_consistency(dataptr dz)
     dz->is_mapping = 0;
     (dz->iparam[SA_WINOVLP])--;
     dz->iparam[SA_CHANS] = dz->iparam[SA_CHANS] + (dz->iparam[SA_CHANS]%4); // Force number of chans to be divisible by 4 (FFT happens twice for cepstrum)
+    //RWD 2025
+    if(checkchans4format(dz->iparam[SA_CHANS],dz->outfilename) == 0) {
+        sprintf(errstr,"Requested analysis channel count %d > 8192: too large for .ana format\n",dz->iparam[SA_CHANS]);
+        return DATA_ERROR;
+    }
     dz->wanted = dz->iparam[SA_CHANS] + 2;
     if(dz->mode == SA_FORMANTS) {   
         if((exit_status = sa_initialise_specenv(dz)) < 0)
@@ -1320,7 +1327,7 @@ int usage2(char *str)
         "INF         A Mono soundfile.\n"
         "TXTOFIL(S)  (Generic) name for text output file(s).\n"
         "ANALOFIL    Analysis output file.\n"
-        "CHS         Number of analysis points : a multiple of 4 (4 - 16380).\n"
+        "CHS         Number of analysis points : a multiple of 4 (4 - 32768).\n"    //RWD 2025 was 16380
         "OVLP        analysis window overlap (1-4), for PVOC analysis.\n"
         "FBANDS      Number of formant peaks to find.\n"
         "-n          Normalise output display.\n"
@@ -4163,3 +4170,17 @@ int rerange_outofrange_pitch(int strandindex,int eventindex,dataptr dz)
     dz->parray[strandindex][pitchindex] = newpitch;
     return FINISHED;
 }
+//RWD 2025 zero error checking - will already have been done!
+static int checkchans4format(int chans, const char* fname)
+{
+    char *lastdot;
+    
+    lastdot = strrchr(fname,'.');
+    if(chans > 8192){
+        if((_stricmp(lastdot,".wav")==0)
+           || (_stricmp(lastdot,".ana")==0))
+            return 0;
+    }
+    
+    return 1;
+}