L'un , pour le calcul du BPM ( je dois être fatigué...)
l'autre , plus technique concernant le rafraichissement qui clignote...
1°
Pour le BPM , je procède de cette manière :
J'ai 255 éléments à jouer les uns après les autres , avec un BPM de 255BPM = 255
TempsARajouter = 60000 / BPM
if T < elapsedtimer()
T = elapsedtimer() + TempsARajouter
endif
il devrais me le jouer en une minute. mais j'ai 4 secondes dans la vue...
je vois pas d'ou ca viens.
Pour le rafraichissement , lorsque mon scrollarea descends , l'image ( la partie du bas clignote) comment reduire cet effet désagréable ?
Merci a vous.
Code : Tout sélectionner
Structure TrackerRect
x.i : y.i
EndStructure
Structure TrackerValue
SoundID.i
Text$
;Filters.i ; on ajoute se que l'on veut
EndStructure
Structure Tracker_Track
Value.TrackerValue[16]
EndStructure
Structure TrackerGadget
TrackerEntry.Tracker_Track[256] ; Liens vers la banque de son
SelectedLine.b[256] ; Pour la multiselection
NbTrack.c
GadgetSize.TrackerRect
Image.i
Surface.i
ScrollArea.i
Thread.i
WindowParent.i
BackgroundColor.i
ForegroundColor.i
SelectedLineColor.i
SelectedItemColor.i
Selected_Row.i
Selected_Column.i
ForceRedraw.b
EndStructure
Procedure TrackerGadgetThread(*Tracker.TrackerGadget)
Repeat
With *Tracker
If \ForceRedraw = #True
\ForceRedraw = #False
StartDrawing(ImageOutput(\Image))
DrawingMode(#PB_2DDrawing_Transparent)
Marge = 2
HexaMarge = 40
TrackSize = ((\GadgetSize\x-21-HexaMarge) / \NbTrack)
;Dessin du Fond
Box(0,0,\GadgetSize\x ,5120,\BackgroundColor)
For Sector = 0 To 255
Line(0,Sector*20,\GadgetSize\x ,0,RGB(192,192,192))
Hexa$ = RSet(Hex(Sector,2),2,"0")
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(0,(Sector*20)+Marge,Hexa$,\ForegroundColor)
DrawText(\GadgetSize\x-40,(Sector*20)+Marge,Hexa$,\ForegroundColor)
; La ligne est selectionné
If \SelectedLine[Sector] = #True
DrawingMode(#PB_2DDrawing_Outlined)
Box(24,Sector*20+2,\GadgetSize\x-4-21-HexaMarge,16,\SelectedLineColor)
EndIf
For i = 0 To \NbTrack -1
; Texte de la cellule
CellText$ = \TrackerEntry[Sector]\Value[i]\Text$
DrawingMode(#PB_2DDrawing_Transparent)
DrawText((TrackSize*i+20+2)+TrackSize/2-TextWidth(CellText$)/2,Sector*20+2,CellText$,\ForegroundColor)
;Selection a la souris
MouseGadgetX = (WindowMouseX(\WindowParent) - GadgetX(\ScrollArea)) + GetGadgetAttribute(\ScrollArea,#PB_ScrollArea_X)
MouseGadgetY = (WindowMouseY(\WindowParent) - GadgetY(\ScrollArea)) + GetGadgetAttribute(\ScrollArea,#PB_ScrollArea_Y)
If MouseGadgetX > TrackSize*i+20+2 And MouseGadgetX < (TrackSize*i+20+2)+TrackSize-4 And MouseGadgetY > Sector*20+2 And MouseGadgetY < (Sector*20+2)+16
DrawingMode(#PB_2DDrawing_Outlined)
Box( TrackSize*i+20+4,Sector*20+3,TrackSize-6,14,\SelectedItemColor) ; Dessin de la selection
\Selected_Row = Sector
\Selected_Column = i+1
EndIf
Next
Next
For i = 0 To \NbTrack
; Dessin du séparateur de track
Box( 20 + (i*TrackSize),0,Marge,5120,RGB(192,192,192))
Next
StopDrawing()
SetGadgetState(\Surface,ImageID(\Image))
EndIf ; End Force redraw.
If WindowMouseX(\WindowParent) > GadgetX(\ScrollArea) And WindowMouseX(\WindowParent) < GadgetX(\ScrollArea) + GadgetWidth(\ScrollArea) And WindowMouseY(\WindowParent) > GadgetY(\ScrollArea) And WindowMouseY(\WindowParent) < GadgetY(\ScrollArea) + GadgetHeight(\ScrollArea)
\ForceRedraw = #True
EndIf
EndWith
ForEver
EndProcedure
Procedure.i TrackerGadget(x,y,width,height,NbTrack)
*Tracker.TrackerGadget = AllocateMemory(SizeOf(TrackerGadget))
If *Tracker = #Null
MessageRequester("Error","Can't make Tracker Gadget , not enough memory")
End
EndIf
With *Tracker
\Image = CreateImage(#PB_Any,width,5120)
\ScrollArea = ScrollAreaGadget(#PB_Any,x,y,width,height,width-21,5120,5)
\Surface = ImageGadget(#PB_Any,0,0,width,5100,ImageID(\Image)) : CloseGadgetList()
\WindowParent = GetActiveWindow()
\GadgetSize\x = width
\GadgetSize\y = height
\BackgroundColor = $000000
\ForegroundColor = $00AA00
\SelectedLineColor = $0044FF
\SelectedItemColor = $00C1FF
\NbTrack = NbTrack
\ForceRedraw = #True
\SelectedLine[1] = #True
\Thread = CreateThread(@TrackerGadgetThread(),*Tracker)
EndWith
ProcedureReturn *Tracker
EndProcedure
Procedure SetGadgetTrackerItemText(*Tracker.TrackerGadget,Row.i,Column.i,Text$)
*Tracker\TrackerEntry[Row]\Value[Column]\Text$ = Text$
EndProcedure
Procedure.s GetGadgetTrackerItemText(*Tracker.TrackerGadget,Row.i,Column.i)
ProcedureReturn *Tracker\TrackerEntry[Row]\Value[Column]\Text$
EndProcedure
Procedure SetGadgetTrackerState(*Tracker.TrackerGadget,state.i)
For i = 0 To 255
*Tracker\SelectedLine[i] = #False
Next
*Tracker\SelectedLine[state] = #True
*Tracker\ForceRedraw = #True
SetGadgetAttribute(*Tracker\ScrollArea,#PB_ScrollArea_Y,(state*20))
EndProcedure
OpenWindow(0,0,0,1024,768,"PureTracker")
; SetWindowColor(0,$AA0011)
FastTracker = TrackerGadget(10,412,1004,346,6)
For R = 0 To 255
For C = 0 To 5
SetGadgetTrackerItemText(FastTracker,R,C,"-- This is :: "+Str( Random(65535) ))
Next
Next
BPM = 255
BPS = 60000/BPM
BEAT_TIMER.i
Ts = ElapsedMilliseconds()
Repeat
event = WindowEvent()
SmartWindowRefresh(0,1)
If BEAT_TIMER<ElapsedMilliseconds()
BEAT_TIMER = ElapsedMilliseconds() + BPS
Line+1
If Line=256
Te = ElapsedMilliseconds()
Tf = Te-Ts
MessageRequester("",Str(Tf))
End
EndIf
EndIf
SetGadgetTrackerState(FastTracker,Line)
Until event = #PB_Event_CloseWindow