Solved

MMTools problem

Posted on 2004-10-18
1
520 Views
Last Modified: 2010-04-05
MMTools problem

How to convert points of left and right channel to Frequency (Hz) and Amplitude (db) ?
and
How to convert Frequency (Hz) and Amplitude (db) to points of left and right channel ?

as

point -> Freq (Hz) and Amp (db)
Freq (Hz) and Amp (db) -> point

Thanks.

-------------->>>>>>>>>>>>>>
Here is demo of MMTools :
-------------->>>>>>>>>>>>>>

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, MMSystem, MMObj, MMDSPObj, MMUtils, MMWave, MMCstDlg, MMRegs, MMPCMSup,
  MMAudio;

type
  TForm1 = class(TForm)
    SrcFile: TMMWaveFile;
    LeftFile: TMMWaveFile;
    Button1: TButton;
    RightFile: TMMWaveFile;
    OpenDialog: TMMWaveOpenDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    point : longint;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

{ This Demo splits a PCM 16 Bit Stereo file in two Mono files }

procedure TForm1.Button1Click(Sender: TObject);
type
   TChannel = record
      Left : Smallint;
      Right: Smallint;
   end;

var
   i: integer;
   nRead,nBytes: Longint;
   Buf: array[0..4095] of TChannel;
   FName,Ext: string;
   wfx: TWaveFormatEx;
begin
   if not OpenDialog.Execute then exit;

   SrcFile.Wave.FileName := OpenDialog.FileName;
   if (SrcFile.Wave.FormatTag <> WAVE_FORMAT_PCM) or
      (SrcFile.Wave.BitLength <> 16) or
      (SrcFile.Wave.Mode <> mStereo) then
   begin
      MessageDlg('This is not a valid input file!',mtError,[mbOK],0);
      exit;
   end;

   // build the correct Wave Header for the Mono files
   pcmBuildWaveHeader(@wfx,SrcFile.Wave.PWaveFormat.wBitsPerSample,
                           1,
                           SrcFile.Wave.PWaveFormat.nSamplesPerSec);

   // build a unique FileName for left destination: "FName_L.wav"
   FName := SrcFile.Wave.FileName;
   Ext := ExtractFileExt(FName);
   FName := Copy(FName,1,Pos(Ext,FName)-1)+'_L'+Ext;
   // delete the DestFile
   DeleteFile(FName);
   // create the file for the left channel
   LeftFile.Wave.CreateFile(FName,@wfx);

   // open the source file
   SrcFile.Wave.OpenFile;

   Screen.Cursor := crHourglass;

   nBytes := SrcFile.Wave.DataSize;
   while (nBytes > 0) do
   begin
      // read the data
      nRead := Min(nBytes,sizeOf(Buf));
      nRead := SrcFile.Wave.ReadDataBytes(@Buf,nRead);

      for i := 0 to (nRead div sizeOf(TChannel))-1 do
      begin
         write out the left and right channel
         point:=PSmallInt(@Buf[i].Left)^;

//       -------------->>>>>>>>>>>>>> HERE
//       -------------->>>>>>>>>>>>>> HERE
//       point convert to Freq (Hz) and Amp (db)
//       Freq (Hz) and Amp (db) convert to point
//       -------------->>>>>>>>>>>>>> HERE
//       -------------->>>>>>>>>>>>>> HERE


         Buf[i].Left:=(point);
         LeftFile.Wave.WriteDataBytes(@Buf[i].Left,sizeOf(Buf[i].Left));
      end;

      dec(nBytes,nRead);
   end;

   SrcFile.Wave.CloseFile;
   LeftFile.Wave.CloseFile;
   RightFile.Wave.CloseFile;

   Screen.Cursor := crDefault;
end;

end.
0
Comment
Question by:treqw
1 Comment
 
LVL 9

Accepted Solution

by:
ginsonic earned 500 total points
ID: 12344575
You can contact MMTools Support
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
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…

760 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

18 Experts available now in Live!

Get 1:1 Help Now