?
Solved

Audio Compression Codecs...

Posted on 1999-08-01
19
Medium Priority
?
524 Views
Last Modified: 2010-04-04
hi all

is it possible to change the priority of the Audio Compression Codes (under Control Panel -> Multimedia -> Advanced Tab -> Audio Compression Codecs) programmatically?

regards
Keith
0
Comment
Question by:keithcsl
  • 10
  • 5
  • 3
  • +1
19 Comments
 
LVL 1

Author Comment

by:keithcsl
ID: 1392235
i think this is not a trivial question. points have been increased to 100.

regards
Keith
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1392236
You could change the positions if the lines in system.ini under [drivers32].
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1392237
This example swaps the first and second codec in ['Drivers32']:


uses IniFiles;

procedure TForm1.Button1Click(Sender: TObject);
var DelphiIni: TIniFile;
    list: TStringList;
    i: Integer;
begin
  list := TStringList.Create;
  DelphiIni := TIniFile.Create('system.ini');
  DelphiIni.ReadSectionValues('Drivers32', list);
  //Swap first and second.....
  list.Exchange(0, 1);
  DelphiIni.EraseSection('Drivers32');
  for i := 0 to list.Count - 1 do
    with list do
    begin
      DelphiIni.WriteString('Drivers32', Names[i], Values[Names[i]]);
    end;
  DelphiIni.Free;
  list.Free;
end;



Be casefull when modifying ini files!

Regards,

Epsylon.
0
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.

 
LVL 15

Expert Comment

by:simonet
ID: 1392238
That's not the right way to do it, Epsylon. Mainly if the code will Windows NT as well.

Settings in Win.ini and System.ini may not change at once.

Keith, there are special API calls (in the Multimedia API) that will let you work with the codecs.

The first thing to do is to enumerate all the codecs using the call acmDriverEnumCallback. You keep on enumerating the drivers (=codecs) until you find the one for which you want to change the priority level. One you find it, you can change its priority using the acmDriverPriority API call, which is pretty straightforward to use.

Yours,

Alex

0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1392239
I know but do you know how I can get access to acmDriverEnum, acmDriverPriority etc......?
0
 
LVL 15

Expert Comment

by:simonet
ID: 1392240
You can import them from your Delphi application:

CONST  MSACM32 = 'msacm32.dll'

uses MMSystem;

function acmDriverEnum(CallBackProc : pointer; hInst, fdwEnum : DWORD) : MMRESULT; stdcall; external MSACM32 name 'acmDriverEnum';

function acmDriverPriority(hadid, dwPriority, fdwPriority : DWORD) : MMRESULT; stdcall; external MSACM32 name acmDriverPriority;

The types above for CallBackProc and hadid are not the exact same ones as defined in msacm32.h, but they are compatible types, so there will be no problem. What I did was just a simplification of the types. It will work fine.

Yours,

Alex
Athena's Place: http://www.bhnet.com.br/~simonet

0
 
LVL 1

Author Comment

by:keithcsl
ID: 1392241
epsylon

i am sorry but simonet is correct. i was reading up on the acm functions yerterday but could not figure out where to start. but now i have a rough idea. if u need the definitions for the acm routines, i have the .pas file. just pop me a mail.

simonet

i will write the code tonight and test it out.

Regards
Keith
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1392242
Hold on, I'm almost ready....
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 400 total points
ID: 1392243
Hi Keith, here is is! If you want the complete project then drop your email address here or send it to Epsylon3@hotmail.com

Thanks to Alex for pointing to MSACM!

Cheers!



unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, IniFiles, MMSystem, Spin;

const
  MSACM32 = 'msacm32.dll';
  ACM_DRIVERPRIORITYF_ENABLE    = $00000001;
  ACM_DRIVERPRIORITYF_DISABLE   = $00000002;
  ACM_DRIVERPRIORITYF_ABLEMASK  = $00000003;
  ACM_DRIVERPRIORITYF_BEGIN     = $00010000;
  ACM_DRIVERPRIORITYF_END       = $00020000;
  ACM_DRIVERPRIORITYF_DEFERMASK = $00030000;
  ACMDRIVERDETAILS_SHORTNAME_CHARS = 32;
  ACMDRIVERDETAILS_LONGNAME_CHARS   =  128;
  ACMDRIVERDETAILS_COPYRIGHT_CHARS  =  80;
  ACMDRIVERDETAILS_LICENSING_CHARS  =  128;
  ACMDRIVERDETAILS_FEATURES_CHARS   =  512;


