Solved

master Volume

Posted on 1998-09-16
16
378 Views
Last Modified: 2010-04-06
Can i control the master volume? If yes, how? I know how to control the wav vol, cd vol and so on but how to control the master volume?
0
Comment
Question by:dagger
  • 6
  • 4
  • 4
  • +2
16 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1340007
What's the master volume?
0
 

Author Comment

by:dagger
ID: 1340008
Master Volume in Windows 95
U have a task bar in Windows 95. Go to the task bar and u can see there is a running clock and besides the running clock there is a sound icon. Left click on the sound icon once and there is a volume control. changing the volume will result changing the voulme for wave, midi, Cd and so on. And if u were to change the voulme for CD onli i.e double click the sound icon and u will able to see the voulme contol for cd ...changing that will onli change the volume of cd onli....See the difference?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1340009
dagger,

do you want to do this with API?
0
 

Author Comment

by:dagger
ID: 1340010
Madshi,
Do you know which Windows API to use, to control the Master Volume?
And i think this is the only solution, by using window API, to control the Master Volume. Is there any other possible way?

Thanks...
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1340011
hi, dagger.

here's something i've just fumbled out:

.

var
  Form1: TForm1;
  pCurrentVolumeLevel: PDWord;
  CurrentVolumeLevel: DWord;

procedure TForm1.FormCreate(Sender: TObject);
begin
  New(pCurrentVolumeLevel);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  auxGetVolume(0, pCurrentVolumeLevel);
  CurrentVolumeLevel := pCurrentVolumeLevel^;
  Trackbar1.position := LoWord(CurrentVolumeLevel) DIV GetTrackBar;
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
  CurrentVolumeLevel := Trackbar1.position * GetTrackBar shl 16;
  CurrentVolumeLevel := CurrentVolumeLevel + (Trackbar1.position * GetTrackBar);

  if auxSetVolume(0, CurrentVolumeLevel) <> 0 then   // <- !!!!!!!!
    ShowMessage('Cannot adjust Volume.');

end;

in the third line above (with the exclamation marks):

on my machine:

0: wave
1: midi
2: cd audio
3: line-in
4: micro
5: VOLUME CONTROL (this is the master volume)
6: pc-speaker

(function auxGetNumDevs returns 7)

i don't know yet how to determine which deviceid is which control. this is in MMSystem.

i'll work on it...

cheers,

Black Death.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1340012
oh, and don't forget to dispose(pCurrentVolumeLevel); on Destroy...

Black Death.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1340013
Hi BlackDeath,

why are you using "New(pCurrentVolumeLevel)" ??????? Why not using "auxGetVolume(0,@CurrentVolumeLevel)" instead? Wouldn't that be much simpler?

Regards, Madshi.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1340014
ugh, yeah. :-(

this one grew - btw: the kind of allocating the pointer's variable memory is not the actual problem.
(sometimes i fall back to my roots when dealing with a special problem.....) :-|

problem *_is_* :

do you have a solution for determining the deviceid of each available control?????

so long,

nastrowje! :-)

Black Death.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 20

Expert Comment

by:Madshi
ID: 1340015
BlackDeath,

I know this was not the problem.  :-)

I didn't know the aux... functions before your comment. So I can't help you with that. I'm using the functions "mixerGetNumDevs/mixerOpen/mixerGetLineInfo/mixerGetLineControls/mixerSetControlDetails" instead. But they are very, very, very, very, very, very, very complicated.
Unfortunately I'm not allowed to give you my sources - my boss would be quite annoyed about that. I wish I were my own boss...   :-(

Regards, Madshi.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1340016
madshi,

i've browsed through those funcs und must say:
this sux.
they're *REALLY* not simple in the common sense.

say - what might be youre job when it's affected by this question?

nevertheless i'm gonna try and see if i can figure out the correct usage of the mixer-funcs. i must be crazy.

if you've got any hints (respecting literature, url's etc. concerning this theme and not interfering with your job), pleez post'em'ere.

i'm quite intersted in this thing now, too.

maybe dagger could adjust the points to 7
(my 2nd number; i think 666, which is my 1st number, is a little bit too much) - just as a lucky charm...

_gosh_, what a pile of *crap*.

we'll see.

so long,

Black Death.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1340017
ach - noch was:

madshi,
before i go on trying to dig it, tell me if these are the solution to the prob.

Black Death.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1340018
BlackDeath,

