projectM-visualizer / projectm

projectM - Cross-platform Music Visualization Library. Open-source and Milkdrop-compatible.
https://discord.gg/mMrxAqaa3W
GNU Lesser General Public License v2.1
3.37k stars 375 forks source link

Input device toggle does not work on OSX 10.14.6 #365

Closed felder closed 4 years ago

felder commented 4 years ago

Using release v3.13 on a 2017 Macbook Pro running OSX 10.14.6, the input device toggle does not seem to actually use different input devices.

Hitting CMD-i shows output that suggests that the device is being switched. However, the visual effects continue to respond only to mic input. I can verify this by toggling the input volume via the sound preferences for the mic and watching the resulting visual effects changes. Doing a similar thing for the currently selected input device, when it is not the internal mic, has no effect.

mackemint commented 4 years ago

I can confirm this behavior on 10.15.4 and High Sierra too.

milkdropper commented 4 years ago

What audio devices do you see when you toggle through the list? My understanding is that right now the default loopback is WASAPI, which is for Windows only.

mackemint commented 4 years ago

I see the input devices I expect to find and in the order they appear under System Preferences -> Sound->Input.

milkdropper commented 4 years ago

I can't run the v3.13 release on my Mac to confirm due to https://github.com/projectM-visualizer/projectm/issues/363, but I looked into it on Windows and found some problems.

I only have one input device and if I toggle over and over my devId keeps incrementing until it crashes. Can you tell me if you see the devID incrementing like below?

INFO: Opened audio capture device index=0 **devId=2**: Mic in at rear panel (Pink) (Realtek High Definition Audio)
INFO: Opened audio capture device index=0 **devId=3**: Mic in at rear panel (Pink) (Realtek High Definition Audio)
INFO: Opened audio capture device index=0 **devId=4**: Mic in at rear panel (Pink) (Realtek High Definition Audio)
...
CRITICAL: Failed to open audio capture device: **Too many open audio devices**

I think I have this fixed now, and I've got some more bug fixes related to audio input toggling I'll commit tomorrow after I get your feedback.

mackemint commented 4 years ago

This is what I get on starting the application and stepping through the inputs with CMD+I:

