Articles   Members Online: 3
-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 determinate the bitrate of a WAV file 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
14-Apr-04
Category
Multimedia
Language
Delphi 2.x
Views
97
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Arthur Young

How to determinate the bitrate of a WAV file?

Answer:

1   {....}
2   
3   private
4   
5   procedure OpenMedia(WaveFile: string);
6     function GetStatus(StatusRequested: DWord): longint;
7       procedure CloseMedia;
8   
9         {....}
10  
11      var
12        MyError, dwFlags: Longint;
13        FDeviceID: Word;
14  
15        {....}
16  
17      uses
18        MMSystem;
19  
20      {....}
21  
22  procedure TForm1.OpenMedia(WaveFile: string);
23  var
24    MyOpenParms: TMCI_Open_Parms;
25  begin
26    with MyOpenParms do
27    begin
28      dwCallback := Handle; // TForm1.Handle
29      lpstrDeviceType := PChar('WaveAudio');
30      lpstrElementName := PChar(WaveFile);
31    end; {with MyOpenParms}
32    dwFlags := MCI_WAIT or MCI_OPEN_ELEMENT or MCI_OPEN_TYPE;
33    MyError := mciSendCommand(0, MCI_OPEN, dwFlags, Longint(@MyOpenParms));
34    // one could use mciSendCommand(DevId, here to specify a particular device
35    if MyError = 0 then
36      FDeviceID := MyOpenParms.wDeviceID
37    else
38      raise Exception.Create('Open Failed');
39  end;
40  
41  function TForm1.GetStatus(StatusRequested: DWORD): Longint;
42  var
43    MyStatusParms: TMCI_Status_Parms;
44  begin
45    dwFlags := MCI_WAIT or MCI_STATUS_ITEM;
46    with MyStatusParms do
47    begin
48      dwCallback := Handle;
49      dwItem := StatusRequested;
50    end;
51    MyError := mciSendCommand(FDeviceID,
52      MCI_STATUS,
53      MCI_WAIT or MCI_STATUS_ITEM,
54      Longint(@MyStatusParms));
55    if MyError = 0 then
56      Result := MyStatusParms.dwReturn
57    else
58      raise Exception.Create('Status call to get status of ' +
59        IntToStr(StatusRequested) + ' Failed');
60  end;
61  
62  procedure TForm1.CloseMedia;
63  var
64    MyGenParms: TMCI_Generic_Parms;
65  begin
66    if FDeviceID > 0 then
67    begin
68      dwFlags := 0;
69      MyGenParms.dwCallback := Handle; // TForm1.Handle
70      MyError := mciSendCommand(FDeviceID, MCI_CLOSE, dwFlags, Longint(@MyGenParms));
71      if MyError = 0 then
72        FDeviceID := 0
73      else
74      begin
75        raise Exception.Create('Close Failed');
76      end;
77    end;
78  end;
79  
80  //Example
81  
82  procedure TForm1.Button1Click(Sender: TObject);
83  begin
84    if OpenDialog1.Execute then
85    begin
86      OpenMedia(OpenDialog1.FileName);
87      with ListBox1.Items do
88      begin
89        Add('Average Bytes / Sec : ' +
90          IntToStr(GetStatus(MCI_WAVE_STATUS_AVGBYTESPERSEC)));
91        Add('Bits / Sample : ' + IntToStr(GetStatus(MCI_WAVE_STATUS_BITSPERSAMPLE)));
92        Add('Samples / Sec : ' + IntToStr(GetStatus(MCI_WAVE_STATUS_SAMPLESPERSEC)));
93        Add('Channels : ' + IntToStr(GetStatus(MCI_WAVE_STATUS_CHANNELS)));
94      end;
95      CloseMedia;
96    end;
97  end;


			
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