museumsvictoria / spatial_audio_server

An audio backend for the multi-layered soundscape of Beyond Perception: Seeing the Unseen, a permanent exhibition at Scienceworks in Melbourne, Australia.
82 stars 14 forks source link

Windows Runtime Error (Input Audio Device Format Unsupported) #60

Closed BlueJayLouche closed 6 years ago

BlueJayLouche commented 6 years ago

C:\Users\dmsadmin\build\beyond_perception_audio_server>cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.4 secs Runningtarget\debug\audio_server.exe thread 'main' panicked at 'calledOption::unwrap()on aNonevalue', src\libcore\option.rs:335:21 note: Run withRUST_BACKTRACE=1for a backtrace. Error while receiving OSC: other os error error: process didn't exit successfully:target\debug\audio_server.exe(exit code: 101)

freesig commented 6 years ago

Yep I'm also getting this error. This error happens when you don't have any inputs plugged into the computer.

However

Once one is plugged in I'm getting

no matching supported audio input formats for the target device

This is where it's happening in audio_server

   let audio_input_stream = app.audio
        .new_input_stream(audio_input_model, audio::input::capture)
        .sample_rate(audio::SAMPLE_RATE as u32)
        .frames_per_buffer(audio::FRAMES_PER_BUFFER)
        .channels(max_supported_input_channels)
        .device(input_device)
        .build()
        .unwrap();

which is calling this

 let format = super::find_best_matching_format(&device, sample_format, channels, sample_rate)?
            .expect("no matching supported audio input formats for the target device"); 

which is getting a Err from This function

mitchmindtree commented 6 years ago

Hey thanks for having a look into this @freesig! It might be easier to debug this by making a minimal simple_audio_input.rs example in nannou (by copying and modifying the template.rs example) first - just so we can verify all the format handling etc is happening properly with a simpler case? If you don't get a chance first I can get around to this in the next few days :+1:

Just checking, do the CPAL enumerate and record examples work on your windows machine? If not then there's probably something lower level to address first.

freesig commented 6 years ago

Ok going to give this a go now

freesig commented 6 years ago

Ok so this is basically happening because the wrong number of channels / sample rate is being called from audio server. But I'm not sure how we should handle this because once we have the asio backend then there will be enough channels and it wont panic. But maybe you don't want to panic because there's less channels?

Another thing I noticed is find_best_matching_format makes calls to default_output_format() and supported_output_formats() even when it's called from the input builder. This isn't a problem if they are matching but if the input is different from the output or one is not available then it will panic.

Suggestions

I think wrong channels could be handled better even if it's more information to the person who is trying to run the audio server. Might be worth making issues for this and the output input mix up. But I think getting the asio backend working is more important right now because otherwise there won't be enough channels anyway.

mitchmindtree commented 6 years ago

Great spot on this bug! I've made a patch here. I'm going to publish a new version of nannou with the patch along with the recent graphics module additions (geom, geom::graph, mesh, draw) tonight.

BlueJayLouche commented 6 years ago

Hey @mitchmindtree, I've just tried your updates on a local PC and I'm getting this on the RUST_BACKTRACE=1

