Show More
@@ -103,6 +103,11 b' class Audio(DisplayObject):' | |||||
103 | import struct |
|
103 | import struct | |
104 | from io import BytesIO |
|
104 | from io import BytesIO | |
105 | import wave |
|
105 | import wave | |
|
106 | try: | |||
|
107 | import numpy as np | |||
|
108 | data = np.array(data,dtype=float) | |||
|
109 | scaled = list(np.int16(data/np.max(np.abs(data))*32767)) | |||
|
110 | except ImportError: | |||
106 | maxabsvalue = float(max(map(abs,data))) |
|
111 | maxabsvalue = float(max(map(abs,data))) | |
107 | scaled = map(lambda x: int(x/maxabsvalue*32767), data) |
|
112 | scaled = map(lambda x: int(x/maxabsvalue*32767), data) | |
108 | fp = BytesIO() |
|
113 | fp = BytesIO() |
General Comments 0
You need to be logged in to leave comments.
Login now