Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

record from input and output devices simultaneously #52

Open
marinos123 opened this issue Aug 13, 2021 · 1 comment
Open

record from input and output devices simultaneously #52

marinos123 opened this issue Aug 13, 2021 · 1 comment

Comments

@marinos123
Copy link

Hello,
Is it possible to use input and output device simultaneously? I try the following but no luck:

    def callback(indata, outdata, frame_count, time_info, status):
        indata[:] = outdata
        loop.call_soon_threadsafe(input_queue.put_nowait, (bytes(indata), status))

    stream = sounddevice.RawStream(
        #device=3,
        channels=1,
        samplerate=16000,
        callback=callback,
        blocksize=1024 * 2,
        dtype="int16",
    )

i also try:

  • add 2 channels
  • set the input and out devices
  • assign output data to input data
@marinos123
Copy link
Author

hello guys

We have tested the script with varius devices. With Corsair HS45 Surround USB Sound Adapter i was able to capture sound from both microphone and speakers, but with HP X1000 Wireless Gaming Headsetwe are unable to get any data from speakers. Here is the script:

async def mic_stream():
    # This function wraps the raw input stream from the microphone forwarding
    # the blocks to an asyncio.Queue.
    loop = asyncio.get_event_loop()
    input_queue = asyncio.Queue()

    def callback(indata, frame_count, time_info, status):
        loop.call_soon_threadsafe(input_queue.put_nowait, (bytes(indata), status))

    stream = sounddevice.RawInputStream(
        #device=[1,25],
        channels=1,
        samplerate=16000,
        callback=callback,
        blocksize=1024 * 2,
        dtype="int16",
    )
    # Initiate the audio stream and asynchronously yield the audio chunks
    # as they become available.
    with stream:
        while True:
            indata, status = await input_queue.get()
            yield indata, status

and here are the settings from the devices:
Corsair HS45 Surround USB Sound Adapter

   0 Microsoft Sound Mapper - Input, MME (2 in, 0 out)
>  1 Headset Microphone (Corsair HS4, MME (2 in, 0 out)
   2 FrontMic (Realtek High Definiti, MME (2 in, 0 out)
   3 Microsoft Sound Mapper - Output, MME (0 in, 2 out)
<  4 Headset Earphone (Corsair HS45 , MME (0 in, 2 out)
   5 Realtek Digital Output (Realtek, MME (0 in, 2 out)
   6 Speakers (Realtek High Definiti, MME (0 in, 2 out)

2- HP X1000 Wireless Gaming Headset (Sound Research)

   0 Microsoft Sound Mapper - Input, MME (2 in, 0 out)
>  1 Headset Microphone (2- HP X1000, MME (2 in, 0 out)
   2 FrontMic (Realtek High Definiti, MME (2 in, 0 out)
   3 Microsoft Sound Mapper - Output, MME (0 in, 2 out)
<  4 Headset Earphone (2- HP X1000 W, MME (0 in, 2 out)
   5 Realtek Digital Output (Realtek, MME (0 in, 2 out)
   6 Speakers (Realtek High Definiti, MME (0 in, 2 out)   

Can anyone help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant