CALilyPondExport Class Reference

LilyPond export filter This class is used to export the document or parts of the document to LilyPond syntax. The most common use is to simply call one of the constructors. More...

#include <lilypondexport.h>

Inheritance diagram for CALilyPondExport:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 CALilyPondExport (QTextStream *out=0)
CAVoicecurVoice ()
CASheetcurSheet ()
CAContextcurContext ()
int curContextIndex ()
int curIndentLevel ()

Private Member Functions

void exportDocumentImpl (CADocument *doc)
void exportSheetImpl (CASheet *sheet)
void exportScoreBlock (CASheet *sheet)
void exportStaffVoices (CAStaff *staff)
void exportVoiceImpl (CAVoice *voice)
void exportLyricsContextBlock (CALyricsContext *lc)
void exportLyricsContextImpl (CALyricsContext *lc)
void writeDocumentHeader ()
int writeRelativeIntro ()
const QString clefTypeToLilyPond (CAClef::CAClefType type, int c1, int offset)
const QString keySignaturePitchToLilyPond (signed char accs, CAKeySignature::CAMajorMinorGender gender)
const QString keySignatureGenderToLilyPond (CAKeySignature::CAMajorMinorGender gender)
const QString playableLengthToLilyPond (CAPlayable::CAPlayableLength length, int dotted)
const QString notePitchToLilyPond (int pitch, signed char accs)
const QString restTypeToLilyPond (CARest::CARestType type)
const QString barlineTypeToLilyPond (CABarline::CABarlineType type)
const QString syllableToLilyPond (CASyllable *s)
const QString relativePitchToString (CANote *note, int prevPitch)
const QString relativePitchToString (int pitch, signed char accs, int prevPitch)
void voiceVariableName (QString &name, int staffNum, int voiceNum)
void spellNumbers (QString &s)
QString markupString (QString)
QString escapeWeirdChars (QString)
void indent ()
void indentMore ()
void indentLess ()
void setCurVoice (CAVoice *voice)
void setCurSheet (CASheet *sheet)
void setCurContext (CAContext *context)
void setCurContextIndex (int c)
void setIndentLevel (int level)

Private Attributes

QTextStream * _out
CAVoice_curVoice
CASheet_curSheet
CAContext_curContext
int _curContextIndex
int _curIndentLevel


Detailed Description

LilyPond export filter This class is used to export the document or parts of the document to LilyPond syntax. The most common use is to simply call one of the constructors.

Copyright (c) 2007, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.

Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.

Copyright (c) 2007, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.

Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.

        CALilyPondExport( myDocument, &textStream );

textStream is usually the file stream or the content of the score source view widget.

See also:
CALilyPondImport

Definition at line 26 of file lilypondexport.h.


Constructor & Destructor Documentation

CALilyPondExport::CALilyPondExport ( QTextStream *  out = 0  ) 

Constructor for voice export. Called when viewing a single voice source in Lily syntax. Exports a voice to LilyPond syntax using the given text stream.

Definition at line 38 of file lilypondexport.cpp.

References setIndentLevel().

Here is the call graph for this function:


Member Function Documentation

CAVoice* CALilyPondExport::curVoice (  )  [inline]

Definition at line 34 of file lilypondexport.h.

References _curVoice.

Referenced by exportStaffVoices(), and writeRelativeIntro().

Here is the caller graph for this function:

CASheet* CALilyPondExport::curSheet (  )  [inline]

Definition at line 35 of file lilypondexport.h.

References _curSheet.

Referenced by exportScoreBlock().

Here is the caller graph for this function:

CAContext* CALilyPondExport::curContext (  )  [inline]

Definition at line 36 of file lilypondexport.h.

References _curContext.

Referenced by exportScoreBlock().

Here is the caller graph for this function:

int CALilyPondExport::curContextIndex (  )  [inline]

Definition at line 37 of file lilypondexport.h.

References _curContextIndex.

Referenced by exportStaffVoices().

Here is the caller graph for this function:

int CALilyPondExport::curIndentLevel (  )  [inline]

