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 "audio/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 { 31 BBFile* bb; 32 EventList _events; 33 int _outChannel; 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; events()42 const EventList events() const { return _events; } events()43 EventList& events() { return _events; } outChannel()44 int outChannel() const { return _outChannel; } setOutChannel(int n)45 void setOutChannel(int n) { _outChannel = n; } insert(const Event & e)46 void insert(const Event& e) { _events.insert(e); } append(const Event & 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; BBChordBBChord65 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 125 int _startChorus; 126 int _endChorus; 127 int _repeats; 128 #if 0 // yet(?) unused 129 int _flags; 130 #endif 131 char* _styleName; 132 QList<BBTrack*> _tracks; 133 int _measures; 134 TimeSigMap _siglist; 135 136 QByteArray ba; 137 const unsigned char* a; 138 int size; 139 int bbDivision; 140 timesigZ()141 int timesigZ() { return styles[_style].timesigZ; } timesigN()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&); tracks()149 QList<BBTrack*>* tracks() { return &_tracks; } measures()150 int measures() const { return _measures; } title()151 const char* title() const { return _title; } siglist()152 TimeSigMap siglist() const { return _siglist; } chords()153 QList<BBChord> chords() { return _chords; } startChorus()154 int startChorus() const { return _startChorus; } endChorus()155 int endChorus() const { return _endChorus; } repeats()156 int repeats() const { return _repeats; } key()157 int key() const { return _key; } 158 void convertTrack(Score* score, BBTrack* track, int staffIdx); 159 }; 160 161 162 } // namespace Ms 163 #endif 164 165