@@ -93,7 +93,7 @@ class W_Spectrogram extends Widget {
9393 // Note that these 3 dropdowns correspond to the 3 global functions below
9494 // You just need to make sure the "id" (the 1st String) has the same name as the corresponding function
9595 addDropdown(" SpectrogramMaxFreq" , " Max Freq" , Arrays . asList(settings. spectMaxFrqArray), settings. spectMaxFrqSave);
96- addDropdown(" SpectrogramSampleRate" , " Samples " , Arrays . asList(settings. spectSampleRateArray), settings. spectSampleRateSave);
96+ addDropdown(" SpectrogramSampleRate" , " Window " , Arrays . asList(settings. spectSampleRateArray), settings. spectSampleRateSave);
9797 addDropdown(" SpectrogramLogLin" , " Log/Lin" , Arrays . asList(settings. fftLogLinArray), settings. spectLogLinSave);
9898
9999 // Resize the height of the data image using default
@@ -334,20 +334,27 @@ class W_Spectrogram extends Widget {
334334
335335 void drawColorScaleReference () {
336336 int colorScaleHeight = 128 ;
337+ // Dynamically scale the Log/Lin amplitude-to-color reference line. If it won't fit, don't draw it.
338+ if (graphH < colorScaleHeight) {
339+ colorScaleHeight = int (h * 1 / 2 );
340+ if (colorScaleHeight > graphH) {
341+ return ;
342+ }
343+ }
337344 pushStyle ();
338345 // draw color scale reference to the right of the spectrogram
339346 for (int i = 0 ; i < colorScaleHeight; i++ ) {
340- float hueValue = hueLimit - map (i * 2 , 0 , 256 , 0 , hueLimit);
347+ float hueValue = hueLimit - map (i * 2 , 0 , colorScaleHeight * 2 , 0 , hueLimit);
341348 if (settings. spectLogLinSave == 0 ) {
342349 hueValue = map (log (hueValue) / log (10 ), 0 , 2 , 0 , hueLimit);
343350 }
344351 // println(hueValue);
345352 // colorMode is HSB, the range for hue is 256, for saturation is 100, brightness is 100.
346353 colorMode (HSB , 256 , 100 , 100 );
347354 // color for stroke is specified as hue, saturation, brightness.
348- stroke (int (hueValue), 100 , 80 );
355+ stroke (ceil (hueValue), 100 , 80 );
349356 strokeWeight (10 );
350- point (x + w - paddingRight/ 2 + 1 , y + paddingTop + midLineY - colorScaleHeight/ 3 - 14 - i);
357+ point (x + w - paddingRight/ 2 + 1 , midLineY + colorScaleHeight/ 2 - i);
351358 }
352359 popStyle ();
353360 }
0 commit comments