refactor: split spectrogram.c into per-concern modules

spectrogram.c was ~2950 lines holding everything. Break it into cohesive
translation units; spectrogram.c keeps only globals + the main frame loop.

New modules:
- spectrogram_types.h  shared types, constants, extern globals, inline math
- fft.c/.h             FFT, bit-reverse, twiddle (standalone, no app deps)
- stft.c/.h            STFT compute, adaptive resolution, FFT-size LRU cache
- audio.c/.h           WAV/ffmpeg load, FreeSignal, bandpass, playback
- render.c/.h          UI scaling, colormaps, texture gen, on-screen drawing
- ui.c/.h              file browser, sidebar, sliders, PNG export

Also:
- utils.c now includes utils.h instead of re-typedef'ing AudioSignal/
  SignalStats (they had to be hand-synced before).
- Remove dead code: ApplyHannWindow and ComputeSTFTHighResRange were never
  called (the live high-res path is ComputeNextHighResChunk).
- Delete the unused raylib-template main.c.
- rspektrum.make: build the new units. premake5.lua: glob src/**.c so a
  future regen stays correct.

Pure code movement otherwise; no behavior change. Builds clean (-Wshadow).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 01:15:51 -07:00
parent ebe35bcd95
commit 3a8f20b783
16 changed files with 2038 additions and 2043 deletions
+30
View File
@@ -119,10 +119,20 @@ GENERATED :=
OBJECTS :=
GENERATED += $(OBJDIR)/spectrogram.o
GENERATED += $(OBJDIR)/fft.o
GENERATED += $(OBJDIR)/stft.o
GENERATED += $(OBJDIR)/audio.o
GENERATED += $(OBJDIR)/render.o
GENERATED += $(OBJDIR)/ui.o
GENERATED += $(OBJDIR)/platform_linux.o
GENERATED += $(OBJDIR)/utils.o
GENERATED += $(OBJDIR)/primitives.o
OBJECTS += $(OBJDIR)/spectrogram.o
OBJECTS += $(OBJDIR)/fft.o
OBJECTS += $(OBJDIR)/stft.o
OBJECTS += $(OBJDIR)/audio.o
OBJECTS += $(OBJDIR)/render.o
OBJECTS += $(OBJDIR)/ui.o
OBJECTS += $(OBJDIR)/platform_linux.o
OBJECTS += $(OBJDIR)/utils.o
OBJECTS += $(OBJDIR)/primitives.o
@@ -193,6 +203,26 @@ $(OBJDIR)/spectrogram.o: src/spectrogram.c
@echo "$(notdir $<)"
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/fft.o: src/fft.c
@echo "$(notdir $<)"
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/stft.o: src/stft.c
@echo "$(notdir $<)"
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/audio.o: src/audio.c
@echo "$(notdir $<)"
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/render.o: src/render.c
@echo "$(notdir $<)"
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/ui.o: src/ui.c
@echo "$(notdir $<)"
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/platform_linux.o: src/platform_linux.c
@echo "$(notdir $<)"
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"