@@ -260,9 +260,7 @@ def get_waveform_data_ms(waveform, sample_rate, hop_length=16):
260260 # (samples / sample_rate) = seconds
261261 # (seconds * 1000) = milliseconds
262262 times_ms = (np .arange (len (bin_mins )) * hop_length ) / sample_rate * 1000
263- times_ms = np .around (times_ms ).astype (float )
264- bin_mins = np .around (bin_mins ).astype (float )
265- bin_maxs = np .around (bin_maxs ).astype (float )
263+ # Keep full precision for min/max (do not round to int; waveform is typically in [-1, 1])
266264 return [(float (t ), float (mn ), float (mx )) for t , mn , mx in zip (times_ms , bin_mins , bin_maxs )]
267265
268266
@@ -1761,10 +1759,15 @@ def compute_wrapper(
17611759 segments ['waveplot' ].append (segment_waveplot )
17621760 if segment_waves :
17631761 segment_waveplot = waveform_ms [start + trim_begin : start + trim_end ]
1764- # convert into JSON-serializable list of [time_ms, min_val, max_val]
1762+ segment_start_ms = (start + trim_begin ) * x_step_ms
1763+ # Segment-relative time (0 at segment start) and enough precision for amplitude
17651764 segment_waveplot = [
1766- [round (val , 3 ) for val in row ]
1767- for row in segment_waveplot
1765+ [
1766+ round (float (t_ms ) - segment_start_ms , 3 ), # time ms relative to segment
1767+ round (float (mn ), 6 ), # min amplitude (avoid rounding to 0)
1768+ round (float (mx ), 6 ), # max amplitude
1769+ ]
1770+ for t_ms , mn , mx in segment_waveplot
17681771 ]
17691772 metadata_waveplot = {
17701773 "waveplot" : segment_waveplot ,
0 commit comments