0
0

Hi,

I use the non-realtime-mode (with Delphi) for playing back audio and writing then result to an audiostream (together with video) in DSP callback. Problem is that it get’s out of sync with very long MP3s (I didn’t test other formats). Very long means a length of 30 minutes and more.

The Problem is that the MP3 seems to be a little bit to slow. In this small sample a 29 minute long sound is played. After 29 minutes a second sound is started. In the resulting sound stream the first sound is still playing (for about 2 seconds) when the second sound starts, althoug the second sound should follow directly after the first sound.
[code:2135hnun]// DSP Callback
function SaveSamples(OriginalBuffer, NewBuffer: Pointer; Length, Param: Integer): Pointer; stdcall;
begin
// ... write the samples to disk

WrittenSoundBytes := WrittenSoundBytes + Length * 4;
SoundTime := (WrittenSoundBytes div 4) / (MixRate) * 1000; // Length of Soundstream in Ms, MixRate is 48 KHz

// ...
end;

[...]

// Play the sounds

SoundTime := 0;
WrittenSoundBytes := 0;
SoundsPlayed := 0;
while SoundTime < 30 * 1000 * 60 do // while SoundTime < 30 minutes do
begin
// Play first Sound
if (SoundTime = 0) and (SoundsPlayed = 0) then
begin
PlayLongMP3; // Play a sound which lasts 29 minutes
SoundsPlayed := SoundsPlayed + 1;
end;

// Play a second sound which should start immediatelly after the first ends
if (SoundTime &gt;= 29 * 1000 * 60)  and (SoundsPlayed = 1) then
begin
  PlayOtherSound; // Play a (short) sound
  SoundsPlayed := SoundsPlayed + 1;
end;

FMOD.FSOUND_Update;

end;

[/code:2135hnun]

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.