inspectrum icon indicating copy to clipboard operation
inspectrum copied to clipboard

Support .wav files

Open samyk opened this issue 7 years ago • 3 comments

Feature request: It would be nice to be able to open .wav files straight into inspectrum.

samyk avatar Dec 19 '16 22:12 samyk

This gains additional value in the context of migrating from other tools, ie Baudline, which natively exports RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo

itdaniher avatar Feb 04 '17 21:02 itdaniher

import scipy.io.wavfile
import sys

filename = sys.argv[1]

fs1, y1 = scipy.io.wavfile.read(filename)

assert y1.dtype.name == 'int16'

stereo_to_complex = lambda a: a[0] + a[1]*1j
y1 = y1/65536.

y1 = stereo_to_complex(y1.T).astype('complex64')

filename = filename.replace('wav', 'cf32')

y1.tofile(str(fs1)+'.'+filename)

boring stack-overflow-derived solution that worked for me!

itdaniher avatar Feb 05 '17 03:02 itdaniher

Created pull request https://github.com/miek/inspectrum/pull/176 . Alternatively you can set the sampling depth manually:

inspectrum -f cs16 file.wav

reald avatar Nov 13 '20 14:11 reald