1

I am currently creating an app that plays music. I would like to add a feature that shows the music lyrics while the music plays, with the current position of the text marked to match the current position in the song. The Bouncing Ball effect, just like you see on every Karaoke screen as the song plays. I have been looking into extending my caf files, adding "string chunks" and then reading them out again. Is this the correct way to do this? Does anybody know of a better/easier/normal way to achieve my goal? As I am not sure how I would synchronize everything, I would be happy for any suggestions, code examples or helpful comments. Maybe somebody has done this before and would be happy to advise me.

Thanks in advance for any information offered.

Alan

Alan
  • 796
  • 9
  • 26

3 Answers3

2

Most Karaoke apps these days use the .Kar file extension. It's a slightly butchered MIDI file with some annotations and it's pretty small in file size.

I have no idea where you'd start to read it though. You could ask these guys: http://www.ikaraokeapp.com/

Most little devs are happy to help others out.

Aurum Aquila
  • 9,126
  • 4
  • 25
  • 24
  • I will ask these guys then. I have really searched high and low for some info on combining lyrics with songs and its seems to be a well kept secret. Thanks. – Alan Jan 30 '11 at 07:18
  • I couldn't get an answer sorry. Kinda forced to put that üart of the project on the back-burner for now. – Alan Jun 30 '11 at 22:21
  • did you find a way to do this mate? I'm building a karaoke app for a client and I'm stuck displaying the lyrics for about week now :( – Ushan87 Jul 15 '13 at 05:56
1

The standard way to do this is using the kar file extension as suggested by the other answer. Here are some more details.

The .kar extension just signifies that a standard midi file contains lyric information. To build your karaoke player you need to do two things: play the instrument part of the midi file and display the lyrics.

This can be achieved in two ways. Either you could use the built in MusicPlayer to play the midi file and then access the lyric information from a virtual endpoint: here

You would need to access midi meta messages with codes 0x01 (text) or 0x05 (lyric). These messages store the lyric data as a series of hex numbers where each hex number represents an ascii character.

This approach allows you to play the MIDI file and access the lyrics. The problem is that you need to be able to display the lyrics ahead of time so the user can read them before they're played.

To do this you could parse the midi file manually: here

You would need to loop over the MIDI file and extract the text lyrics with their time stamps. Then you could display a section of lyrics ahead of time and change the colour or do a bouncing ball effect as the lyrics became due.

Community
  • 1
  • 1
James Andrews
  • 3,257
  • 3
  • 31
  • 45
0

You should be able to do this through the MusicPlayer API, specifically the MusicTrack MIDIMetaEvent assuming midi type music is acceptable.

MIDIMetaEvent

Describes a MIDI metaevent such as lyric text, time signature, and so on.

typedef struct MIDIMetaEvent {
   UInt8    metaEventType;
   UInt8    unused1;
   UInt8    unused2;
   UInt8    unused3;
   UInt32   dataLength;
   UInt8    data[1];
} MIDIMetaEvent;

Alternately, you might also made some headway looking at iD3 metadata for storing lyrics and timing info.

Either way, there will be lots of file prep in getting the lyrics and timing into the music files.

spring
  • 18,009
  • 15
  • 80
  • 160