Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

timers and the like

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 Melvin   Members   

122
Like
Likes
Like

Posted 22 January 2002 - 11:44 AM

Hey all, I have recently began construction of a program that will allow you to play drum rythms on the pc. Obviously this is going to require the ability to play sounds with the beat, at very specific and exact intervals. I decided to use a timer to figure out how much time is left before it should play the next note. However, that has been very inconsistent. Sometimes it plays very smoothly, mostly it plays offbeat. Here is a snippet of my code that plays the sounds: for (int i=0;i<=(11*loops+loops-1);i++) { k=0; while (!GetMessage(&msg, hdlg, 0, 0)) { //empty loop that waits for the WM_TIMER message. } //not perfect, but it works for now.. SetTimer(hdlg,IDC_COUNTTIMER, tempo, NULL); while (play[frame][k]==1) { prebuffed[frame][k]->Play(0,0,0); k++; } NextNote(); } anyway, it seems like it should work to me, but of course there is a reason im still in the beginners forum. I was just wondering if anyone had any better timers or ideas to smooth out the sound playing. Melvin

#2 mickey   Members   

100
Like
Likes
Like

Posted 22 January 2002 - 11:29 PM

yeah, use the windows high timer resolution,

like WM_PAINT, your timer messages is not the top priority of windows to retrieve in the messages,

#3 Melvin   Members   

122
Like
Likes
Like

Posted 23 January 2002 - 11:00 AM

Alrighty, I shall look into that. I have another question for you all: Is there a better way to find out if the WM_TIMER message has been posted? I have to tried to use PeekMessage, but, alas, i cannot get it to work right. So if any of you have a good example of how to make PeekMessage or something similar work properly, it would be greatly appreciated.

Thank you,
melvin

#4 Oluseyi   Members   

2076
Like
Likes
Like

Posted 23 January 2002 - 11:41 AM


while(true)
{
if(PeekMessage(&msg, hwnd, 0, 0, PM_NOREMOVE))
{
switch(GetMessage(&msg, hwnd, 0, 0))
{
case 0:
// received WM_QUIT
return msg.message;

case -1:
// error!
break;

default:
TranslateMessage(&msg);
DispatchMessage(&msg);
break;
}
}
}


[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!


#5 mickey   Members   

100
Like
Likes
Like

Posted 25 January 2002 - 06:12 AM

you could create a file(log file, as what they call it), you could stuff things there, then just open it when you terminate your program.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.