Canorus 0.0
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CAMidiImport Class Reference

#include <midiimport.h>

Inheritance diagram for CAMidiImport:
Inheritance graph
[legend]

Classes

struct  CATime
 

Public Member Functions

 CAMidiImport (CADocument *document=0, QTextStream *in=0)
 
virtual ~CAMidiImport ()
 
void closeFile ()
 
CADocumentimportDocumentImpl ()
 
CASheetimportSheetImpl ()
 
QList< QList< CAMidiNote * > > importMidiNotes ()
 
const QString readableStatus ()
 
QList< int > midiProgramList ()
 
- Public Member Functions inherited from CAImport
 CAImport (QTextStream *stream=0)
 
 CAImport (const QString stream)
 
virtual ~CAImport ()
 
void setStreamFromFile (const QString filename)
 
QString fileName ()
 
virtual const QString readableStatus ()
 
void importDocument ()
 
void importSheet ()
 
void importStaff ()
 
void importVoice ()
 
void importLyricsContext ()
 
void importFunctionMarkContext ()
 
CADocumentimportedDocument ()
 
CASheetimportedSheet ()
 
CAStaffimportedStaff ()
 
CAVoiceimportedVoice ()
 
CALyricsContextimportedLyricsContext ()
 
CAFunctionMarkContextimportedFunctionMarkContext ()
 
- Public Member Functions inherited from CAFile
 CAFile ()
 
virtual ~CAFile ()
 
const int status ()
 
const int progress ()
 
virtual const QString readableStatus ()=0
 
void setStreamFromFile (const QString filename)
 
void setStreamToFile (const QString filename)
 
void setStreamFromDevice (QIODevice *device)
 
void setStreamToDevice (QIODevice *device)
 
void setStreamToString ()
 
QString getStreamAsString ()
 

Private Types

enum  CALilyPondDepth { Score , Layout , Voice , Chord }
 

Private Member Functions

CASheetimportSheetImplPmidiParser (CASheet *sheet)
 
void importMidiEvents ()
 
void initMidiImport ()
 
CAVoicecurVoice ()
 
void setCurVoice (CAVoice *voice)
 
void addError (QString description, int lineError=0, int charError=0)
 
CADiatonicPitch matchPitchToKey (CAVoice *voice, int midiPitch)
 
QString & in ()
 
CALilyPondDepth curDepth ()
 
void pushDepth (CALilyPondDepth depth)
 
CALilyPondDepth popDepth ()
 
int curLine ()
 
int curChar ()
 
void writeMidiFileEventsToScore_New (CASheet *sheet)
 
void writeMidiChannelEventsToVoice_New (int channel, int voiceIndex, CAStaff *staff, CAVoice *voice)
 
CAMusElementgetOrCreateClef (int time, int voiceIndex, CAStaff *staff, CAVoice *voice)
 
int getNextKeySignatureTime ()
 
CAMusElementgetOrCreateKeySignature (int time, int voiceIndex, CAStaff *staff, CAVoice *voice)
 
CAMusElementgetOrCreateTimeSignature (int time, int voiceIndex, CAStaff *staff, CAVoice *voice)
 
void fixAccidentals (CASheet *s)
 

Private Attributes

CADiatonicPitch _actualKeySignature
 
signed char _actualKeySignatureAccs [7]
 
int _actualKeyAccidentalsSum
 
CAVoice_curVoice
 
CASlur_curSlur
 
CASlur_curPhrasingSlur
 
QStack< CALilyPondDepth_depth
 
int _curLine
 
int _curChar
 
QList< QString > _errors
 
QList< QString > _warnings
 
QList< int > _midiProgramList
 
CADocument_document
 
QVector< QList< QList< CAMidiImportEvent * > * > * > _allChannelsEvents
 
QList< CAMidiImportEvent * > _eventsX
 
QVector< int > _allChannelsMediumPitch
 
QVector< CAClef * > _allChannelsClef
 
QVector< CAKeySignature * > _allChannelsKeySignatures
 
QVector< CAMidiImportEvent * > _allChannelsTimeSignatures
 
int _actualClefIndex
 
int _actualKeySignatureIndex
 
int _actualTimeSignatureIndex
 
int _numberOfAllVoices
 

Static Private Attributes

static const QRegExp WHITESPACE_DELIMITERS
 
