#!/usr/bin/env python3 """wavstat.py [window seconds] - per channel peak/RMS and, per window, RMS of each channel. Reads the float32 or int16 WAVs parec writes (audio_sink.sh record).""" import struct, sys import numpy as np def read_wav(path): d = open(path, 'rb').read() pos, fmt, data = 12, None, None while pos + 8 <= len(d): tag, size = d[pos:pos + 4], struct.unpack(' 2: n = int(float(sys.argv[2]) * rate) for i in range(0, len(a), n): w = a[i:i + n] print('%7.2f s ' % (i / rate) + ' '.join('%.4f' % v for v in np.sqrt((w ** 2).mean(0))))