Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 662
  • Last Modified:

master volume control

I want my delphi 1.0 program to control the multi media master volume lever. How do I do that?
0
dan451
Asked:
dan451
  • 2
  • 2
1 Solution
 
Stuart_JohnsonCommented:
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
 
dan451Author Commented:
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
 
dan451Author Commented:
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
 
Stuart_JohnsonCommented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now