Definition at line 38 of file lilypondexport.h.

References _curIndentLevel.

Referenced by indent().

Here is the caller graph for this function:

void CALilyPondExport::exportDocumentImpl ( CADocument doc  )  [private, virtual]

Exports the current document to Lilypond syntax as a complete .ly file.

Reimplemented from CAExport.

Definition at line 486 of file lilypondexport.cpp.

References exportSheetImpl(), CAExport::out(), CADocument::sheetAt(), CADocument::sheetCount(), and writeDocumentHeader().

Here is the call graph for this function:

void CALilyPondExport::exportSheetImpl ( CASheet sheet  )  [private, virtual]

Exports the current sheet to Lilypond syntax.

Reimplemented from CAExport.

Definition at line 509 of file lilypondexport.cpp.

References CASheet::contextAt(), CASheet::contextCount(), CAContext::contextType(), exportLyricsContextBlock(), exportScoreBlock(), exportStaffVoices(), CAContext::LyricsContext, setCurContextIndex(), setCurSheet(), and CAContext::Staff.

Referenced by exportDocumentImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

void CALilyPondExport::exportScoreBlock ( CASheet sheet  )  [private]

Exports the block for LilyPond from the current sheet. Looks like this:

        \score {
                <<
                        \new Staff {
                                <<
                                        \new Voice { \voiceOne \StaffOneVoiceOne }
                                        \new Voice { \voiceTwo \StaffOneVoiceTwo }
                                >>
                        }
                        \new Staff {
                                <<
                                        \new Voice { \voiceOne \StaffTwoVoiceOne }
                                        \new Voice { \voiceTwo \StaffTwoVoiceTwo }
                                >>
                        }
                        ...
                >>
        }

Definition at line 630 of file lilypondexport.cpp.

References CALyricsContext::associatedVoice(), CASheet::contextAt(), CASheet::contextCount(), CAContext::contextType(), curContext(), curSheet(), indent(), indentLess(), indentMore(), CAContext::LyricsContext, CAContext::name(), CAVoice::name(), CAExport::out(), setCurContext(), spellNumbers(), CAVoice::staff(), CAContext::Staff, CAStaff::voiceAt(), CAStaff::voiceCount(), CAStaff::voiceList(), and voiceVariableName().

Referenced by exportSheetImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

void CALilyPondExport::exportStaffVoices ( CAStaff staff  )  [private]

Exports all the voices in the staff to Lilypond. Each voice in the staff is stored as a Lilypond variable:

StaffOneVoiceOne = c { ... }

Definition at line 569 of file lilypondexport.cpp.

References curContextIndex(), curVoice(), exportVoiceImpl(), indent(), CAVoice::name(), CAExport::out(), setCurVoice(), CAStaff::voiceAt(), CAStaff::voiceCount(), and voiceVariableName().

Referenced by exportSheetImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

void CALilyPondExport::exportVoiceImpl ( CAVoice v  )  [private, virtual]

Exports the given voice music elements to LilyPond syntax.

See also:
CALilypondImport

Todo:
If the time isn't the same, insert hidden rests to fill the needed time

Todo:
If the time isn't the same, insert hidden rests to fill the needed time

Todo:
If the time isn't the same, insert hidden rests to fill the needed time

Todo:
If the time isn't the same, insert hidden rests to fill the needed time

Todo:
If the time isn't the same, insert hidden rests to fill the needed time

Todo:
If the time isn't the same, insert hidden rests to fill the needed time

Reimplemented from CAExport.

Definition at line 48 of file lilypondexport.cpp.

