Solved

master volume control

Posted on 1998-11-10
4
637 Views
Last Modified: 2010-04-04
I want my delphi 1.0 program to control the multi media master volume lever. How do I do that?
0
Comment
Question by:dan451
  • 2
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 100 total points
ID: 1346375
Dan,

In your Uses clause, declare MMSystem.  Then, to set the volume, use the API function AuxSetVolume(DeviceID, VolumeLevel) where DeviceID is the device you want to adjust (5 for the master volume control) and VolumeLevel is the new level.

Setting the volume is tricky and will require a bit of research to get it to work.  I had a quick read of the help file and it wasnt much good.  If you want more info, let me know and I'll post you the way to do it.  You shouldnt have too many problems regardles..

Cheers!

Stu.
0
 

Author Comment

by:dan451
ID: 1346376
Hi Stu,

Thanks for your answer but I was not able to make it work. I did some experienting and this is what I found.

AuxSetVolume(DeviceID, VolumeLevel)
AuxGetVolume(DeviceID, VolumeLevel)
I played with the get volume command. I assume except for what the functions do they both go to the same place. With the device id set to 5 i get an error code ~ MMSYSERR_BADDEVICEID

But device id 0 does controls the line device and id 1 controls the cd device. I tried other id's all gave me MMSYSERR_BADDEVICEID

I thought maybe I could gain control with with the wave and midi volume control. No help. Below is my souce code and the results.
I know it is possible to control the master volume from a program because the netscape media player does it. Let me know if u still want to work on it or not. If not I still give u some points for a good try.

Thanks
  Danny


0
 

Author Comment

by:dan451
ID: 1346377
unit Voltest;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, mmsystem, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  lVolume: Longint;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);

var
  ccode: word;

begin
  {
  line in is $0
  the cd is $1
  ccode := auxGetVolume( $0, @lVolume ); }

  {
  the wave is $0
  ccode := waveOutGetVolume( $0, @lVolume );}

  {
   $1 controls returns $ffff as the volume, returns no error code. $ffff
      does not coraspond to anything.
   $0 returns and error 8 ~ mmsyserr_NotSupported
  ccode := midiOutGetVolume( $2, @lVolume ); }

  if ccode <> 0 then begin
    messagedlg( 'ccode is ' + intToStr( ccode ), mtinformation, [mbOk], 0 );
    if MMSYSERR_BADDEVICEID = ccode then
      messagedlg( 'ccode is MMSYSERR_BADDEVICEID', mtinformation, [mbOk], 0 );
    end;
  label1.caption := intToHex( lVolume, 4 )
end;

end.

0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1346378
Hi Dan,

I'll have a go at it shortly.  However, one thing I must mention is that some sound cards do not work with any of these API calls.  It depends on the sound card.  I have no explaination as to why, but its a sad fact.  We develop multi-media educational products, and when SoundBlaster cards where the norm, we had no problems adjusting the mixer settings.  Now with all these cheap second rate sound cards, we have stopped doing it (we actually launch Windows mixer!).

As I said, I'll see if i can figure something out for you.  I'll let you know either way.

Stu
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

861 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

23 Experts available now in Live!

Get 1:1 Help Now