type
  FOURCC = array[0..3] of Char;

  PACMDRIVERDETAILS = ^TACMDRIVERDETAILS;
  TACMDRIVERDETAILS = packed record
    cbStruct: DWORD;          // number of valid bytes in structure
    fccType: FOURCC;          // compressor type 'audc'
    fccComp: FOURCC;          // sub-type (not used; reserved)
    wMid: WORD;               // manufacturer id
    wPid: WORD;               // product id
    vdwACM: DWORD;            // version of the ACM *compiled* for
    vdwDriver: DWORD;         // version of the driver
    fdwSupport: DWORD;        // misc. support flags
    cFormatTags: DWORD;       // total unique format tags supported
    cFilterTags: DWORD;       // total unique filter tags supported
    hicon: HICON;             // handle to custom icon
    szShortName: array[0..ACMDRIVERDETAILS_SHORTNAME_CHARS-1] of Char;
    szLongName: array[0..ACMDRIVERDETAILS_LONGNAME_CHARS-1] of Char;
    szCopyright: array[0..ACMDRIVERDETAILS_COPYRIGHT_CHARS-1] of Char;
    szLicensing: array[0..ACMDRIVERDETAILS_LICENSING_CHARS-1] of Char;
    szFeatures: array[0..ACMDRIVERDETAILS_FEATURES_CHARS-1] of Char;
  end;



  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    SpinEdit1: TSpinEdit;
    Button4: TButton;
    procedure Enumerate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
  TacmDriverEnumCallback = function (hadid, dwInstance, fdwSupport: DWORD): MMRESULT; stdcall;
  function acmDriverDetails(hadid: DWORD; padd: PACMDRIVERDETAILS; fdwDetails: DWORD) : MMRESULT; stdcall; external MSACM32 name 'acmDriverDetailsA';
  function acmDriverEnum(CallBackProc : TacmDriverEnumCallback; hInst, fdwEnum : DWORD) : MMRESULT; stdcall; external MSACM32 name 'acmDriverEnum';
  function acmDriverPriority(hadid, dwPriority, fdwPriority : DWORD) : MMRESULT; stdcall; external MSACM32 name 'acmDriverPriority';

var
  Form1: TForm1;
  IDList: TList;

implementation

{$R *.DFM}

function CallBack(hadid, dwInstance, fdwSupport: DWORD): MMRESULT; stdcall;
var details: TACMDRIVERDETAILS;
begin
  IDList.Add(Pointer(hadid));
  details.cbStruct := sizeof(details);
  acmDriverDetails(hadid, @details, 0);
  Form1.ListBox1.Items.Add(details.szLongName);
  Result := 1;
end;

procedure TForm1.Enumerate(Sender: TObject);
begin
  IDList.Clear;
  ListBox1.Clear;
  acmDriverEnum(@CallBack, 0, 0);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  IDList := TList.Create;
  acmDriverEnum(@CallBack, 0, 0);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  IDList.Free;
end;

// Sets the selected item in the listbox to the highest priority
procedure TForm1.Button2Click(Sender: TObject);
begin
  if ListBox1.ItemIndex <> -1 then
  begin
    acmDriverPriority(DWORD(IDList[ListBox1.ItemIndex]), 1, 0);
    IDList.Clear;
    ListBox1.Clear;
    acmDriverEnum(@CallBack, 0, 0);
  end;
end;

// Sets the selected item in the listbox to the lowest priority
procedure TForm1.Button3Click(Sender: TObject);
begin
   if ListBox1.ItemIndex <> -1 then
  begin
    acmDriverPriority(DWORD(IDList[ListBox1.ItemIndex]), DWORD(-1), 0);
    IDList.Clear;
    ListBox1.Clear;
    acmDriverEnum(@CallBack, 0, 0);
  end;
end;

