Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Member Functions | Private Attributes
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 exportMarks (CAMusElement *)
void exportPlayable (CAPlayable *elt)
void writeDocumentHeader ()
CADiatonicPitch writeRelativeIntro ()
void doAnacrusisCheck (CATimeSignature *time)
const QString clefTypeToLilyPond (CAClef::CAClefType type, int c1, int offset)
const QString diatonicKeyGenderToLilyPond (CADiatonicKey::CAGender gender)
const QString playableLengthToLilyPond (CAPlayableLength length)
const QString diatonicPitchToLilyPond (CADiatonicPitch p)
const QString restTypeToLilyPond (CARest::CARestType type)
const QString barlineTypeToLilyPond (CABarline::CABarlineType type)
const QString syllableToLilyPond (CASyllable *s)
const QString relativePitchToString (CANote *note, CADiatonicPitch prevPitch)
const QString relativePitchToString (CADiatonicPitch p, CADiatonicPitch 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
CADiatonicPitch _lastNotePitch
CAPlayableLength _lastPlayableLength
int _curStreamTime

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

Constructor & Destructor Documentation

CALilyPondExport::CALilyPondExport ( QTextStream *  out = 0)

Constructor for the lilypond export. Called when viewing a single voice source in Lily syntax or exporting the whole document to a file.

Uses out for the output.

References setIndentLevel().

Here is the call graph for this function:


Member Function Documentation

Converts the barline type to LilyPond syntax.

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::clefTypeToLilyPond ( CAClef::CAClefType  clefType,
int  c1orig,
int  offset 
) [private]

Converts the given clefType to LilyPond syntax.

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:

References _curContext.

Referenced by exportScoreBlock().

Here is the caller graph for this function:

References _curContextIndex.

Referenced by exportStaffVoices().

Here is the caller graph for this function:

References _curIndentLevel.

Referenced by indent().

Here is the caller graph for this function:

References _curSheet.

Referenced by exportScoreBlock().

Here is the caller graph for this function:

References _curVoice.

Referenced by doAnacrusisCheck(), exportStaffVoices(), and writeRelativeIntro().

Here is the caller graph for this function:

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

See also:
keySignaturePitchToLilyPond()

References CADiatonicKey::Major, and CADiatonicKey::Minor.

Referenced by exportVoiceImpl().

Here is the caller graph for this function:

Converts the note pitch to LilyPond syntax.

References CADiatonicPitch::accs(), and CADiatonicPitch::noteName().

Referenced by exportVoiceImpl(), and relativePitchToString().

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.

Referenced by markupString().

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.

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

Here is the call graph for this function:

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

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:

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

Reimplemented from CAExport.

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::exportMarks ( CAMusElement elt) [private]

Exports the music element's elt marks.

References CAMusElement::markList(), CAMark::markType(), CAExport::out(), CAMark::RehersalMark, and CAMark::Text.

Referenced by exportVoiceImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

void CALilyPondExport::exportPlayable ( CAPlayable elt) [private]
void CALilyPondExport::exportScoreBlock ( CASheet sheet) [private]
   Exports the \score 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 }
                                >>
                        }
                        ...
                >>
        }

References CALyricsContext::associatedVoice(), CASheet::contextAt(), CASheet::contextCount(), CAContext::contextType(), curContext(), curSheet(), indent(), indentLess(), indentMore(), CAContext::LyricsContext, CAContext::name(), CAVoice::name(), CAExport::out(), setCurContext(), spellNumbers(), CAContext::Staff, CAVoice::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::exportSheetImpl ( CASheet sheet) [private, virtual]

Exports the current sheet to Lilypond syntax.

Reimplemented from CAExport.

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::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 { ... }

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

Reimplemented from CAExport.

References _curStreamTime, _lastNotePitch, _lastPlayableLength, CAMusElement::Barline, CABarline::barlineType(), barlineTypeToLilyPond(), CATimeSignature::beat(), CATimeSignature::beats(), CAClef::c1(), CAMusElement::Clef, CAClef::clefType(), clefTypeToLilyPond(), CAKeySignature::diatonicKey(), diatonicKeyGenderToLilyPond(), CADiatonicKey::diatonicPitch(), diatonicPitchToLilyPond(), doAnacrusisCheck(), exportMarks(), exportPlayable(), CADiatonicKey::gender(), indent(), indentLess(), indentMore(), CAMusElement::isPlayable(), CAMusElement::KeySignature, CAVoice::musElementAt(), CAVoice::musElementCount(), CAMusElement::musElementType(), CAClef::offset(), CAExport::out(), setCurVoice(), CABarline::Single, CAMusElement::TimeSignature, CAMusElement::timeStart(), CAPlayableLength::Undefined, and writeRelativeIntro().

Referenced by exportStaffVoices().

Here is the call graph for this function:

Here is the caller graph for this function:

void CALilyPondExport::indent ( ) [private]

Output tabs according to _indentLevel.

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::indentLess ( ) [inline, private]

References _curIndentLevel.

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

Here is the caller graph for this function:

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

References _curIndentLevel.

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

Here is the caller graph for this function:

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

Encapsulates the given string into {}.

References escapeWeirdChars().

Referenced by writeDocumentHeader().

Here is the call graph for this function:

Here is the caller graph for this function:

const QString CALilyPondExport::playableLengthToLilyPond ( CAPlayableLength  playableLength) [private]
const QString CALilyPondExport::relativePitchToString ( CANote note,
CADiatonicPitch  prevPitch 
) [inline, private]

References CANote::diatonicPitch().

Referenced by exportPlayable(), and writeRelativeIntro().

Here is the call graph for this function:

Here is the caller graph for this function:

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()

References diatonicPitchToLilyPond(), and CADiatonicPitch::noteName().

Here is the call graph for this function:

Converts the rest type to LilyPond syntax.

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

Referenced by exportPlayable().

Here is the caller graph for this function:

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

References _curContext.

Referenced by exportScoreBlock().

Here is the caller graph for this function:

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

References _curContextIndex.

Referenced by exportSheetImpl().

Here is the caller graph for this function:

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

References _curSheet.

Referenced by exportSheetImpl().

Here is the caller graph for this function:

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

References _curVoice.

Referenced by exportStaffVoices(), and exportVoiceImpl().

Here is the caller graph for this function:

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

References _curIndentLevel.

Referenced by CALilyPondExport().

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.

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

Here is the caller graph for this function:

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:

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"

References spellNumbers().

Referenced by exportScoreBlock(), and exportStaffVoices().

Here is the call graph for this function:

Here is the caller graph for this function:

Export document title, subtitle, composer, copyright etc.

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:

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!

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

Referenced by exportVoiceImpl().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Referenced by curContext(), and setCurContext().

Referenced by curSheet(), and setCurSheet().

Referenced by exportPlayable(), and exportVoiceImpl().

Referenced by curVoice(), and setCurVoice().

Referenced by exportPlayable(), and exportVoiceImpl().

Referenced by exportPlayable(), and exportVoiceImpl().

QTextStream* CALilyPondExport::_out [private]

The documentation for this class was generated from the following files: