sonic-pi-net / sonic-pi

Code. Music. Live.
https://sonic-pi.net
Other
10.74k stars 918 forks source link

Sonic Pi boot error when using audio interface for output #2725

Closed owenstranathan closed 2 years ago

owenstranathan commented 3 years ago

Hello hard-working maintainers, First I'd like you to know just how much I appreciate Sonic-Pi. It's really freakin' sweet. Second I have an issue (no duh) I just purchased a Behringer U-PHORIA UMC202HD audio interface so I could record my analog synth and use the samples in sonic pi. (link to the interface: https://www.amazon.com/gp/product/B00QHURUBE/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1) One cool thing about the interface is I can plug headphones into it and hear my PC audio through it while I directly monitor the synth output. I'd hoped I could just run some sonic-pi code in the background over the interface and doodle on the synth, free form, but... When I have the sound output set to the audio interface sonic pi will not start. 😢

You can see the error below under Scsynth Output:

...
Booting with:
  In: MME : Microphone (UMC202HD 192k)
  Out: MME : Speakers (UMC202HD 192k)
SC_PortAudioDriver: PortAudio failed at Pa_OpenStream with error: 'Unanticipated host error'
could not initialize audio.

Alone you wouldn't think that was the issue but if I change my output device then the program starts and works as expected. I couldn't find any issues that seemed to relate to this (it's a pretty dang specific issue). Are there any known driver compatibility issues with Sonic Pi and this specific audio interface?

Thanks in advance!

Sonic Pi Boot Error Report

System Information

GUI Log

C:\Users\owen\.sonic-pi\log\gui.log

[GUI] -                            
[GUI] -                            
[GUI] -                            
[GUI] - Welcome to the Sonic Pi GUI
[GUI] - ===========================
[GUI] -                            
[GUI] - {4aa336ca-de2c-4b80-99b7-03cbb8a66894}
[GUI] - ui locale:  en-US
[GUI] - sys locale: en_US
[GUI] - translations available 
[GUI] - Discovering port numbers...
[GUI] - Port entry server-listen-to-gui : 51235 : 51235
[GUI] - Port entry gui-send-to-server : 51235 : 51235
[GUI] - Port entry gui-listen-to-server : 51236 : 51236
[GUI] - Port entry server-send-to-gui : 51236 : 51236
[GUI] - Port entry scsynth : 51237 : 51237
[GUI] - Port entry scsynth-send : 51237 : 51237
[GUI] - Port entry server-osc-cues : 4560 : 4560
[GUI] - Port entry erlang-router : 51238 : 51238
[GUI] - Port entry websocket : 51239 : 51239
[GUI] - Detecting port numbers...
[GUI] - GUI listen to server port 51236
[GUI] -    port: 51236 [OK]
[GUI] - Server listen to gui port 51235
[GUI] -    port: 51235 [OK]
[GUI] - Server incoming OSC cues port 4560
[GUI] -    port: 4560 [OK]
[GUI] - Scsynth port 51237
[GUI] -    port: 51237 [OK]
[GUI] - Server send to GUI port 51236
[GUI] -    port: 51236 [OK]
[GUI] - GUI send to server port 51235
[GUI] -    port: 51235 [OK]
[GUI] - Scsynth send port 51237
[GUI] -    port: 51237 [OK]
[GUI] - Erlang router port 51238
[GUI] -    port: 51238 [OK]
[GUI] - Websocket port 51239
[GUI] -    port: 51239 [OK]
[GUI] - All ports OK
[GUI] - hiding main window
[GUI] - initialising toolbar icons
[GUI] - setting up window structure
[GUI] - restoring scope states 
[GUI] - creating status bar
[GUI] - creating info panel
[GUI] - creating shortcuts
[GUI] - creating tool bar
[GUI] - initialising documentation window
[GUI] - launching Sonic Pi Runtime Server:
[GUI] - starting UDP OSC Server on port 51236...
[GUI] - UDP OSC Server ready and listening
[GUI] - Ruby server pid registered: 9388
[GUI] - wait for sync
[GUI] - waiting for Sonic Pi Server to boot...
............................................................
[GUI] - Critical error! Could not boot Sonic Pi Server.
[GUI] - stopping UDP OSC Server...
[GUI] - Critical Error. Unable to connect to server..
[GUI] - UDP OSC Server no longer listening

Server Errors

C:\Users\owen\.sonic-pi\log\server-errors.log

Server Output

C:\Users\owen\.sonic-pi\log\server-output.log

Sonic Pi server booting...
The time is 2021-03-10 21:43:38 -0600
Using primary protocol: udp
Detecting port numbers...
Listen port: 51235
  - OK
Scsynth port: 51237
  - OK
Scsynth send port: 51237
  - OK
OSC cues port: 4560
  - OK
Erlang port: 51238
  - OK
Websocket port: 4562
  - OK
Opening UDP Server to listen to GUI on port: 51235
ERROR: Unable to write information for PID 12744 to path C:/Users/owen/AppData/Local/Temp/sonic-pi-pids/12744!
undefined method `cmdline' for nil:NilClass

Scsynth Output

C:\Users\owen\.sonic-pi\log\scsynth.log

# Starting SuperCollider 2021-03-10 21:43:38

Device options:
  - MME : Microsoft Sound Mapper - Input   (device #0 with 2 ins 0 outs)
  - MME : Microphone (UMC202HD 192k)   (device #1 with 2 ins 0 outs)
  - MME : Microphone (HD Webcam C270)   (device #2 with 1 ins 0 outs)
  - MME : Microphone (High Definition Aud   (device #3 with 2 ins 0 outs)
  - MME : Microsoft Sound Mapper - Output   (device #4 with 0 ins 2 outs)
  - MME : Speakers (UMC202HD 192k)   (device #5 with 0 ins 2 outs)
  - MME : Speakers (High Definition Audio   (device #6 with 0 ins 2 outs)
  - MME : 4 - VS248 (AMD High Definition    (device #7 with 0 ins 2 outs)
  - Windows DirectSound : Primary Sound Capture Driver   (device #8 with 2 ins 0 outs)
  - Windows DirectSound : Microphone (UMC202HD 192k)   (device #9 with 2 ins 0 outs)
  - Windows DirectSound : Microphone (HD Webcam C270)   (device #10 with 1 ins 0 outs)
  - Windows DirectSound : Microphone (High Definition Audio Device)   (device #11 with 2 ins 0 outs)
  - Windows DirectSound : Primary Sound Driver   (device #12 with 0 ins 2 outs)
  - Windows DirectSound : Speakers (UMC202HD 192k)   (device #13 with 0 ins 2 outs)
  - Windows DirectSound : Speakers (High Definition Audio Device)   (device #14 with 0 ins 2 outs)
  - Windows DirectSound : 4 - VS248 (AMD High Definition Audio Device)   (device #15 with 0 ins 2 outs)
  - Windows WASAPI : Speakers (High Definition Audio Device)   (device #16 with 0 ins 2 outs)
  - Windows WASAPI : Speakers (UMC202HD 192k)   (device #17 with 0 ins 2 outs)
  - Windows WASAPI : 4 - VS248 (AMD High Definition Audio Device)   (device #18 with 0 ins 2 outs)
  - Windows WASAPI : Microphone (HD Webcam C270)   (device #19 with 1 ins 0 outs)
  - Windows WASAPI : Microphone (UMC202HD 192k)   (device #20 with 2 ins 0 outs)
  - Windows WASAPI : Microphone (High Definition Audio Device)   (device #21 with 2 ins 0 outs)
  - Windows WDM-KS : Output (AMD HD Audio HDMI out #3)   (device #22 with 0 ins 2 outs)
  - Windows WDM-KS : Headset Earphone (@System32\drivers\bthhfenum.sys,#2;%1 Hands-Free AG Audio%0

;(Bose Mini II SoundLink))   (device #23 with 0 ins 1 outs)
  - Windows WDM-KS : Headset Microphone (@System32\drivers\bthhfenum.sys,#2;%1 Hands-Free AG Audio%0

;(Bose Mini II SoundLink))   (device #24 with 1 ins 0 outs)
  - Windows WDM-KS : Headset (@System32\drivers\bthhfenum.sys,#2;%1 Hands-Free AG Audio%0

;(Bose QC35 II))   (device #25 with 0 ins 1 outs)
  - Windows WDM-KS : Headset (@System32\drivers\bthhfenum.sys,#2;%1 Hands-Free AG Audio%0

;(Bose QC35 II))   (device #26 with 1 ins 0 outs)
  - Windows WDM-KS : Microphone (HD Audio Mixed capture)   (device #27 with 2 ins 0 outs)
  - Windows WDM-KS : Speakers (HD Audio Speaker)   (device #28 with 0 ins 2 outs)
  - Windows WDM-KS : Headset (@System32\drivers\bthhfenum.sys,#2;%1 Hands-Free AG Audio%0

;(Boombot REX))   (device #29 with 0 ins 1 outs)
  - Windows WDM-KS : Headset (@System32\drivers\bthhfenum.sys,#2;%1 Hands-Free AG Audio%0

;(Boombot REX))   (device #30 with 1 ins 0 outs)
  - Windows WDM-KS : Speakers ()   (device #31 with 0 ins 2 outs)
  - Windows WDM-KS : Microphone (Steam Streaming Microphone Wave)   (device #32 with 8 ins 0 outs)
  - Windows WDM-KS : Speakers (Steam Streaming Microphone Wave)   (device #33 with 0 ins 8 outs)
  - Windows WDM-KS : Speakers (UMC202HD 192k)   (device #34 with 0 ins 2 outs)
  - Windows WDM-KS : Microphone (UMC202HD 192k)   (device #35 with 2 ins 0 outs)
  - Windows WDM-KS : Input (Steam Streaming Speakers Wave)   (device #36 with 8 ins 0 outs)
  - Windows WDM-KS : Speakers (Steam Streaming Speakers Wave)   (device #37 with 0 ins 8 outs)
  - Windows WDM-KS : Headphones ()   (device #38 with 0 ins 2 outs)
  - Windows WDM-KS : Headphones ()   (device #39 with 0 ins 2 outs)
  - Windows WDM-KS : Microphone (HD Webcam C270)   (device #40 with 1 ins 0 outs)

Requested devices:
  In:
  - (default)
  Out:
  - (default)

Selecting default system input/output devices

Booting with:
  In: MME : Microphone (UMC202HD 192k)
  Out: MME : Speakers (UMC202HD 192k)
SC_PortAudioDriver: PortAudio failed at Pa_OpenStream with error: 'Unanticipated host error'
could not initialize audio.

Process Log

C:\Users\owen\.sonic-pi\log\processes.log


    ask-clear.rb

Clearing pids: []
No pids to clear :-)
Started [9388] [-] "C:\Program Files\Sonic Pi\app\gui\qt\build\Release\..\..\..\..\..\app\server\native\ruby\bin\ruby.exe"  --enable-frozen-string-literal -E utf-8 "C:\Program Files\Sonic Pi\app\gui\qt\build\Release\..\..\..\..\..\app\server\ruby\bin\sonic-pi-server.rb" -u 51235 51236 51237 51237 4560 51238 51239 [-] C:/Users/owen/AppData/Local/Temp/sonic-pi-pids/9388
ERROR: Unable to write information for PID 12744 to path C:/Users/owen/AppData/Local/Temp/sonic-pi-pids/12744!
undefined method `cmdline' for nil:NilClass
owenstranathan commented 3 years ago

This looks like the same issue or at least the same error coming from scsynth. https://github.com/supercollider/supercollider/issues/4395 But I think the fact that I can tie it to the audio interface is novel.

ethancrawford commented 3 years ago

@owenstranathan - you may or may not find some useful comments in https://github.com/sonic-pi-net/sonic-pi/issues/2678... Unfortunately, SuperCollider has had occasional problems with PortAudio for years now, which still has some issues with various configurations and does not provide helpful error messages.

owenstranathan commented 3 years ago

@ethancrawford Thanks for the quick reply. I followed that issue and then another linked within and ended up at #2528 The fellow there seems to have had success by changing the properties on his device to match the sample rate specified in the sonic pi audio-settings.toml So I did the same. And sure enough, it works My output device was previously defaulting to 16bit, 48000Hz. I set it manually to 24 bit, 44100Hz, and the start-up failure is resolved.

image

Interestingly enough I tried it the other way and it doesn't work. I tried to leave my device sample rate unchanged at 48000 Hz and set the sound_card_sample_rate value in audio-settings.toml to 48000 Hz and the crash persists. So it doesn't seem like adjusting the configured sample rate to match the device sample rate will always fix the issue. I'm not sure this could be resolved programmatically but if there is a way to query the audio device being used's sample rate and compare it with the configured sample rate then the issue could at least be logged I think. I'm not familiar with how SonicPi achieves any of this but there must be some windows API for accessing that information. If someone could point me to the area where these things happen in the code I could try tinkering around with that in my spare time.

If that's not agreeable I could update/add to documentation about this issue specifically. Let me know if I can help.

Thanks again!

ethancrawford commented 3 years ago

Hi @owenstranathan - apologies for the delay. It's not exactly the same thing, but you will notice at https://github.com/sonic-pi-net/sonic-pi/blob/main/app/server/ruby/lib/sonicpi/scsynthexternal.rb#L322, we detect the input and output sample rates of the default sound device on MacOS, and log various messages related to this. I'm not quite sure how something similar might look for Windows, but thought it was worth pointing out the above at least 🙂

samaaron commented 2 years ago

We have completely overhauled the building and booting systems in the recently released v4 of Sonic Pi:

https://github.com/sonic-pi-net/sonic-pi/releases

Please give that a try and feel free to create a new issue if you're still having problems.