Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to control the MIDI speaker output volume Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
Multimedia
Language
Delphi 2.x
Views
76
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How can I control the MIDI speaker output volume? If that's not directly possible: 
how can I programmatically open the volume control?

Answer:

First you need to ID the device


1   tmpreg := TRegistry.Create;
2   tmpreg.RootKey := HKEY_CURRENT_USER;
3   tmpreg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Multimedia\MIDIMap', 
4   false);
5   
6   
7   { ... }
8   if tmpreg.ValueExists('CurrentInstrument') then
9   begin
10    MidiOutPutDev := tmpreg.ReadString('CurrentInstrument');
11  end;
12  tmpreg.destroy;
13  { ... }
14  
15  then get a handle of the device
16  
17  
18  amt := MidiOutGetNumDevs;
19  MidiOutputDevid := -1;
20  for t := 1 to amt do
21  begin
22    MidiOutGetDevCaps(t - 1, @Midicap, Sizeof(Midicap));
23    if Strpas(@MidiCap.szPName) = MidiOutPutDev then
24    begin
25      MidiOutputDevid := t - 1;
26    end;
27  end;
28  
29  
30  //Then set the volume either master or seperate
31  
32  
33  procedure SetVolumeMidi(RVolume, LVolume: Cardinal);
34  begin
35    midiOutSetVolume(MidiOutputDevid, (RVolume * 256 * 256) + LVolume);
36  end;
37  
38  procedure SetMVolumeWave(Volume: Cardinal);
39  var
40    pl, pr: Cardinal;
41  begin
42    pr := (WRPan * Volume) div 100;
43    pl := (WLPan * Volume) div 100;
44    waveOutSetVolume(WaveOutputDevid, (pr * 256 * 256) + pl);
45  end;



Include mmsystem in your Uses clause

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC