Created
May 10, 2017 22:32
-
-
Save richtier/6b05b2bb3ceff20f3d9557227b8789c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import array | |
import struct | |
def float_to_16_bit_pcm(raw_floats): | |
floats = array.array('f', raw_floats) | |
samples = [sample * 32767 for sample in floats] | |
raw_ints = struct.pack("<%dh" % len(samples), *samples) | |
return raw_ints |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you