hi,
my girlfriend is a singer and uses rosegarden... and i'm the one you
have to get things working for her :)
not much needed to print my simple .rg via lilypond
- patch below fixes:
- handle lyrics the lilypond 2.0 way
- add a "_" when a note doesn't have a lyric
(inspired by LyricEditDialog::unparse() which add ".")
- character ' is useful in lyrics and lilypond doesn't choke, so
allow it (protectIllegalChars)
- closing bar at the end (\bar "|.")
NB: i don't know if it breaks oldStyle, and only tested on 1 file!
- what is still buggy:
- i don't know why, but the track name is offset by 1.
(staffName)
this patch is for rosegarden4 0.9.5 but applies on CVS version too.
please tell if this is the right way to send patch
cu
--- rosegarden-4-0.9.5/gui/lilypondio.cpp.pix 2003-11-26 16:26:33.000000000 +0100
+++ rosegarden-4-0.9.5/gui/lilypondio.cpp 2004-01-07 00:32:21.715086938 +0100
@@ -457,7 +457,6 @@
// tmpStr.replace(QRegExp("\\("), "");
// tmpStr.replace(QRegExp("\\)"), "");
tmpStr.replace(QRegExp("\""), "");
- tmpStr.replace(QRegExp("'"), "");
// tmpStr.replace(QRegExp("-"), "\\-");
@@ -701,7 +700,10 @@
std::ostringstream voiceNumber, lyricNumber;
voiceNumber << "voice " << voiceCounter;
lyricNumber << "lyric " << voiceCounter++;
-
+
+ if (exportLyrics && !oldStyle) {
+ str << indent(col) << "\\addlyrics" << std::endl;
+ }
str << indent(col++) << "\\context Voice = \"" << voiceNumber.str()
<< "\" {"; // indent+
@@ -724,6 +726,7 @@
std::string lilyText = ""; // text events
std::string lilyLyrics = ""; // lyric events
std::string prevStyle = ""; // track note styles
+ bool note_ended_with_a_lyric = true;
Rosegarden::Key key;
@@ -735,19 +738,22 @@
writeBar(*i, barNo, col, key,
lilyText, lilyLyrics,
- prevStyle, eventsInProgress, str);
+ prevStyle, eventsInProgress, str, note_ended_with_a_lyric);
if (exportBarChecks) {
str << " |";
}
}
+ // closing bar
+ str << std::endl << indent(col) << " \\bar \"|.\"";
+
// close Voice context
str << std::endl << indent(--col) << "} % Voice" << std::endl; // indent-
// write accumulated lyric events to the Lyric context, if user
// desires
- if (exportLyrics && (lilyLyrics != "")) {
+ if (exportLyrics) {
str << indent(col) << "\\context Lyrics = \"" << lyricNumber.str()
<< "\" \\lyrics { " << std::endl;
str << indent(++col) << lilyLyrics << " " << std::endl;
@@ -894,7 +900,8 @@
std::string &lilyLyrics,
std::string &prevStyle,
eventendlist &eventsInProgress,
- std::ofstream &str)
+ std::ofstream &str,
+ bool ¬e_ended_with_a_lyric)
{
KConfig *cfg = kapp->config();
cfg->setGroup(NotationView::ConfigGroup);
@@ -1059,9 +1066,12 @@
if ((*i)->isa(Text::EventType)) {
- if (oldStyle) { //!!! work this out for lily 2.x
- handleText(*i, lilyText, lilyLyrics);
- }
+ std::string textType;
+ if ((*i)->get<String>(Text::TextTypePropertyName, textType) &&
+ textType == Text::Lyric)
+ note_ended_with_a_lyric = true;
+
+ handleText(*i, lilyText, lilyLyrics);
} else if ((*i)->isa(Note::EventType)) {
@@ -1084,6 +1094,11 @@
(*i)->get<Bool>(TIED_FORWARD, noteTiedForward);
if (noteTiedForward) tiedForward = true;
+ if (!noteTiedForward) {
+ if (!note_ended_with_a_lyric) lilyLyrics += "_ ";
+ note_ended_with_a_lyric = false;
+ }
+
str << " ";
} else if ((*i)->isa(Indication::EventType)) {
@@ -1190,10 +1205,13 @@
}
} else if ((*i)->isa(Text::EventType)) {
-
- if (oldStyle) { //!!! work this out for lily 2.x
- handleText(*i, lilyText, lilyLyrics);
- }
+
+ std::string textType;
+ if ((*i)->get<String>(Text::TextTypePropertyName, textType) &&
+ textType == Text::Lyric)
+ note_ended_with_a_lyric = true;
+
+ handleText(*i, lilyText, lilyLyrics);
}
if ((*i)->isa(Indication::EventType)) {
@@ -1293,7 +1311,7 @@
} else if (text.getTextType() == Text::Lyric) {
- lilyLyrics += s + " ";
+ lilyLyrics += "\"" + s + "\" ";
} else if (text.getTextType() == Text::Dynamic) {
--- rosegarden-4-0.9.5/gui/lilypondio.h.pix 2003-09-16 20:20:33.000000000 +0200
+++ rosegarden-4-0.9.5/gui/lilypondio.h 2004-01-06 22:47:27.358370619 +0100
@@ -58,7 +58,7 @@
void writeBar(Rosegarden::Segment *, int barNo, int col,
Rosegarden::Key &key, std::string &lilyText, std::string &lilyLyrics,
std::string &prevStyle, eventendlist &eventsInProgress,
- std::ofstream &str);
+ std::ofstream &str, bool ¬e_ended_with_a_lyric);
Rosegarden::timeT calculateDuration(Rosegarden::Segment *s,
const Rosegarden::Segment::iterator &i,