DGL
https://delphigl.com/forum/

Sound Length
https://delphigl.com/forum/viewtopic.php?f=19&t=4103
Seite 1 von 1

Autor:  Stucuk [ Fr Mai 06, 2005 15:10 ]
Betreff des Beitrags:  Sound Length

Anyone know how long 1 Byte of sound lasts in miliseconds with a frequency of 22050 ?

Autor:  Delphic [ Fr Mai 06, 2005 15:15 ]
Betreff des Beitrags: 

well, i think you're talking not of one byte but of one sample. an it lasts exactly 1/22050 second, i.e. about 0.0454 ms.

Autor:  Stucuk [ Fr Mai 06, 2005 19:14 ]
Betreff des Beitrags: 

Maybe its how im doing it but the sound doesn't go from one "block" of sound to the next "block" of sound.....

Im trying to get the sound for the ROQ's to work right (Video format used in Q3 Engines). Each frame can have a varible length of sound attached to it. The prog shoves the sound into a array (for each frame that passes) until the current sound "block" has been played. Once its been played it shoves the array into memory, clears it and then begins the process again. The problem being when does the sound finish.

Code:
  1.  
  2. If Cinematic.State = 1 then //if Cinematic.AudioSampleOffset > 0 then
  3.     if Cinematic.AudioTime >= (Cinematic.CurAudioBufferLength/2)*(1/22050) then
  4.     begin
  5.     FSOUND_Sample_Upload(Sound.FEmitters[Cinematic.FmodEmitterID].SamplePtr,Cinematic.AudioBuffer,FSOUND_SIGNED);
  6.     Sound.PlaySound(Cinematic.FmodEmitterID);
  7.  
  8.     Cinematic.CurAudioBufferLength := Cinematic.AudioSampleOffset;
  9.     FillChar(Cinematic.AudioBuffer[0], Cinematic.AudioSampleCount * SizeOf(SmallInt), 0);
  10.     Cinematic.AudioSampleOffset := 0;
  11.     Cinematic.AudioTime := 0;
  12.     end;
  13.  
  14.     If Cinematic.State = 1 then
  15.     Cinematic.AudioTime := Cinematic.AudioTime + gTimer.FrameTime;
  16.  


Sound seems to be a bit off, more noticable in videos which have a short amount of sound per frame.

Autor:  AL [ Sa Mai 07, 2005 11:50 ]
Betreff des Beitrags: 

I'm not that familiar with FMod but I think, you should queue the buffers. Right now, you simply play a buffer and wait for it to be finished. Then you play the next one. Now what happens if the souncard is done right after your "if Cinematic.AudioTime >= (Cinematic.CurAudioBufferLength/2)*(1/22050)" and has to wait for the mainloop to repeat? I guess thats your small pause.

I would keep at least one more buffer in the queue, so that your soundcard can switch to the next buffer as soon as it is finished with the current one...

Autor:  Stucuk [ Sa Mai 07, 2005 12:18 ]
Betreff des Beitrags: 

What queue? Iv seen only channels and samples in FMOD. There are no queues that i can see.

Autor:  AL [ So Mai 08, 2005 16:55 ]
Betreff des Beitrags: 

I don't know FMod, but OpenAL and even the Windows API have queues.

Autor:  Stucuk [ Mo Mai 09, 2005 16:57 ]
Betreff des Beitrags: 

Http://www.fmod.org/docs

Above link lists all commands.

Autor:  AL [ Mo Mai 09, 2005 20:48 ]
Betreff des Beitrags: 

hmm, looks like FMod doesn't support queues. Another proof, that it's better to write stuff like that yourself (at least sometimes).

Autor:  Delphic [ Mo Mai 09, 2005 21:31 ]
Betreff des Beitrags: 

I remember some callback mode in fmod, where fmod is asking for new data when needed. This works well as long as your program consumes similar times for preparing the next part of sound. I used this mechanism for my simple synthesizer tutors.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/