Author Topic: How to dim app's volume if microphone has input?  (Read 336 times)

lori3

  • Posts: 2
I am working with C++/BASS/SFML on Windows 10 64 bit.
I have installed an app named WO Mic to stream audio from my phone to the PC.

I'd like to implement a function that dims the C++ app's volume whenever the virtual microphone of the WU app has input coming in.
(basically a bool function that returns true whenever mic receives input)
I have read a couple of posts but I really can't wrap my head around how to do it.

Code: [Select]
BASS_DEVICEINFO dinfo;
for (int a = 0; BASS_RecordGetDeviceInfo(a, &dinfo); a++)
if ((dinfo.flags & BASS_DEVICE_ENABLED) && (dinfo.flags & BASS_DEVICE_TYPE_MASK) == BASS_DEVICE_TYPE_MICROPHONE) { // found an enabled microphone
std::cout << "mic found" << std::endl;
break;
}
this gets the microphone, but this is about how far I have gone.

Can you please help me? :D

Ian @ un4seen

  • Administrator
  • Posts: 22253
Re: How to dim app's volume if microphone has input?
« Reply #1 on: 22 Jul '19 - 14:23 »
You can use BASS_ChannelGetLevel(Ex) to get the microphone's current level. Before doing that, you will need to initialize recording from the microphone using BASS_RecordInit and BASS_RecordStart. Please see the documentation for details on those functions.

lori3

  • Posts: 2
Re: How to dim app's volume if microphone has input?
« Reply #2 on: 23 Jul '19 - 20:38 »
Thanks, but is there a way to do this without actually playing the microphone?

Ian @ un4seen

  • Administrator
  • Posts: 22253
Re: How to dim app's volume if microphone has input?
« Reply #3 on: 24 Jul '19 - 14:33 »
You may be able to achieve what you want with the BASSWASPI add-on and its BASS_WASAPI_GetDeviceLevel function. That gets the level from the device rather than from captured sample data. Note BASSWASAPI has its own device list, and you would need to use BASS_WASAPI_GetDeviceInfo (instead of BASS_RecordGetDeviceInfo) to find the mic.