B4J Question JavaxMidi-B4xLib for B4j

Luca1967

Active Member
If I wanted to modify (or insert) the lyric of a song, is it possible to do it through your library?
 

stevel05

Expert
Licensed User
Longtime User
You can certainly extract the lyrics, and you can add and remove lyric events, so yes you can. But it is not as simple as it sounds as the events need to be lined up with melody notes (to make it work effectively) And the Lyric events should only be on track 0 (not that all producers of midi files with lyrics stick to that).
 
Upvote 0

Luca1967

Active Member
You can certainly extract the lyrics, and you can add and remove lyric events, so yes you can. But it is not as simple as it sounds as the events need to be lined up with melody notes (to make it work effectively) And the Lyric events should only be on track 0 (not that all producers of midi files with lyrics stick to that).

Yes, I know.
Should I use MidiShortMessage and MidiMessageBuilder to replace the data?
If I wanted to substitute the syllable "BAL" at the ticks 33365 is what I said correct?

For instance. I have a song where the lyrics are on track 4.
So it would be enough for me to delete the lyrics events in track 4 and rewrite them with the tick and the text. I generate the tick.
 
Last edited:
Upvote 0

Luca1967

Active Member
In this mode?

Dim TX As MidiTrack = Seq.GetTracks(Traccia)
Seq.DeleteTrack(TX) ' cancello traccia lyric
Seq.CreateTrack
Dim MetaMessage As MidiMetaMessage
MetaMessage.Initialize
Dim data1(3) As Byte
data1(0) = 0x61
data1(1) = 0x61
data1(2) = 0x61
MetaMessage.setmessage(MidiMetaMessage_Static.LYRIC,data1,3)
Dim midiev As MidiEvent
midiev.CreateMeta(MetaMessage,33365)
TX.add(midiev)
MidiSystemStatic.Write(Seq,1,"c:\","prova.mid") ' salva la base
 
Upvote 0

Luca1967

Active Member
or in this mode?

Dim TX As MidiTrack = Seq.GetTracks(Traccia)
Seq.DeleteTrack(TX) ' cancello traccia lyric
Seq.CreateTrack

TX.add(MidiEventBuilder.Lyric("AAA",33365))

MidiSystemStatic.Write(Seq,1,"c:\","prova.mid") ' salva la base
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
It is easier to just try it :).

Once you have deleted a track you cannot write to it so you will have to get the object for the newly created track. But be careful deleting the track, there may be midi note events on the track too.
You could also just run through all the lyric events and remove them from the track. Then add the new ones, preferably to the existing track 0.

Do you have the latest version of the midi lib? MidiEventBuilder should ask for a CharacterSet.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
If the lyrics are all in the correct place, you can also keep a list of the existing events, remove them from an existing track, modify the lyric and then add them to a track.
 
Upvote 0

Luca1967

Active Member
If the lyrics are all in the correct place, you can also keep a list of the existing events, remove them from an existing track, modify the lyric and then add them to a track.
thanks

with this routine i delete event lyrics in tracks (in that case tracks4)

Dim TX As MidiTrack = Seq.GetTracks(Traccia)
For i = 0 To TX.Size-1
Dim Mevt As MidiEvent = TX.Get(i)
Dim XX As String
XX= Mevt.ToString(Mevt.GetMessage)
If XX.Contains("Lyrics") Then
TX.Remove(Mevt)
End If
Next

With this routine i create a track and add lyrics, but I can't specify the track number

Dim TX As MidiTrack = Seq.GetTracks(Traccia)
Seq.DeleteTrack(TX) ' cancello traccia lyric
Dim t As MidiTrack = Seq.CreateTrack
T.add(MidiEventBuilder.Lyric("AAA",33365))
MidiSystemStatic.Write(Seq,1,"c:\","prova.mid") ' salva la base


How do I add events to a track?
 
Upvote 0
Top