2020-06-07 23:03:11.084 SDLprojectM[2174:95573] INFO: GL_VERSION: 4.1 NVIDIA-14.0.32 355.11.11.10.10.143 2020-06-07 23:03:11.084 SDLprojectM[2174:95573] INFO: GL_SHADING_LANGUAGE_VERSION: 4.10 2020-06-07 23:03:11.084 SDLprojectM[2174:95573] INFO: GL_VENDOR: NVIDIA Corporation 2020-06-07 23:03:11.085 SDLprojectM[2174:95573] INFO: Using data directory: /usr/local/share/projectM 2020-06-07 23:03:11.085 SDLprojectM[2174:95573] INFO: Looking for configuration file in data dir: /usr/local/share/projectM. 2020-06-07 23:03:11.085 SDLprojectM[2174:95573] INFO: Config file not found, using built-in settings. Data directory=/Applications/projectM SDL.app/Contents/Resources/ 2020-06-07 23:03:11.234 SDLprojectM[2174:95573] INFO: Using audio driver: coreaudio 2020-06-07 23:03:11.234 SDLprojectM[2174:95573] INFO: Found audio capture device 0: PreSonus FireStudio 2020-06-07 23:03:11.234 SDLprojectM[2174:95573] INFO: Found audio capture device 1: Soundflower (2ch) 2020-06-07 23:03:11.234 SDLprojectM[2174:95573] INFO: Found audio capture device 2: Soundflower (64ch) 2020-06-07 23:03:11.234 SDLprojectM[2174:95573] INFO: Found audio capture device 3: StreamingIn Detected devices: 2020-06-07 23:03:11.484 SDLprojectM[2174:95573] INFO: Opened audio capture device index=0 devId=2: PreSonus FireStudio 2020-06-07 23:03:11.484 SDLprojectM[2174:95573] INFO: Samples: 2048, frequency: 44100, channels: 2, format: 33056 2020-06-07 23:03:32.886 SDLprojectM[2174:95573] INFO: Opened audio capture device index=1 devId=3: Soundflower (2ch) 2020-06-07 23:03:32.886 SDLprojectM[2174:95573] INFO: Samples: 2048, frequency: 44100, channels: 2, format: 33056 2020-06-07 23:03:33.107 SDLprojectM[2174:95573] INFO: Displaying preset: Aderrasi - Crystal Storm.milk 2020-06-07 23:03:37.314 SDLprojectM[2174:95573] INFO: Opened audio capture device index=2 devId=4: Soundflower (64ch) 2020-06-07 23:03:37.314 SDLprojectM[2174:95573] INFO: Samples: 2048, frequency: 44100, channels: 2, format: 33056 2020-06-07 23:03:41.057 SDLprojectM[2174:95573] INFO: Opened audio capture device index=3 devId=5: StreamingIn 2020-06-07 23:03:41.057 SDLprojectM[2174:95573] INFO: Samples: 2048, frequency: 44100, channels: 2, format: 33056 2020-06-07 23:03:41.612 SDLprojectM[2174:95573] INFO: Opened audio capture device index=0 devId=6: PreSonus FireStudio 2020-06-07 23:03:41.612 SDLprojectM[2174:95573] INFO: Samples: 2048, frequency: 44100, channels: 2, format: 33056 2020-06-07 23:03:42.404 SDLprojectM[2174:95573] INFO: Opened audio capture device index=1 devId=7: Soundflower (2ch) 2020-06-07 23:03:42.404 SDLprojectM[2174:95573] INFO: Samples: 2048, frequency: 44100, channels: 2, format: 33056 2020-06-07 23:03:43.061 SDLprojectM[2174:95573] INFO: Opened audio capture device index=2 devId=8: Soundflower (64ch) 2020-06-07 23:03:43.061 SDLprojectM[2174:95573] INFO: Samples: 2048, frequency: 44100, channels: 2, format: 33056

milkdropper commented 4 years ago

I confirmed that the same issue exists in Windows (to test you have to disable WASAPI loopback capture). If I toggle through devices projectM still only ever listens to the first input source.

I fixed your issue in a rewrite of some of the audio toggling here https://github.com/projectM-visualizer/projectm/pull/368 and more specifically here https://github.com/projectM-visualizer/projectm/pull/368/commits/5fd5bbc8148af780382061241623009a63ccce7a. I forgot to track how I fixed this bug specifically, but it likely had to do with changes to endAudioCapture (and more use of it).

felder commented 4 years ago

Here is what I get when I run projectM and step through the inputs.

"Spotify" is from loopback which is an app that allows you to create input devices using the output from others and is the source I'm hoping to use for the visualizations.