References CANote::accidentals(), CAMusElement::Barline, CABarline::barlineType(), barlineTypeToLilyPond(), CATimeSignature::beat(), CATimeSignature::beats(), CAClef::c1(), CAMusElement::Clef, CAClef::clefType(), clefTypeToLilyPond(), CAPlayable::dotted(), CANote::getChord(), indent(), indentLess(), indentMore(), CANote::isFirstInTheChord(), CANote::isLastInTheChord(), CANote::isPartOfTheChord(), CAMusElement::KeySignature, keySignatureGenderToLilyPond(), keySignaturePitchToLilyPond(), CAKeySignature::majorMinorGender(), CAVoice::musElementAt(), CAVoice::musElementCount(), CAMusElement::musElementType(), CAMusElement::Note, CAKeySignature::numberOfAccidentals(), CAClef::offset(), CAExport::out(), CANote::phrasingSlurEnd(), CANote::phrasingSlurStart(), CANote::pitch(), CAPlayable::playableLength(), playableLengthToLilyPond(), relativePitchToString(), CAMusElement::Rest, CARest::restType(), restTypeToLilyPond(), setCurVoice(), CABarline::Single, CANote::slurEnd(), CANote::slurStart(), CANote::tieStart(), CAMusElement::timeLength(), CAMusElement::TimeSignature, CAMusElement::timeStart(), CAPlayable::Undefined, and writeRelativeIntro().

Referenced by exportStaffVoices().

Here is the call graph for this function:

Here is the caller graph for this function:

void CALilyPondExport::exportLyricsContextBlock ( CALyricsContext lc  )  [private]

Exports the lyrics in form: SopranoLyricsOne = { My bu -- ny is o -- ver the o -- cean __ My bu -- ny. }

Definition at line 200 of file lilypondexport.cpp.

References exportLyricsContextImpl(), indent(), indentLess(), indentMore(), CAContext::name(), CAExport::out(), and spellNumbers().

Referenced by exportSheetImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

void CALilyPondExport::exportLyricsContextImpl ( CALyricsContext lc  )  [private, virtual]

Exports the syllables only without the SopranoLyircsOne = {} frame.

Reimplemented from CAExport.

Definition at line 219 of file lilypondexport.cpp.

References CAExport::out(), CALyricsContext::syllableAt(), CALyricsContext::syllableCount(), and syllableToLilyPond().

Referenced by exportLyricsContextBlock().

Here is the call graph for this function:

Here is the caller graph for this function:

void CALilyPondExport::writeDocumentHeader (  )  [private]

Export document title, subtitle, composer, copyright etc.

Definition at line 532 of file lilypondexport.cpp.

References CAExport::exportedDocument(), indent(), indentLess(), indentMore(), markupString(), and CAExport::out().

Referenced by exportDocumentImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

int CALilyPondExport::writeRelativeIntro (  )  [private]

Writes the voice's note intro and returns the note pitch for the current voice. This function is usually used for writing the beginning of the voice.

Warning:
This function doesn't write "{" paranthesis to mark the start of the voice!

Definition at line 231 of file lilypondexport.cpp.

References curVoice(), CAVoice::musElementAt(), CAVoice::musElementCount(), CAMusElement::musElementType(), CAMusElement::Note, CAExport::out(), and relativePitchToString().

Referenced by exportVoiceImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

const QString CALilyPondExport::clefTypeToLilyPond ( CAClef::CAClefType  clefType,
int  c1orig,
int  offset 
) [private]

Converts the given clefType to LilyPond syntax.

Definition at line 282 of file lilypondexport.cpp.

References CAClef::C, CAClef::F, CAClef::G, CAClef::PercussionHigh, CAClef::PercussionLow, and CAClef::Tab.

Referenced by exportVoiceImpl().

Here is the caller graph for this function:

const QString CALilyPondExport::keySignaturePitchToLilyPond ( signed char  numberOfAccs,
CAKeySignature::CAMajorMinorGender  gender 
) [private]

Returns the key signature pitch in LilyPond syntax. Pitch is always lower-case regardless of the Key signature gender. eg. "e" for E-Major (4 sharps) or e-minor (1 sharp)

See also:
keySignatureGenderToLilyPond()

Definition at line 328 of file lilypondexport.cpp.

References CAKeySignature::Major, CAKeySignature::Minor, and notePitchToLilyPond().

Referenced by exportVoiceImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

const QString CALilyPondExport::keySignatureGenderToLilyPond ( CAKeySignature::CAMajorMinorGender  gender  )  [private]

Returns the key signature gender major/minor in LilyPond syntax.

See also:
keySignaturePitchToLilyPond()

Definition at line 357 of file lilypondexport.cpp.

References CAKeySignature::Major, and CAKeySignature::Minor.

Referenced by exportVoiceImpl().

Here is the caller graph for this function:

const QString CALilyPondExport::playableLengthToLilyPond ( CAPlayable::CAPlayableLength  playableLength,
int  dotted 
) [private]

Converts the note length to LilyPond syntax.

Definition at line 369 of file lilypondexport.cpp.

References CAPlayable::Breve, CAPlayable::Eighth, CAPlayable::Half, CAPlayable::HundredTwentyEighth, CAPlayable::Quarter, CAPlayable::Sixteenth, CAPlayable::SixtyFourth, CAPlayable::ThirtySecond, and CAPlayable::Whole.

Referenced by exportVoiceImpl().

Here is the caller graph for this function:

const QString CALilyPondExport::notePitchToLilyPond ( int  pitch,
signed char  accs 
) [private]

Converts the note pitch to LilyPond syntax.

Definition at line 409 of file lilypondexport.cpp.

Referenced by keySignaturePitchToLilyPond(), and relativePitchToString().

Here is the caller graph for this function:

const QString CALilyPondExport::restTypeToLilyPond ( CARest::CARestType  type  )  [private]

Converts the rest type to LilyPond syntax.

Definition at line 432 of file lilypondexport.cpp.

References CARest::Hidden, and CARest::Normal.

Referenced by exportVoiceImpl().

Here is the caller graph for this function:

const QString CALilyPondExport::barlineTypeToLilyPond ( CABarline::CABarlineType  type  )  [private]

Converts the barline type to LilyPond syntax.

Definition at line 446 of file lilypondexport.cpp.

References CABarline::Dotted, CABarline::Double, CABarline::End, CABarline::RepeatClose, CABarline::RepeatCloseOpen, CABarline::RepeatOpen, and CABarline::Single.

Referenced by exportVoiceImpl().

Here is the caller graph for this function:

const QString CALilyPondExport::syllableToLilyPond ( CASyllable s  )  [private]

Definition at line 472 of file lilypondexport.cpp.

References CASyllable::hyphenStart(), CASyllable::melismaStart(), and CASyllable::text().

Referenced by exportLyricsContextImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

const QString CALilyPondExport::relativePitchToString ( CANote note,
int  prevPitch 
) [inline, private]

Definition at line 64 of file lilypondexport.h.

References CANote::accidentals(), and CANote::pitch().

Referenced by exportVoiceImpl(), and writeRelativeIntro().

Here is the call graph for this function:

Here is the caller graph for this function:

const QString CALilyPondExport::relativePitchToString ( int  pitch,
signed char  accs,
int  prevPitch 
) [private]

This function returns the relative note pitch in LilyPond syntax on the given Canorus pitch and previous note pitch.

eg. pitch=10, accs=1, prevPitch=5 => returns "f'"

See also:
notePitchToLilyPond()

Definition at line 260 of file lilypondexport.cpp.

References notePitchToLilyPond().

Here is the call graph for this function:

void CALilyPondExport::voiceVariableName ( QString &  name,
int  staffNum,
int  voiceNum 
) [private]

Modify name to contain a string "StaffXVoiceY" where X and Y are spelled-out versions of staffNum and voiceNum, respectively. This is for generating names of Lilypond variables from Canorus staff and voices indices, since Lilypond variable names must contain only alphabetical characters.

Example: voiceVariableName( name, 1, 2 ); --> name is "StaffOneVoiceTwo"

Definition at line 599 of file lilypondexport.cpp.

References spellNumbers().

Referenced by exportScoreBlock(), and exportStaffVoices().

Here is the call graph for this function:

Here is the caller graph for this function:

void CALilyPondExport::spellNumbers ( QString &  s  )  [private]

Spell out numbers in a QString: "Staff1Voice2" -> "StaffOneVoiceTwo" This is necessary because Lilypond variable names can only contain letters.

