Solved

master volume control

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

12 Experts available now in Live!

Get 1:1 Help Now