Solved

master volume control

Posted on 1998-11-10
4
642 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
creating threads in delphi 1 131
Performance of SQL statement 37 127
Drag & Drop... Data from one grid to another 2 41
shape, triangle, dbctrlgrid 3 17
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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