static const QRegExp SYNTAX_DELIMITERS
 
static const QRegExp DELIMITERS
 

Additional Inherited Members

- Signals inherited from CAImport
void documentImported (CADocument *)
 
void sheetImported (CASheet *)
 
void staffImported (CAStaff *)
 
void voiceImported (CAVoice *)
 
void lyricsContextImported (CALyricsContext *)
 
void functionMarkContextImported (CAFunctionMarkContext *)
 
void importDone (int status)
 
- Protected Member Functions inherited from CAImport
virtual CADocumentimportDocumentImpl ()
 
virtual CASheetimportSheetImpl ()
 
virtual CAStaffimportStaffImpl ()
 
virtual CAVoiceimportVoiceImpl ()
 
virtual CALyricsContextimportLyricsContextImpl ()
 
virtual CAFunctionMarkContextimportFunctionMarkContextImpl ()
 
QTextStream & in ()
 
- Protected Member Functions inherited from CAFile
void setStatus (const int status)
 
void setProgress (const int progress)
 
QTextStream * stream ()
 
virtual void setStream (QTextStream *stream)
 
QFile * file ()
 
void setFile (QFile *file)
 
- Protected Attributes inherited from CAImport
QString _fileName
 

Member Enumeration Documentation

◆ CALilyPondDepth

Enumerator
Score 
Layout 
Voice 
Chord 

Constructor & Destructor Documentation

◆ CAMidiImport()

CAMidiImport::CAMidiImport ( CADocument document = 0,
QTextStream *  in = 0 
)

References _allChannelsEvents, _allChannelsMediumPitch, _document, _midiProgramList, and initMidiImport().

Here is the call graph for this function:

◆ ~CAMidiImport()

CAMidiImport::~CAMidiImport ( )
virtual

Member Function Documentation

◆ addError()

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

References _curChar, _curLine, _errors, curChar(), and curLine().

Here is the call graph for this function:

◆ closeFile()

void CAMidiImport::closeFile ( )

References CAFile::file().

Here is the call graph for this function:

◆ curChar()

int CAMidiImport::curChar ( )
inlineprivate

References _curChar.

Referenced by addError(), and readableStatus().

Here is the caller graph for this function:

◆ curDepth()

CALilyPondDepth CAMidiImport::curDepth ( )
inlineprivate

References _depth.

◆ curLine()

int CAMidiImport::curLine ( )
inlineprivate

References _curLine.

Referenced by addError(), and readableStatus().

Here is the caller graph for this function:

◆ curVoice()

CAVoice * CAMidiImport::curVoice ( )
inlineprivate

References _curVoice.

◆ fixAccidentals()

void CAMidiImport::fixAccidentals ( CASheet s)
private

Tries to assume the correct accidental for the alien notes in the key signature. Currently this function searches for disalterations (eg. cis -> c, where c is the note in the scale). The algorithm solves the toggling notes (eg. e es e -> e dis e) and transition notes (eg. e dis d -> e es d).

References CAFile::setStatus(), and CASheet::voiceList().

Referenced by importSheetImplPmidiParser().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNextKeySignatureTime()

int CAMidiImport::getNextKeySignatureTime ( )
private

This function looks in the keySignatureReferences

References _actualKeySignatureIndex, and _allChannelsKeySignatures.

Referenced by writeMidiChannelEventsToVoice_New().

Here is the caller graph for this function:

◆ getOrCreateClef()

CAMusElement * CAMidiImport::getOrCreateClef ( int  time,
int  voiceIndex,
CAStaff staff,
CAVoice voice 
)
private

◆ getOrCreateKeySignature()

CAMusElement * CAMidiImport::getOrCreateKeySignature ( int  time,
int  voiceIndex,
CAStaff staff,
CAVoice voice 
)
private

This function looks in the keySignatureReferences

References _actualKeySignatureIndex, _allChannelsKeySignatures, and CAStaff::keySignatureRefs().

Referenced by writeMidiChannelEventsToVoice_New().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOrCreateTimeSignature()

CAMusElement * CAMidiImport::getOrCreateTimeSignature ( int  time,
int  voiceIndex,
CAStaff staff,
CAVoice voice 
)
private

Docu neeeded, definitively! rud

References _actualTimeSignatureIndex, _allChannelsTimeSignatures, and CAStaff::timeSignatureRefs().