my job is just programming. Unfortunately my boss doesn't want me to post here too much of my complete sources. I would really like to, but I'm just not allowed to. I think my boss has a little paranoia (pssst - don't tell him that).
With the mixer functions you can do everything what the windows mixer does. The windows mixer is just the graphical implementation of all this complex mixer functions. So you can do EVERYTHING with them.
OK, I'll give you some lines to begin with. If you want to change some control use mixerGetControlDetails/mixerSetControlDetails.

procedure ShowMixerControls;
var booleanToChar : array [boolean] of string = ('-','+');
var mix     : integer;
    mixCaps : TMixerCaps;
    ml      : TMixerLine;
    c1      : cardinal;
    str     : string;
 function ContainsControl(ml: TMixerLine; ct: cardinal) : boolean;
 var mlc : TMixerLineControls;
     mc  : TMixerControl;
 begin
   with mlc do begin
     cbStruct:=SizeOf(mlc);
     dwLineID:=ml.dwLineID; cControls:=ml.cControls;
     dwControlType:=ct;
     cbmxctrl:=SizeOf(mc); pamxctrl:=@mc;
   end;
   result:=mixerGetLineControls(mix,@mlc,MIXER_GETLINECONTROLSF_ONEBYTYPE)=MMSYSERR_NOERROR;
 end;
 procedure EnumMixerSources(dstComponentType: cardinal);
 var i1      : cardinal;
     s1      : string;
     ml1,ml2 : TMixerLine;
 begin
   with ml1 do begin
     cbStruct:=SizeOf(ml1); dwComponentType:=dstComponentType;
   end;
   if mixerGetLineInfo(mix,@ml1,MIXER_GETLINEINFOF_COMPONENTTYPE)<>MMSYSERR_NOERROR then exit;
   s1:=ml1.szName; while length(s1)<25 do s1:=s1+' ';
   str:=str+Copy(s1,1,25)+'  ';
   str:=str+booleanToChar[ContainsControl(ml1,MIXERCONTROL_CONTROLTYPE_VOLUME   )]+'    ';
   str:=str+booleanToChar[ContainsControl(ml1,MIXERCONTROL_CONTROLTYPE_MUTE     )]+'    ';
   str:=str+booleanToChar[ContainsControl(ml1,MIXERCONTROL_CONTROLTYPE_PEAKMETER)]+'    ';
   str:=str+booleanToChar[ContainsControl(ml1,MIXERCONTROL_CONTROLTYPE_MUX      )]+'    ';
   str:=str+booleanToChar[ContainsControl(ml1,MIXERCONTROL_CONTROLTYPE_MIXER    )]+'    '#$D#$A;
   for i1:=0 to ml1.cConnections-1 do begin
     with ml2 do begin
       cbStruct:=SizeOf(ml2); dwDestination:=ml1.dwDestination; dwSource:=i1;
     end;
     if mixerGetLineInfo(mix,@ml2,MIXER_GETLINEINFOF_SOURCE)<>MMSYSERR_NOERROR then exit;
     s1:='  '+ml2.szName; while length(s1)<25 do s1:=s1+' ';
     str:=str+Copy(s1,1,25)+'  ';
     str:=str+booleanToChar[ContainsControl(ml2,MIXERCONTROL_CONTROLTYPE_VOLUME   )]+'    ';
     str:=str+booleanToChar[ContainsControl(ml2,MIXERCONTROL_CONTROLTYPE_MUTE     )]+'    ';
     str:=str+booleanToChar[ContainsControl(ml2,MIXERCONTROL_CONTROLTYPE_PEAKMETER)]+#$D#$A;
   end;
 end;
begin
  if (mixerGetNumDevs>0) and (mixerOpen(@mix,0,0,0,MIXER_OBJECTF_MIXER)=MMSYSERR_NOERROR) and
     (mixerGetDevCaps(0,@mixCaps,sizeOf(mixCaps))=MMSYSERR_NOERROR) then
    try
      str:='Name                       Vol. Mute Peak Mux Mixer'#$D#$A;
      ml.cbStruct:=sizeOf(ml);
      for c1:=0 to mixCaps.cDestinations-1 do begin
        ml.dwDestination:=c1;
        mixerGetLineInfo(mix,@ml,MIXER_GETLINEINFOF_DESTINATION);
        EnumMixerSources(ml.dwComponentType);
        //MIXERLINE_COMPONENTTYPE_DST_SPEAKERS);
        //EnumMixerSources(MIXERLINE_COMPONENTTYPE_DST_WAVEIN);
      end;
      MessageBox(0,PChar(str),'Mixer',0);
    finally mixerClose(mix) end;
end;

Regards, Madshi.
0
 

Author Comment

by:dagger
ID: 1340019
OK, I have increase the points. Looks like this is going to take me some time to look into this master volume thingy. I am really puzzle when i look into this codes especially from Madshi. I am not really an expert like u guys.
Anyway, i will check with u guys from time to time. By the way, BlackDeath, i am not going to reject your answer, since u haven't completed it yet. And, ha ha ha , i don't know that is the correct one or not.

Cheers, dagger.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1340020
hoy, dagger!

i can't find any answer (?) so what are you not going to reject?
be sure - i'm working on it.
and as soon as i've got something that worx i'll post it here, ok?

regs,
Black Death.
0
 

Author Comment

by:dagger
ID: 1340021
I not going to reject cos there isn't any proposed anwer to reject. All the discussion above are mainly comments only.
I have increased the points to 10. Chow.

Cheers, dagger
0
 

Accepted Solution

by:
bome earned 10 total points
ID: 1340022
Found that.
Normally it shoudln't be OK to get points for another peoples work, but, this is far too little points for the problem and it's a long time ago that I answered a question...

http://www.wilsonc.demon.co.uk/delphi.htm

and download mixer demo and mixer explorer. It's free and with full source.

bome

PS: certainly it includes the way to control the master volume.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

15 Experts available now in Live!

Get 1:1 Help Now