Jump to content
  • Advertisement
Sign in to follow this  
Tsoppannos

Best algorithm solution to synchronize lyrics with songs?

This topic is 2138 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

As mentioned in the topic I need a algorithm solution to synchronize lyrics with songs.

I have access to view the current time as in what the current millisecond of the song is playing right now.

Also I got timestamps in my lyrics.

 

Any suggestions here?

Edited by Tsoppannos

Share this post


Link to post
Share on other sites
Advertisement

Do I understand correctly that you have both the current time-code in the song and the lyrics are time-stamped?

 

If that's correct, and assuming the lyrics' time-stamps are accurate you should be able to simply sequentially display lyrics in order as (or more ideally just before) the time-codes are reached in the song.  Some experimentation with a couple of different sample tracks should very quickly reveal how far ahead of time each lyric should be displayed.

 

 

You might want a more robust solution -- or just more time-stamps! -- if you're planning to highlight lyrics word-for-word as the song proceeds, but simply displaying them as the time-codes are reached should be sufficient for displaying whole lines at appropriate times.

 

 

Hope that's helpful! smile.png

Share this post


Link to post
Share on other sites

The title of the thread is not descriptive enough, because I don't know what you are trying to do at all. Is this a karaoke type of thing? Or are you putting subtitles in a video? Or do you have a text and some rough description of the song and you are trying to come up with a melodic rhythm that places the stressed syllables in strong parts of the bar? OK, it's probably not the last one, but that's the one I find most interesting. :)

Share this post


Link to post
Share on other sites

You want a key-value pair (key will be timestamp, value will be lyric text, with highlighting info if appropriate e.g. karaoke), stored in a random access container (e.g. an array), sorted on increasing timestamp so you can do a binary search-like algorithm on the key (current time) to find the currently (or most recently) displayed lyric and the time of the next event.

 

EDIT: Without knowing which language you are using it's difficult to give a full solution. The important thing is the container is sorted in order of ascending timestamp.

Edited by Paradigm Shifter

Share this post


Link to post
Share on other sites

Sorry guys I was in a rush when I wrote my first post so i'll try to be more specific on this one.

So what I wanna do is show whole lines from the lyrics which I have in .txt files.

The lyric timestamp format looks like this: "[00:16:22] I know try to make the best of bad situations".

I have access to see where I'm at on current track playing.

Language being used is Javascript.

Share this post


Link to post
Share on other sites

So what part of this are you having trouble with? It seems pretty straight forward to me...

It's not that straight forward to me tongue.png

Edited by Tsoppannos

Share this post


Link to post
Share on other sites

Well, your algorithm is very simple:

 

Compare the current time of the playing track to the next time-stamp in your lyrics file.  If they are equal, display the lyric.  

Repeat for the next time-stamp until all lyrics have been displayed.

 

For convenience, you'll probably want to read all of the lyrics and time-stamps into a sequentially sorted (i.e. ordered first-to-last) array before starting playback of the file.

 

 

Did you really mean you need a code sample?

 

Are you using any libraries?  Are you running in the web-browser, or a different environment?

Share this post


Link to post
Share on other sites

Well, your algorithm is very simple:

 

Compare the current time of the playing track to the next time-stamp in your lyrics file.  If they are equal, display the lyric.  

Repeat for the next time-stamp until all lyrics have been displayed.

 

For convenience, you'll probably want to read all of the lyrics and time-stamps into a sequentially sorted (i.e. ordered first-to-last) array before starting playback of the file.

 

 

Did you really mean you need a code sample?

 

Are you using any libraries?  Are you running in the web-browser, or a different environment?

No code is really needed  just pointers.

I'm running it as a application for Spotify, I'm also using JQuery.

Thanks mate I think I can use this, much appreciated

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!