Модераторы: Poseidon, Snowy, bems, MetalFan
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Как получить громкость и частоту из wav файла, Работа с Wav файлами 
:(
    Опции темы
AW
Дата 22.12.2004, 20:48 (ссылка)    |    (голосов: 0) Загрузка ... Загрузка ... Быстрая цитата Цитата


Unregistered











Необходимо не просто проигрывать файл
а получить все что там в нём есть
то есть частоту семпл и громкость dB
Это нужно для построения спектральной картинки по типу в CoolEdit pro 2000
Там необходимо для каждой частоты получить свою громкость
Вопрос срочный так что просьба о своих соображенниях пишите на [email protected]

НУУУУУУУУУУУ очень нужно.
  Вверх
Marriage
Дата 22.12.2004, 21:34 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 842
Регистрация: 4.5.2004
Где: Таганрог

Репутация: нет
Всего: 2



Цитата

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ActnList;

type
  TWaveHeader = record
    ident1: array[0..3] of Char;      // Must be "RIFF"
    len: DWORD;                        // remaining length after this header
    ident2: array[0..3] of Char;      // Must be "WAVE"
    ident3: array[0..3] of Char;      // Must be "fmt "
    reserv: DWORD;                    // Reserved Size
    wFormatTag: Word;                  // format type
    nChannels: word;                  // number of channels (i.e. mono, stereo, etc.)
    nSamplesPerSec: DWORD;            //sample rate
    nAvgBytesPerSec: DWORD;            //for buffer estimation
    nBlockAlign: Word;                //block size of data
    wBitsPerSample: Word;              //number of bits per sample of mono data
    ident4: array[0..3] of Char;      //Must be "data"
    cbSize: dWord;                      //the count in bytes of the size of
  end;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    OpenDialog1: TOpenDialog;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    ActionList1: TActionList;
    Action1: TAction;
    Button5: TButton;
    procedure Button1Click(Sender: TObject);
    function GetFileSize:LongInt;
    procedure Button2Click(Sender: TObject);
    procedure CreateNewWav(w:TWaveHeader);


    procedure Button3Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);

  private
    w: TWaveHeader;
    file_in:File of byte;
    s:Array of byte;
    { Private declarations }
  public
    { Public declarations }
end;



var
  Form1: TForm1;

implementation





{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
Wav:TWaveHeader;
count,i:integer;
q:byte;

begin

OpenDialog1.Execute;

If  OpenDialog1.FileName = '' then
  Exit;


ListBox1.Clear;

AssignFile( file_in,OpenDialog1.FileName );
count := GetFileSize;
SetLength(s,count);
reset(file_in);



For i := 0 to count-1 do
  Begin
  read(file_in,q);
  s[i] := q;
  End;


CloseFile(file_in);

Button2Click(Sender);

end;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
function TForm1.GetFileSize:LongInt;
var
q:byte;
i:integer;
Begin
reset(File_in);

i:=0;

while not EOF(File_in) do
  Begin
    read(file_in,q);
    i:=i+1;
  End;

  result:=i;
End;

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
procedure TForm1.Button2Click(Sender: TObject);
const
  riff = 'RIFF';
  wave = 'WAVE';
var
  f: TFileStream;

begin
  if not FileExists(OpenDialog1.FileName) then
    exit; //exit the function if the file does not exists

  try
    f := TFileStream.create(OpenDialog1.FileName, fmOpenRead);
    f.Read(w, Sizeof(w)); //Reading the file header

    if w.ident1 <> riff then
    begin //Test if it is a RIFF file, otherwise exit
      Showmessage('This is not a RIFF File');
      exit;
    end;

    if w.ident2 <> wave then
    begin //Test if it is a wave file, otherwise exit
      Showmessage('This is not a valid wave file  ');
      exit;
    end;

  finally
    f.free;
  end;
  ListBox1.Items.Add(w.ident4 );
  ListBox1.Items.Add(w.ident3 );
  ListBox1.Items.Add('Äëèííà ïîñëå çàãîëîâêà :'+IntToStr(w.len));
  ListBox1.Items.Add('Çàðåçåðâèðîâàííûé ðàçìåð:'+IntToStr(w.reserv) );
  ListBox1.Items.Add('ÒÈÏ ÔÎÐÌÀÒÀ:'+IntToStr(w.wFormatTag) );
  ListBox1.Items.Add('Êîëè÷åñòâî êàíàëîâ :'+IntToStr(w.nChannels) )    ;
  ListBox1.Items.Add('Samples  â ñåêóíäó ... :'+IntToStr(w.nSamplesPerSec) ) ;
  ListBox1.Items.Add('áèòîâ â ñåêóíäó :'+IntToStr(w.nAvgBytesPerSec) )    ;
  ListBox1.Items.Add('Äëèííà ïîñëå çàãîëîâêà :'+IntToStr(w.nBlockAlign ));
  ListBox1.Items.Add('Äëèííà DATA :'+IntToStr(w.nBlockAlign ));
  ListBox1.Items.Add('Áèòîâ íà 1 Sample :'+IntToStr(w.wBitsPerSample ));
  ListBox1.Items.Add('Äëèííà âñåãî :'+IntToStr(w.cbSize ));
end;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
procedure TForm1.CreateNewWav(w:TWaveHeader);
Begin

End;

////////////////////////////////////////////////////////////////////////////////

{
type
  TWaveHeader = record
    ident1: array[0..3] of Char;      // Must be "RIFF"
    len: DWORD;                        // remaining length after this header
    ident2: array[0..3] of Char;      // Must be "WAVE"
    ident3: array[0..3] of Char;      // Must be "fmt "
    reserv: DWORD;                    // Reserved Size
    wFormatTag: Word;                  // format type
    nChannels: Word;                  // number of channels (i.e. mono, stereo, etc.)
    nSamplesPerSec: DWORD;            //sample rate
    nAvgBytesPerSec: DWORD;            //for buffer estimation
    nBlockAlign: Word;                //block size of data
    wBitsPerSample: Word;              //number of bits per sample of mono data
    cbSize: Word;                      //the count in bytes of the size of
    ident4: array[0..3] of Char;      //Must be "data"
end;
}


procedure TForm1.Button3Click(Sender: TObject);

begin


end;


//Ïðÿ÷åì èç ñïèñêà Application ...
procedure TForm1.FormActivate(Sender: TObject);
begin
//ShowWindow(Application.Handle, SW_HIDE);
end;

///Òèïà ñïðÿòàòü, íî íå ðàáîòàåò !!!
end.

{
with zip do
    begin
        FileName := 'D:\123\test.zip';

        // Create a new archive file
        OpenArchive(fmCreate);

        // Set path to folder with some text files to BaseDir
        BaseDir := 'd:\123';

 
        // Add all files and directories from 'C:\SOURCE_FOLDER' to the archive

        AddFiles('*.*');

        // Set path to destination folder
        BaseDir := 'D:\123';

        // Extract all files and directories from the archive to 'C:\DESTINATION_FOLDER'
        //ExtractFiles('*.*');

        // Close the archive
        CloseArchive;

    end;
}




Пожалуйста !


--------------------
Praemonitus, praemunitus
PM MAIL ICQ   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Delphi: Общие вопросы"
SnowyMetalFan
bemsPoseidon
Rrader

Запрещается!

1. Публиковать ссылки на вскрытые компоненты

2. Обсуждать взлом компонентов и делиться вскрытыми компонентами

  • Литературу по Дельфи обсуждаем здесь
  • Действия модераторов можно обсудить здесь
  • С просьбами о написании курсовой, реферата и т.п. обращаться сюда
  • Вопросы по реализации алгоритмов рассматриваются здесь
  • 90% ответов на свои вопросы можно найти в DRKB (Delphi Russian Knowledge Base) - крупнейшем в рунете сборнике материалов по Дельфи


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Snowy, MetalFan, bems, Poseidon, Rrader.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Delphi: Общие вопросы | Следующая тема »


 




[ Время генерации скрипта: 0.0675 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.