Referenced by writeMidiChannelEventsToVoice_New().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ importDocumentImpl()

CADocument * CAMidiImport::importDocumentImpl ( )
virtual

Reimplemented from CAImport.

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

Here is the call graph for this function:

◆ importMidiEvents()

void CAMidiImport::importMidiEvents ( )
private

The midi file is opened by calling the pmidi wrapper function pmidi_open_midi_file(), then, in a polling loop, the wrapper function pmidi_parse_midi_file() brings out the relevant midi events which are stored in the array _allChannelsEvents[]. All time signatures are stored in the array _allChannelsTimeSignatures[]. The work of pmidi and the wrapper is done then.

All time values are scaled here to canorus' own music time scale.

Further processing is referred to function writeMidiFileEventsToScore_New().

References _allChannelsEvents, _allChannelsKeySignatures, _allChannelsTimeSignatures, _midiProgramList, pmidi_outs::bottom, pmidi_outs::chan, CAImport::fileName(), CAPlayableLength::HundredTwentyEighth, pmidi_outs::key, pmidi_outs::length, CADiatonicKey::Major, pmidi_outs::micro_tempo, pmidi_outs::minor, CADiatonicKey::Minor, pmidi_outs::note, CAPlayableLength::playableLengthToTimeLength(), pmidi_open_midi_file(), pmidi_out, pmidi_parse_midi_file(), PMIDI_STATUS_CONTROL, PMIDI_STATUS_DUMMY, PMIDI_STATUS_END, PMIDI_STATUS_KEYSIG, PMIDI_STATUS_KEYTOUCH, PMIDI_STATUS_NOTE, PMIDI_STATUS_PITCH, PMIDI_STATUS_PRESSURE, PMIDI_STATUS_PROGRAM, PMIDI_STATUS_ROOT, PMIDI_STATUS_SMPTEOFFS, PMIDI_STATUS_SYSEX, PMIDI_STATUS_TEMPO, PMIDI_STATUS_TEXT, PMIDI_STATUS_TIMESIG, PMIDI_STATUS_VERSION, pmidi_outs::program, CAPlayableLength::Quarter, CAFile::setStatus(), pmidi_outs::time, pmidi_outs::time_base, pmidi_outs::top, and pmidi_outs::vel.

Referenced by importMidiNotes(), and importSheetImplPmidiParser().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ importMidiNotes()

QList< QList< CAMidiNote * > > CAMidiImport::importMidiNotes ( )

Imports the given MIDI file and returns a list of CAMidiNote objects sorted by timeStart per channel.

This function is usually called when raw MIDI operations are done and the actual notes etc. aren't needed.

Warning
This function returns notes only (without rests).
Only abstract note times are preserved. Real MIDI note times (in miliseconds) are lost.

References _allChannelsEvents, and importMidiEvents().

Here is the call graph for this function:

◆ importSheetImpl()

CASheet * CAMidiImport::importSheetImpl ( )
virtual

Reimplemented from CAImport.

References _document, CAImport::fileName(), importSheetImplPmidiParser(), and CASheet::setName().

Referenced by importDocumentImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ importSheetImplPmidiParser()

CASheet * CAMidiImport::importSheetImplPmidiParser ( CASheet sheet)
private

References fixAccidentals(), importMidiEvents(), CAFile::setStatus(), and writeMidiFileEventsToScore_New().

Referenced by importSheetImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ in()

QString & CAMidiImport::in ( )
inlineprivate

References CAFile::stream().

Here is the call graph for this function:

◆ initMidiImport()

void CAMidiImport::initMidiImport ( )
private

References _curChar, _curLine, _curPhrasingSlur, and _curSlur.

Referenced by CAMidiImport().

Here is the caller graph for this function:

◆ matchPitchToKey()

CADiatonicPitch CAMidiImport::matchPitchToKey ( CAVoice voice,
int  midiPitch 
)
private

This function is a duplicat in CAKeybdInput! Should be moved to CADiatonicPitch an be reused.

This function looks up the current key signiture. Then it computes the proper accidentials for the note.

This function should be somewhere else, maybe in CADiatonicPitch ?

