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

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

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

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

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



tatus<>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;

SetVolumeOfAudio(AudioData, Start, Finish-Start+1, VolumeEdit.Value/100);

end;

Status := waiting;

PaintBox1.Repaint;

end;

procedure TMainForm.ChangeVolumeBitBtnClick(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;

ChangeVolumeOfAudio(AudioData, Start, Finish-Start+1, VolumeEdit.Value/100);

end;

Status := waiting;

PaintBox1.Repaint;

end;

procedure TMainForm.NormalizeBitBtnClick(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;

Normalize(AudioData, Start, Finish-Start+1);

end;

Status := waiting;

end;

procedure TMainForm.EffectButtonClick(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;

if Sender = BitBtn13 then Echo(AudioData, Start, Finish-Start+1, EffOptionsForm.nResponsesEdit.Value, EffOptionsForm.ResponseTimeEdit.Value, EffOptionsForm.ResponseVolumeEdit.Value/100);

if Sender = BitBtn14 then Reverberation(AudioData, Start, Finish-Start+1, EffOptionsForm.nEchosEdit.Value, EffOptionsForm.DelayEdit.Value, EffOptionsForm.EchoVolumeEdit.Value/100);

if Sender = BitBtn15 then ChangeVolumeOfAudio(AudioData, Start, Finish-Start+1, 0);

if Sender = BitBtn16 then ReChangeVolumeOfAudio(AudioData, Start, Finish-Start+1, 1);

{case EffectBox.ItemIndex of

0: ChangeVolumeOfAudio(AudioData, Start, Finish-Start+1, 0);

1: ReChangeVolumeOfAudio(AudioData, Start, Finish-Start+1, 1);

2: Echo(AudioData, Start, Finish-Start+1, nResponsesEdit.Value, ResponseTimeEdit.Value, ResponseVolumeEdit.Value/100);

3: Reverberation(AudioData, Start, Finish-Start+1, nEchosEdit.Value, DelayEdit.Value, EchoVolumeEdit.Value/100);

end;}

end;

Status := waiting;

PaintBox1.Repaint;

end;

procedure TMainForm.PaintAudioGraph;

var

PaintPos, MaxPaintPos: Cardinal;

AudioPos, {SamplesPerPoint,} LeftSamples, MaxAmplitude: Cardinal;

numChannels, Channel, i: Word;

Smp, Smp1: Integer;

begin

with PaintBox1.Canvas do

begin

Pen.Color := clBlack;

MoveTo(Round(PaintBox1.Width/2),0);

LineTo(Round(PaintBox1.Width/2), Round(PaintBox1.Height));

MoveTo(0, Round(PaintBox1.Height/2));

LineTo(PaintBox1.Width, Round(PaintBox1.Height/2));

Pen.Color := clGreen;

end;

MaxPaintPos := PaintBox1.Width;

=0then"> if AudioPosition-PaintBox1.Width*SamplesPerPoint >= 0 then

begin

AudioPos := AudioPosition-PaintBox1.Width*SamplesPerPoint;

PaintPos := 0;

end

else

begin

AudioPos := 0;

PaintPos := PaintBox1.Width - Trunc(AudioPosition/SamplesPerPoint);

end;

numChannels := AudioData.nChannels;

MaxAmplitude := 1;

for i := 1 to AudioData.nBitsPerSample do

MaxAmplitude := MaxAmplitude*2;

Smp := 0;

for Channel := 0 to numChannels-1 do

begin

AudioData.ReadSample(AudioPos, Channel, Smp1);

Smp := Smp + Smp1;

end;

Smp := Round(Smp/numChannels);

PaintBox1.Canvas.MoveTo(PaintPos-Round(PaintBox1.Width/2), Round(PaintBox1.Height/2-Smp/MaxAmplitude*PaintBox1.Height));

LeftSamples := SamplesPerPoint;

while PaintPos<=(MaxPaintPos+Round(PaintBox1.Width/2)) do

begin

Smp := 0;

for Channel := 0 to numChannels-1 do

begin

AudioData.ReadSample(AudioPos, Channel, Smp1);

Smp := Smp + Smp1;

end;

if (Selection.StartExists)and(Selection.FinishExists)and

Selection.Start)and(AudioPosSelection.Start)and(AudioPos<Selection.Finish)

then PaintBox1.Canvas.Pen.Color := clRed

else PaintBox1.Canvas.Pen.Color := clGreen;

Smp := Round(Smp/numChannels);

PaintBox1.Canvas.LineTo(PaintPos-Round(PaintBox1.Width/2), Round(PaintBox1.Height/2-Smp/MaxAmplitude*PaintBox1.Height));

Inc(AudioPos);

Dec(LeftSamples);

if LeftSamples = 0 then

begin

Inc(PaintPos);

LeftSamples := SamplesPerPoint;

end;

end;

end;

procedure TMainForm.PaintBox1Paint(Sender: TObject);

begin

PaintAudioGraph;

end;

procedure TMainForm.WaveOutButtonClick(Sender: TObject);

begin

ShellExecute(Handle, open, PChar(sndvol32.exe), , , SW_Show);

end;

procedure TMainForm.WaveInButtonClick(Sender: TObject);

begin

ShellExecute(Handle, open, PChar(sndvol32.exe), PChar(/r), , SW_Show);

end;

procedure TMainForm.CopyToFileButtonClick(Sender: TObject);

var

FileName, Ext, EncMode, StereoMode, BitRate: String;

i: Byte;

TempAudio: TAudioData;

Code: Integer;

PCM: TPCMFile;

MP3: TMP3File;

EM1: TEM1File;

AudioSize: Cardinal;

begin

if Status<>waiting then Exit;

if SaveDialog.Execute then

FileName := SaveDialog.FileName else Exit;

Ext := ExtractFileExt(FileName);

with AudioData do

AudioSize := Data.Size div nBlockAlign;

TempAudio := TAudioData.Create;

with Selection do

begin

if not StartExists or not FinishExists then

begin

DeleteMarkers;

Start := 0;

Finish := AudioSize-1;

end;

CopyAudio(AudioData, TempAudio, Start, Finish);

end;

for i := 1 to Length(Ext) do Ext[i] := UpCase(Ext[i]);

if Ext = .WAV then

begin

PCM := TPCMFile.Create(FileName, TempAudio);

PCM.Destroy;

end;

if Ext = .MP3 then

begin

if RadioButton1.Checked then

begin

BitRate := MP3OptionsForm.ConstantBitRateComboBox.Text;

EncMode := -b;

end;

if RadioButton2.Checked then

begin

BitRate := MP3OptionsForm.AverageBitRateComboBox.Text;

EncMode := --abr;

end;

if RadioButton3.Checked then

begin

Str(MP3OptionsForm.VariableBitrateComboBox.ItemIndex, BitRate);

EncMode := -V;

end;

case MP3OptionsForm.StereoModeComboBox.ItemIndex of

0: StereoMode := s;

1: StereoMode := j;

2: StereoMode := f;

3: StereoMode := d;

4: StereoMode := m;

end;

MP3 := TMP3File.Create(FileName, TempAudio, BitRate, EncMode, StereoMode);

MP3.Destroy;

end;

if Ext = .EM1 then

begin

EM1 := TEM1File.Create(FileName, TempAudio);

EM1.Destroy;

end;

TempAudio.Destroy;

end;

procedure TMainForm.SaveUndoInfo;

begin

if not UndoCheckBox.Checked then Exit;

UndoInfo.AudioPosition := AudioPosition;

UndoInfo.Selection.Start := Selection.Start;

UndoInfo.Selection.Finish := Selection.Finish;

UndoInfo.Selection.StartExists := Selection.StartExists;

UndoInfo.Selection.FinishExists := Selection.FinishExists;

UndoInfo.AudioData.Data.Clear;

CopyAudio(AudioData, UndoInfo.AudioData, 0, AudioData.Data.Size div AudioData.nBlockAlign - 1);

end;

procedure TMainForm.UndoButtonClick(Sender: TObject);

begin

if Status<>waiting then Exit;

if UndoInfo.AudioData.Data.Size = 0 then Exit;

Status := undo;

DeleteMarkers;

AudioData.Data.Clear;

CopyAudio(UndoInfo.AudioData, AudioData, 0, UndoInfo.AudioData.Data.Si

s