2020-06-08 09:41:21.304 SDLprojectM[799:12356] INFO: GL_VERSION: 4.1 ATI-2.11.21 2020-06-08 09:41:21.304 SDLprojectM[799:12356] INFO: GL_SHADING_LANGUAGE_VERSION: 4.10 2020-06-08 09:41:21.304 SDLprojectM[799:12356] INFO: GL_VENDOR: ATI Technologies Inc. 2020-06-08 09:41:21.305 SDLprojectM[799:12356] INFO: Using data directory: /usr/local/share/projectM 2020-06-08 09:41:21.305 SDLprojectM[799:12356] INFO: Looking for configuration file in data dir: /usr/local/share/projectM. 2020-06-08 09:41:21.305 SDLprojectM[799:12356] INFO: Config file not found, using built-in settings. Data directory=/Applications/projectM SDL.app/Contents/Resources/ [PresetFactory] url is idle://Geiss & Sperl - Feedback (projectM idle HDR mix).milk 2020-06-08 09:41:21.496 SDLprojectM[799:12356] INFO: Using audio driver: coreaudio 2020-06-08 09:41:21.496 SDLprojectM[799:12356] INFO: Found audio capture device 0: Built-in Microphone 2020-06-08 09:41:21.496 SDLprojectM[799:12356] INFO: Found audio capture device 1: USB Advanced Audio Device 2020-06-08 09:41:21.496 SDLprojectM[799:12356] INFO: Found audio capture device 2: Spotify Detected devices: 2020-06-08 09:41:22.199 SDLprojectM[799:12356] INFO: Opened audio capture device index=0 devId=2: Built-in Microphone 2020-06-08 09:41:22.199 SDLprojectM[799:12356] INFO: Samples: 2048, frequency: 44100, channels: 2, format: 33056 fps: 60 2020-06-08 09:41:35.277 SDLprojectM[799:12356] INFO: Opened audio capture device index=1 devId=3: USB Advanced Audio Device 2020-06-08 09:41:35.277 SDLprojectM[799:12356] INFO: Samples: 2048, frequency: 44100, channels: 2, format: 33056 2020-06-08 09:41:36.643 SDLprojectM[799:12356] INFO: Opened audio capture device index=2 devId=4: Spotify 2020-06-08 09:41:36.643 SDLprojectM[799:12356] INFO: Samples: 2048, frequency: 44100, channels: 2, format: 33056 2020-06-08 09:41:37.919 SDLprojectM[799:12356] INFO: Opened audio capture device index=0 devId=5: Built-in Microphone 2020-06-08 09:41:37.919 SDLprojectM[799:12356] INFO: Samples: 2048, frequency: 44100, channels: 2, format: 33056

milkdropper commented 4 years ago

So I think it's a confirmed bug and audio toggling doesn't work right now. But for info I did some research and found a potential free alternative to loopback: https://support.shinywhitebox.com/hc/en-us/articles/204161459-Installing-iShowU-Audio-Capture

Ideally this kind of functionality should be built into SDL (similar to WASAPI lookback on Windows)

felder commented 4 years ago

@milkdropper I checked out branch "littlethings" and built it. I can confirm device input toggling works with your fix. :)

talesa commented 4 years ago

@milkdropper I would like to confirm as well :) many thanks, you're doing such an amazing job with this project

kylef027 commented 4 years ago

Is there any way to force the program to use a different input when it starts vs having the controls toggleable? Since I'm on macOS 10.15.5 I have to run the 3.1.2 version which doesn't have the option, but even if I was able to just get it to be a static input of say Spotify or a web browser instead of the mic it would be sufficient until a Catalina fix comes out

milkdropper commented 4 years ago

For Mac my understanding is that we can get proper support for toggling input devices but to switch to a specific program like Spotify requires a driver and special signing requirements from Apple. This is not realistic short-term so a free option is this: https://support.shinywhitebox.com/hc/en-us/articles/204161459-Installing-iShowU-Audio-Capture

kylef027 commented 4 years ago

Ah, interesting, thanks for the information. I'll give that a try tonight, appreciate all the work you guys have done!

talesa commented 4 years ago

If I may chip in - when you're using iShowU Audio Capture and you want to the music outputted on two devices (e.g. iShowU Audio Capture and Default/Headphones) you can use Audio MIDI Setup to define a Multi-Output Device as per https://obsproject.com/forum/resources/os-x-capture-audio-with-ishowu-audio-capture.505/

bolandross commented 4 years ago

Hey folks,

I'm having the same problem on High Sierra 10.13.6

It seems to be impossible to change input device, always the internal mic is chosen. Pressing cmd-i doesn't do anything for me. Having tried several loopback utilities didn't result in any success. In System Preferences -> Sound -> Input, I can see all my virtual input devices and also see the VU meters jumping when clicking on them, but projectM SDL.app always chooses the the same device.

Any ideas?

milkdropper commented 4 years ago

Fixed with merge of https://github.com/projectM-visualizer/projectm/commit/c5533e3efeea2ce1a5624b14d7dbebc686ee6799 into https://github.com/projectM-visualizer/projectm/releases/tag/v3.1.7 and Steam release https://store.steampowered.com/app/1358800/projectM_Music_Visualizer/