this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

restore old FFT

alice 1f394434 6da9543f

+19 -12
+4
CLAUDE.md
··· 10 10 11 11 **IMPORTANT: Never run `./debug-macos.sh` or any build commands unless explicitly instructed by the user. The user will handle building and testing.** 12 12 13 + **IMPORTANT:** When given permission to build and test, use **THIS EXACT COMMAND**: ./debug-macos.sh -p -h -s 14 + 15 + You will find the build output in `build/bin/tic80`. 16 + 13 17 ### macOS 14 18 ```bash 15 19 # Recommended: Use the debug script
+1 -1
src/cqtdata.h
··· 4 4 #define CQT_BINS 120 5 5 #define CQT_OCTAVES 10 6 6 #define CQT_BINS_PER_OCTAVE 12 7 - #define CQT_FFT_SIZE 16384 // 16K FFT - excellent low-frequency resolution with minimal performance impact 7 + #define CQT_FFT_SIZE 8192 // 8K FFT - balanced time/frequency resolution, ~5.4 fps update rate 8 8 9 9 // CQT frequency range 10 10 #define CQT_MIN_FREQ 20.0f // Sub-bass for electronic music
+2 -1
src/ext/cqt.c
··· 218 218 } 219 219 220 220 // Copy audio data from the shared buffer 221 - // TEMPORARY: sampleBuf now has FFT_SIZE * 2 = 2048 * 2 = 4096 samples 221 + // sampleBuf is defined in fft.c as extern 222 + extern float sampleBuf[]; 222 223 memcpy(cqtAudioBuffer, sampleBuf, CQT_FFT_SIZE * sizeof(float)); 223 224 224 225 // Check if we have any audio data
+11 -6
src/ext/fft.c
··· 19 19 kiss_fftr_cfg fftcfg; 20 20 ma_context context; 21 21 ma_device captureDevice; 22 - float sampleBuf[FFT_SIZE * 2]; 22 + // Include CQT header to get CQT_FFT_SIZE 23 + #include "../cqtdata.h" 24 + 25 + // Shared audio buffer - must be large enough for both FFT and CQT 26 + // FFT needs FFT_SIZE * 2 (2048) samples, CQT needs CQT_FFT_SIZE samples 27 + #define AUDIO_BUFFER_SIZE (CQT_FFT_SIZE > (FFT_SIZE * 2) ? CQT_FFT_SIZE : (FFT_SIZE * 2)) 28 + float sampleBuf[AUDIO_BUFFER_SIZE]; 23 29 24 30 void miniaudioLogCallback(void* userData, ma_uint32 level, const char* message) 25 31 { ··· 47 53 48 54 void OnReceiveFrames(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) 49 55 { 50 - frameCount = frameCount < FFT_SIZE * 2 ? frameCount : FFT_SIZE * 2; 56 + frameCount = frameCount < AUDIO_BUFFER_SIZE ? frameCount : AUDIO_BUFFER_SIZE; 51 57 52 58 // Just rotate the buffer; copy existing, append new 53 59 const float* samples = (const float*)pInput; 54 60 float* p = sampleBuf; 55 - for (int i = 0; i < FFT_SIZE * 2 - frameCount; i++) 61 + for (int i = 0; i < AUDIO_BUFFER_SIZE - frameCount; i++) 56 62 { 57 63 *(p++) = sampleBuf[i + frameCount]; 58 64 } ··· 184 190 return true; 185 191 #else 186 192 187 - memset(sampleBuf, 0, sizeof(float) * FFT_SIZE * 2); 193 + memset(sampleBuf, 0, sizeof(float) * AUDIO_BUFFER_SIZE); 188 194 189 - // TEMPORARY: Using 4096-point FFT to support CQT 190 - // TODO: Restore to 2048 and implement separate buffer for CQT 195 + // FFT uses 2048-point FFT as originally intended 191 196 fftcfg = kiss_fftr_alloc(FFT_SIZE * 2, false, NULL, NULL); 192 197 193 198 ma_context_config context_config = ma_context_config_init();
+1 -4
src/fftdata.h
··· 1 1 #pragma once 2 2 #include <stdbool.h> 3 - // TEMPORARY: Changed from 1024 to 8192 to support CQT's 16384-point FFT 4 - // This breaks FFT bin resolution but enables CQT to work properly 5 - // TODO: Restore to 1024 and implement separate buffer for CQT 6 - #define FFT_SIZE 8192 3 + #define FFT_SIZE 1024 7 4 extern float fPeakMinValue; 8 5 extern float fPeakSmoothing; 9 6 extern float fPeakSmoothValue;