locked
[uwp]how to change volume in audiograph RRS feed

  • Question

  • The AudioFileInputNode of the audiograph has many effects, but I can't find how to change the volume.

    The MediaElement has a volume property ,so I can change it.

    Actually, I wanna know how to change the audio outputdevice and the volume.

    I can change MediaElement volume but I don't know how to change the audio outputdevice.

    I can change the outputdeviceof the audiograph but I don't know how to change the volume.

    Thanks for reply.

    Monday, January 11, 2016 4:35 AM

Answers

  • Hi Evan

    You could consider setting the output gain of the audio source? The gain sets the amplitude of the signal which in audio terms relates to volume.

    you can see more information here:

    https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.audio.audiofileinputnode.aspx

    https://en.wikipedia.org/wiki/Gain_(electronics)

    I hope this helped.

    • Proposed as answer by Fred Bao Tuesday, January 26, 2016 8:17 AM
    • Marked as answer by Fred Bao Wednesday, January 27, 2016 1:53 AM
    Monday, January 11, 2016 9:02 AM

All replies

  • Hi Evan

    You could consider setting the output gain of the audio source? The gain sets the amplitude of the signal which in audio terms relates to volume.

    you can see more information here:

    https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.audio.audiofileinputnode.aspx

    https://en.wikipedia.org/wiki/Gain_(electronics)

    I hope this helped.

    • Proposed as answer by Fred Bao Tuesday, January 26, 2016 8:17 AM
    • Marked as answer by Fred Bao Wednesday, January 27, 2016 1:53 AM
    Monday, January 11, 2016 9:02 AM
  • Use the .OutgoingGain property as shown below.

    private static async Task AddFileToSounds(string uri) { // Load and add resource sound file to memory dictionary for playing var soundFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri(uri)); var fileInputResult = await graph.CreateFileInputNodeAsync(soundFile); if (AudioFileNodeCreationStatus.Success == fileInputResult.Status) { fileInputs.Add(soundFile.Name, fileInputResult.FileInputNode); fileInputResult.FileInputNode.Stop(); // set volume here using outgoing gain, values 0 - 1 fileInputResult.FileInputNode.OutgoingGain = 0.1; fileInputResult.FileInputNode.AddOutgoingConnection(deviceOutput); } }


    Thursday, August 2, 2018 4:09 PM