Solved

Control Master Volume From App..

Posted on 1998-08-18
8
372 Views
Last Modified: 2012-08-13
How can I control the system volume from within my app using API? I found sample code for controlling the wav volumes, but I would like to control ALL output. The master volume I guess it could be called...

Thanks

Gary
0
Comment
Question by:garymace
  • 4
  • 2
  • 2
8 Comments
 
LVL 1

Expert Comment

by:kuk010998
ID: 1429751
Well, I really do not want points for this, but Dr. GUI had an answer a while ago. I think copying the text here would not be legal, but it should be available online... Lemme see... Oops, MS's MSDN site is incompatible with ie3...  Nah, can't find it. It was in MSDN news (the big newsletter coming with a MSDN subscription) March/april 1998 (Vol. 7 Number 2), page 3, bottom of 1st column. You got access to that? The article mentions "There is no simple API", the function names "mixerGetNumDevs", "mixerGetLineInfo", "mixerGetLineControls" and "mixerGetControlDetails", and bugs in win32api.txt...

Have fun!
0
 
LVL 1

Expert Comment

by:kuk010998
ID: 1429752
0
 

Author Comment

by:garymace
ID: 1429753
No, I do not have access to MSDN. Thanks anyway..

Gary

0
 
LVL 1

Expert Comment

by:kuk010998
ID: 1429754
Didn't they offer MSDN online free? Might be worth a try. On the other hand, the 'premium' in the URL above might exclude you again... In any case, that article did not offer a complete solution anyway, so you'd search the MSDN library for those keywords I gave. The MSDN library is a must anyway.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 1

Accepted Solution

by:
nilos earned 20 total points
ID: 1429755
Dr. GUI is gratified that you're concerned for your users' hearing. It speaks volumes for your intelligence and compassion. There are few things more annoying than an application that's just too noisy. It's almost as bad as stealing focus from the foreground application.

Unfortunately, there is no simple API call to get or set the volume. It requires iterating through four layers of functions and structures to get or set the system volume.

First, call mixerGetNumDevs to locate the correct mixer device. Next, call mixerGetLineInfo to determine which line of the device controls the volume to the speakers. Then, call mixerGetLineControls to determine which control on that line lets you change the volume. Finally, call mixerGetControlDetails to obtain the structure containing the volume setting.

To actually change the volume you must work around Visual Basic's limited ability to handle pointers. (Or you could write a COM object in Visual C++ to do this.) The availability of the VarPtr() function in Visual Basic 5.0 smooths the way considerably. Note that you'll have to declare some of the structures and functions yourself because of bugs in the WIN32API.TXT file that shipped with Visual Basic.

By the way, it would probably be a good idea to put the volume back when your application exits—changing it permanently for the user is kinda rude.


0
 
LVL 1

Expert Comment

by:kuk010998
ID: 1429756
That's the text I meant. Just I do not republish copyrighted information...
0
 
LVL 1

Expert Comment

by:nilos
ID: 1429757
I was concerned about to publish copyrighted info but, in this case I did not break any copyright law because:

a) Dr. Guy is a public information
b) I do not publish his text pretending it was mine
c) This place is not a public, in the strict sense, place

d) garymace needs this information to do a better usage of a Microsoft product.

Based on that I don't think that Microsoft will sue me.





0
 

Author Comment

by:garymace
ID: 1429758
Thank you nilos for the post.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now