Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

what about singalong prog

by stabu (Scribe)
on Mar 12, 2006 at 10:16 UTC ( #536056=perlquestion: print w/replies, xml ) Need Help??

stabu has asked for the wisdom of the Perl Monks concerning the following question:


Just starting to get up to speed with perl and I've decided to begin with a fun prog, such as getting a song lyric text file and making perl display the words as they're sung by the singer.

It would be a kind of karaoke type prog. It's true I would prefer the TV version where a ball would bounce on the words as they came up, but for now, I reckon I'd be happy if I can get perl to display the words on a new line as they come up. I've thought about it a bit and it could be complicated, am I biting off more than I can chew? The timing aspect could be a bit tricky.

Any wild or even reasonable ideas as to how I could start to approach this?

Many thanks in advance

Replies are listed 'Best First'.
Re: what about singalong prog
by zentara (Archbishop) on Mar 12, 2006 at 11:57 UTC
    Check out Tk-Karoake Player-w-timidity. You need to figure out what file types you want to use. The easiset are .kar files, or (midi-with-text). The music and lyrics are synchronized for you, and the freeware player timidity can be run from Perl.

    If you want to use real audio files( wav, mp3, etc.) you will need to setup a timing system, to start the audio and text script at the same time, then display text at the right times for each song. That would take alot of work.

    Stick with .kar or .mid with text, since there is already a huge free library of them available on the net.

    I'm not really a human, but I play one on earth. flash japh
Re: what about singalong prog
by spiritway (Vicar) on Mar 12, 2006 at 10:48 UTC

    Well, theoretically, you might try something along the lines of deciding how many actual lines there are, and spreading them out according to the length of the music. This would be fairly crude, because many songs have refrains, or repeats, or other timing issues that would mess this up.

    You *might* try something like a hardware solution that would detect the beats of the music, and then display text after the correct number of beats has been detected. I don't see how you could do this automatically though - you'd have to use a different count for each song.

    Something simpler might be to just allow the singer to request the words by pressing a button on the mic or something of that nature. But that would probably be kind of boring...

Re: what about singalong prog
by ayrnieu (Beadle) on Mar 12, 2006 at 11:23 UTC

    Any wild <snip> ideas as to how I could start to approach this?

    In two steps. User1 types the lyrics into an editor and presses a button which starts a player and then a clock as soon as that player produces "now producing audio" output. User1 then then hits the spacebar throughout the song.

    Later, User2 with the same audio, a similar enough player, and User1's data gets a scrolling line of text as the song plays.

    As for the program? At first it might just read a line from the lyric file and produce a "$milliseconds: o/~ I put my trust in you o/~" line. Later the user interface might change and the program might produce "$milliseconds: o/~ I put my trust in you o/~\n$milliseconds+1: o/` I o/`\n$milliseconds+1200: o/` put o/`". Later you might find that the best solution makes use of something visual with floating text and random-access audio play.

    Most of your hard work may be making things easier for user1. But you can still do much with a tedious first pass.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://536056]
Approved by wfsp
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2022-05-25 19:54 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (90 votes). Check out past polls.