Jump to content
Search Community

A Tidy way to Tween to audio?

Luckyde test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hey guys small question but i couldn't find any docs on it. 
Say you had an audio piece you trigger on play(for iOS reasons) and you wanted to sync an item to the beat is there a cleaner way than what I'm doing in this codepen. (click on the sound icon).
Basically i'm starting the tweenlite timeline after the audio fully loads and it looks really busy atm. 
Is there a way to go e.g.

TweenMax.to(mything, 1,{top:100,delay:Time.InAudio(0.3)});
instead of starting a timeline hoping for the best so that it doesn't go off sync with the audio. 
Currently on the devices apart from desktop that are slower it goes off sync on the first time but then afterwards it works perfectly on repeat.

I was just wondering if there's a cleaner way to do it than what I'm doing which I'm sure there is. Lines 57-132 is the the code for the beat matching.

Thanks!

See the Pen bZrbpp by LuckyDe (@LuckyDe) on CodePen

Link to comment
Share on other sites

Hello Luckyde

 

Take a look at the <audio> elements currentTime property:

You can see something similar in this forum topic that talks about using GSAP to animate the playhead of a video:

 

http://greensock.com/forums/topic/12771-animating-the-playhead-of-video-element-is-it-possible/#entry53567

 

Hope this helps!

 

:)

  • Like 5
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...