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