Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
CAMidiImport Class Reference

#include <midiimport.h>

Inheritance diagram for CAMidiImport:
Inheritance graph
[legend]

List of all members.

Classes

struct  CATime

Public Member Functions

 CAMidiImport (QTextStream *in=0)
virtual ~CAMidiImport ()
void closeFile ()
CADocumentimportDocumentImpl ()
CASheetimportSheetImpl ()
const QString readableStatus ()

Private Types

enum  CALilyPondDepth { Score, Layout, Voice, Chord }
enum  smtpOffsComponents {
  hr, min, se, fr,
  ff, next
}

Private Member Functions

void initMidiImport ()
CAVoicecurVoice ()
void setCurVoice (CAVoice *voice)
const QString parseNextElement ()
const QString peekNextElement ()
void addError (QString description, int lineError=0, int charError=0)
CAPlayableLength playableLengthFromLilyPond (QString &playableElt, bool parse=false)
bool isNote (const QString elt)
CADiatonicPitch relativePitchFromLilyPond (QString &note, CADiatonicPitch prevPitch, bool parse=false)
bool isRest (const QString elt)
CARest::CARestType restTypeFromLilyPond (QString &rest, bool parse=false)
CAClef::CAPredefinedClefType predefinedClefTypeFromLilyPond (const QString clef)
int clefOffsetFromLilyPond (const QString clef)
CABarline::CABarlineType barlineTypeFromLilyPond (const QString bar)
CADiatonicKey::CAGender diatonicKeyGenderFromLilyPond (QString gender)
CATime timeSigFromLilyPond (QString time)
CAMusElementfindSharedElement (CAMusElement *elt)
QString & in ()
CALilyPondDepth curDepth ()
void pushDepth (CALilyPondDepth depth)
CALilyPondDepth popDepth ()
int curLine ()
int curChar ()
int getVariableLength (QByteArray *x)
QByteArray getHead (QByteArray *x)
int getByte (QByteArray *x)
int getWord16 (QByteArray *x)
int getWord24 (QByteArray *x)
int getWord32 (QByteArray *x)
QByteArray getString (QByteArray *x, int len)
void printQByteArray (QByteArray x)
void noteOn (bool on, int channel, int pitch, int velocity, int time)
void combineMidiFileEvents ()
void quantizeMidiFileEvents ()
void exportNonChordsToOtherVoices ()
void writeMidiFileEventsToScore (CASheet *sheet)
void writeMidiChannelEventsToVoice (int channel, CAStaff *staff, CAVoice *voice)

Private Attributes

CAVoice_curVoice
CASlur_curSlur
CASlur_curPhrasingSlur
QStack< CALilyPondDepth_depth
int _curLine
int _curChar
QList< QString > _errors
QList< QString > _warnings
int _dataIndex
int _nextTrackIndex
bool _parseError
int _smtpOffset [next]
int _microSecondsPerMidiQuarternote
CADocument_document
QVector< QList< QList
< CAMidiImportEvent * > * > * > 
_allChannelsEvents
QList< CAMidiImportEvent * > _eventsX

Static Private Attributes

static const QRegExp WHITESPACE_DELIMITERS = QRegExp("[\\s]")
static const QRegExp SYNTAX_DELIMITERS = QRegExp("[<>{}]")
static const QRegExp DELIMITERS

Member Enumeration Documentation

Enumerator:
Score 
Layout 
Voice 
Chord 
Enumerator:
hr 
min 
se 
fr 
ff 
next 

Constructor & Destructor Documentation

CAMidiImport::CAMidiImport ( QTextStream *  in = 0)

References _allChannelsEvents, and initMidiImport().

Here is the call graph for this function:


Member Function Documentation

void CAMidiImport::addError ( QString  description,
int  lineError = 0,
int  charError = 0 
) [private]

References _curChar, _curLine, and _errors.

Genarates barline type from the LilyPond syntax for the given barline from format "barlineType".

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

int CAMidiImport::clefOffsetFromLilyPond ( const QString  constClef) [private]

Returns the Canorus octava or whichever interval above or below the clef.

References CAFile::file().

Here is the call graph for this function:

Combines the midi on/off events and reduces them to a note with a length. Note off events are, which can also be a note on with velocity zero, are thus eaten up and are invalidated by pitch -1.

todo: rounding fine grained note lenghts, dispersing small rests

todo: combine concurrent notes to chords or export concurrent notes to a next voice.

References _allChannelsEvents.

Referenced by importSheetImpl().

Here is the caller graph for this function:

