## Wave files editing- is it possible using Wave Audio Package?

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

### Wave files editing- is it possible using Wave Audio Package?

Hello

Is it possible to:

- play wave file from selected position
- take a piece of wave file from point X to Y and save it to another wave file
- take a piece from one wave file and a piece from another wave file and merge them into one wave file

all of it using Wave Audio Package

thank you very much

James
james
Member

Posts: 2
Joined: October 11th, 2005, 3:45 pm

The package doesn't provide a wave editor, however you can do the specified actions using the methods of TWave class.

Kambiz

Kambiz

Posts: 2428
Joined: March 7th, 2003, 7:10 pm

### Is my approach correct?

First of all:
Your components are really great

As you know what I try to achieve is:
I have FileA.wav and FileB.wav.
I want to take 5 last seconds from FileB and insert them to the beginning of the FileA.

These are my approaches to solve the task:

Take the last 5 seconds from 'FileB' and add it to the beginning of the 'FileA'

Code: Select all
procedure TForm1.Button3Click(Sender: TObject);var WaveLength : Integer;    Stream : TStream;begin  // Stream approach  AudioPlayer1.Wave.LoadFromFile('FileB.wav');  WaveLength := AudioPlayer1.Wave.Length;  AudioPlayer1.Wave.Delete(0, WaveLength - 5000);  Stream := TStream.Create;  AudioPlayer1.Wave.SaveToStream(Stream); //abstract error  AudioPlayer1.Wave.LoadFromFile('FileA.wav');  AudioPlayer1.Wave.Insert(WaveLength, TWave(Stream));  AudioPlayer1.Wave.SaveToFile('Result.wav');  Stream.Free;end;procedure TForm1.Button4Click(Sender: TObject);var WaveLength : Integer;begin  // less elegant approach, but it works fine  AudioPlayer1.Wave.LoadFromFile('FileB.wav');  WaveLength := AudioPlayer1.Wave.Length;  AudioPlayer1.Wave.Delete(0, WaveLength - 5000);  AudioPlayer2.Wave.LoadFromFile('FileA.wav');  WaveLength := AudioPlayer2.Wave.Length;  AudioPlayer2.Wave.Insert(0, AudioPlayer1.Wave);  AudioPlayer2.Wave.SaveToFile('Result.wav');end;

Questions:

1. Is it possible to make it in more clever way?
2. WHy do I get an abstract error in the first example?

James
james
Member

Posts: 2
Joined: October 11th, 2005, 3:45 pm

You cannot type cast a Stream to TWave, otherwise you will get either AV or Abstract exception.

The second approach is the only way that you can reach to your goal using the Wave Audio package.
Kambiz

Kambiz