Feb-24-2017, 01:12 PM
Hi,
I am rather new to the whole python thing... that being said I have dabble in several areas of signal processing. I am an engineering student and had to do a few projects for my courses. The way these projects worked was pretty much always the same you took what your professor showed you in the lecture and altered it...
one of my problems is this: the examples from the lectures generally included a huge amount of "toolset" that just made everything work (I assume) so that you could focus on actually creating filters... What I am looking for is not a magical line of code that fixes everything... I want to understand what I am doing...
So... now I wanted to do a project of my own and from scratch... Nothing too complicated for now: Read in a .wav-file, make it mono (if applicable), reduce the bitdepth to 8 bit (maybe even less), write a new file. The signal related actions aren't really the problem... but I just cannot get my head around how python does things. At this point I am not even sure where my problem is...
So here is what I have so far:
I am rather new to the whole python thing... that being said I have dabble in several areas of signal processing. I am an engineering student and had to do a few projects for my courses. The way these projects worked was pretty much always the same you took what your professor showed you in the lecture and altered it...
one of my problems is this: the examples from the lectures generally included a huge amount of "toolset" that just made everything work (I assume) so that you could focus on actually creating filters... What I am looking for is not a magical line of code that fixes everything... I want to understand what I am doing...
So... now I wanted to do a project of my own and from scratch... Nothing too complicated for now: Read in a .wav-file, make it mono (if applicable), reduce the bitdepth to 8 bit (maybe even less), write a new file. The signal related actions aren't really the problem... but I just cannot get my head around how python does things. At this point I am not even sure where my problem is...
So here is what I have so far:
import numpy as np import time, wave, pyaudio import scipy.io.wavfile bitdepth = 8 input_file = "16AGR_The_Hunted_Percy(OUT).wav" channles = 0 stepsize = (1.0 - (-1.0))/(2**bitdepth) print "Reading file" original = scipy.io.wavfile.read(input_file) audio = original[1] print audioThis gives me this output:
Output:Reading file
[[-1 -2]
[ 1 1]
[-4 -3]
...,
[ 4 -2]
[-4 2]
[ 4 -1]]
So from what I have gathered scipy.io.wavfile.read returns a list with three objects the second of which should contain the audio data (in this case stereo). Since there are about 200k samples in the file the output does not show all of them.. fine.. but what is that? [-1 -2]? That is no audio sample I have ever seen... and all integers? I have no idea what I am seeing here... and at this point no idea where to look for answers...