MuseScore  3.4
Music composition and notation
bb.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2009-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 __BB_H__
14 #define __BB_H__
15 
16 #include "midi/midifile.h"
17 
18 namespace Ms {
19 
20 const int MAX_BARS = 255;
21 
22 class BBFile;
23 struct MNote;
24 class Score;
25 
26 //---------------------------------------------------------
27 // BBTrack
28 //---------------------------------------------------------
29 
30 class BBTrack {
34  bool _drumTrack;
35 
36  void quantize(int startTick, int endTick, EventList* dst);
37 
38  public:
39  BBTrack(BBFile*);
40  ~BBTrack();
41  bool empty() const;
42  const EventList events() const { return _events; }
43  EventList& events() { return _events; }
44  int outChannel() const { return _outChannel; }
45  void setOutChannel(int n) { _outChannel = n; }
46  void insert(const Event& e) { _events.insert(e); }
47  void append(const Event& e) { _events.append(e); }
48 
49  void findChords();
50  int separateVoices(int);
51  void cleanup();
52 
53  friend class BBFile;
54  };
55 
56 //---------------------------------------------------------
57 // BBChord
58 //---------------------------------------------------------
59 
60 struct BBChord {
61  int beat;
62  unsigned char bass;
63  unsigned char root;
64  unsigned char extension;
65  BBChord() {
66  beat = 0;
67  bass = 0;
68  root = 0;
69  extension = 0;
70  }
71  };
72 
73 //---------------------------------------------------------
74 // BBStyle
75 //---------------------------------------------------------
76 
77 struct BBStyle {
78  int timesigZ, timesigN;
79  };
80 
81 //---------------------------------------------------------
82 // BBStyle
83 //---------------------------------------------------------
84 
85 static const BBStyle styles[] = {
86  { 4, 4 }, // Jazz Swing
87  { 12, 8 }, // Country 12/8
88  { 4, 4 }, // Country 4/4
89  { 4, 4 }, // Bossa Nova
90  { 4, 4 }, // Ethnic
91  { 4, 4 }, // Blues Shuffle
92  { 4, 4 }, // Blues Straight
93  { 3, 4 }, // Waltz
94  { 4, 4 }, // Pop Ballad
95  { 4, 4 }, // should be Rock Shuffle
96  { 4, 4 }, // lite Rock
97  { 4, 4 }, // medium Rock
98  { 4, 4 }, // Heavy Rock
99  { 4, 4 }, // Miami Rock
100  { 4, 4 }, // Milly Pop
101  { 4, 4 }, // Funk
102  { 3, 4 }, // Jazz Waltz
103  { 4, 4 }, // Rhumba
104  { 4, 4 }, // Cha Cha
105  { 4, 4 }, // Bouncy
106  { 4, 4 }, // Irish
107  { 12, 8 }, // Pop Ballad 12/8
108  { 12, 8 }, // Country12/8 old
109  { 4, 4 }, // Reggae
110  };
111 
112 //---------------------------------------------------------
113 // BBFile
114 //---------------------------------------------------------
115 
116 class BBFile {
117  QString _path;
118  unsigned char _version;
119  char* _title;
120  int _style, _key, _bpm;
121 
122  unsigned char _barType[MAX_BARS];
123  QList<BBChord> _chords;
124 
127  int _repeats;
128 #if 0 // yet(?) unused
129  int _flags;
130 #endif
131  char* _styleName;
132  QList<BBTrack*> _tracks;
135 
136  QByteArray ba;
137  const unsigned char* a;
138  int size;
140 
141  int timesigZ() { return styles[_style].timesigZ; }
142  int timesigN() { return styles[_style].timesigN; }
143  Fraction processPendingNotes(Score*, QList<MNote*>* notes, const Fraction&, int);
144 
145  public:
146  BBFile();
147  ~BBFile();
148  bool read(const QString&);
149  QList<BBTrack*>* tracks() { return &_tracks; }
150  int measures() const { return _measures; }
151  const char* title() const { return _title; }
152  TimeSigMap siglist() const { return _siglist; }
153  QList<BBChord> chords() { return _chords; }
154  int startChorus() const { return _startChorus; }
155  int endChorus() const { return _endChorus; }
156  int repeats() const { return _repeats; }
157  int key() const { return _key; }
158  void convertTrack(Score* score, BBTrack* track, int staffIdx);
159  };
160 
161 
162 } // namespace Ms
163 #endif
164 
char * _styleName
Definition: bb.h:131
int separateVoices(int)
Definition: bb.cpp:998
int startChorus() const
Definition: bb.h:154
char * _title
Definition: bb.h:119
int key() const
Definition: bb.h:157
int endChorus() const
Definition: bb.h:155
const EventList events() const
Definition: bb.h:42
QString _path
Definition: bb.h:117
BBFile * bb
Definition: bb.h:31
int _style
Definition: bb.h:120
bool _drumTrack
Definition: bb.h:34
friend class BBFile
Definition: bb.h:53
int size
Definition: bb.h:138
int beat
Definition: bb.h:61
Definition: bb.h:77
void quantize(int startTick, int endTick, EventList *dst)
Definition: bb.cpp:770
unsigned char root
Definition: bb.h:63
Definition: bb.h:116
QList< BBTrack * > _tracks
Definition: bb.h:132
void findChords()
Definition: bb.cpp:927
unsigned char _version
Definition: bb.h:118
Definition: bb.h:60
void insert(const Event &)
Definition: event.cpp:381
Definition: score.h:391
int timesigZ
Definition: bb.h:78
void insert(const Event &e)
Definition: bb.h:46
int measures() const
Definition: bb.h:150
~BBTrack()
Definition: bb.cpp:49
unsigned char bass
Definition: bb.h:62
Definition: event.h:319
QByteArray ba
Definition: bb.h:136
BBTrack(BBFile *)
Definition: bb.cpp:42
QList< BBTrack * > * tracks()
Definition: bb.h:149
const int MAX_BARS
Definition: bb.h:20
int _outChannel
Definition: bb.h:33
EventList & events()
Definition: bb.h:43
void cleanup()
Definition: bb.cpp:873
unsigned char extension
Definition: bb.h:64
int timesigN
Definition: bb.h:78
TimeSigMap siglist() const
Definition: bb.h:152
Definition: aeolus.cpp:26
int _repeats
Definition: bb.h:127
Definition: event.h:264
QList< BBChord > chords()
Definition: bb.h:153
bool empty() const
int _endChorus
Definition: bb.h:126
int bbDivision
Definition: bb.h:139
const char * title() const
Definition: bb.h:151
int _startChorus
Definition: bb.h:125
int timesigN()
Definition: bb.h:142
BBChord()
Definition: bb.h:65
void setOutChannel(int n)
Definition: bb.h:45
Definition: bb.cpp:58
Definition: bb.h:30
QList< BBChord > _chords
Definition: bb.h:123
Definition: fraction.h:46
int _measures
Definition: bb.h:133
int outChannel() const
Definition: bb.h:44
Definition: sig.h:127
TimeSigMap _siglist
Definition: bb.h:134
void append(const Event &e)
Definition: bb.h:47
int repeats() const
Definition: bb.h:156
EventList _events
Definition: bb.h:32
int timesigZ()
Definition: bb.h:141
const unsigned char * a
Definition: bb.h:137