?
Solved

MMTools problem

Posted on 2004-10-18
1
Medium Priority
?
531 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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