MuseScore  3.4
Music composition and notation
stringdata.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2011 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __TABLATURE_H__
14 #define __TABLATURE_H__
15 
16 #include "xml.h"
17 
18 namespace Ms {
19 
20 class Chord;
21 class Note;
22 
23 //---------------------------------------------------------
24 // StringData
25 //---------------------------------------------------------
26 
27 // defines the string of an instrument
28 struct instrString {
29  int pitch; // the pitch of the string
30  bool open; // true: string is open | false: string is fretted
31 
32  bool operator==(const instrString& d) const { return d.pitch == pitch && d.open == open; }
33  };
34 
35 class StringData {
36 // QList<int> stringTable { 40, 45, 50, 55, 59, 64 }; // guitar is default
37 // int _frets = 19;
38  QList<instrString> stringTable { }; // no strings by default
39  int _frets = 0;
40 
41  static bool bFretting;
42 
43  bool convertPitch(int pitch, int pitchOffset, int* string, int* fret) const;
44  int fret(int pitch, int string, int pitchOffset) const;
45  int getPitch(int string, int fret, int pitchOffset) const;
46  void sortChordNotes(QMap<int, Note *>& sortedNotes, const Chord* chord, int pitchOffset, int* count) const;
47 
48 public:
50  StringData(int numFrets, int numStrings, int strings[]);
51  StringData(int numFrets, QList<instrString>& strings);
52  bool convertPitch(int pitch, Staff* staff, const Fraction& tick, int* string, int* fret) const;
53  int fret(int pitch, int string, Staff* staff, const Fraction& tick) const;
54  void fretChords(Chord * chord) const;
55  int getPitch(int string, int fret, Staff* staff, const Fraction& tick) const;
56  static int pitchOffsetAt(Staff* staff, const Fraction& tick);
57  int strings() const { return stringTable.size(); }
58  int frettedStrings() const;
59  const QList<instrString>& stringList() const { return stringTable; }
60  QList<instrString>& stringList() { return stringTable; }
61  int frets() const { return _frets; }
62  void setFrets(int val) { _frets = val; }
63  void read(XmlReader&);
64  void write(XmlWriter&) const;
65  void writeMusicXML(XmlWriter& xml) const;
66  bool operator==(const StringData& d) const { return d._frets == _frets && d.stringTable == stringTable; }
67  };
68 
69 } // namespace Ms
70 #endif
71 
int pitch
Definition: stringdata.h:29
Definition: stringdata.h:28
Global staff data not directly related to drawing.
Definition: staff.h:62
int strings() const
Definition: stringdata.h:57
QList< instrString > stringTable
Definition: stringdata.h:38
Definition: xml.h:67
bool open
Definition: stringdata.h:30
void setFrets(int val)
Definition: stringdata.h:62
Definition: stringdata.h:35
bool operator==(const StringData &d) const
Definition: stringdata.h:66
bool operator==(const instrString &d) const
Definition: stringdata.h:32
StringData()
Definition: stringdata.h:49
Definition: aeolus.cpp:26
Definition: xml.h:218
Graphic representation of a chord.
Definition: chord.h:55
static bool bFretting
Definition: stringdata.h:41
Definition: fraction.h:46
const QList< instrString > & stringList() const
Definition: stringdata.h:59
QList< instrString > & stringList()
Definition: stringdata.h:60
int frets() const
Definition: stringdata.h:61
int _frets
Definition: stringdata.h:39