def writewav24(filename, rate, data):
 a32 = _np.asarray(data, dtype=_np.int32)
 if (a32.ndim == 1):
  a32.shape = (a32.shape + (1,))
 a8 = ((a32.reshape((a32.shape + (1,))) >> _np.array([0, 8, 16])) & 255)
 wavdata = a8.astype(_np.uint8).tostring()
 w = _wave.open(filename, 'wb')
 w.setnchannels(a32.shape[1])
 w.setsampwidth(3)
 w.setframerate(rate)
 w.writeframes(wavdata)
 w.close()

def writewav24 ( filename , rate , data ) : a32 = _np . asarray ( data , dtype = _np . int32 ) if ( a32 . ndim == 1 ) : a32 . shape = ( a32 . shape + ( 1 , ) ) a8 = ( ( a32 . reshape ( ( a32 . shape + ( 1 , ) ) ) >> _np . array ( [ 0 , 8 , 16 ] ) ) & 255 ) wavdata = a8 . astype ( _np . uint8 ) . tostring ( ) w = _wave . open ( filename , 'wb' ) w . setnchannels ( a32 . shape [ 1 ] ) w . setsampwidth ( 3 ) w . setframerate ( rate ) w . writeframes ( wavdata ) w . close ( )
create a 24 bit wav file .