Система обработки аудиоинформации. Подсистема фильтрации и обработки сигнала

Дипломная работа - Компьютеры, программирование

Другие дипломы по предмету Компьютеры, программирование

Скачать Бесплатно!
Для того чтобы скачать эту работу.
1. Пожалуйста введите слова с картинки:

2. И нажмите на эту кнопку.
закрыть



ze div UndoInfo.AudioData.nBlockAlign - 1);

if UndoInfo.Selection.StartExists then

begin

AudioPosition := UndoInfo.Selection.Start;

SetMarker;

end;

if UndoInfo.Selection.FinishExists then

begin

AudioPosition := UndoInfo.Selection.Finish;

SetMarker;

end;

AudioPosition := UndoInfo.AudioPosition;

SetAudioPosition;

UndoInfo.AudioData.Data.Clear;

Status := waiting;

end;

procedure TMainForm.EMailButtonClick(Sender: TObject);

begin

ShellExecute(Handle, open, PChar(mailto:Andrei512@narod.ru), PChar(), , SW_Show);

end;

procedure TMainForm.BrainWaveButtonClick(Sender: TObject);

var

AudioSize: Cardinal;

begin

if Status<>waiting then Exit;

Status := deformation;

SaveUndoInfo;

with AudioData do

AudioSize := Data.Size div nBlockAlign;

with Selection do

begin

if not StartExists or not FinishExists then

begin

DeleteMarkers;

Start := 0;

Finish := AudioSize-1;

end;

AddBrainWave(AudioData, Start, Finish-Start+1, BWFreqEdit1.Value, BWFreqEdit2.Value);

end;

Status := waiting;

end;

procedure TMainForm.Left10ButtonClick(Sender: TObject);

var

AudioSize, Smp10ms: Cardinal;

begin

if Status<>waiting then Exit;

with AudioData do

AudioSize := Data.Size div nBlockAlign;

Smp10ms := Round(AudioData.nSamplesPerSec/100);

if Sender = Left10Button then

if AudioPosition < Smp10ms then AudioPosition := 0 else AudioPosition := AudioPosition - Smp10ms

else

if AudioPosition + Smp10ms >= AudioSize then AudioPosition := AudioSize - 1 else AudioPosition := AudioPosition + Smp10ms;

SetAudioPosition;

end;

procedure TMainForm.SSelButtonClick(Sender: TObject);

var

AudioSize: Cardinal;

begin

if Status<>waiting then Exit;

with AudioData do

AudioSize := Data.Size div nBlockAlign;

if Sender = {SSelButton}BitBtn3 then

if Selection.StartExists then AudioPosition := Selection.Start else AudioPosition := 0

else

if Selection.FinishExists then AudioPosition := Selection.Finish else AudioPosition := AudioSize - 1;

SetAudioPosition;

end;

procedure TMainForm.HelpButtonClick(Sender: TObject);

begin

HelpForm.Visible := True;

HelpForm.Show;

end;

procedure TMainForm.UndoCheckBoxClick(Sender: TObject);

begin

if UndoCheckBox.Checked then

UndoButton.Enabled := True

else

begin

UndoButton.Enabled := False;

UndoInfo.AudioData.Data.Clear;

end;

end;

procedure TMainForm.N4Click(Sender: TObject);

begin

MainForm.Close;

end;

procedure TMainForm.N43Click(Sender: TObject);

begin

AudioOptionsForm.Visible := True;

AudioOptionsForm.Show;

end;

procedure TMainForm.MP31Click(Sender: TObject);

begin

MP3OptionsForm.Visible := True;

MP3OptionsForm.Show;

end;

procedure TMainForm.N44Click(Sender: TObject);

begin

EffOptionsForm.Visible := True;

EffOptionsForm.Show;

end;

procedure TMainForm.ButtonZoomInClick(Sender: TObject);

begin

SamplesPerPoint := SamplesPerPoint div 2;

if (SamplesPerPoint<1) then SamplesPerPoint:=1;

PaintBox1.Repaint;

end;

procedure TMainForm.ButtonZoomOutClick(Sender: TObject);

begin

SamplesPerPoint := SamplesPerPoint * 2;

PaintBox1.Repaint;

end;

procedure TMainForm.AudioOptionsButtonClick(Sender: TObject);

begin

AudioOptionsForm.Visible := True;

AudioOptionsForm.Show;

end;

procedure TMainForm.MP3OptionsButtonClick(Sender: TObject);

begin

MP3OptionsForm.Visible := True;

MP3OptionsForm.Show;

end;

procedure TMainForm.EffOptionsButtonClick(Sender: TObject);

begin

EffOptionsForm.Visible := True;

EffOptionsForm.Show;

end;

end.

 

П. 1.2. ТЕКСТ МОДУЛЯ PCM_FORMAT.PAS

 

unit PCM_Format;

interface

uses

SysUtils, AudioFormat;

type

TPCMFile = class(TAudioFile)

public

RIFFLabel: String;