References _actualKeyAccidentalsSum, _actualKeySignature, _actualKeySignatureAccs, CADiatonicPitch::C, CAKeySignature::diatonicKey(), CADiatonicPitch::diatonicPitchFromMidiPitch(), CADiatonicPitch::diatonicPitchFromMidiPitchKey(), CAVoice::getPreviousByType(), CAMusElement::KeySignature, and CAVoice::lastTimeEnd().

Referenced by writeMidiChannelEventsToVoice_New().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ midiProgramList()

QList< int > CAMidiImport::midiProgramList ( )
inline

References _midiProgramList.

◆ popDepth()

CALilyPondDepth CAMidiImport::popDepth ( )
inlineprivate

References _depth.

◆ pushDepth()

void CAMidiImport::pushDepth ( CALilyPondDepth  depth)
inlineprivate

References _depth.

◆ readableStatus()

const QString CAMidiImport::readableStatus ( )
virtual

Displays a string left of the progress bar

Reimplemented from CAImport.

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

Here is the call graph for this function:

◆ setCurVoice()

void CAMidiImport::setCurVoice ( CAVoice voice)
inlineprivate

References _curVoice.

Referenced by writeMidiFileEventsToScore_New().

Here is the caller graph for this function:

◆ writeMidiChannelEventsToVoice_New()

void CAMidiImport::writeMidiChannelEventsToVoice_New ( int  channel,
int  voiceIndex,
CAStaff staff,
CAVoice voice 
)
private

◆ writeMidiFileEventsToScore_New()

void CAMidiImport::writeMidiFileEventsToScore_New ( CASheet sheet)
private

Member Data Documentation

◆ _actualClefIndex

int CAMidiImport::_actualClefIndex
private

◆ _actualKeyAccidentalsSum

int CAMidiImport::_actualKeyAccidentalsSum
private

Referenced by matchPitchToKey().

◆ _actualKeySignature

CADiatonicPitch CAMidiImport::_actualKeySignature
private

Referenced by matchPitchToKey().

◆ _actualKeySignatureAccs

signed char CAMidiImport::_actualKeySignatureAccs[7]
private

Referenced by matchPitchToKey().

◆ _actualKeySignatureIndex

int CAMidiImport::_actualKeySignatureIndex
private

◆ _actualTimeSignatureIndex

int CAMidiImport::_actualTimeSignatureIndex
private

◆ _allChannelsClef

QVector<CAClef*> CAMidiImport::_allChannelsClef
private

◆ _allChannelsEvents

QVector<QList<QList<CAMidiImportEvent*>*>*> CAMidiImport::_allChannelsEvents
private

◆ _allChannelsKeySignatures

QVector<CAKeySignature*> CAMidiImport::_allChannelsKeySignatures
private

◆ _allChannelsMediumPitch

QVector<int> CAMidiImport::_allChannelsMediumPitch
private

◆ _allChannelsTimeSignatures

QVector<CAMidiImportEvent*> CAMidiImport::_allChannelsTimeSignatures
private

◆ _curChar

int CAMidiImport::_curChar
private

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

◆ _curLine

int CAMidiImport::_curLine
private

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

◆ _curPhrasingSlur

CASlur* CAMidiImport::_curPhrasingSlur
private

Referenced by initMidiImport().

◆ _curSlur

CASlur* CAMidiImport::_curSlur
private

Referenced by initMidiImport().

◆ _curVoice

CAVoice* CAMidiImport::_curVoice
private

Referenced by curVoice(), and setCurVoice().

◆ _depth

QStack<CALilyPondDepth> CAMidiImport::_depth
private

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

◆ _document

CADocument* CAMidiImport::_document
private

◆ _errors

QList<QString> CAMidiImport::_errors
private

Referenced by addError().

◆ _eventsX

QList<CAMidiImportEvent*> CAMidiImport::_eventsX
private

◆ _midiProgramList

QList<int> CAMidiImport::_midiProgramList
private

◆ _numberOfAllVoices

int CAMidiImport::_numberOfAllVoices
private

◆ _warnings

QList<QString> CAMidiImport::_warnings
private

◆ DELIMITERS

const QRegExp CAMidiImport::DELIMITERS
staticprivate

◆ SYNTAX_DELIMITERS

const QRegExp CAMidiImport::SYNTAX_DELIMITERS
staticprivate

◆ WHITESPACE_DELIMITERS

const QRegExp CAMidiImport::WHITESPACE_DELIMITERS
staticprivate

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