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

Provide more information about unanticipated host errors #53

Open
sairus7 opened this issue Nov 26, 2020 · 5 comments
Open

Provide more information about unanticipated host errors #53

sairus7 opened this issue Nov 26, 2020 · 5 comments

Comments

@sairus7
Copy link

sairus7 commented Nov 26, 2020

Can't get sound stream from audio input (mic), tried on several machines running Windows 10:

using PortAudio
devices = PortAudio.devices()
for d in devices
    try
        stream = PortAudioStream(d.name, 2, 0) # same errors with 4, 0
        @show stream
    catch err
        @error err
    end
end

Any ideas?

@bramtayl
Copy link
Member

Hi @sairus7 can you give a bit more info here? What errors do you get? What devices do you have, and how many work?

@sairus7
Copy link
Author

sairus7 commented May 31, 2021

I have the same errors on different machines, for example:

julia> devices = PortAudio.devices()
10-element Vector{PortAudio.PortAudioDevice}:
 PortAudio.PortAudioDevice("Microsoft Sound Mapper - Input", "MME", 2, 0, 44100.0, 0, 0.09, 0.09, 0.18, 0.18)
 PortAudio.PortAudioDevice("Microphone (Realtek High Defini", "MME", 2, 0, 44100.0, 1, 0.09, 0.09, 0.18, 0.18)
 PortAudio.PortAudioDevice("Microsoft Sound Mapper - Output", "MME", 0, 2, 44100.0, 2, 0.09, 0.09, 0.18, 0.18)
 PortAudio.PortAudioDevice("Speakers (Realtek High Definiti", "MME", 0, 2, 44100.0, 3, 0.09, 0.09, 0.18, 0.18)
 PortAudio.PortAudioDevice("Realtek Digital Output (Realtek", "MME", 0, 2, 44100.0, 4, 0.09, 0.09, 0.18, 0.18)
 PortAudio.PortAudioDevice("Microphone (Realtek HD Audio Mic input)", "Windows WDM-KS", 2, 0, 48000.0, 5, 0.01, 0.01, 0.04, 0.04)
 PortAudio.PortAudioDevice("SPDIF Out (Realtek HDA SPDIF Out)", "Windows WDM-KS", 0, 2, 44100.0, 6, 0.01, 0.01, 0.04, 0.04)
 PortAudio.PortAudioDevice("Microphone Array (Realtek HD Audio Mic Array input)", "Windows WDM-KS", 4, 0, 48000.0, 7, 0.01, 0.01, 0.04, 0.04)
 PortAudio.PortAudioDevice("Stereo Mix (Realtek HD Audio Stereo input)", "Windows WDM-KS", 2, 0, 48000.0, 8, 0.01, 0.01, 0.04, 0.04)
 PortAudio.PortAudioDevice("Speakers (Realtek HD Audio output)", "Windows WDM-KS", 0, 2, 48000.0, 9, 0.01, 0.01, 0.04, 0.04)

julia> for d in devices
           try
               stream = PortAudioStream(d.name, 2, 0) # same errors with 4, 0
               @show stream
           catch err
               @error err
           end
       end
┌ Error: ErrorException("libportaudio: Can't write to an input only stream")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Can't write to an input only stream")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Unanticipated host error")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Unanticipated host error")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Unanticipated host error")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6

@sairus7
Copy link
Author

sairus7 commented May 31, 2021

At the same time I can get a couple of sink streams (speakers):

julia> for d in devices
           try
               stream = PortAudioStream(d.name, 0, 2)
               @show stream
           catch err
               @error err
           end
       end
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[4]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[4]:6
stream = PortAudioStream{Float32}
  Samplerate: 44100.0Hz

  2 channel sink: "Microsoft Sound Mapper - Output"
stream = PortAudioStream{Float32}
  Samplerate: 44100.0Hz

  2 channel sink: "Speakers (Realtek High Definiti"
stream = PortAudioStream{Float32}
  Samplerate: 44100.0Hz

  2 channel sink: "Realtek Digital Output (Realtek"
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[4]:6
┌ Error: ErrorException("libportaudio: Unanticipated host error")
└ @ Main REPL[4]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[4]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[4]:6
┌ Error: ErrorException("libportaudio: Unanticipated host error")
└ @ Main REPL[4]:6

@bramtayl
Copy link
Member

Hmm, well, the Invalid number of channels errors are expected. Several of your devices only support input or output channels. We could potentially throw this error earlier from julia.

The Can't write to an input only stream errors should have been fixed on master by 0187b49 . Maybe try again on master?

Not sure about the Unanticipated host errors though. libportaudio does provide a mechanism for gettting more information about unanticipated host errors, so we could potentially do that when these kind of errors are thrown.

@sairus7
Copy link
Author

sairus7 commented May 31, 2021

Yes, tried this on master and got at least two working input streams:

julia> for d in devices
           try
               stream = PortAudioStream(d.name, 2, 0) # same errors with 4, 0
               @show stream
           catch err
               @error err
           end
       end
stream = PortAudioStream{Float32}
  Samplerate: 44100.0Hz

  2 channel source: "Microsoft Sound Mapper - Input"
stream = PortAudioStream{Float32}
  Samplerate: 44100.0Hz

  2 channel source: "Microphone (Realtek High Defini"
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[7]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[7]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[7]:6
┌ Error: ErrorException("libportaudio: Unanticipated host error")
└ @ Main REPL[7]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[7]:6
┌ Error: ErrorException("libportaudio: Unanticipated host error")
└ @ Main REPL[7]:6
┌ Error: ErrorException("libportaudio: Unanticipated host error")
└ @ Main REPL[7]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[7]:6

julia> for d in devices
           try
               stream = PortAudioStream(d.name, 4, 0) # same errors with 4, 0
               @show stream
           catch err
               @error err
           end
       end
stream = PortAudioStream{Float32}
  Samplerate: 44100.0Hz

  4 channel source: "Microsoft Sound Mapper - Input"
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Unanticipated host error")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6
┌ Error: ErrorException("libportaudio: Invalid number of channels")
└ @ Main REPL[8]:6

@bramtayl bramtayl changed the title Read from audio input on Windows Provide more information about unanticipated host errors Jul 26, 2021
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

2 participants