int CAMidiImport::curChar ( ) [inline, private]

References _curChar.

Referenced by readableStatus().

Here is the caller graph for this function:

CALilyPondDepth CAMidiImport::curDepth ( ) [inline, private]

References _depth.

int CAMidiImport::curLine ( ) [inline, private]

References _curLine.

Referenced by readableStatus().

Here is the caller graph for this function:

CAVoice* CAMidiImport::curVoice ( ) [inline, private]

References _curVoice.

Referenced by findSharedElement().

Here is the caller graph for this function:

Returns the key signature gender from format \genderType.

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

If not a chord move overlapping notes to other voices.

The algorithm is this: For every note on event we look if there are follow up events that overlap. If there is a overlap the second note will be moved to a higher (index of the) voice, so high, where it can be stay without overlap.

References _allChannelsEvents, and next.

Referenced by importSheetImpl().

Here is the caller graph for this function:

Gathers a list of music elements with the given element's start time and returns the first music element in the gathered list with the same attributes.

This method is usually called when voices have "shared" music elements (barlines, clefs etc.). However, in LilyPond syntax the music element can/should be present in all the voices. This function finds this shared music element, if it already exists.

If the music element with the same properties exists, user should delete its own instance and add an already existing instance of the returned shared music element to the voice.

See also:
CAMusElement::compare()

References CAVoice::contains(), curVoice(), CAStaff::getEltByType(), CAMusElement::musElementType(), CAVoice::staff(), and CAMusElement::timeStart().

Here is the call graph for this function:

int CAMidiImport::getByte ( QByteArray *  x) [private]

References _dataIndex, and _parseError.

Referenced by getWord24(), and importSheetImpl().

Here is the caller graph for this function:

QByteArray CAMidiImport::getHead ( QByteArray *  x) [private]

References _dataIndex, and _parseError.

Referenced by importSheetImpl().

Here is the caller graph for this function:

QByteArray CAMidiImport::getString ( QByteArray *  x,
int  len 
) [private]

References _dataIndex, and _parseError.

Referenced by importSheetImpl().

Here is the caller graph for this function:

int CAMidiImport::getVariableLength ( QByteArray *  x) [private]

References _dataIndex, _parseError, and next.

Referenced by importSheetImpl().

Here is the caller graph for this function:

int CAMidiImport::getWord16 ( QByteArray *  x) [private]

References _dataIndex, and _parseError.

Referenced by getWord24(), getWord32(), and importSheetImpl().

Here is the caller graph for this function:

int CAMidiImport::getWord24 ( QByteArray *  x) [private]

References getByte(), and getWord16().

Referenced by importSheetImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

int CAMidiImport::getWord32 ( QByteArray *  x) [private]

References getWord16().

Referenced by importSheetImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from CAImport.

References _document, CADocument::addSheet(), and importSheetImpl().

Here is the call graph for this function:

QString& CAMidiImport::in ( ) [inline, private]

Reimplemented from CAImport.

References CAFile::stream().

Referenced by parseNextElement(), and peekNextElement().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAMidiImport::initMidiImport ( ) [private]

References _curChar, _curLine, _curPhrasingSlur, _curSlur, _document, and _microSecondsPerMidiQuarternote.

Referenced by CAMidiImport().

Here is the caller graph for this function:

bool CAMidiImport::isNote ( const QString  elt) [private]

Returns true, if the given LilyPond element is a note.

See also:
isRest()
bool CAMidiImport::isRest ( const QString  elt) [private]

Returns true, if the given LilyPond element is a rest.

See also:
isNote()
void CAMidiImport::noteOn ( bool  on,
int  channel,
int  pitch,
int  velocity,
int  time 
) [private]

References _allChannelsEvents.

Referenced by importSheetImpl().

Here is the caller graph for this function:

const QString CAMidiImport::parseNextElement ( ) [private]
    Returns the first element in input stream ended with one of the delimiters and shorten input stream for the element.
Todo:
Only one-character syntax delimiters are supported so far.
See also:
peekNextElement()

References DELIMITERS, and in().

Here is the call graph for this function:

const QString CAMidiImport::peekNextElement ( ) [private]

Returns the first element in input stream ended with one of the delimiters but don't shorten the stream.

See also:
parseNextElement()

References DELIMITERS, and in().

Here is the call graph for this function:

CAPlayableLength CAMidiImport::playableLengthFromLilyPond ( QString &  elt,
bool  parse = false 
) [private]

