home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, FileCtrl, ExtCtrls, WAVFile;
-
- type
- TMainForm = class(TForm)
- DriveList: TDriveComboBox;
- FolderList: TDirectoryListBox;
- FileList: TFileListBox;
- CloseButton: TButton;
- InfoBevel: TBevel;
- IconImage: TImage;
- ValidHeaderLabel: TLabel;
- FileSizeLabel: TLabel;
- ValidHeaderText: TEdit;
- ChannelModeText: TEdit;
- ChannelModeLabel: TLabel;
- SampleRateLabel: TLabel;
- BitsPerSampleLabel: TLabel;
- DurationLabel: TLabel;
- SampleRateText: TEdit;
- BitsPerSampleText: TEdit;
- DurationText: TEdit;
- FileSizeText: TEdit;
- procedure CloseButtonClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FileListChange(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- private
- { Private declarations }
- WAVFile: TWAVFile;
- procedure ClearAll;
- end;
-
- var
- MainForm: TMainForm;
-
- implementation
-
- {$R *.dfm}
-
- procedure TMainForm.ClearAll;
- begin
- { Clear all captions }
- ValidHeaderText.Text := '';
- ChannelModeText.Text := '';
- SampleRateText.Text := '';
- BitsPerSampleText.Text := '';
- FileSizeText.Text := '';
- DurationText.Text := '';
- end;
-
- procedure TMainForm.CloseButtonClick(Sender: TObject);
- begin
- { Exit }
- Close;
- end;
-
- procedure TMainForm.FormCreate(Sender: TObject);
- begin
- { Create object }
- WAVFile := TWAVFile.Create;
- { Reset captions }
- ClearAll;
- end;
-
- procedure TMainForm.FileListChange(Sender: TObject);
- begin
- { Clear captions }
- ClearAll;
- if FileList.FileName = '' then exit;
- if FileExists(FileList.FileName) then
- { Load WAV header }
- if WAVFile.ReadFromFile(FileList.FileName) then
- if WAVFile.Valid then
- begin
- { Fill captions }
- ValidHeaderText.Text := 'Yes';
- ChannelModeText.Text := WAVFile.ChannelMode;
- SampleRateText.Text := IntToStr(WAVFile.SampleRate) + ' hz';
- BitsPerSampleText.Text := IntToStr(WAVFile.BitsPerSample) + ' bit';
- FileSizeText.Text := IntToStr(WAVFile.FileSize) + ' bytes';
- DurationText.Text := FormatFloat('.000', WAVFile.Duration) + ' sec.';
- end
- else
- { Header not found }
- ValidHeaderText.Text := 'No'
- else
- { Read error }
- ShowMessage('Can not read header in the file: ' + FileList.FileName)
- else
- { File does not exist }
- ShowMessage('The file does not exist: ' + FileList.FileName);
- end;
-
- procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- { Free memory }
- WAVFile.Free;
- end;
-
- end.
-