Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

MMTools problem

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
treqw
Asked:
treqw
1 Solution
 
ginsonicCommented:
You can contact MMTools Support
0

Featured Post

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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now