How to set and get GSM call's volume in eVC4? - Windows Mobile Development and Hacking General

Dear all:
I am developping a program to change XDAII's sound.
using waveOutSetVolume() and waveOutGetVolume() can set and get XDAII's volume correctly, when playing multimedia or other applications.
But it does not work for GSM call. I mean in a GSM call, these two functions cannot do anything about gsm's volume.
Who know how to set and get GSM's volume in a call?
using waveOutGetNumDevs() can only return 1, which means only 1 waveform device available. whether it is mean GSM audio device is not a waveform device? then how to control it?
thanks

Do u means ringtone volume?

YES. Do u have any idea?

Not sure if this will work but try looking up phoneSetRing in the help:-
LONG WINAPI phoneSetRing(
HPHONE hPhone,
DWORD dwRingMode,
DWORD dwVolume
);
hPhone
Handle to the open phone device. The application must be the owner of the phone device.
dwRingMode
Ringing pattern with which to ring the phone. This parameter must be within the range of zero to the value of the dwNumRingModes member in the PHONECAPS structure. If dwNumRingModes is zero, the ring mode of the phone cannot be controlled; if dwNumRingModes is 1, a value of zero for dwRingMode indicates that the phone should not be rung (silence), and other values from 1 to dwNumRingModes are valid ring modes for the phone device.
dwVolume
The volume level with which the phone is ringing. This is a number in the range 0x00000000 (silence) to 0x0000FFFF (maximum volume). The actual granularity and quantization of volume settings in this range are service provider-specific. A value for dwVolume that is out of range is set to the nearest value in the range.
Jamie

I know how to set ring volume, but how to display it?
Dear all:
Now i can set ring volume according some experts help. they had ever past some guides in this forum. I just re-paste part of my program.
void SetGSMVolume(DWORD *devGSMVolumeLevel)
{
HKEY Key = NULL;
//dwPhoneVolumeLevel between 0 and 0xFFFFFFFF
DWORD res = RegOpenKeyEx(HKEY_CURRENT_USER,_T("\\ControlPanel\\Volume"),0,0,&Key);
if (res == ERROR_SUCCESS)
{
res = RegSetValueEx(Key,_T("Ringer"),0,REG_DWORD,(LPBYTE)devGSMVolumeLevel,sizeof(DWORD));
if (res != ERROR_SUCCESS) {;}
//RegCloseKey(Key);
}
RegCloseKey(Key);
Sleep(500);
}
But I meet another question: I can set any value for the ring, and read it out correctly. But the display on icon is not right. The icon always fixed at some point, I can set it use pen, not program.
Who can help me to synchrize the display and my ring volume?
The value in registry is aligned with what i set, not same with its display.
thanks

Related

phoneOpen, phoneGetVolume (TAPI)

