Author Topic: timing effects / music  (Read 1500 times)

0 Members and 1 Guest are viewing this topic.

Offline waste

  • C= 64
  • **
  • Posts: 46
  • Karma: 2
    • View Profile
timing effects / music
« on: June 09, 2016 »
hi all,

i managed to use the PurebasicUserlib by eNeRGy/dAWN PtkRplay in order to play / locate postion , row  with ptp music modules

i would like to start scrolltexts, rasterbars , all graphical stuff based on music rythm , 

how do you deal with that in your intros / demos  ? using timers ?

i tryied with conditions like 

Code: [Select]
If Ptk_GetPosition() > 1 And Ptk_GetRow() =1
drawstars()
EndIf

but it's getting hard when adding more effects ... , i use Mp3d lib and EP_fxlib ,

i can have rasters/ sinusscroll / starfield simulteanously , without trying to set them on music ,

for example , my main loop  looks like that

Code: [Select]
Repeat
  event =WindowEvent()
 
MP_AmbientSetLight (RGB(0,0,40))

EP_Move32Scroll(0)
EP_2DStarsDraw()
EP_DisplayRasterBar(0,30)
EP_DisplayRasterBar(1,450)

Until GetAsyncKeyState_(#VK_ESCAPE)


scroll , rasters and stars must be in a loop ,

so i tried  :
Code: [Select]
Procedure DrawStars()
 Repeat
    event=WindowEvent()
   
    EP_2DStarsDraw()
   MP_RenderWorld()
  MP_Flip ()       
    Until Ptk_GetPosition() =20
  EndProcedure


when ptk position is = 20 , stars don't stop ...  and if i set a scrolltext to start at postion 3 , i think it starts but no display ( to much MP_Flip() perhaps

so i don't know wich way i should choose,   select/case  , While / wend ? ......

Offline padman

  • Senior Member
  • Pentium
  • ********
  • Posts: 976
  • Karma: 258
    • View Profile
Re: timing effects / music
« Reply #1 on: June 09, 2016 »
Well, hard to tell why it's not working from just the small snippets you provided. I created a small working example for myself and everything works fine. It stops/starts the starfield and finally exits when position=4. Maybe saving the result of Ptk_GetPosition in a global variable (i.e. position=Ptk_GetPosition() ) will already do the trick in your case... Anyway, here's my example. ZIP con exe attached. (Assumes you have the userlib installed already for everyone else!)

Pad.


Code: [Select]
MAX_STAR=500
STAR_SPEED=6


Global Dim star_x.l(MAX_STAR)
Global Dim star_y.l(MAX_STAR)
Global Dim star_z.l(MAX_STAR)

Global speed=4

InitSprite() : InitKeyboard()


OpenWindow(1, 0, 0, 800, 600, "Ptk_GetPosition() Example",  #PB_Window_ScreenCentered )
OpenWindowedScreen(WindowID(1), 0, 0, 800, 600, 0, 0, 0)


Ptk_InitDriver(GetForegroundWindow_(),20)
Ptk_InitModule(?tune,0)
Ptk_Play()

Procedure  rnd(min.w,max.w)
  a =  max - Random (max-min)
  ProcedureReturn a
EndProcedure


Procedure  setup_stars()
  For c.w=0 To 500
    star_x(c)= Rnd(-600/2,800/2) << 6
    star_y(c)= Rnd(-600/2,800/2) << 6
    star_z(c)=Rnd(2,255)
 Next
EndProcedure

Procedure UpdateStar()
  For c=0 To 500
    star_z(c)=star_z(c)-speed
    If star_z(c)<=2
      star_z(c)=255
    EndIf
    s_x=(star_x(c)/star_z(c))+(800/2)
    s_y=(star_y(c)/star_z(c))+(600/2)
    col=255-star_z(c)
    FrontColor (RGB(col,col,col))
    Box (s_x,s_y,3,3)
   
  Next

EndProcedure

setup_stars()


Repeat
 
  ClearScreen(RGB(0,0,0))
  WaitWindowEvent(1)
 
  StartDrawing(ScreenOutput())   
 
  position=Ptk_GetPosition()
 
  If position=1 : speed=0 : EndIf
  If position=2 : speed=4 : EndIf
  If position=3 : speed=0 : EndIf
 
  updatestar()

  StopDrawing()                   
 
  FlipBuffers()
  ExamineKeyboard()
 Until KeyboardPushed(#PB_Key_Escape)  Or position=4
 
Ptk_Stop()
Ptk_ReleaseDriver()

End

DataSection
tune:
IncludeBinary "Comic Bakery Remix.ptp"
EndDataSection
Challenge Trophies Won:

Offline waste

  • C= 64
  • **
  • Posts: 46
  • Karma: 2
    • View Profile
Re: timing effects / music
« Reply #2 on: June 09, 2016 »
 :)

it starts now ! as same time you posted your code,

here is mine without data section and init stuff from beginning, just main loop and procedures

Code: [Select]
Procedure DrawStars()

  event=WindowEvent()
    EP_2DStarsDraw()
 
EndProcedure
   
 
Procedure DrawSineScroll()
 
  event=WindowEvent()
    EP_Move32Scroll(0)
   
EndProcedure
 
 
Procedure DrawRasters()
 
  event=WindowEvent()
    EP_DisplayRasterBar(0,30)
    EP_DisplayRasterBar(1,450)
     
EndProcedure




;-------Main-------------



Repeat
  event =WindowEvent()
 
  MP_AmbientSetLight (RGB(0,0,40))
 
  MP_DrawText(0,0,"Position: " +Str(Ptk_GetPosition()))
 
If Ptk_GetPosition() >= 1   
       DrawStars()
EndIf
 
 
If Ptk_GetPosition() >=3
       DrawSineScroll()
EndIf
   
If Ptk_GetPosition() >=4
        DrawRasters()
EndIf
 
   
  MP_RenderWorld()
  MP_Flip ()       
     
 
   
Until GetAsyncKeyState_(#VK_ESCAPE)



Ptk_Stop()
Ptk_ReleaseDriver()



End



will try with a global variable to save position and stop stars , thank you for you quick help




Offline inc.

  • Contact me @ skype: a5recordings
  • Amiga 1200
  • ****
  • Posts: 260
  • Karma: 16
  • I SPEAK ENGLISH & GERMAN as good as i can :D
    • View Profile
Re: timing effects / music
« Reply #3 on: June 09, 2016 »
can not test :(

don't have the libs
currently coding in PureBasic: GLSL Shader Maker & Editor Tool for further Demo coding usage

Offline waste

  • C= 64
  • **
  • Posts: 46
  • Karma: 2
    • View Profile
Re: timing effects / music
« Reply #4 on: June 10, 2016 »

attachment ProtrekkrReplay_V254.rar 

very usefull lib,

Offline inc.

  • Contact me @ skype: a5recordings
  • Amiga 1200
  • ****
  • Posts: 260
  • Karma: 16
  • I SPEAK ENGLISH & GERMAN as good as i can :D
    • View Profile
Re: timing effects / music
« Reply #5 on: January 23, 2018 »
thanks
currently coding in PureBasic: GLSL Shader Maker & Editor Tool for further Demo coding usage