RIFFSize: LongWord;

fccType: String;

fmt_Label: String;

fmtSize: LongWord;

formatTag: Word;

nChannels: Word;

nSamplesPerSec: LongWord;

nAvgBytesPerSec: LongWord;

nBlockAlign: Word;

nBitsPerSample: Word;

DataID: String;

AdvDataBegin: LongWord; //*

DataSize: LongWord;

DataLabel: String;

SndDataBegin: LongWord; //*

nDataBytes: LongWord;

constructor Open(FileName: string);

function ReadSample(Number, Channel: LongInt): Integer;

procedure WriteSample(Number, Channel: LongInt; Value: Integer);

procedure ReadAudioData(var AudioData: TAudioData);

constructor Create(FileName: string; var AudioData: TAudioData);

private

{ Private declarations }

end;

implementation

constructor TPCMFile.Open(FileName: String);

begin

inherited Open(FileName);

ReadString(RIFFLabel, 4);

Read(RIFFSize, 4);

ReadString(fccType, 4);

ReadString(fmt_Label, 4);

Read(fmtSize, 4);

Read(formatTag, 2);

Read(nChannels, 2);

Read(nSamplesPerSec, 4);

Read(nAvgBytesPerSec, 4);

Read(nBlockAlign, 2);

Read(nBitsPerSample, 2);

Position := $14 + fmtSize;

ReadString(DataLabel, 4);

if DataLabel <> data then

begin

DataId := DataLabel;

Read(DataSize, 4);

AdvDataBegin := Position;

Position := Position + DataSize;

ReadString(DataLabel, 4);

end

else

begin

DataID := ;

DataSize := 0;

end;

Read(nDataBytes, 4);

SndDataBegin := Position;

end;

function TPCMFile.ReadSample(Number, Channel: LongInt): Integer;

var

i: Byte;

Value, Mult: LongWord;

begin

Position := SndDataBegin + Number*nBlockAlign + Channel*Trunc(nBlockAlign/nChannels);

Value := 0;

Read(Value, Trunc(nBlockAlign/nChannels));

Mult := 1;

for i := 0 to Trunc(nBlockAlign/nChannels)-1 do Mult := Mult*256;

if nBitsPerSample>8 then

if Value >= Mult/2 then ReadSample := Value - Mult else ReadSample := Value

else

ReadSample := Value-128;

end;

procedure TPCMFile.WriteSample(Number, Channel: LongInt; Value: Integer);

begin

Position := SndDataBegin + Number*nBlockAlign + Channel*Trunc(nBlockAlign/nChannels);

if nBitsPerSample<=8 then Value := Value+128;

Write(Value, Trunc(nBlockAlign/nChannels));

end;

procedure TPCMFile.ReadAudioData(var AudioData: TAudioData);

const

MaxBufSize = 65536;

var

i: Cardinal;

BufSize: Cardinal;

Buf: array [0..MaxBufSize] of Byte;

begin

AudioData.Data.Clear;

Position := SndDataBegin;

while Position<Size do

begin

if Size-Position>=MaxBufSize then BufSize := MaxBufSize else BufSize := Size-Position;

Read(Buf, BufSize);

AudioData.Data.Write(Buf, BufSize);

end;

AudioData.nChannels := nChannels;

AudioData.nSamplesPerSec := nSamplesPerSec;

AudioData.nBitsPerSample := nBitsPerSample;

AudioData.Calculate_nBlockAlign;

end;

constructor TPCMFile.Create(FileName: string; var AudioData: TAudioData);

const

MaxBufSize = 65536;

var

i: Cardinal;

BufSize: Cardinal;

Buf: array [0..MaxBufSize] of Byte;

begin

inherited Create(FileName);

RIFFLabel := RIFF;

RIFFSize := AudioData.Data.Size+4*3+2*2+4*2+2*2+4*2;

fccType := WAVE;

fmt_Label := fmt ;

fmtSize := 16;

formatTag := 1; //???

nChannels := AudioData.nChannels;

nSamplesPerSec := AudioData.nSamplesPerSec;

nBlockAlign := AudioData.nBitsPerSample div 8;

0thenInc(nBlockAlign);"> if AudioData.nBitsPerSample mod 8 <> 0 then Inc(nBlockAlign);

nBlockAlign := nBlockAlign*nChannels;

nAvgBytesPerSec := nSamplesPerSec*nBlockAlign;

nBitsPerSample := AudioData.nBitsPerSample;

DataLabel := data;

nDataBytes := AudioData.Data.Size;

WriteString(RIFFLabel, 4);

Write(RIFFSize, 4);

WriteString(fccType, 4);

WriteString(fmt_Label, 4);

Write(fmtSize, 4);

Write(formatTag, 2);

Write(nChannels, 2);

Write(nSamplesPerSec, 4);

Write(nAvgBytesPerSec, 4);

Write(nBlockAlign, 2);

Write(nBitsPerSample, 2);

WriteString(DataLabel, 4);<

s