// Sets the selected item in the listbox to the priority entered in the spinedit
procedure TForm1.Button4Click(Sender: TObject);
begin
  if ListBox1.ItemIndex <> -1 then
  begin
    acmDriverPriority(DWORD(IDList[ListBox1.ItemIndex]), SpinEdit1.Value, 0);
    IDList.Clear;
    ListBox1.Clear;
    acmDriverEnum(@CallBack, 0, 0);
  end;
end;

end.
0
 
LVL 15

Expert Comment

by:simonet
ID: 1392244
(Edited by Computer101) EPSYLON, THAT WAS MY ANSWER.

Keith, reject Epsylon's answer, because I answered that first. He just used code I suggested, and, if it wasn't for me, he wouldn't have a (Edited by Computer101)ing clue on how to do it.

What's wrong with you, Epsylon? Are you double-crossing me?

>Thanks to Alex for pointing to MSACM!

(Edited by Computer101) that. I was gonna answer this one.

Alex
0
 
LVL 15

Expert Comment

by:simonet
ID: 1392245
Sorry for the bad language, but I am really upset with what's going on here (Epsylon's blind hunger for points).

What's going on at EE?

Alex
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1392246
Alex, I just give a complete example. What's wrong with that? I happens to me too that someone uses my suggestion and gets to points.

And most of this example I did myself!

I just can't stand you react like this!!!!!!

I AM FIRST WITH FULL CODE!!!!

> and, if it wasn't for me, he wouldn't have a (Edited by Computer101)ing clue on how to do it.

Yeah, try me!
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1392247
Keith, I spend about an hour (didn't count) on it so I would regret it when you reject my answer. This site is here to help people and not to fight about points.

You decide what to do.....

Regards,

Epsylon.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1392248
Alex, I can post a 100 point Q for you if Keith accepts my answer. I will give you an 'A'.
0
 
LVL 15

Expert Comment

by:simonet
ID: 1392249
Sure you did, Epsylon. If you did, what does this mean?


Comment
From: Epsylon Date: Sunday, August 01 1999 - 12:09PM EST  

I know but do you know how I can get access to acmDriverEnum, acmDriverPriority etc......?
 


You didn't have a clue on how to work it. Once I gave all the tips it was very, very easy to write code for it. Your first idea was to use the ini files. You didn't even think about using the API calls.

Pay attention to my comment to Keith:

>The first thing to do is to enumerate all the codecs using
>the call acmDriverEnumCallback. You keep on enumerating
>the drivers (=codecs) until you find the one for which you
>want to change the priority level. One you find it, you
>can change its priority using the acmDriverPriority API
>call, which is pretty straightforward to use.

Everything one needs is there. If Keith had asked me for working code, I'd have posted it.

Well, so much for trying to help people.

Alex



0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1392250
> You didn't have a clue on how to work it

At that moment, yes. But I would have found out it meself sooner or later, that's for sure.

 
> Everything one needs is there. If Keith had asked me for working code, I'd have posted it.

Why did't you post that in the first place. I started coding after Keith said he would try it and saw nothing from you.

It may be easy for you and me but maybe not for Keith. I don't know that.

I added the acmDriverDetails function and the structures and constants, put all together and made a demo. I spend time on it, Alex, time!
Time to fully answer this question and help Keith since my first answer was not good enough.

Because you refered to the MSACM I offered to post a question for you.


> Well, so much for trying to help people

I gave two example here, so don't tell me that I didn't do anything to help. Why don't you just wait what Keith decides? After all I think Keith must be very much offended by all these comments.

Stop forcing the issue!
0
 
LVL 1

Expert Comment

by:delphiexpert
ID: 1392251
Wow, you guys are really hungry for points arent you?
I'm about to post a question myself, I look forward to having you two fight it out! :)

0
 
LVL 1

Author Comment

by:keithcsl
ID: 1392252
simonet and epsylon...

u have placed me in a very bad situation... all i needed was some help... now i have to decide who to go against????!? both of u r very good and experienced programmers, so please, i would like to end this question now and not carry on further...

Keith
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1392253
Don't worry, Keith, I'll give ALex the points as promised. Sorry for what happend here.....

Thanks for the points.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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…
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…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…

589 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