Python alsaaudio.PCM_FORMAT_S32_LE Examples
The following are 1
code examples of alsaaudio.PCM_FORMAT_S32_LE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
alsaaudio
, or try the search function
.
Example #1
Source File: main.py From AlexaChipDEPRECATED with MIT License | 6 votes |
def play(f): device = alsaaudio.PCM() device.setchannels(f.getnchannels()) device.setrate(f.getframerate()) if f.getsampwidth() == 1: device.setformat(alsaaudio.PCM_FORMAT_U8) # Otherwise we assume signed data, little endian elif f.getsampwidth() == 2: device.setformat(alsaaudio.PCM_FORMAT_S16_LE) elif f.getsampwidth() == 3: device.setformat(alsaaudio.PCM_FORMAT_S24_LE) elif f.getsampwidth() == 4: device.setformat(alsaaudio.PCM_FORMAT_S32_LE) else: raise ValueError('Unsupported format') device.setperiodsize(320) data = f.readframes(320) while data: # Read data from stdin device.write(data) data = f.readframes(320)