Yes I meant that. But its wrong because if no event is queued no sound will be played. There are alternatives...
But I feel so sleepy and can't think... I better go to bed. Good night!
Yes I meant that. But its wrong because if no event is queued no sound will be played. There are alternatives...
But I feel so sleepy and can't think... I better go to bed. Good night!
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
Why it fills time_str with one unicode char 11 times?
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
that is not important for this question, pls just help me get the timing right...
the last code didnt worked either, the timing still has some delay :\
Help pls
Sorry but I should understand your code before doing anything to it.
One way is to make a provider and a consumer thread. Provider provides the sequence to be played by consumer thread.
I thought it would be hard for you. To find an easier way, I need a very clean code that I fully understand.
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
hmm can u explain that "provider" metod pls??
oh and btw if u really need to know, it fills time_str in every position (except [12]) with space, so it needs to loop 11 times.
I mean why time_str has 11 chars?
Provider thread is a thread you write to set the time_str.
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
the time_str has 11 chars because it is a string, that will then turn into an integer, this means that the max number of that integer is 99999999.
As you are filling that string yourself, there is no need to have a string at all. You can put it directly to an int.
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
Its for saving the string into a surface, so the user can keep track of the value
I didn't tested it. Just a proposal.
Code:while (quit==0) { apply_surface(bg, screen,0,0); y=atoi(time_str); if (y<=0) y=1; if ((SDL_GetTicks()-timing) == (60000/y)) { if (SDL_PollEvent(&event)) { //Quit Metronome if (event.type==SDL_QUIT) { quit=1; } //-------------------------------- if (event.type==SDL_KEYDOWN) { SDL_EnableUNICODE(SDL_ENABLE); if (event.key.keysym.unicode>=(Uint16)'0' && event.key.keysym.unicode <=(Uint16)'9') { if (x<11) { time_str[x]=(char)event.key.keysym.unicode; x++; text=NULL; } } if (event.key.keysym.sym==SDLK_RETURN) { x=0; while (x<11) { time_str[x]=' '; x++; } x=0; text=NULL; } } text=TTF_RenderText_Solid(font, time_str, textcolor); } Mix_PlayChannel(-1,clap,0); timing=SDL_GetTicks(); } apply_surface(text, screen,0,0); SDL_Flip(screen); }
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
nop that doesnt work, it doesnt let me input nothing and the program enters in an infinite loop cause the events only happen when ((SDL_GetTicks()-timing) == (60000/y)) and when i input something AT THE SAME EXACT TIME, wich is impossible. and besides it still delays a little bit.
the delay has to do with lots of things (cpu speed... etc...) and what i want to know is how to round that and i want to know how to get THE PERFECT TIMING.
If SDL has an event queue maybe you need to call PumpEvents() just before if block in my last post.
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
I recommend using OpenAL or some other better third party sound API. FMOD is also one I would recommend. I'm assuming SDL is trying to offer a very basic sound system so it is easy to get simple sounds playing but probably was not designed to be a fully featured sound API.
I also have problems like that!Thanks for answer and help!^^
-------------------------------------------------------------------------------
Learn more about our Fashion Games website.Fashion Games