Canorus
0.7
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
import
midiimport.h
Go to the documentation of this file.
1
8
#ifndef MIDIIMPORT_H_
9
#define MIDIIMPORT_H_
10
11
#include <QString>
12
#include <QStack>
13
14
#include "
core/voice.h
"
15
#include "
core/rest.h
"
16
#include "
core/keysignature.h
"
17
#include "
core/clef.h
"
18
#include "
core/timesignature.h
"
19
#include "
core/barline.h
"
20
#include "
core/lyricscontext.h
"
21
#include "
core/syllable.h
"
22
#include "
core/playablelength.h
"
23
#include "
core/diatonicpitch.h
"
24
25
#include "
import/import.h
"
26
27
class
QTextStream;
28
class
CAMidiDevice
;
29
class
CAMidiImportEvent
;
30
31
class
CAMidiImport
:
public
CAImport
{
32
public
:
33
// Constructor
34
CAMidiImport
( QTextStream *
in
=0 );
35
36
// Destructor
37
virtual
~CAMidiImport
();
38
39
// close midi in file after import
40
void
closeFile
();
41
42
// where the real work is done
43
CADocument
*
importDocumentImpl
();
44
CASheet
*
importSheetImpl
();
45
46
const
QString
readableStatus
();
47
48
private
:
49
void
initMidiImport
();
50
51
static
const
QRegExp
WHITESPACE_DELIMITERS
;
52
static
const
QRegExp
SYNTAX_DELIMITERS
;
53
static
const
QRegExp
DELIMITERS
;
54
55
// Internal time signature
56
struct
CATime
{
57
int
beats
;
58
int
beat
;
59
};
60
61
enum
CALilyPondDepth
{
62
Score
,
63
Layout
,
64
Voice
,
65
Chord
66
};
67
68
inline
CAVoice
*
curVoice
() {
return
_curVoice
; }
69
inline
void
setCurVoice
(
CAVoice
*voice) {
_curVoice
= voice; }
70
71
const
QString
parseNextElement
();
72
const
QString
peekNextElement
();
73
void
addError
(QString description,
int
lineError = 0,
int
charError = 0);
74
76
// Helper functions //
78
CAPlayableLength
playableLengthFromLilyPond
( QString &playableElt,
bool
parse=
false
);
79
80
bool
isNote
(
const
QString elt);
81
CADiatonicPitch
relativePitchFromLilyPond
(QString ¬e,
CADiatonicPitch
prevPitch,
bool
parse=
false
);
82
bool
isRest
(
const
QString elt);
83
CARest::CARestType
restTypeFromLilyPond
(QString& rest,
bool
parse=
false
);
84
CAClef::CAPredefinedClefType
predefinedClefTypeFromLilyPond
(
const
QString clef );
85
int
clefOffsetFromLilyPond
(
const
QString clef );
86
CABarline::CABarlineType
barlineTypeFromLilyPond
(
const
QString bar);
87
CADiatonicKey::CAGender
diatonicKeyGenderFromLilyPond
(QString gender);
88
CATime
timeSigFromLilyPond
(QString time);
89
90
CAMusElement
*
findSharedElement
(
CAMusElement
*elt);
91
93
// Getter/Setter methods //
95
inline
QString&
in
() {
return
*
stream
()->string(); }
96
inline
CALilyPondDepth
curDepth
() {
return
_depth
.top(); }
97
inline
void
pushDepth
(
CALilyPondDepth
depth) {
_depth
.push(depth); }
98
inline
CALilyPondDepth
popDepth
() {
return
_depth
.pop(); }
99
inline
int
curLine
() {
return
_curLine
; }
100
inline
int
curChar
() {
return
_curChar
; }
101
102
// Attributes
103
CAVoice
*
_curVoice
;
104
CASlur
*
_curSlur
;
105
CASlur
*
_curPhrasingSlur
;
106
QStack<CALilyPondDepth>
_depth
;
// which block is currently processed
107
int
_curLine
,
_curChar
;
108
QList<QString>
_errors
;
109
QList<QString>
_warnings
;
110
111
//inline CAVoice *templateVoice() { return _templateVoice; }
112
//CAVoice *_templateVoice; // used when importing voice to set the staff etc.
113
115
// Helper functions //
117
int
getVariableLength
(QByteArray *x );
118
QByteArray
getHead
(QByteArray *x);
119
int
getByte
(QByteArray *x);
120
int
getWord16
(QByteArray *x);
121
int
getWord24
(QByteArray *x);
122
int
getWord32
(QByteArray *x);
123
QByteArray
getString
(QByteArray *x,
int
len);
124
void
printQByteArray
( QByteArray x );
// debugging only
125
int
_dataIndex
;
126
int
_nextTrackIndex
;
127
bool
_parseError
;
128
void
noteOn
(
bool
on,
int
channel,
int
pitch,
int
velocity,
int
time );
129
130
enum
smtpOffsComponents
{
131
hr
,
min
,
se
,
fr
,
ff
,
next
132
};
133
int
_smtpOffset
[
next
];
134
int
_microSecondsPerMidiQuarternote
;
135
136
CADocument
*
_document
;
137
QVector<QList<QList<CAMidiImportEvent*>*>*>
_allChannelsEvents
;
138
QList<CAMidiImportEvent*>
_eventsX
;
139
void
combineMidiFileEvents
();
140
void
quantizeMidiFileEvents
();
141
void
exportNonChordsToOtherVoices
();
142
void
writeMidiFileEventsToScore
(
CASheet
*sheet );
143
void
writeMidiChannelEventsToVoice
(
int
channel,
CAStaff
*staff,
CAVoice
*voice );
144
};
145
146
#endif
/* MIDIIMPORT_H_ */
Generated on Fri Jan 11 2013 14:40:12 for Canorus by
1.8.3