Its probably not the best solution, but im sure it will work. Maybe you find existing libs or so for some steps, i dont know for python. The steps I suggest are:
- Load the wave file.
- Create the sample values (amplitude) for each frame (depending on frame size, litte/big endian, signed/unsigned).
- Divide the resulting array of int values into windows, e.g. sample 0-511, 512-1023, ...
- Perform the window function, for the windows that you want to join.
- Do your joining.
- Store the windows back in a byte array, the inverse operation of the first stepp.
Old Post: You have to calculate the sample value, in java a function for a 2byte/frame soundfile would look like this:
public static int createIntFrom16( byte _8Bit1, byte _8Bit2 ) {
return ( 8Bit1<<8 ) | ( 8Bit2 &0x00FF );
}
Normaly you will have to care about weather or not the file uses little endian, I don't know if the phython lib will take this into account.
Once you have created all sample values, you have to divide your file into windows, e.g. of size 512 samples. Then you can window the values, and create back the byte values. For 16bit it would look like this:
public static byte[] createBytesFromInt(int i) {
byte[] bytes = new byte[2];
bytes[0]=(byte)(i>>8);
bytes[1]=(byte)i;
return bytes;
}
InsertNickHere
2010-06-16 06:58:57