2012-05-26 14:49:10 +02:00
|
|
|
//=============================================================================
|
|
|
|
// MusE Score
|
|
|
|
// Linux Music Score Editor
|
|
|
|
// $Id:$
|
|
|
|
//
|
|
|
|
// Copyright (C) 2010 Werner Schweer and others
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License version 2.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
#ifndef __IMPORTGTP_H__
|
|
|
|
#define __IMPORTGTP_H__
|
|
|
|
|
|
|
|
#include "libmscore/mscore.h"
|
|
|
|
#include "libmscore/fraction.h"
|
2014-06-13 11:36:57 +02:00
|
|
|
#include "libmscore/fret.h"
|
2014-07-04 14:40:37 +02:00
|
|
|
#include "libmscore/chordrest.h"
|
2014-06-30 16:17:48 +02:00
|
|
|
#include "libmscore/slur.h"
|
2014-06-10 14:36:13 +02:00
|
|
|
#include "libmscore/clef.h"
|
|
|
|
#include "libmscore/keysig.h"
|
2014-07-01 11:00:31 +02:00
|
|
|
#include "libmscore/chordrest.h"
|
2014-06-10 14:36:13 +02:00
|
|
|
#include "libmscore/clef.h"
|
|
|
|
#include "libmscore/keysig.h"
|
2014-07-09 16:54:43 +02:00
|
|
|
#include "libmscore/hairpin.h"
|
2014-07-24 10:28:18 +02:00
|
|
|
#include "libmscore/ottava.h"
|
2014-07-24 11:30:27 +02:00
|
|
|
#include "libmscore/drumset.h"
|
2012-05-26 14:49:10 +02:00
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
|
|
|
|
2012-05-26 14:49:10 +02:00
|
|
|
class Score;
|
|
|
|
class Chord;
|
|
|
|
class Note;
|
|
|
|
class Segment;
|
|
|
|
class Measure;
|
|
|
|
class Tuplet;
|
|
|
|
|
|
|
|
static const int GP_MAX_LYRIC_LINES = 5;
|
|
|
|
static const int GP_MAX_TRACK_NUMBER = 32;
|
|
|
|
static const int GP_MAX_STRING_NUMBER = 7;
|
2013-06-04 22:18:25 +02:00
|
|
|
static const int GP_DEFAULT_PERCUSSION_CHANNEL = 9;
|
2012-05-26 14:49:10 +02:00
|
|
|
|
|
|
|
static const int GP_INVALID_KEYSIG = 127;
|
|
|
|
|
2014-04-25 10:43:42 +02:00
|
|
|
static const int GP_VOLTA_BINARY = 1;
|
|
|
|
static const int GP_VOLTA_FLAGS = 2;
|
|
|
|
|
2014-07-17 09:32:30 +02:00
|
|
|
enum class Repeat : char;
|
|
|
|
|
2012-05-26 14:49:10 +02:00
|
|
|
struct GpTrack {
|
|
|
|
int patch;
|
|
|
|
uchar volume, pan, chorus, reverb, phase, tremolo;
|
|
|
|
};
|
|
|
|
|
2014-04-25 10:43:42 +02:00
|
|
|
struct GPVolta {
|
|
|
|
int voltaType;
|
|
|
|
QList<int> voltaInfo;
|
|
|
|
};
|
|
|
|
|
2014-07-25 18:52:31 +02:00
|
|
|
/* How the fermatas are represented in Guitar Pro is two integers, the
|
|
|
|
* first is an index value and the second is the time division that
|
|
|
|
* index value refers to, and they are givin with respect to a
|
|
|
|
* measure. Time division 0 means a minim, 1 is a crotchet, 2 is a
|
|
|
|
* quaver and so on, with the index (counting from 0) refering to how
|
|
|
|
* many time divisions occur before the fermata. These numbers are
|
|
|
|
* separated in GP6 with a '/' character. For example, a note
|
|
|
|
* occurring on the third beat of a measure in a 4/4 bar would be
|
|
|
|
* represented as 2/1.
|
|
|
|
*/
|
|
|
|
struct GPFermata {
|
|
|
|
int index;
|
|
|
|
int timeDivision;
|
|
|
|
};
|
|
|
|
|
2012-05-26 14:49:10 +02:00
|
|
|
struct GpBar {
|
|
|
|
Fraction timesig;
|
2014-07-28 12:28:22 +02:00
|
|
|
bool freeTime;
|
2012-05-26 14:49:10 +02:00
|
|
|
int keysig;
|
|
|
|
QString marker;
|
|
|
|
BarLineType barLine;
|
2014-07-17 09:32:30 +02:00
|
|
|
Repeat repeatFlags;
|
2012-05-26 14:49:10 +02:00
|
|
|
int repeats;
|
2014-04-25 10:43:42 +02:00
|
|
|
GPVolta volta;
|
2014-07-30 12:59:48 +02:00
|
|
|
QString direction;
|
|
|
|
QString directionStyle;
|
2012-05-26 14:49:10 +02:00
|
|
|
|
|
|
|
GpBar();
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// GuitarPro
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class GuitarPro {
|
|
|
|
protected:
|
|
|
|
static const char* errmsg[];
|
|
|
|
int version;
|
|
|
|
int key;
|
|
|
|
|
2014-07-25 18:52:31 +02:00
|
|
|
QMap<int, QList<GPFermata>*> fermatas;
|
2014-07-24 10:28:18 +02:00
|
|
|
Ottava** ottava;
|
2014-07-09 16:54:43 +02:00
|
|
|
Hairpin** hairpins;
|
2012-05-26 14:49:10 +02:00
|
|
|
Score* score;
|
|
|
|
QFile* f;
|
|
|
|
int curPos;
|
2014-04-26 13:00:31 +02:00
|
|
|
int previousTempo;
|
2014-08-06 10:49:16 +02:00
|
|
|
int previousDynamic;
|
2014-08-11 19:56:07 +02:00
|
|
|
int ottavaFound;
|
|
|
|
QString ottavaValue;
|
2014-05-22 17:03:55 +02:00
|
|
|
int tempo;
|
2014-07-01 11:00:31 +02:00
|
|
|
QMap<int,int> slides;
|
2012-05-26 14:49:10 +02:00
|
|
|
|
2014-04-25 10:43:42 +02:00
|
|
|
int voltaSequence;
|
2013-09-26 18:00:31 +02:00
|
|
|
QTextCodec* _codec;
|
2014-06-30 16:17:48 +02:00
|
|
|
Slur** slurs;
|
2013-09-26 18:00:31 +02:00
|
|
|
|
2012-05-26 14:49:10 +02:00
|
|
|
void skip(qint64 len);
|
|
|
|
void read(void* p, qint64 len);
|
|
|
|
int readUChar();
|
|
|
|
int readChar();
|
|
|
|
QString readPascalString(int);
|
|
|
|
QString readWordPascalString();
|
|
|
|
QString readBytePascalString();
|
|
|
|
int readInt();
|
|
|
|
QString readDelphiString();
|
2014-04-25 10:43:42 +02:00
|
|
|
void readVolta(GPVolta*, Measure*);
|
2014-04-29 16:23:39 +02:00
|
|
|
virtual void readBend(Note*);
|
2014-08-11 19:56:07 +02:00
|
|
|
virtual bool readMixChange(Measure* measure);
|
2012-05-26 14:49:10 +02:00
|
|
|
virtual int readBeatEffects(int track, Segment*) = 0;
|
|
|
|
void readLyrics();
|
|
|
|
void readChannels();
|
|
|
|
void setTuplet(Tuplet* tuplet, int tuple);
|
|
|
|
Fraction len2fraction(int len);
|
|
|
|
void addDynamic(Note*, int d);
|
2014-04-26 13:00:31 +02:00
|
|
|
void setTempo(int n, Measure* measure);
|
2012-05-26 14:49:10 +02:00
|
|
|
void createMeasures();
|
|
|
|
void applyBeatEffects(Chord*, int beatEffects);
|
2014-04-29 16:23:39 +02:00
|
|
|
void readTremoloBar(int track, Segment*);
|
2014-06-13 11:36:57 +02:00
|
|
|
void readChord(Segment* seg, int track, int numStrings, QString name, bool gpHeader);
|
2014-07-04 14:40:37 +02:00
|
|
|
void restsForEmptyBeats(Segment* seg, Measure* measure, ChordRest* cr, Fraction& l, int track, int tick);
|
2014-06-30 16:17:48 +02:00
|
|
|
void createSlur(bool hasSlur, int staffIdx, ChordRest* cr);
|
2014-08-11 19:56:07 +02:00
|
|
|
void createOttava(bool hasOttava, int track, ChordRest* cr, QString value);
|
2014-07-01 11:00:31 +02:00
|
|
|
void createSlide(int slide, ChordRest* cr, int staffIdx);
|
2014-07-09 16:54:43 +02:00
|
|
|
void createCrecDim(int staffIdx, int track, int tick, bool crec);
|
2014-07-15 11:20:18 +02:00
|
|
|
void addTextToNote(QString string, TextStyle textStyle, Note* note);
|
2014-07-14 10:33:12 +02:00
|
|
|
void addPalmMute(Note* note);
|
2014-07-15 11:20:18 +02:00
|
|
|
void addLetRing(Note* note);
|
2014-07-15 13:43:56 +02:00
|
|
|
void addTap(Note* note);
|
|
|
|
void addSlap(Note* note);
|
|
|
|
void addPop(Note* note);
|
2012-05-26 14:49:10 +02:00
|
|
|
|
|
|
|
public:
|
2014-07-24 11:30:27 +02:00
|
|
|
void initGuitarProDrumset();
|
2012-05-26 14:49:10 +02:00
|
|
|
QString title, subtitle, artist, album, composer;
|
|
|
|
QString transcriber, instructions;
|
|
|
|
QStringList comments;
|
|
|
|
GpTrack channelDefaults[GP_MAX_TRACK_NUMBER * 2];
|
|
|
|
int staves;
|
|
|
|
int measures;
|
|
|
|
QList<GpBar> bars;
|
|
|
|
|
2014-06-02 18:14:11 +02:00
|
|
|
enum class GuitarProError : char { GP_NO_ERROR, GP_UNKNOWN_FORMAT,
|
2012-05-26 14:49:10 +02:00
|
|
|
GP_EOF, GP_BAD_NUMBER_OF_STRINGS
|
|
|
|
};
|
|
|
|
|
|
|
|
GuitarPro(Score*, int v);
|
|
|
|
virtual ~GuitarPro();
|
|
|
|
virtual void read(QFile*) = 0;
|
|
|
|
QString error(GuitarProError n) const { return QString(errmsg[int(n)]); }
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// GuitarPro1
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class GuitarPro1 : public GuitarPro {
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void readNote(int string, Note* note);
|
|
|
|
virtual int readBeatEffects(int track, Segment*);
|
|
|
|
|
|
|
|
public:
|
|
|
|
GuitarPro1(Score* s, int v) : GuitarPro(s, v) {}
|
|
|
|
virtual void read(QFile*);
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// GuitarPro2
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class GuitarPro2 : public GuitarPro1 {
|
|
|
|
|
|
|
|
public:
|
|
|
|
GuitarPro2(Score* s, int v) : GuitarPro1(s, v) {}
|
|
|
|
virtual void read(QFile*);
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// GuitarPro3
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class GuitarPro3 : public GuitarPro1 {
|
|
|
|
|
2014-03-14 19:52:37 +01:00
|
|
|
virtual int readBeatEffects(int track, Segment* segment);
|
2012-05-26 14:49:10 +02:00
|
|
|
public:
|
|
|
|
GuitarPro3(Score* s, int v) : GuitarPro1(s, v) {}
|
|
|
|
virtual void read(QFile*);
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// GuitarPro4
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class GuitarPro4 : public GuitarPro {
|
|
|
|
|
2014-07-01 11:00:31 +02:00
|
|
|
int slide;
|
2012-05-26 14:49:10 +02:00
|
|
|
void readInfo();
|
2014-08-06 10:49:16 +02:00
|
|
|
bool readNote(int string, int staffIdx, Note* note);
|
2014-03-14 19:52:37 +01:00
|
|
|
virtual int readBeatEffects(int track, Segment* segment);
|
2014-08-11 19:56:07 +02:00
|
|
|
virtual bool readMixChange(Measure* measure);
|
2014-07-01 11:00:31 +02:00
|
|
|
int convertGP4SlideNum(int slide);
|
2012-05-26 14:49:10 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
GuitarPro4(Score* s, int v) : GuitarPro(s, v) {}
|
|
|
|
virtual void read(QFile*);
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// GuitarPro5
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class GuitarPro5 : public GuitarPro {
|
|
|
|
|
2014-07-01 11:00:31 +02:00
|
|
|
int slide;
|
2012-05-26 14:49:10 +02:00
|
|
|
void readInfo();
|
|
|
|
void readPageSetup();
|
2014-03-14 19:52:37 +01:00
|
|
|
virtual int readBeatEffects(int track, Segment* segment);
|
2014-06-30 16:17:48 +02:00
|
|
|
bool readNote(int string, Note* note);
|
2014-08-11 19:56:07 +02:00
|
|
|
virtual bool readMixChange(Measure* measure);
|
|
|
|
void readMeasure(Measure* measure, int staffIdx, Tuplet*[], bool mixChange);
|
2012-05-26 14:49:10 +02:00
|
|
|
void readArtificialHarmonic();
|
|
|
|
void readTracks();
|
2014-08-11 19:56:07 +02:00
|
|
|
void readMeasures(int startingTempo);
|
|
|
|
int readBeat(int tick, int voice, Measure* measure, int staffIdx, Tuplet** tuplets, bool mixChange);
|
2014-06-30 16:17:48 +02:00
|
|
|
bool readNoteEffects(Note*);
|
2012-05-26 14:49:10 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
GuitarPro5(Score* s, int v) : GuitarPro(s, v) {}
|
|
|
|
virtual void read(QFile*);
|
|
|
|
};
|
|
|
|
|
2014-05-22 17:03:55 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// GuitarPro6
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class GuitarPro6 : public GuitarPro {
|
|
|
|
|
|
|
|
private:
|
|
|
|
// an integer stored in the header indicating that the file is not compressed (BCFS).
|
|
|
|
const int GPX_HEADER_UNCOMPRESSED = 1397113666;
|
|
|
|
// an integer stored in the header indicating that the file is not compressed (BCFZ).
|
|
|
|
const int GPX_HEADER_COMPRESSED = 1514554178;
|
|
|
|
int position=0;
|
2014-07-01 11:00:31 +02:00
|
|
|
QMap<int, int>* slides;
|
2014-05-22 17:03:55 +02:00
|
|
|
QByteArray* buffer;
|
|
|
|
// a constant storing the amount of bits per byte
|
|
|
|
const int BITS_IN_BYTE = 8;
|
|
|
|
// contains all the information about notes that will go in the parts
|
|
|
|
struct GPPartInfo {
|
|
|
|
QDomNode masterBars;
|
|
|
|
QDomNode bars;
|
|
|
|
QDomNode voices;
|
|
|
|
QDomNode beats;
|
|
|
|
QDomNode notes;
|
|
|
|
QDomNode rhythms;
|
|
|
|
};
|
2014-06-13 11:36:57 +02:00
|
|
|
// a mapping from identifiers to fret diagrams
|
|
|
|
QMap<int, FretDiagram*> fretDiagrams;
|
2014-05-22 17:03:55 +02:00
|
|
|
void parseFile(char* filename, QByteArray* data);
|
|
|
|
int readBit();
|
|
|
|
QByteArray getBytes(QByteArray* buffer, int offset, int length);
|
|
|
|
void readGPX(QByteArray* buffer);
|
|
|
|
int readInteger(QByteArray* buffer, int offset);
|
|
|
|
QByteArray readString(QByteArray* buffer, int offset, int length);
|
|
|
|
int readBits(int bitsToRead);
|
|
|
|
int readBitsReversed(int bitsToRead);
|
|
|
|
void readGpif(QByteArray* data);
|
|
|
|
void readScore(QDomNode* metadata);
|
2014-06-13 11:36:57 +02:00
|
|
|
void readChord(QDomNode* diagram, int track);
|
2014-05-22 17:03:55 +02:00
|
|
|
int findNumMeasures(GPPartInfo* partInfo);
|
|
|
|
void readMasterTracks(QDomNode* masterTrack);
|
2014-06-10 14:36:13 +02:00
|
|
|
void readDrumNote(Note* note, int element, int variation);
|
2014-07-25 18:52:31 +02:00
|
|
|
int readBeats(QString beats, GPPartInfo* partInfo, Measure* measure, int tick, int staffIdx, int voiceNum, Tuplet* tuplets[], int measureCounter);
|
2014-08-11 19:56:07 +02:00
|
|
|
void readBars(QDomNode* barList, Measure* measure, ClefType oldClefId[], GPPartInfo* partInfo, int measureCounter);
|
2014-05-22 17:03:55 +02:00
|
|
|
void readTracks(QDomNode* tracks);
|
|
|
|
void readMasterBars(GPPartInfo* partInfo);
|
|
|
|
Fraction rhythmToDuration(QString value);
|
2014-07-25 18:52:31 +02:00
|
|
|
Fraction fermataToFraction(int numerator, int denominator);
|
2014-05-22 17:03:55 +02:00
|
|
|
QDomNode getNode(QString id, QDomNode nodes);
|
|
|
|
void unhandledNode(QString nodeName);
|
2014-07-01 11:00:31 +02:00
|
|
|
void makeTie(Note* note);
|
2014-08-06 10:49:16 +02:00
|
|
|
int* previousDynamic;
|
|
|
|
void addTremoloBar(Segment* segment, int track, int whammyOrigin, int whammyMiddle, int whammyEnd);
|
2014-05-22 17:03:55 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void readNote(int string, Note* note);
|
|
|
|
virtual int readBeatEffects(int track, Segment*);
|
|
|
|
|
|
|
|
public:
|
|
|
|
GuitarPro6(Score* s) : GuitarPro(s, 6) {}
|
|
|
|
virtual void read(QFile*);
|
|
|
|
};
|
2013-05-13 18:49:17 +02:00
|
|
|
|
|
|
|
} // namespace Ms
|
2012-05-26 14:49:10 +02:00
|
|
|
#endif
|