Skip to content

Instantly share code, notes, and snippets.

@paramsen
Last active June 11, 2018 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paramsen/b7dc45a127194e3e92623fa38a99599d to your computer and use it in GitHub Desktop.
Save paramsen/b7dc45a127194e3e92623fa38a99599d to your computer and use it in GitHub Desktop.
Script that reads a file with raw pcm data in little endian float32 and prints the mean.
import sys
import numpy
import struct
f = sys.argv[1]
avg = lambda f: numpy.mean(numpy.absolute(numpy.fromfile(f, '<f4')), dtype=numpy.float64)
print('average of %s: %.16f' % (f, avg(f)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment