Can I set system volume from code behind?
I know that in WP8 no way to do this. Maybe in WP8.1 ms added some api for system volume access?
This is not possible I have tried using the WASAPI drivers from Microsoft.
As an added note quoting from MSFT support James Dailey:
AFAIK there is no good way to manipulate the global audio level on
Windows Phone 8.1 (WP8.1). Theoretically you can change the audio
volume of any app that uses the default audio session “zero”. However,
if the app chooses to initialize it’s audio session with a custom
GUID you will not have access to the session volume for its custom
audio session. Again this is theoretical based on my knowledge of the
inner workings of WASAPI. I’ve never actually tried it on the phone.
To manipulate the audio volume of apps using audio session “zero” you
simply initialize your IAudioClient with an AudioSessionGuid parameter
of “{00000000-0000-0000-0000-000000000000}”. You can then use
ISimpleAudioVolume::SetMasterVolume to set the volume for this audio
session. You will need to use C++ / Cx since we do not support
calling WASAPI from managed code.
The above suggestion does not work.
Related
I have searched through documentations, but cannot find a way to figure out either the system volume or the volume level at which the app would play
Read through:
Sound
ElementSound
Is there a way to find it in UWP?
I need to report volume changes to viewability
Thanks for your interest. Unfortunately, currently there is no better way to report the volume you said. We can only control the app level's volume such as mediaplayperelement volume setting. We do not have any event to listen for system volume changes. We suggest you could make desktop bridge app and use desktop extension part to get system volume and send it to UWP client with AppService.
I have a C# UWP application using Windows IoT Core on Raspberry Pi 3. Is there a way to control the master volume output level of the pi from C# code?
As far as i know, there is no API in UWP used to change the System's Volume directly. It's all about the ecosystem of the app itself being managed by the system. You may try to find Win32 API to control master volume.
Here is an answer to changing the master volume from C++, also includes SetMute, etc. You can call the api in C#.Maybe it is helpful for you.
Changing master volume level
In addition, WASAPI provides client-specified volume and mute settings uniformly to all of the streams in the session. Users can adjust the volume and mute settings for all of the sessions in the system. But
WASAPI is only available in C++. if you want to do it from a C# UWP App, you can create a RuntimeComponent in C++CX that will provide this feature to your app.
https://learn.microsoft.com/en-us/windows/desktop/coreaudio/audio-sessions
I have a Bluetooth Low Energy (BLE) device that streams audio through a custom service, and need to be able to use it in any Windows application (e.g. stream the audio to Skype or Google Chrome for example). I believe the only way is to make this audio source appear as a standard Windows audio input, but how to do this ?
I think the most reliable way to interract with a BLE device is through UWP (using Windows.Devices.Bluetooth.BluetoothLEDevice), so I used it to get the audio data. Then, I used the Windows.Media.Audio.AudioGraph to interract with the audio system. I'm able to generate the Windows audio stream from the BLE audio data with the AudioFrameInputNode and output it to my application default output with AudioDeviceOutputNode.
I can't override the default system audio input and audio output (e.g the laptop microphone and speakers) so in order to be able to use the output from my application as an input in other application, I used VB-Audio (https://www.vb-audio.com/) combined with the "App volume and device preferences" Windows feature. This way, I can use the VB-Audio Cable to connect the output of my application to the input of another, without having to set them as default system devices.
In theory, this should do what I need to do, but in fact, this setup isn't reliable.
I don't understand why, but the behavior isn't consistent at all. Most of the time, changing the audio settings (from "App volume and device preferences" and the "Audio devices panel") have no effect. With the same settings, sometimes it works but sometimes it doesn't (audio from my application is played on speaker instead of VB-Cable input, etc.)...
I don't know where the problem comes from, VB-Audio or Windows itself ? Is there a more reliable alternative to this setup ?
Otherwise, is there another way to use a custom audio source from an application like a standard Windows audio input ?
Please let me know if anything is unclear or you need any more information.
EDIT:
I think this post is actually about the same issue that I'm facing.
Up until now I thought that changing the system volume from your app is impossible, until recently a new app called Quite Hours (http://www.windowsphone.com/en-us/store/app/quiet-hours/f347a36b-80c0-430f-8631-e55046ee5a2a) actually did just that in a very neat way.
Does anyone please know how to do that programmatically? I tried using the MediaElement or the xna MediaPlayer and the backgroundAudioPlayer and nothing worked. Any help would be appreciated!
Thank you!
The developers of the apps mentioned in the OP were able to change system volume under WP8.0. Apparently whatever method they used has now been disabled under WP8.1. The following apps now display disclaimers that they no longer work on Windows Phone 8.1: Quiet Hours and Volume Manager
They direct to the following page to vote to allow this functionality: Windows Phone Dev User Voice
Additionally please read the following thread on the MSDN forum: MSDN change system volume Windows Phone 8. This functionality was likely achieved using WASAPI (which I have personally tried, and failed, it does not work, comment if you want my code to try it.), or the developers of the volume apps might have had access to AudioClientRestricted.h. If one had that h file, one would have access to system volume under WP8.1, so I somehow doubt the developers used the h file designated for OEMs because it would work un 8.1.
Talking with James Dailey (who works # MSFT) indicates it is technically possible using WASAPI ISimpleAudioVolume If you read # the bottom of that page there is a comment indicating you must use IAudioEndpointVolume
Added note from James Dailey # MSFT:
AFAIK there is no good way to manipulate the global audio level on
Windows Phone 8.1 (WP8.1). Theoretically you can change the audio
volume of any app that uses the default audio session “zero”. However,
if the app chooses to initialize it’s audio session with a custom
GUID you will not have access to the session volume for its custom
audio session. Again this is theoretical based on my knowledge of the
inner workings of WASAPI. I’ve never actually tried it on the phone.
To manipulate the audio volume of apps using audio session “zero” you
simply initialize your IAudioClient with an AudioSessionGuid parameter
of “{00000000-0000-0000-0000-000000000000}”. You can then use
ISimpleAudioVolume::SetMasterVolume to set the volume for this audio
session. You will need to use C++ / Cx since we do not support
calling WASAPI from managed code.
There currently is no API available for controlling the system volume. You can however control the volume in the elements of your application (via the classes MediaElement, BackgroundAudioAgent).
You can also control the volume on sound effects of your application using XNA API.
See http://msdn.microsoft.com/en-us/library/bb195052%28v=xnagamestudio.30%29.aspx
Is it possible to record audio only when there is someone talking? I want to listen to the microphone and only start recording when the "volume" is greater than some noise level (meaning someone is talking) I also need to change the pitch of the recorded audio.
I tried MediaCapture class in C# but StartRecordToStorageFileAsync from a sample is not useable in my scenario. In Windows Phone I use XNA but I cannot find a similiar API in Windows 8.
Check this thread on MSDN forums: How to get the decibel with C#?
It seems like there is and probably will not be APIs for doing that in C#, Visual Basic or JavaScript and you need to do it in a native component.
The Core Audio/WASAPI APIs from the article mentioned in that thread should have what you need: Win32 and COM for Metro style apps (multimedia)
I think this document has a description of a sample for capturing audio from a Kinect sensor that might have relevant code samples showing how you would use GetBuffer() calls to get the buffer of raw audio samples that you could process to get the information you need.