Skip to content

Instantly share code, notes, and snippets.

@ntrrgc
Created November 28, 2025 01:25
Show Gist options
  • Select an option

  • Save ntrrgc/c1dbbd193a7fd170f43ba4f9aeb13457 to your computer and use it in GitHub Desktop.

Select an option

Save ntrrgc/c1dbbd193a7fd170f43ba4f9aeb13457 to your computer and use it in GitHub Desktop.
Compute maximum PCM sample (scipy)
import timeit
import scipy.io.wavfile
t0 = timeit.default_timer()
_, samples = scipy.io.wavfile.read("test.wav")
for channel_ix, max_sample in enumerate(samples.max(axis=0)):
print(f"Channel {channel_ix} max: 0x{max_sample:x}")
t1 = timeit.default_timer()
print(f"Elapsed {(t1-t0)*1000:.3f}ms")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment