HardwareHeaven.com

HardwareHeaven.com

Looking for the skin chooser?
 
 
  • Home

  • Hardware reviews

  • Articles

  • News

  • Tools

  • Gaming at HardwareHeaven

  • Forums

 

Go Back   HardwareHeaven.com > Forums > Hardware and Related Topics > kX Project Audio Driver Support Forum > Effects and the DSP


Reply
 
Thread Tools
Old Aug 25, 2006, 04:37 AM   #1
S-3D enthusiast
 
Tril's Avatar
 
Join Date: Sep 2004
Location: Canada
Posts: 1,676
Rep Power: 64
Tril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud of
System Specs

Timer's clock not synced to soundcard's clock

This is a C++ programming question. I'm trying to use a timer with a short delay (32 ms) but since its clock is not exactly the same as the clock of the soundcard, it loses sync with the soundcard after a few seconds. That's a clock drift problem. I use CreateTimerQueueTimer to make a queue timer. It's the first type of timer I tried in my code and I haven't tried any other types yet.

I'm wondering if there's a way to make a timer use the same clock as the soundcard.

If that's not possible, I'm looking for advices on what to do to overcome that problem.
Tril is offline   Reply With Quote


Old Aug 26, 2006, 11:15 AM   #2
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

I do not know a lot about it, never having had to do such things, but since nobody else has responded as of yet...

The sound card has its own timer, but it seems that we cannot access these from kX (I have not seen any interrupt handlers that we have access to in the SDK, etc.). Again, I do not know a lot about it, so maybe there is a good reason for this.

The only other thing I can think of, is to read the sample counter from the wall clock register and compare the count from previous checks to find out how much time has passed, and add delays to try and keep it in sync.

i.e.
Set the Windows timer (which is not all that accurate to being with, btw) for a shorter interval than you need, leaving enough time to do your work within the needed time period, and when the processing has completed, read the sample counter, and delay until the correct amount of time has passed.
i.e. (something like the following psuedocode)
while ((GetSampleCount() - previous_count) < 1536); // delay until 32ms has passed

You might even skip using the timer all togther and just create a loop.
i.e.
while (true)
{
previous_count = GetSampleCount();
do_work();
while ((GetSampleCount() - previous_count) < 1536); // delay
}

Although, I am not sure how much of a performance hit such a loop would be, and of course a lot would depend on what you need to do, etc (maybe you do not need the delay, and only need to know the time difference, etc).

I do not know, just a thought... Have you tried asking Eugene about it?
Russ is offline   Reply With Quote
Old Aug 26, 2006, 12:01 PM Threadstarter Thread Starter   #3
S-3D enthusiast
 
Tril's Avatar
 
Join Date: Sep 2004
Location: Canada
Posts: 1,676
Rep Power: 64
Tril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud ofTril has much to be proud of
System Specs

Quote:
I do not know, just a thought... Have you tried asking Eugene about it?
Nope.


I'm playing with this to try to do something differently in redocneXk, to see if it works better, worse or equally well by using a timer.

I found a solution that seems to work. Every time the timer runs, I compare how full the audio buffer is compared to how full it was when I first started the timer. I make the timer adjust its speed to keep the buffer always full about the same amount.
Tril is offline   Reply With Quote
Old Aug 26, 2006, 12:49 PM   #4
h/h member-shmember
 
Join Date: Dec 2002
Location: Evil Empire
Posts: 2,639
Rep Power: 69
Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!

for a playback sync i assume you should use something like waveOutGetPosition and/or 'Multimedia Timers' (sorry, can''t help more)
edit: btw. another option is to correct your position according to asio getSamplePosition

Last edited by Max M.; Aug 26, 2006 at 01:03 PM.
Max M. is offline   Reply With Quote
Old Aug 26, 2006, 03:50 PM   #5
HardwareHeaven Senior Member
 
Join Date: Apr 2005
Location: FI
Posts: 400
Rep Power: 0
jiiteepee is on a distinguished road

Could these functions be helpful for to keep streams in sync:

http://www.codeproject.com/csharp/hi...timercshar.asp
more: http://support.microsoft.com/kb/q172338/

jiitee
jiiteepee is offline   Reply With Quote
Reply

Thread Tools