Volume change from c# app

  • Thread starter Thread starter Balint Toth
  • Start date Start date
B

Balint Toth

Hi all,

How can I change the volume level from a c# application? I tried
OpenNETCF.Multimedia.Audio but it doesnt work. It runs on the emulator OK,
but on my RED-E 1100 it halts when I create the player object:

OpenNETCF.Multimedia.Audio.Player player = new
OpenNETCF.Multimedia.Audio.Player();

Do I need some other initialization before this? Or is there any other
volume control in .NET CF?

Best regards,
Bálint Tóth
 
You should be able to P/Invoke the wavefore audio methods:

[DllImport ("coredll.dll")]
protected static extern Wave.MMSYSERR waveOutSetVolume(IntPtr hwo, uint
dwVolume);

I would imagine the problem may be with the volume you are passing. Volume
is a weird problem on devices...

Not all devices support volume changes. To determine whether the device
supports volume control, use the WAVECAPS_VOLUME flag to test the dwSupport
member of the WAVEOUTCAPS structure (filled by the waveOutGetDevCaps
function). To determine whether the device supports volume control on both
the left and right channels, use the WAVECAPS_LRVOLUME flag.

Most devices do not support the full 16 bits of volume-level control and
will not use the high-order bits of the requested volume setting. For
example, for a device that supports 4 bits of volume control, requested
volume level values of 0x4000, 0x4FFF, and 0x43BE all produce the same
physical volume setting: 0x4000. The waveOutGetVolume function returns the
full 16-bit setting set with waveOutSetVolume.

Volume settings are interpreted logarithmically. This means the perceived
increase in volume is the same when increasing the volume level from 0x5000
to 0x6000 as it is from 0x4000 to 0x5000.

As far as I have been able to determine, there is no way to tell how many
bits of volume are supported.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 
FYI, that code is from the P/Invoke Library if you want to see the entire
audio solution:

http://msdn.microsoft.com/library/en-us/dnnetcomp/html/PInvokeLib.asp

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
Geoff Schwab said:
You should be able to P/Invoke the wavefore audio methods:

[DllImport ("coredll.dll")]
protected static extern Wave.MMSYSERR waveOutSetVolume(IntPtr hwo, uint
dwVolume);

I would imagine the problem may be with the volume you are passing. Volume
is a weird problem on devices...

Not all devices support volume changes. To determine whether the device
supports volume control, use the WAVECAPS_VOLUME flag to test the dwSupport
member of the WAVEOUTCAPS structure (filled by the waveOutGetDevCaps
function). To determine whether the device supports volume control on both
the left and right channels, use the WAVECAPS_LRVOLUME flag.

Most devices do not support the full 16 bits of volume-level control and
will not use the high-order bits of the requested volume setting. For
example, for a device that supports 4 bits of volume control, requested
volume level values of 0x4000, 0x4FFF, and 0x43BE all produce the same
physical volume setting: 0x4000. The waveOutGetVolume function returns the
full 16-bit setting set with waveOutSetVolume.

Volume settings are interpreted logarithmically. This means the perceived
increase in volume is the same when increasing the volume level from 0x5000
to 0x6000 as it is from 0x4000 to 0x5000.

As far as I have been able to determine, there is no way to tell how many
bits of volume are supported.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.

Balint Toth said:
Hi all,

How can I change the volume level from a c# application? I tried
OpenNETCF.Multimedia.Audio but it doesnt work. It runs on the emulator OK,
but on my RED-E 1100 it halts when I create the player object:

OpenNETCF.Multimedia.Audio.Player player = new
OpenNETCF.Multimedia.Audio.Player();

Do I need some other initialization before this? Or is there any other
volume control in .NET CF?

Best regards,
Bálint Tóth
 
Thanks, I found great resources! But my main problem isn't solved: I would
like to make sound heard during a phone call. But my phone (eighter my PDA)
mutes all sound played on the device. There is a menu in
Settings/Accessability: In-Call alert volume. I suppose there is a way to
play sounds "to the phone line", but I don't have a clue, how.

This would be very important for me.

Thanks in advance,
Bálint Tóth

Geoff Schwab said:
FYI, that code is from the P/Invoke Library if you want to see the entire
audio solution:

http://msdn.microsoft.com/library/en-us/dnnetcomp/html/PInvokeLib.asp

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx
 
Back
Top