C:\Users\dmsadmin\build\beyond_perception_audio_server\target\debug>audio_server.exe thread 'main' panicked at 'called Option::unwrap() on a None value', src\libcore\option.rs:335:21 stack backtrace: 0: std::sys::windows::backtrace::unwind_backtrace at C:\projects\rust\src\libstd\sys\windows\backtrace\mod.rs:65 1: std::sys_common::backtrace::print at C:\projects\rust\src\libstd\sys_common\backtrace.rs:56 2: std::panicking::default_hook::{{closure}} at C:\projects\rust\src\libstd\panicking.rs:381 3: std::panicking::default_hook at C:\projects\rust\src\libstd\panicking.rs:397 4: std::panicking::rust_panic_with_hook at C:\projects\rust\src\libstd\panicking.rs:577 5: std::panicking::begin_panic at C:\projects\rust\src\libstd\panicking.rs:538 6: std::panicking::begin_panic_fmt at C:\projects\rust\src\libstd\panicking.rs:522 7: std::panicking::rust_begin_panic at C:\projects\rust\src\libstd\panicking.rs:498 8: core::panicking::panic_fmt at C:\projects\rust\src\libcore\panicking.rs:71 9: core::panicking::panic at C:\projects\rust\src\libcore\panicking.rs:51 10: core::option::Option::unwrap at C:\projects\rust\src\libcore\macros.rs:20 11: audio_server::model at C:\Users\dmsadmin\build\beyond_perception_audio_server\src\lib\lib.rs:85 12: nannou::Builder<audio_server::Model, nannou::event::Event>::run<audio_server::Model,nannou::event::Event> at C:\Users\dmsadmin.cargo\git\checkouts\nannou-e23af9ed3049bd88\aea4dfd\src\lib.rs:142 13: audio_server::run at C:\Users\dmsadmin\build\beyond_perception_audio_server\src\lib\lib.rs:40 14: audio_server::main at C:\Users\dmsadmin\build\beyond_perception_audio_server\src\bin\main.rs:4 15: std::rt::lang_start::{{closure}}<()> at C:\projects\rust\src\libstd\rt.rs:74 16: std::panicking::try::do_call<closure,i32> at C:\projects\rust\src\libstd\panicking.rs:476 17: panic_unwind::__rust_maybe_catch_panic at C:\projects\rust\src\libpanic_unwind\lib.rs:101 18: std::rt::lang_start_internal at C:\projects\rust\src\libstd\rt.rs:50 19: std::rt::lang_start<()> at C:\projects\rust\src\libstd\rt.rs:74 20: main 21: __scrt_common_main_seh at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283 22: BaseThreadInitThunk Error while receiving OSC: other os error

Hope this information is helpful.

mitchmindtree commented 6 years ago

Hey andrew, thanks for that!

It's complaining that there is no default input device availble on the system (it expects one for realtime input sources). Do you have any available on the system? E.g. a mic or something like soundflower?

If I get a chance I'll change the behaviour to allow for having no input streams so the user can still test WAV sources, but i'll leave this till after the soundscape etc is finished. For now I've added a clearer error message for when this occurs.

BlueJayLouche commented 6 years ago

That’s odd because I had the Dante Virtual Soundcard running, and it has inputs.

On Fri, 6 Apr 2018 at 15:32, mitchmindtree notifications@github.com wrote:

Hey andrew, thanks for that!

It's complaining that there is no default input device availble on the system (it expects one for realtime input sources). Do you have any available on the system? E.g. a mic or something like soundflower?

If I get a chance I'll change the behaviour to allow for having no input streams so the user can still test WAV sources, but i'll leave this till after the soundscape etc is finished. For now I've added a clearer error message for when this occurs.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mitchmindtree/beyond_perception_audio_server/issues/60#issuecomment-379152525, or mute the thread https://github.com/notifications/unsubscribe-auth/AIPI7VtQXGYD54oYfYvk6AJalFJxe9uuks5tlv3fgaJpZM4Snz5I .

freesig commented 6 years ago

Was Dante in wdm mode or ASIO mode?

BlueJayLouche commented 6 years ago

That issue was in asio.

I got the server to launch this morning using WDM, but it just had the white screen. Tried to run a backtrace, but got no data. I'll have another crack

On 9 April 2018 at 09:02, Tom notifications@github.com wrote:

Was Dante in wdm mode or ASIO mode?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mitchmindtree/beyond_perception_audio_server/issues/60#issuecomment-379589942, or mute the thread https://github.com/notifications/unsubscribe-auth/AIPI7UefQs8BHbgrc8g4hBByvnmswzMVks5tmpcDgaJpZM4Snz5I .

freesig commented 6 years ago

Yep currently there isn't supported for ASIO but I'm working on it.

mitchmindtree commented 6 years ago

Gonna close this as I think most of this should be fixed by now and the rest is addressed by #52.