Hello,
I try to retrieve (then set) the volume, ring type ... of my XDA using TAPI
I call phoneInitializeEx, phoneOpen, phoneGetVolume but I always get the same value for the volume (even if I chnage it of course)
Does anybody knows why ?
Does anybody have and can post a sample code source showing how to unse these functiuns (phoneInitializeEx, phoneOpen, phoneGetVolume, phoneGetStatus ...)
Regards.
To set the phone volume (in mono) try:
Code:
set(DWORD dwVolume)
{
if (dwVolume > 0xFFFF) dwVolume = 0xFFFF;
dwVolume += dwVolume * 0x10000;
DWORD ret;
switch ((ret = waveOutSetVolume(0, dwVolume))) {
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
case (etc....)
}
To get the volume, try:
Code:
DWORD get()
{
DWORD dwVolume;
DWORD ret;
switch ((ret = waveOutGetVolume(0, &dwVolume))) {
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
case (etc...)
}
// Return average of left and right:
if (dwVolume > 0xFFFF) {
dwVolume = ((dwVolume & 0xFFFF) + (dwVolume / 0xFFFF)) / 2;
}
return dwVolume;
}
This is code for XDA I. I have not tried this on XDA II which as we know, has two volume channels.....
Ben.
I upgraded my XDA1 with WM2003 and I have 2 channels for the volume too.
I will try your code but I think this will change only the system volume (I will need to do that too so thanks) but not the phone volume.
First I want to pilot the phone settings (ring, volume...) from an application.
And it seems that only TAPI can do it... but it is not working for the moment
Glad the code will be useful.
If you find the correct method for XDA II, please let me know, I'll need it my self soon.
Ben
Your code works well to set/get the sytem volume
I just modifed it a little as the output is mono
Code:
//**********************************************************************
//Set The System Volume
//Steps (0,13107,26214,39321,52428,65535)
DWORD setVolume(DWORD dwVolume)
{
if (dwVolume > 0xFFFF)
dwVolume = 0xFFFF;
if (dwVolume < 0x0000)
dwVolume = 0x0000;
DWORD ret;
switch ((ret = waveOutSetVolume(0, dwVolume)))
{
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
default :
break;
}
return 0;
}
//**********************************************************************
//Get The System Volume
DWORD getVolume()
{
DWORD dwVolume;
DWORD ret;
switch ((ret = waveOutGetVolume(0, &dwVolume)))
{
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
default :
break;
}
dwVolume = (dwVolume & 0xFFFF);
return dwVolume;
}
But the phoneGetVolume still gives incoherent results
Someone see something wrong in the code below ?
I set the phone volume to 0 on the device but PhoneGetvolume send me 40092 ???
Code:
LONG result;
HPHONE hPhone;
DWORD dwVolume;
DWORD dwRingMode;
DWORD dwNumDevs= 01;
DWORD dwAPIVersion=0x00020002;
PHONESTATUS PhoneStatus;
HPHONEAPP hPhoneApp = 0;
PHONEINITIALIZEEXPARAMS PhoneInitializeExParams;
PhoneInitializeExParams.dwTotalSize = 2 * sizeof(PHONEINITIALIZEEXPARAMS);
PhoneInitializeExParams.dwOptions = PHONEINITIALIZEEXOPTION_USEEVENT;
// PhoneInitializeExParams.dwOptions = PHONEINITIALIZEEXOPTION_USEHIDDENWINDOW;
result = phoneInitializeEx(&hPhoneApp,NULL,NULL,NULL,&dwNumDevs,&dwAPIVersion,&PhoneInitializeExParams);
result = phoneOpen(hPhoneApp, 0, &hPhone, dwAPIVersion, 0, 0,PHONEPRIVILEGE_OWNER);
result = phoneGetVolume(hPhone,PHONEHOOKSWITCHDEV_SPEAKER,&dwVolume); //range 0x00000000 to 0x0000FFFF (65535)
In fact when I set the phone volume using
PocketSetVolume the vlaue is well saved because I get it when I use after PocketGetVolume.
But the phone volume is not really changed ?
Nobody has a sample that uses these functions ?
Or not obligatory these functions but others functions that change the phone volume ?
zendrui said:
In fact when I set the phone volume using
PocketSetVolume the vlaue is well saved because I get it when I use after PocketGetVolume.
But the phone volume is not really changed ?
Nobody has a sample that uses these functions ?
Or not obligatory these functions but others functions that change the phone volume ?
Click to expand...
Click to collapse
I have found that by changing the following registry keys, I can change the volume of the Phone
[HKEY_CURRENT_USER\ControlPanel\Volume]
"Ringer"=dword:00000000
Use hex 00000000, 33333333, 66666666, 99999999, cccccccc, ffffffff
[HKEY_CURRENT_USER\ControlPanel\SoundCategories\Ring]
"InitVol"=dword:00000000
Use hex 0, 1, 2, 3, 4, 5
This work beautifully for my Qtek running WM2003, but I have tried the same approach for the system-volume by changing
[HKEY_CURRENT_USER\ControlPanel\Volume]
"Volume"=dword:00000000
Use hex 00000000, 33333333, 66666666, 99999999, cccccccc, ffffffff
But this does not work! I have checked the registry and the value goes in correctely (The in-system volum control stores the same values in the same key).
How can I use the above code-snippets from the .Net Compact Framework? (I'm guessing a P/Invoke but what DLL is the call hidden in)
Cato
I am trying to make it works, but fail...please let me know if you know how to use the registry to update it...my email is
[email protected]
Thanks
I used the P/Invoke sample from Microsoft to get a working sample that read and updated the registry, and simply tried all possible combo's of a 4byte-array to see what would produce the correct result
Cato
I found a article mention it !!!
http://www.cegadgets.com/winceregfaq.htm#2.8 Where are volume and sound settings stored?
Not sure it works or not !!!
Please let me know if you know how to use the AudioUpdateFromRegistry, defined in coredll
Thanks :wink:
One more acticle !!!
http://www.pocketpcdn.com/forum/viewtopic.php?t=111
But I dunno how to make it works.
Any runnable example?
Hello,
after many tries I didn't find how to use TAPI functions ... this seems not towork ..
But you can change all the phone settings (volume, ring mode, ring tone, notifications ...) in the registry ... as I did for PocketZenPhone
See under that key HKEY_CURRENT_USER\ControlPanel
For the system volume I use the functions I posted upper
Hey, any example to do it?
Thanks zendrui
If you use EVC
Simply open the registry key
HKEY Key;
RegOpenKeyEx(HKEY_CURRENT_USER,_T("\\ControlPanel\\Volume"),0,0,&Key);
Then use RegQueryValueEx to retrieve the value/setting you want
Hi zendrui,
I am able to update the registry, but I am not able to call AudioUpdateFromRegistry to notify the system to update the status from registry.
Could you able to exeute this API?
Thanks,
Paul
Sorry for the last post didn't have the keys in my mind
So to change the phone volume here are the keys needed
Code:
//dwPhoneVolumeLevel between 0 and 0xFFFFFFFF
res = RegOpenKeyEx(HKEY_CURRENT_USER,_T("\\ControlPanel\\Volume"),0,0,&Key);
if (res == ERROR_SUCCESS)
{
res = RegSetValueEx(Key,_T("Ringer"),0,REG_DWORD,(LPBYTE)&dwPhoneVolumeLevel,sizeof(DWORD));
if (res != ERROR_SUCCESS)
{
RegCloseKey(Key);
return -1;
}
}
RegCloseKey(Key);
//dwInitVol between 1 and 5
res = RegOpenKeyEx(HKEY_CURRENT_USER,_T("\\ControlPanel\\SoundCategories\\Ring"),0,0,&Key);
if (res == ERROR_SUCCESS)
{
res = RegSetValueEx(Key,_T("InitVol"),0,REG_DWORD,(LPBYTE)&dwInitVol,sizeof(DWORD));
if (res != ERROR_SUCCESS)
{
RegCloseKey(Key);
return -1;
}
}
RegCloseKey(Key);
It changes the phone volume and the display
PS : I post this code hoping is to help people to develop freewares (or low low cost software :wink
COOL !!! Thanks zendrui !!!!
Now I can set the Ringer volume !!!
How about set the system sound volume?
Fot the system volume see upper of this thread I posted the code I use. It works perfect
O yes...It works under eVC++
Let me try to implement it in VS.NET
Thanks
bong99 said:
O yes...It works under eVC++
Let me try to implement it in VS.NET
Thanks
Click to expand...
Click to collapse
Please tell me if you make it, as I have tried various P/Invoke calls that all result in a No Supported Exception.
Cato
PS: Sorry that I could not get you a working code before but I was under with the flu last week

Changing speaking loudness on the telephone (with TAPI)

I've a question to change the telephone sound volume of the mda II for speaking. For this I found the function phoneSetVolume(HPHONE hPhone, DWORD dwHookSwitchDev, DWORD dwVolume) of the TAPI.
Now I've the problem that I don't know how to get the handle to the phone (HPHONE).
Can anybody help me?
Thanks!
use phoneOpen
There is still a problem...
Okay, but the function phoneOpen requires also parameters which I don't know where I can get they. For instance the HPHONEAPP. Where can I get the phone application or the deviceID and then the LPPHONE.
I am very thankful to you when you could help me how to get the parameters.
Or is it possible to change the volume of the telephone speaker by changing a registry key? Do you know the key name?
Thanks a lot!
Re: There is still a problem...
phoneInitializeEx gives you PhoneApp and number of phone devices, phoneOpen gives you hPhone, deviceID is probably 0 (test all deviceIDs starting from 0 to the count returned by phoneInitializeEx). Read MSDN for more information.
I don't know the registry key, and modifying it would not change the device volume immediately.
Thanks for your reply!
When I use the function phoneInitializeEx() it returns a value that is negative but not an determined error. Here is my code. Can you say me whats wrong?!
HPHONEAPP lpHPhoneApp;
DWORD lpdwNumDevs;
DWORD lpdwAPIVersion;
PHONEINITIALIZEEXPARAMS lpPhoneInitializeExParams;
long result = phoneInitializeEx(&lpHPhoneApp, NULL, NULL, NULL, &lpdwNumDevs, &lpdwAPIVersion, &lpPhoneInitializeExParams);

volume setting

I am trying to set the volume to my needs then put it back after. I have use the code from ppc developer network and when that did not set the correct volume I also did the registry as well. Don't worry about "reg", its my registry class and it works fine.
DWORD oldReg=0;
oldReg=reg->readDWORDfromReg(name,path);
reg->saveDWORDtoRegistry(name,path,0xffffffff);
WAVEFORMATEX wf;
wf.wFormatTag = WAVE_FORMAT_PCM;
wf.nChannels = 1;
wf.nSamplesPerSec = 8000 * 1000;
wf.wBitsPerSample = 8;
wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8;
wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
wf.cbSize = 0;
HWAVEOUT hwo;
DWORD dwVolume=0xffffffff;
DWORD oldVolume=0;
int waveDevice=-1;
UINT numberOfDevices=waveOutGetNumDevs();
for(UINT id=0;id<numberOfDevices;id++)
{
if (waveOutOpen(&hwo,id,&wf,0,0,CALLBACK_NULL)==MMSYSERR_NOERROR)
{
waveDevice=id;
waveOutGetVolume(hwo,&oldVolume);
waveOutSetVolume(hwo,dwVolume);
waveOutClose(hwo);
break;
}
}
.........playing sound here all ok....
//put the volume back
if(waveDevice!=-1)
{
if (waveOutOpen(&hwo, waveDevice, &wf, 0, 0, CALLBACK_NULL) == MMSYSERR_NOERROR)
{
waveOutSetVolume(hwo, oldVolume);
waveOutClose(hwo);
}
}
reg->saveDWORDtoRegistry(name,path,oldReg);
I can set the volume to any value below the origional volume but any attempt to set a volume higher just dose nothing. There are no errors (checking left out here), just the same level. I did not seriously expect the registry part to work as I guess there is some event to trigger that change, but others seem to get results from waveOutSetVolume.
Well, I never tried changing volume by code, but I know TCPMP player does it well and it's open source so might be worth taking a look at.
Thanks levenum, I will give it a look.
Before I got a chance to look at that code I got a result. I have been using PlaySound to play a resource with no volume change working. When I use waveOutWrite to play a buffer containing the same data I can get the volume change I am after. There is still something wrong with my code because the sound gets garbled but I think I will figure that part out. I also want to next test playsound with a file instead of a resource.
<edit>
using playsound with the same file plays clear sound but the volume change is not working. Its a pity because to get the waveoutwrite to work properly i had to fill in the WAVEFORMATEX with the CORRECT values. This means that if I am allowing the user to specify files to play I will have to find out the samples per second and bits per sample info before I can use the file.

TyTN with increasing ring AND vibrate

My ancient SE P910i could have an increasing ring with vibrate, I've noticed my TyTN can't do that. Anyone know of any way that this can be acheived? Registry hack, small app or otherwise?
See if this helps. Courtesy of Wiki here...
Change ringtone/vibrate/LED flash characteristics
If you would like more control over how your device rings/vibrates/flashes its LEDs on events, you can can change the Script values of these events.
For example, for an incoming call performing 'activate device, play ringtone, wait 3 seconds, repeat':
HKCU\ControlPanel\Sounds\RingTone0\Script = "apw3r" (REG_SZ string, no quotes)
For performing 'active device, set volume to 33%, play ringtone, set volume to 67%, play ringtone, set volume to 100%, play ringtone (no repeat)':
HKCU\ControlPanel\Sounds\RingTone0\Script = "ac33pc67pc100p" (REG_SZ string, no quotes)
The following are the full codes available to you. Please note that all the codes are executed simultaneously except after a ringtone play / wait code. E.g. 'v1p' will vibrate and play at the same time, while vibrating for 1 second. But 'pv1' will play the ringtone through all the way first, then start vibrating for 1 second.
a = activate device
cN = set volume to N in percentage max volume
fN = flash notification LED for N seconds
p = play ringtone. Note that this will play the ringtone all the way through before continuing with the next code.
r = repeat. Note that this should be the last code in your Script string, if used at all.
vN = vibrate for N seconds
wN = wait for N seconds. Note that the device will wait this long before continuing with the next code.
Thanks mgmchan, but that looks damn complicated for an accountant
Nay, you can find this forum, post on this forum, you won't have any problem doing that.
1. Find a registry editor. Resco should be a good choice.
2. Once you run the editor, those HKCU\ControPanel\... etc will become very obvious to you. May be that sample string "ac33p..." suits your need already.
Have fun.
it's not complicated at all - the problem is that many (if not all) profile changers will modify this script without the option for you to provide a custom script of your own - quite frustrating

Get and set current volume profile

Hallo,
I have the following problem with my C++ (MFC) program. I need to set the volume of the device to full for a short time and after set reset it to the state it was before. Currently I at the beginning, I read the current volume of the device with the following:
waveOutGetVolume(NULL, &dwOldVolume);
and after that set it to my volume with this:
waveOutSetVolume(NULL, dwVolume);
no I do my sound stuff and after that I restore the devices volume with:
waveOutSetVolume(NULL, dwOldVolume);
This works in most cases very well. But there is one problem: If the device is set to "vibrate only" (resulting in the little vibration icon in the tray), my function will set the device after it is done not to "vibration only", but to normal ring tone with volume 0. Exceptionally if the selected ring tone has not the vibration option selected, every next upcoming call will not be recognized.
How can I get the selected profile from the phone ("Normal", "Vibration only", "Mute") and how can I restore it (by combining it with my volume functions above to set the correct volume if the selected profile is "normal")?
I hope I could make my point clear. ;-)
Thanks for any help!
Miggedy
Look/try for SndSetSound ....
Example:
TCHAR szDestination[MAX_PATH];
SNDFILEINFO sndFile = {0};
if(mode == 2) // silent
{
sndFile.sstType = SND_SOUNDTYPE_NONE;
}
else if(mode == 3) // vibrate
{
sndFile.sstType = SND_SOUNDTYPE_VIBRATE;
}
else // sound (normal)
{
sndFile.sstType = SND_SOUNDTYPE_ON;
}
szDestination[0] = 0;
StringCchCopy(sndFile.szPathName, MAX_PATH, szDestination);
// Set the ringtone.
SndSetSound(SND_EVENT_ALL, &sndFile, TRUE);
Yes, that is what I was looking for. Works perfectly.
Thank your very much!

Categories

Resources