diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-10-13 11:30:30 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-10-13 11:30:30 +0100 |
| commit | 6f23b55a7783f93549115a133ca2e6e938bd0cd1 (patch) | |
| tree | 6c674d088eb37dd9d91992366cfa6ddb3e0e69e5 /hacks | |
| parent | f9068dcbfbb09082e29e2a779ef1a7a2f6ee849e (diff) | |
Some attempts to block referencing of DCPs when it is not possible.
Diffstat (limited to 'hacks')
| -rw-r--r-- | hacks/fft.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/hacks/fft.py b/hacks/fft.py new file mode 100644 index 000000000..ab700a5ec --- /dev/null +++ b/hacks/fft.py @@ -0,0 +1,50 @@ +#!/usr/bin/python + +import wave +import sys +import struct +from pylab import * +import numpy + +f = wave.open(sys.argv[1], 'rb') +width = f.getsampwidth() +peak = pow(2, width * 8) / 2 +channels = f.getnchannels() +frames = f.getnframes() +print '%d bytes per sample' % width +print '%d channels' % channels +print '%d frames' % frames +data = [] +for i in range(0, channels): + data.append([]) + +for i in range(0, frames): + frame = f.readframes(1) + for j in range(0, channels): + v = 0 + for k in range(0, width): + v |= ord(frame[j * width + k]) << (k * 8) + if v >= peak: + v = v - 2 * peak + data[j].append(v) + +f.close() + +names = ['L', 'R', 'C', 'Lfe', 'Ls', 'Rs'] +dyn_range = 20 * log10(pow(2, 23)) + +for i in range(0, channels): + s = numpy.fft.fft(data[i]) +# subplot(channels, 1, i + 1) + # 138.5 is a fudge factor: + semilogx(arange(0, frames / 2, 0.5), 20 * log10(abs(s) + 0.1) - dyn_range, label = names[i]) + xlim(100, frames / 4) +plt.gca().xaxis.grid(True, which='major') +plt.gca().xaxis.grid(True, which='minor') +plt.gca().yaxis.grid(True) +legend(loc = 'lower right') +show() + +#plot(abs(numpy.fft.fft(data[0]))) +#plot(data[0]) +#show() |
