protected void GetVolumeSink(System.UInt32 InstanceID, DvRenderingControl.Enum_A_ARG_TYPE_Channel Channel, out System.UInt16 CurrentVolume) { if (ID_Table.ContainsKey(InstanceID) == false) { throw(new UPnPCustomException(802, InstanceID.ToString() + " is not a valid InstanceID")); } else { AVConnection c = (AVConnection)ID_Table[InstanceID]; CurrentVolume = c.GetVolume(Channel); } }
protected void VolumeSink(AVConnection sender, DvRenderingControl.Enum_A_ARG_TYPE_Channel Channel, System.UInt16 DesiredVolume) { if (InvokeRequired) { Invoke(new AVConnection.VolumeChangedHandler(VolumeSink), sender, Channel, DesiredVolume); return; } SetVolume((int)DesiredVolume, Channel); switch (Channel) { case DvRenderingControl.Enum_A_ARG_TYPE_Channel.LF: LeftChannel = DesiredVolume; break; case DvRenderingControl.Enum_A_ARG_TYPE_Channel.RF: RightChannel = DesiredVolume; break; } int balance = ((int)System.Math.Pow(((double)LeftChannel - (double)RightChannel) / (double)10, 4)); if (LeftChannel > RightChannel) balance = balance * (-1); if (Channel != DvRenderingControl.Enum_A_ARG_TYPE_Channel.MASTER) { player.settings.balance = balance; DesiredVolume = (UInt16)((float)System.Math.Max(LeftChannel, RightChannel) * ((float)sender.GetVolume(DvRenderingControl.Enum_A_ARG_TYPE_Channel.MASTER) / (float)100)); } else { DesiredVolume = (UInt16)((float)System.Math.Max(LeftChannel, RightChannel) * ((float)sender.GetVolume(DvRenderingControl.Enum_A_ARG_TYPE_Channel.MASTER) / (float)100)); } //int nv = -1 * (int)(System.Math.Pow(((100 - ((((double)DesiredVolume) / 2.2) + 20)) / 10),4)); player.settings.volume = DesiredVolume; }