Solved

MMTools problem

Posted on 2004-10-18
1
522 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reading complex type element repeats first one found several times 3 38
Delphi cmd execution 6 55
FMX StringGrid1->Canvas->FillRect Problem 3 127
DBGrid or StringGrid ? 6 62
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

10 Experts available now in Live!

Get 1:1 Help Now