Solved

master Volume

Posted on 1998-09-16
16
383 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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