Generates playable lentgth and number of dots from the note/rest string in LilyPond syntax. If the playable element doesn't include length, { CAPlayable::CAPlayableLength::Undefined, 0 } is returned. This function also shortens the given string for the playable length, if parse is True.

See also:
relativePitchFromString()

References CAPlayableLength::dotted(), CAPlayableLength::setDotted(), and CAPlayableLength::setMusicLength().

Here is the call graph for this function:

CALilyPondDepth CAMidiImport::popDepth ( ) [inline, private]

References _depth.

Genarates clef type from the LilyPond syntax for the given clef from format "clefType".

References CAClef::Alto, CAClef::Baritone, CAClef::Bass, CAClef::French, CAClef::Mezzosoprano, CAClef::Percussion, CAClef::Soprano, CAClef::Subbass, CAClef::Tablature, CAClef::Tenor, CAClef::Treble, and CAClef::Varbaritone.

void CAMidiImport::printQByteArray ( QByteArray  x) [private]

Referenced by importSheetImpl().

Here is the caller graph for this function:

void CAMidiImport::pushDepth ( CALilyPondDepth  depth) [inline, private]

References _depth.

Quantisize the notes and rests, don't affect the duration of the music.

References _allChannelsEvents.

Referenced by importSheetImpl().

Here is the caller graph for this function:

const QString CAMidiImport::readableStatus ( ) [virtual]

Reimplemented from CAImport.

References curChar(), curLine(), and CAFile::status().

Here is the call graph for this function:

CADiatonicPitch CAMidiImport::relativePitchFromLilyPond ( QString &  constNName,
CADiatonicPitch  prevPitch,
bool  parse = false 
) [private]

Generates the note pitch and number of accidentals from the note written in LilyPond syntax.

See also:
playableLengthFromLilyPond()

References CADiatonicPitch::noteName().

Here is the call graph for this function:

CARest::CARestType CAMidiImport::restTypeFromLilyPond ( QString &  elt,
bool  parse = false 
) [private]

Genarates rest type from the LilyPond syntax for the given rest. This function also shortens the given string for the rest type, if parse is True.

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

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

References _curVoice.

Referenced by writeMidiFileEventsToScore().

Here is the caller graph for this function:

Returns the time signature beat and beats in beats/beat format.

void CAMidiImport::writeMidiChannelEventsToVoice ( int  channel,
CAStaff staff,
CAVoice voice 
) [private]

References _allChannelsEvents, CASheet::addContext(), CAStaff::addVoice(), setCurVoice(), CASheet::staffList(), CANote::StemNeutral, CAStaff::voiceList(), and writeMidiChannelEventsToVoice().

Referenced by importSheetImpl().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

QVector<QList<QList<CAMidiImportEvent*>*>*> CAMidiImport::_allChannelsEvents [private]
int CAMidiImport::_curChar [private]

Referenced by addError(), curChar(), and initMidiImport().

int CAMidiImport::_curLine [private]

Referenced by addError(), curLine(), and initMidiImport().

Referenced by initMidiImport().

Referenced by initMidiImport().

Referenced by curVoice(), and setCurVoice().

int CAMidiImport::_dataIndex [private]

Referenced by curDepth(), popDepth(), and pushDepth().

QList<QString> CAMidiImport::_errors [private]

Referenced by addError().

Referenced by importSheetImpl(), and initMidiImport().

Referenced by importSheetImpl().

bool CAMidiImport::_parseError [private]

Referenced by importSheetImpl().

QList<QString> CAMidiImport::_warnings [private]
const QRegExp CAMidiImport::DELIMITERS [static, private]
Initial value:
        QRegExp(
                CAMidiImport::WHITESPACE_DELIMITERS.pattern().left(CAMidiImport::WHITESPACE_DELIMITERS.pattern().size()-1) +
                CAMidiImport::SYNTAX_DELIMITERS.pattern().mid(1)
        )

Combined WHITESPACE_DELIMITERS and SYNTAX_DELIMITERS.

Referenced by parseNextElement(), and peekNextElement().

const QRegExp CAMidiImport::SYNTAX_DELIMITERS = QRegExp("[<>{}]") [static, private]

Delimiters which separate various music elements in LilyPond syntax, but are specific for LilyPond syntax. They are reported as its own element when parsing the next element.

See also:
nextElement(), parseNextElement()
const QRegExp CAMidiImport::WHITESPACE_DELIMITERS = QRegExp("[\\s]") [static, private]

Delimiters which separate various music elements in LilyPond syntax. These are new lines, tabs, blanks etc.

See also:
nextElement(), parseNextElement()

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