Canorus  0.0
lilypondimport.h
Go to the documentation of this file.
1 
8 #ifndef LILYPONDIMPORT_H_
9 #define LILYPONDIMPORT_H_
10 
11 #include <QString>
12 #include <QStack>
13 
14 #include "score/voice.h"
15 #include "score/rest.h"
16 #include "score/keysignature.h"
17 #include "score/clef.h"
18 #include "score/timesignature.h"
19 #include "score/barline.h"
20 #include "score/lyricscontext.h"
21 #include "score/syllable.h"
22 #include "score/playablelength.h"
23 #include "score/diatonicpitch.h"
24 
25 #include "import/import.h"
26 
27 class QTextStream;
28 
29 class CALilyPondImport : public CAImport {
30 public:
31  // Constructors
32  CALilyPondImport( const QString in );
33  CALilyPondImport( QTextStream *in=0 );
34  CALilyPondImport( CADocument *document, QTextStream *in=0 );
35  inline void setTemplateVoice( CAVoice *voice ) { _templateVoice = voice; }
36 
37  // Destructor
38  virtual ~CALilyPondImport();
39 
40  const QString readableStatus();
42 
43 private:
44  void initLilyPondImport();
45 
46  static const QRegExp WHITESPACE_DELIMITERS;
47  static const QRegExp SYNTAX_DELIMITERS;
48  static const QRegExp DELIMITERS;
49 
50  // Internal time signature
51  struct CATime {
52  int beats;
53  int beat;
54  };
55 
60  Chord
61  };
62 
63  // Actual import of the input string
66 
67  inline CAVoice *curVoice() { return _curVoice; }
68  inline void setCurVoice(CAVoice *voice) { _curVoice = voice; }
69 
70  const QString parseNextElement();
71  const QString peekNextElement();
72  void addError(QString description, int lineError = 0, int charError = 0);
73 
75  // Helper functions //
77  CAPlayableLength playableLengthFromLilyPond( QString &playableElt, bool parse=false );
78 
79  bool isNote(const QString elt);
80  CADiatonicPitch relativePitchFromLilyPond(QString &note, CADiatonicPitch prevPitch, bool parse=false);
81  bool isRest(const QString elt);
82  CARest::CARestType restTypeFromLilyPond(QString& rest, bool parse=false);
84  int clefOffsetFromLilyPond( const QString clef );
87  CATime timeSigFromLilyPond(QString time);
88 
90 
92  // Getter/Setter methods //
94  inline QString& in() { return *stream()->string(); }
95  inline CALilyPondDepth curDepth() { return _depth.top(); }
96  inline void pushDepth(CALilyPondDepth depth) { _depth.push(depth); }
97  inline CALilyPondDepth popDepth() { return _depth.pop(); }
98  inline int curLine() { return _curLine; }
99  inline int curChar() { return _curChar; }
100 
101  // Attributes
105  QStack<CALilyPondDepth> _depth; // which block is currently processed
107  QList<QString> _errors;
108  QList<QString> _warnings;
109 
110  inline CAVoice *templateVoice() { return _templateVoice; }
111  CAVoice *_templateVoice; // used when importing voice to set the staff etc.
112 
114 };
115 
116 #endif /* LILYPONDIMPORT_H_ */
CABarline::RepeatClose
@ RepeatClose
Definition: barline.h:25
CASlur::SlurPreferred
@ SlurPreferred
Definition: slur.h:24
rest.h
CALilyPondImport::Voice
@ Voice
Definition: lilypondimport.h:59
CALilyPondImport::CATime
Definition: lilypondimport.h:51
CANote::setSlurStart
void setSlurStart(CASlur *slurStart)
Definition: note.h:59
CAPlayable::staff
CAStaff * staff()
Definition: playable.h:33
CAStaff::getEltByType
QList< CAMusElement * > getEltByType(CAMusElement::CAMusElementType type, int startTime)
Definition: staff.cpp:272
CARest
Represents a rest in the score.
Definition: rest.h:15
CALilyPondImport::popDepth
CALilyPondDepth popDepth()
Definition: lilypondimport.h:97
CALilyPondImport::SYNTAX_DELIMITERS
static const QRegExp SYNTAX_DELIMITERS
Definition: lilypondimport.h:47
note.h
CALilyPondImport::Chord
@ Chord
Definition: lilypondimport.h:60
CAClef::Treble
@ Treble
Definition: clef.h:22
CAClef
Definition: clef.h:18
CALilyPondImport::_depth
QStack< CALilyPondDepth > _depth
Definition: lilypondimport.h:105
CABarline::CABarlineType
CABarlineType
Definition: barline.h:19
CANote
Represents a note in the score.
Definition: note.h:18
CAPlayableLength::setDotted
void setDotted(const int d)
Definition: playablelength.h:38
lilypondimport.h
CADocument
Class which represents the current document.
Definition: document.h:19
playable.h
CANote::setPhrasingSlurEnd
void setPhrasingSlurEnd(CASlur *pSlurEnd)
Definition: note.h:62
CASlur::TieType
@ TieType
Definition: slur.h:34
CAVoice
Class which represents a voice in the staff.
Definition: voice.h:23
CALilyPondImport::findSharedElement
CAMusElement * findSharedElement(CAMusElement *elt)
Definition: lilypondimport.cpp:492
CABarline::RepeatCloseOpen
@ RepeatCloseOpen
Definition: barline.h:26
CAPlayableLength::CAMusicLength
CAMusicLength
Definition: playablelength.h:18
slur.h
CALilyPondImport::curVoice
CAVoice * curVoice()
Definition: lilypondimport.h:67
CABarline::End
@ End
Definition: barline.h:23
CATimeSignature
Represents a time signature in the staff.
Definition: timesignature.h:18
CAClef::Alto
@ Alto
Definition: clef.h:27
CALilyPondImport::WHITESPACE_DELIMITERS
static const QRegExp WHITESPACE_DELIMITERS
Definition: lilypondimport.h:46
CALilyPondImport::CATime::beat
int beat
Definition: lilypondimport.h:53
CAVoice::lastMusElement
CAMusElement * lastMusElement()
Definition: voice.h:74
diatonicpitch.h
CALilyPondImport::Layout
@ Layout
Definition: lilypondimport.h:58
CARest::Normal
@ Normal
Definition: rest.h:19
CALilyPondImport::importSheetImpl
CASheet * importSheetImpl()
Definition: lilypondimport.cpp:76
CAClef::Tenor
@ Tenor
Definition: clef.h:28
CALilyPondImport::CALilyPondDepth
CALilyPondDepth
Definition: lilypondimport.h:56
CALilyPondImport::setTemplateVoice
void setTemplateVoice(CAVoice *voice)
Definition: lilypondimport.h:35
CADiatonicKey
Musical key.
Definition: diatonickey.h:15
CAClef::Tablature
@ Tablature
Definition: clef.h:33
CALilyPondImport::peekNextElement
const QString peekNextElement()
Definition: lilypondimport.cpp:445
CALilyPondImport::relativePitchFromLilyPond
CADiatonicPitch relativePitchFromLilyPond(QString &note, CADiatonicPitch prevPitch, bool parse=false)
Definition: lilypondimport.cpp:531
CAFile::stream
QTextStream * stream()
Definition: file.h:36
CAClef::Percussion
@ Percussion
Definition: clef.h:32
CABarline::RepeatOpen
@ RepeatOpen
Definition: barline.h:24
CARest::Hidden
@ Hidden
Definition: rest.h:20
CAPlayableLength::setMusicLength
void setMusicLength(const CAMusicLength l)
Definition: playablelength.h:37
CALyricsContext::addSyllable
bool addSyllable(CASyllable *, bool replace=true)
Definition: lyricscontext.cpp:185
CALilyPondImport::importLyricsContextImpl
CALyricsContext * importLyricsContextImpl()
Definition: lilypondimport.cpp:362
CALilyPondImport::playableLengthFromLilyPond
CAPlayableLength playableLengthFromLilyPond(QString &playableElt, bool parse=false)
Definition: lilypondimport.cpp:583
CALilyPondImport::isRest
bool isRest(const QString elt)
Definition: lilypondimport.cpp:522
CAPlayableLength::musicLength
const CAMusicLength musicLength()
Definition: playablelength.h:34
CALilyPondImport::_errors
QList< QString > _errors
Definition: lilypondimport.h:107
CALilyPondImport::_curLine
int _curLine
Definition: lilypondimport.h:106
CADiatonicKey::CAGender
CAGender
Definition: diatonickey.h:17
keysignature.h
CAPlayableLength::Quarter
@ Quarter
Definition: playablelength.h:23
syllable.h
CAVoice::cloneVoiceProperties
void cloneVoiceProperties(CAVoice *v)
Definition: voice.cpp:81
CAImport::fileName
QString fileName()
Definition: import.cpp:96
CADiatonicPitch::noteName
const int noteName() const
Definition: diatonicpitch.h:50
CADiatonicPitch
Musical note pitch.
Definition: diatonicpitch.h:16
CALilyPondImport::parseNextElement
const QString parseNextElement()
Definition: lilypondimport.cpp:403
CALilyPondImport::initLilyPondImport
void initLilyPondImport()
Definition: lilypondimport.cpp:63
CALilyPondImport::clefOffsetFromLilyPond
int clefOffsetFromLilyPond(const QString clef)
Definition: lilypondimport.cpp:656
CAFile::status
const int status()
Definition: file.h:21
CALilyPondImport::restTypeFromLilyPond
CARest::CARestType restTypeFromLilyPond(QString &rest, bool parse=false)
Definition: lilypondimport.cpp:615
CALilyPondImport::CATime::beats
int beats
Definition: lilypondimport.h:52
CASyllable::setHyphenStart
void setHyphenStart(bool h)
Definition: syllable.h:26
CANote::setPhrasingSlurStart
void setPhrasingSlurStart(CASlur *pSlurStart)
Definition: note.h:61
CABarline::Single
@ Single
Definition: barline.h:21
CAClef::Bass
@ Bass
Definition: clef.h:23
CAClef::Subbass
@ Subbass
Definition: clef.h:31
CADiatonicKey::Minor
@ Minor
Definition: diatonickey.h:19
CANote::updateTies
void updateTies()
Definition: note.cpp:236
CABarline::Double
@ Double
Definition: barline.h:22
CAClef::Baritone
@ Baritone
Definition: clef.h:29
CALilyPondImport::_curChar
int _curChar
Definition: lilypondimport.h:106
CAClef::Soprano
@ Soprano
Definition: clef.h:25
CALilyPondImport::in
QString & in()
Definition: lilypondimport.h:94
CASheet::setName
void setName(const QString name)
Definition: sheet.h:47
CAMusElement
An abstract class which represents every music element in the score.
Definition: muselement.h:21
CASlur::PhrasingSlurType
@ PhrasingSlurType
Definition: slur.h:36
CALilyPondImport::_curSlur
CASlur * _curSlur
Definition: lilypondimport.h:103
CABarline::Undefined
@ Undefined
Definition: barline.h:20
CALilyPondImport::curDepth
CALilyPondDepth curDepth()
Definition: lilypondimport.h:95
CALilyPondImport::addError
void addError(QString description, int lineError=0, int charError=0)
Definition: lilypondimport.cpp:69
CALyricsContext::repositSyllables
void repositSyllables()
Definition: lyricscontext.cpp:83
CAClef::Mezzosoprano
@ Mezzosoprano
Definition: clef.h:26
CALilyPondImport::isNote
bool isNote(const QString elt)
Definition: lilypondimport.cpp:513
CAPlayableLength
Musical length of notes and rests.
Definition: playablelength.h:16
CAPlayableLength::dotted
const int dotted()
Definition: playablelength.h:35
playablelength.h
CALilyPondImport::_curPhrasingSlur
CASlur * _curPhrasingSlur
Definition: lilypondimport.h:104
CAClef::French
@ French
Definition: clef.h:24
CALilyPondImport::_templateVoice
CAVoice * _templateVoice
Definition: lilypondimport.h:111
CALilyPondImport::barlineTypeFromLilyPond
CABarline::CABarlineType barlineTypeFromLilyPond(const QString bar)
Definition: lilypondimport.cpp:701
CALilyPondImport::setCurVoice
void setCurVoice(CAVoice *voice)
Definition: lilypondimport.h:68
CAKeySignature
Represents a key signature sign in the staff.
Definition: keysignature.h:19
CASyllable
Lyrics under the note.
Definition: syllable.h:19
CAVoice::append
void append(CAMusElement *elt, bool addToChord=false)
Definition: voice.cpp:120
CASlur::SlurType
@ SlurType
Definition: slur.h:35
CANote::setTieStart
void setTieStart(CASlur *tieStart)
Definition: note.h:57
CALilyPondImport::readableStatus
const QString readableStatus()
Definition: lilypondimport.cpp:716
CAPlayableLength::Undefined
@ Undefined
Definition: playablelength.h:19
CAMusElement::musElementTypeToString
static const QString musElementTypeToString(CAMusElementType)
Definition: muselement.cpp:88
CALilyPondImport::diatonicKeyGenderFromLilyPond
CADiatonicKey::CAGender diatonicKeyGenderFromLilyPond(QString gender)
Definition: lilypondimport.cpp:678
CAMusElement::Note
@ Note
Definition: muselement.h:25
sheet.h
CALyricsContext
One stanza line of lyrics.
Definition: lyricscontext.h:19
timesignature.h
barline.h
CANote::setSlurEnd
void setSlurEnd(CASlur *slurEnd)
Definition: note.h:60
CAMusElement::timeStart
virtual int timeStart() const
Definition: muselement.h:51
CAVoice::staff
CAStaff * staff()
Definition: voice.h:29
CANote::diatonicPitch
CADiatonicPitch & diatonicPitch()
Definition: note.h:35
CADiatonicKey::Major
@ Major
Definition: diatonickey.h:18
CASyllable::setMelismaStart
void setMelismaStart(bool m)
Definition: syllable.h:28
CARest::CARestType
CARestType
Definition: rest.h:17
CALilyPondImport::~CALilyPondImport
virtual ~CALilyPondImport()
Definition: lilypondimport.cpp:60
CALilyPondImport::pushDepth
void pushDepth(CALilyPondDepth depth)
Definition: lilypondimport.h:96
CABarline
Music element which represents a barline in the score.
Definition: barline.h:17
CALilyPondImport
Definition: lilypondimport.h:29
CALilyPondImport::Score
@ Score
Definition: lilypondimport.h:57
voice.h
CALilyPondImport::importVoiceImpl
CAVoice * importVoiceImpl()
Definition: lilypondimport.cpp:109
clef.h
CALilyPondImport::_document
CADocument * _document
Definition: lilypondimport.h:113
CALilyPondImport::DELIMITERS
static const QRegExp DELIMITERS
Definition: lilypondimport.h:48
CASheet
Represents a single sheet of paper in the document.
Definition: sheet.h:22
CABarline::Dotted
@ Dotted
Definition: barline.h:27
CALilyPondImport::timeSigFromLilyPond
CATime timeSigFromLilyPond(QString time)
Definition: lilypondimport.cpp:688
CAClef::CAPredefinedClefType
CAPredefinedClefType
Definition: clef.h:20
CAImport
Base class for import filters.
Definition: import.h:20
CALilyPondImport::templateVoice
CAVoice * templateVoice()
Definition: lilypondimport.h:110
CAClef::Varbaritone
@ Varbaritone
Definition: clef.h:30
CALilyPondImport::curLine
int curLine()
Definition: lilypondimport.h:98
CASlur
Slur, Tie, Phrasing slur and Laissez vibrer tie This class represents any type of slur....
Definition: slur.h:18
lyricscontext.h
CALilyPondImport::_curVoice
CAVoice * _curVoice
Definition: lilypondimport.h:102
CAMusElement::musElementType
CAMusElementType musElementType()
Definition: muselement.h:46
CALilyPondImport::predefinedClefTypeFromLilyPond
CAClef::CAPredefinedClefType predefinedClefTypeFromLilyPond(const QString clef)
Definition: lilypondimport.cpp:632
CALilyPondImport::curChar
int curChar()
Definition: lilypondimport.h:99
CALilyPondImport::CALilyPondImport
CALilyPondImport(const QString in)
Definition: lilypondimport.cpp:44
CAClef::Undefined
@ Undefined
Definition: clef.h:21
import.h
CALilyPondImport::_warnings
QList< QString > _warnings
Definition: lilypondimport.h:108
CASlur::setNoteEnd
void setNoteEnd(CANote *noteEnd)
Definition: slur.h:54