From e914fc6a53e3618b1792be410c16ac2c209e2a36 Mon Sep 17 00:00:00 2001 From: Mike Randrup Date: Thu, 7 Mar 2024 10:03:20 -0600 Subject: [PATCH 1/3] Added input device search logging and configuration block --- CAPlayThroughController.mm | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/CAPlayThroughController.mm b/CAPlayThroughController.mm index da121bf..5122cfe 100644 --- a/CAPlayThroughController.mm +++ b/CAPlayThroughController.mm @@ -47,6 +47,18 @@ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF #import "CAPlayThroughController.h" +/// Configuration Section + +// BlackHole can be found at https://github.com/ExistentialAudio/BlackHole +// I got this info from https://forums.macrumors.com/threads/mac-cant-control-display-monitor-volume.2270285/ +/// Replace with prefix of desired input device on your system +/// Run once and look at log for list of input device names if unsure +static NSString *const kInputDevicePrefix = @"USB"; + +/// Replace with prefix of designed output device on your system +/// The names of your devices can be found in the Preferences -> Sound +static NSString *const kOutputDevicePrefix = @"External"; + @implementation CAPlayThroughController static void BuildDeviceMenu(AudioDeviceList *devlist, NSPopUpButton *menu, AudioDeviceID initSel); AudioDeviceID AudioDeviceWithNameWithPrefixInDeviceList(NSString*prefix,AudioDeviceList*devList); @@ -61,10 +73,8 @@ - (id)init - (void)awakeFromNib { - // BlackHole can be found at https://github.com/ExistentialAudio/BlackHole - // I got this info from https://forums.macrumors.com/threads/mac-cant-control-display-monitor-volume.2270285/ - inputDevice=AudioDeviceWithNameWithPrefixInDeviceList(@"BlackHole 2ch", mInputDeviceList); - NSArray*a=AudioDevicesWithNameWithPrefixInDeviceList(@"BenQ", mOutputDeviceList); + inputDevice = AudioDeviceWithNameWithPrefixInDeviceList(kInputDevicePrefix, mInputDeviceList); + NSArray* a = AudioDevicesWithNameWithPrefixInDeviceList(kOutputDevicePrefix, mOutputDeviceList); if([a count]>=1){ outputDevice = [a[0] unsignedIntValue]; playThroughHost = new CAPlayThroughHost(inputDevice,outputDevice); @@ -172,13 +182,20 @@ - (IBAction)outputDeviceSelected:(id)sender } } AudioDeviceID AudioDeviceWithNameWithPrefixInDeviceList(NSString*prefix,AudioDeviceList*devList){ + NSLog(@"Checking for device starting with: %@", prefix); int index=0; AudioDeviceList::DeviceList &thelist = devList->GetList(); for (AudioDeviceList::DeviceList::iterator i = thelist.begin(); i != thelist.end(); ++i, ++index) { NSString*name=[NSString stringWithUTF8String:(*i).mName]; + NSLog(@"Found device %@", name); + if([name hasPrefix:prefix]){ + NSLog(@"Matched, choosing this device."); return (*i).mID; } + else { + NSLog(@"Not a match, skipping."); + } } abort(); } From 6c86001064e0de0171f290f078d11142d20d34dd Mon Sep 17 00:00:00 2001 From: Mike Randrup Date: Thu, 7 Mar 2024 10:04:30 -0600 Subject: [PATCH 2/3] Restored the Author's original device names --- CAPlayThroughController.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CAPlayThroughController.mm b/CAPlayThroughController.mm index 5122cfe..e72576d 100644 --- a/CAPlayThroughController.mm +++ b/CAPlayThroughController.mm @@ -53,11 +53,11 @@ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // I got this info from https://forums.macrumors.com/threads/mac-cant-control-display-monitor-volume.2270285/ /// Replace with prefix of desired input device on your system /// Run once and look at log for list of input device names if unsure -static NSString *const kInputDevicePrefix = @"USB"; +static NSString *const kInputDevicePrefix = @"BlackHole 2ch"; /// Replace with prefix of designed output device on your system /// The names of your devices can be found in the Preferences -> Sound -static NSString *const kOutputDevicePrefix = @"External"; +static NSString *const kOutputDevicePrefix = @"BenQ"; @implementation CAPlayThroughController static void BuildDeviceMenu(AudioDeviceList *devlist, NSPopUpButton *menu, AudioDeviceID initSel); From 322cf0afafd775580258de39f9412c9855869c74 Mon Sep 17 00:00:00 2001 From: Mike Randrup Date: Thu, 7 Mar 2024 10:06:27 -0600 Subject: [PATCH 3/3] Clarified log messages --- CAPlayThroughController.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CAPlayThroughController.mm b/CAPlayThroughController.mm index e72576d..bde2e51 100644 --- a/CAPlayThroughController.mm +++ b/CAPlayThroughController.mm @@ -187,10 +187,10 @@ AudioDeviceID AudioDeviceWithNameWithPrefixInDeviceList(NSString*prefix,AudioDev AudioDeviceList::DeviceList &thelist = devList->GetList(); for (AudioDeviceList::DeviceList::iterator i = thelist.begin(); i != thelist.end(); ++i, ++index) { NSString*name=[NSString stringWithUTF8String:(*i).mName]; - NSLog(@"Found device %@", name); + NSLog(@"Found input device %@", name); if([name hasPrefix:prefix]){ - NSLog(@"Matched, choosing this device."); + NSLog(@"Matched, choosing this input device."); return (*i).mID; } else {