I've a program that playbacks a selected region in a wav-file.
During playback, I display the sound as a graph
and a cursor is walking over the curve to indicate the current position.
For displaying the cursor, I used a multimediatimer,
set to interval / resolution = 100 / 100.
The first time the program works well.
If I repeat the sound, after one or more times, the timer seems to hang completely.
Changing to interval / resolution = 100 / 10, hangs the timer already in the first playback of the sound.
I've replaced the timer with the default D7-timer with an interval of 100 ms (windows XP), for the rest I changed nothing,
and the program runs without any problems.
Didn't I set the interval / resolution not correct,
or did I something else wrong,
or is it a bug ?
The strange thing is that I can set breakpoints in the drawing procedure,
and yes it still stops there, even if the display seems to hang.
So it looks like the multimedia timer and the redraw procedure bites each other.
Below is my draw procedure:
With the default timer, I also don't need the draw_busy flag and the canvas.refresh. These variables were introduced to see if they would solve the problems with multi-media timer.
If it helps to have the complete code,
I possible can make a small demo program,
let me know.
thanks,
Stef Mientki
- Code: Select all
procedure TForm5.Draw_Cursor ( x : integer ) ;
(*******************************************************************************
*******************************************************************************)
begin
if draw_busy then exit;
draw_busy := True;
x := round ( 1.0 * x / display_compression );
if x <> prev_cursor then
begin
with image1.Canvas do
begin
Pen.mode := pmxor;
pen.color := color2xor ( clfuchsia );
//erase old line
if prev_cursor >= 0 then
begin
moveto ( prev_cursor, 0 );
lineto ( prev_cursor, height-1 );
end ;
//draw new line
moveto ( x, 0 );
lineto ( x, height-1 );
prev_cursor := x ;
end;
image1.Canvas.Refresh;
end;
draw_busy:=False;
end;