Beispiel #1
0
        public static void SetWaveOutVolume(float value, IntPtr hWaveOut, object lockObject)
        {
            if (value < 0.0)
            {
                throw new ArgumentOutOfRangeException(nameof(value), "Volume must be between 0.0 and 1.0");
            }
            if (value > 1.0)
            {
                throw new ArgumentOutOfRangeException(nameof(value), "Volume must be between 0.0 and 1.0");
            }
            int      dwVolume = (int)(value * (double)ushort.MaxValue) + ((int)(value * (double)ushort.MaxValue) << 16);
            MmResult result;

            lock (lockObject)
                result = AudioInterop.waveOutSetVolume(hWaveOut, dwVolume);
            MmException.Try(result, "waveOutSetVolume");
        }