Dark Bit Factory & Gravity
PROGRAMMING => C / C++ /C# => Topic started by: S0lll0s on April 04, 2013
-
I am starting my first (2d) demo now, and I get along pretty well except for major synchronization problems.
I do not have a graphics timer, I base all my graphics on the current audio time as I only play a mp3 for my first demo.
The libraries I use are SDL with OpenGL and BASS as an Audio Library. I am creating my own engine from scratch.
The music for my demo is Awolnation - Sail, so you should go ahead and obtain a mp3 of that song (legally of course) and put it as sail.mp3 in the binary folder if you want to test it.
I know that Sail is 119 BPM and my Syncing works pretty well for the first ~50seconds, but then it slowly drifts off and gets really bad. It should draw a green Hexagon every when the kick starts (and every 2nd bar before that too).
This is how I check if the kick just kick'd:
int millis = (int)( time * 1000.0f ); //time is the playback pos in seconds (double)
int everyX = (int)( 119.0 / 60.0f * 1000.0f ); //everyX is the time it takes for a bar to pass
if ( ( millis + everyX / 4 + everyX ) % ( everyX * 2 ) < 80 ) //The song starts with an offset and I want every 2nd bar
return true;
-
my Syncing works pretty well for the first ~50seconds, but then it slowly drifts off and gets really bad.
Hi S0lll0s,
I picked the track from youtube (this (http://www.youtube.com/watch?v=PPtSKimbjOU)) and opened it in some random wave editor.
The track starts at 0.175s.
Between 33.424 and 65.692 are exactly 8 sequences, makes 4.0335 seconds per sequence.
Let's assume 8 beats per sequence (which results in 119.003 bpm).
Now I simplified your main loop to the following:
float nextBeat= 0.175f; // start of the track
float secondsPerBeat= 4.0335f / 8.0;
while( true )
{
...
glClear( GL_COLOR_BUFFER_BIT );
musicTime = BASS_ChannelBytes2Seconds( sailMusic, BASS_ChannelGetPosition( sailMusic, BASS_POS_BYTE ) );
if (musicTime >= nextBeat)
{
nextBeat += secondsPerBeat;
callback2();
}
SDL_GL_SwapBuffers();
}
And a green hexagon is flashing to the beat.
Should be possible to get the rest working from here on.
how do I draw "thick" lines in OpenGL?
You call glLineWidth with the desired width.
And after that, how do I do 90° turns with those
(http://www.trafficsign.us/100/warn/w1-1.gif)
??? ???
and make them grow?
(http://www.abload.de/img/penissize-300x2252vqfd.jpg)
;D ;D
-
my Syncing works pretty well for the first ~50seconds, but then it slowly drifts off and gets really bad.
Hi S0lll0s,
[...]
And a green hexagon is flashing to the beat.
Should be possible to get the rest working from here on.
Thank you, I moved on with the graphics but synchronization still didn't work, I will try this now.
how do I draw "thick" lines in OpenGL?
You call glLineWidth with the desired width.
And after that, how do I do 90° turns with those
I meant curves that look smooth, like the grey in this one:
(http://img.usabilitypost.com/0901/bad_corner.png)
and make them grow?
(http://www.abload.de/img/penissize-300x2252vqfd.jpg)
;D ;D
-
I meant curves that look smooth, like the grey in this one:
(http://img.usabilitypost.com/0901/bad_corner.png)
Curves are usually drawn by subdividing the round parts into many small line segments.
The more segments you use, the smoother it looks.
In your case it's probably enough to keep a bit of space between two lines and connect them with a quarter of a circle.
You might want to look up splines (http://www.mvps.org/directx/articles/catmull/), too.
by growing I mean starting very short and progressively get longer.
Well, I guess you're already able to draw a short line and a long line.
So I'm pretty sure you can draw any length in between, too...
And what you're asking for is varying the length over time.
-
by growing I mean starting very short and progressively get longer.
Well, I guess you're already able to draw a short line and a long line.
So I'm pretty sure you can draw any length in between, too...
And what you're asking for is varying the length over time.
[/quote]
Anyways, thanks for that link. I tried to find a good introduction to splines and this seems worth the read, I could only find spline librarys and extremely mathematical info.
-
Maybe you find this (http://cubic.org/docs/hermite.htm) helpful for a start.