Definition at line 775 of file lilypondexport.cpp.

Referenced by exportLyricsContextBlock(), exportScoreBlock(), and voiceVariableName().

Here is the caller graph for this function:

QString CALilyPondExport::markupString ( QString  in  )  [private]

Encapsulates the given string into {}.

Definition at line 552 of file lilypondexport.cpp.

References escapeWeirdChars().

Referenced by writeDocumentHeader().

Here is the call graph for this function:

Here is the caller graph for this function:

QString CALilyPondExport::escapeWeirdChars ( QString  in  )  [private]

Replaces characters like backslashes and double brackets with their escaped variant.

Definition at line 559 of file lilypondexport.cpp.

Referenced by markupString().

Here is the caller graph for this function:

void CALilyPondExport::indent (  )  [private]

Output tabs according to _indentLevel.

Definition at line 763 of file lilypondexport.cpp.

References curIndentLevel(), and CAExport::out().

Referenced by exportLyricsContextBlock(), exportScoreBlock(), exportStaffVoices(), exportVoiceImpl(), and writeDocumentHeader().

Here is the call graph for this function:

Here is the caller graph for this function:

void CALilyPondExport::indentMore (  )  [inline, private]

Definition at line 75 of file lilypondexport.h.

References _curIndentLevel.

Referenced by exportLyricsContextBlock(), exportScoreBlock(), exportVoiceImpl(), and writeDocumentHeader().

Here is the caller graph for this function:

void CALilyPondExport::indentLess (  )  [inline, private]

Definition at line 76 of file lilypondexport.h.

References _curIndentLevel.

Referenced by exportLyricsContextBlock(), exportScoreBlock(), exportVoiceImpl(), and writeDocumentHeader().

Here is the caller graph for this function:

void CALilyPondExport::setCurVoice ( CAVoice voice  )  [inline, private]

Definition at line 81 of file lilypondexport.h.

References _curVoice.

Referenced by exportStaffVoices(), and exportVoiceImpl().

Here is the caller graph for this function:

void CALilyPondExport::setCurSheet ( CASheet sheet  )  [inline, private]

Definition at line 82 of file lilypondexport.h.

References _curSheet.

Referenced by exportSheetImpl().

Here is the caller graph for this function:

void CALilyPondExport::setCurContext ( CAContext context  )  [inline, private]

Definition at line 83 of file lilypondexport.h.

References _curContext.

Referenced by exportScoreBlock().

Here is the caller graph for this function:

void CALilyPondExport::setCurContextIndex ( int  c  )  [inline, private]

Definition at line 84 of file lilypondexport.h.

References _curContextIndex.

Referenced by exportSheetImpl().

Here is the caller graph for this function:

void CALilyPondExport::setIndentLevel ( int  level  )  [inline, private]

Definition at line 85 of file lilypondexport.h.

References _curIndentLevel.

Referenced by CALilyPondExport().

Here is the caller graph for this function:


Member Data Documentation

QTextStream* CALilyPondExport::_out [private]

Definition at line 90 of file lilypondexport.h.

CAVoice* CALilyPondExport::_curVoice [private]

Definition at line 91 of file lilypondexport.h.

Referenced by curVoice(), and setCurVoice().

CASheet* CALilyPondExport::_curSheet [private]

Definition at line 92 of file lilypondexport.h.

Referenced by curSheet(), and setCurSheet().

CAContext* CALilyPondExport::_curContext [private]

Definition at line 93 of file lilypondexport.h.

Referenced by curContext(), and setCurContext().

int CALilyPondExport::_curContextIndex [private]

Definition at line 94 of file lilypondexport.h.

Referenced by curContextIndex(), and setCurContextIndex().

int CALilyPondExport::_curIndentLevel [private]

Definition at line 95 of file lilypondexport.h.

Referenced by curIndentLevel(), indentLess(), indentMore(), and setIndentLevel().


The documentation for this class was generated from the following files:
Generated on Sat Feb 9 13:15:40 2008 for Canorus by  doxygen 1.5.3