Show More
@@ -17,9 +17,10 b' class Audio(DisplayObject):' | |||
|
17 | 17 | |
|
18 | 18 | Parameters |
|
19 | 19 | ---------- |
|
20 | data : numpy array, unicode, str or bytes | |
|
20 | data : numpy array, list, unicode, str or bytes | |
|
21 | 21 | Can be a |
|
22 |
* Numpy 1d array containing the desired waveform (mono) |
|
|
22 | * Numpy 1d array containing the desired waveform (mono) | |
|
23 | * List of float or integer representing the waveform (mono) | |
|
23 | 24 | * String containing the filename |
|
24 | 25 | * Bytestring containing raw PCM data or |
|
25 | 26 | * URL pointing to a file on the web. |
@@ -109,8 +110,8 b' class Audio(DisplayObject):' | |||
|
109 | 110 | raise ValueError("encoding of stereo PCM signals are unsupported") |
|
110 | 111 | scaled = np.int16(data/np.max(np.abs(data))*32767).tolist() |
|
111 | 112 | except ImportError: |
|
112 | print("Numpy is required to encode PCM from an array") | |
|
113 | raise | |
|
113 | maxabsvalue = float(max([abs(x) for x in data])) | |
|
114 | scaled = [int(x/maxabsvalue*32767) for x in data] | |
|
114 | 115 | fp = BytesIO() |
|
115 | 116 | waveobj = wave.open(fp,mode='wb') |
|
116 | 117 | waveobj.setnchannels(1) |
General Comments 0
You need to be logged in to leave comments.
Login now