Skip to content
This repository was archived by the owner on Aug 11, 2026. It is now read-only.

Commit e140e51

Browse files
jon-myersclaude
andauthored
fix: preserve time_resolution in crop_frequency() and crop_time() (#54)
Both crop methods were not passing time_resolution to new SpectrogramData instances, causing them to fall back to DEFAULT_TIME_RESOLUTION (0.01508s) instead of the accurate value calculated from database duration (e.g. 0.015103s). This small discrepancy accumulates over long recordings, causing significant timing misalignment. For a 2192-second recording, the error reached ~0.15s. Now both methods preserve the parent spectrogram's time_resolution, ensuring accurate timing throughout the crop chain. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 49c75bd commit e140e51

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

idtap/spectrogram.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ def crop_frequency(self, min_hz: Optional[float] = None,
243243
cropped_data,
244244
self.audio_id,
245245
freq_range=(freq_bins[min_idx], freq_bins[max_idx - 1] if max_idx > min_idx else freq_bins[min_idx]),
246-
bins_per_octave=self.bins_per_octave
246+
bins_per_octave=self.bins_per_octave,
247+
time_resolution=self._time_resolution
247248
)
248249

249250
def crop_time(self, start_time: Optional[float] = None,
@@ -277,7 +278,8 @@ def crop_time(self, start_time: Optional[float] = None,
277278
cropped_data,
278279
self.audio_id,
279280
freq_range=self.freq_range,
280-
bins_per_octave=self.bins_per_octave
281+
bins_per_octave=self.bins_per_octave,
282+
time_resolution=self._time_resolution
281283
)
282284

283285
def get_extent(self) -> List[float]:

0 commit comments

Comments
 (0)