Solved

master volume control

Posted on 1998-11-10
4
648 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

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…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

615 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