Skip to content

Commit

Permalink
Add device enumeration to PyAudioDeviceInputStream and PyAudioDeviceO…
Browse files Browse the repository at this point in the history
…utputStream
  • Loading branch information
romanroibu committed Nov 21, 2019
1 parent d4cac97 commit e1d5269
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions pupil_audio/pyaudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,20 @@ def sample_width(self):
with _pyaudio_session_context() as session:
return session.get_sample_size(self.format)

@staticmethod
def enumerate_devices():
return sorted(_pyaudio_inputs().values(), key=lambda x: x["index"])


class PyAudioDeviceOutputStream(OutputStreamWithCodec[str]):

def __init__(self):
raise NotImplementedError # TODO: Implement

@staticmethod
def enumerate_devices():
return sorted(_pyaudio_outputs().values(), key=lambda x: x["index"])


# PRIVATE

Expand Down Expand Up @@ -270,15 +278,3 @@ def _create_pyaudio_session():
def _destroy_pyaudio_session(session):
session.terminate()
logger.debug("PyAudio session destroyed")


if __name__ == "__main__":
print(f"Inputs:")
for name, info in _pyaudio_inputs().items():
print(f"\t{name}")
print(f"\t\t{info}")
print(f"------------------------------------------")
print(f"Outputs:")
for name, info in _pyaudio_outputs().items():
print(f"\t{name}")
print(f"\t\t{info}")

0 comments on commit e1d5269

Please sign in to comment.