Skip to content

Commit 6870ad3

Browse files
jon-myersclaude
andauthored
fix: flip spectrogram frequency axis to match freq_bins ordering (#53)
The server data has row 0 = highest frequency, but freq_bins property calculates assuming row 0 = lowest frequency. This caused frequency cropping to select the wrong portion of the spectrum (e.g., requesting 200-400 Hz would actually return high frequencies like 2000-2400 Hz). Now flip the data immediately after loading in from_audio_id() so: - Row 0 = lowest frequency (matching freq_bins[0]) - Row -1 = highest frequency (matching freq_bins[-1]) This fixes frequency alignment between spectrograms and pitch contours in visualization contexts. Note: Visualizations using this API should remove any flipud() calls they were using to work around this issue. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2588367 commit 6870ad3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

idtap/spectrogram.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ def from_audio_id(cls, audio_id: str, client: Optional['SwaraClient'] = None) ->
111111
shape = tuple(metadata['shape']) # [freq_bins, time_frames]
112112
data = np.frombuffer(decompressed, dtype=np.uint8).reshape(shape)
113113

114+
# Flip frequency axis so row 0 = lowest frequency (matches freq_bins ordering)
115+
# Server data has row 0 = highest frequency, but we want row 0 = lowest
116+
data = np.flipud(data)
117+
114118
# Get exact audio duration from recording database
115119
time_resolution = None
116120
try:

0 commit comments

Comments
 (0)