Mercurial > hg > silvet
comparison src/Instruments.cpp @ 176:8af9b6cd7451
Add some ensemble instrument packs
author | Chris Cannam |
---|---|
date | Wed, 21 May 2014 15:03:12 +0100 |
parents | 6003a9af43af |
children | 59e3cca75b8d |
comparison
equal
deleted
inserted
replaced
175:abfd19f5cc1a | 176:8af9b6cd7451 |
---|---|
28 using std::vector; | 28 using std::vector; |
29 using std::cerr; | 29 using std::cerr; |
30 using std::endl; | 30 using std::endl; |
31 | 31 |
32 const char *simpleInstruments[] = { | 32 const char *simpleInstruments[] = { |
33 // Each instrument has two consecutive slots, one for the pack | |
34 // name and one for the template to look up | |
33 "Guitar", "guitar", | 35 "Guitar", "guitar", |
34 "Violin", "violin", | 36 "Violin", "violin", |
35 "Cello", "cello", | 37 "Cello", "cello", |
36 "Horn", "horn", | 38 "Horn", "horn", |
37 "Flute", "flute", | 39 "Flute", "flute", |
38 "Oboe", "oboe", | 40 "Oboe", "oboe", |
39 "Clarinet", "clarinet", | 41 "Clarinet", "clarinet", |
40 "Tenor Sax", "tenorsax", | 42 "Tenor Sax", "tenorsax", |
41 "Bassoon", "bassoon", | 43 "Bassoon", "bassoon", |
42 }; | 44 }; |
45 | |
46 static bool | |
47 isString(int i) | |
48 { | |
49 string tname(simpleInstruments[i+1]); | |
50 return tname == "violin" | |
51 || tname == "cello" | |
52 ; | |
53 } | |
54 | |
55 static bool | |
56 isWind(int i) | |
57 { | |
58 string tname(simpleInstruments[i+1]); | |
59 return tname == "horn" | |
60 || tname == "flute" | |
61 || tname == "oboe" | |
62 || tname == "clarinet" | |
63 || tname == "tenorsax" | |
64 || tname == "bassoon" | |
65 ; | |
66 } | |
43 | 67 |
44 static InstrumentPack::Templates | 68 static InstrumentPack::Templates |
45 templatesFor(string name) | 69 templatesFor(string name) |
46 { | 70 { |
47 for (int i = 0; i < SILVET_TEMPLATE_COUNT; ++i) { | 71 for (int i = 0; i < SILVET_TEMPLATE_COUNT; ++i) { |
109 pianoTemplates); | 133 pianoTemplates); |
110 if (isOK(piano)) { | 134 if (isOK(piano)) { |
111 ii.push_back(piano); | 135 ii.push_back(piano); |
112 } | 136 } |
113 | 137 |
138 vector<Templates> stringTemplates; | |
139 vector<Templates> windTemplates; | |
140 | |
114 for (int i = 0; | 141 for (int i = 0; |
115 i < int(sizeof(simpleInstruments)/sizeof(simpleInstruments[0])); | 142 i < int(sizeof(simpleInstruments)/sizeof(simpleInstruments[0])); |
116 i += 2) { | 143 i += 2) { |
117 vector<Templates> tt; | 144 vector<Templates> tt; |
118 Templates t = templatesFor(simpleInstruments[i+1]); | 145 Templates t = templatesFor(simpleInstruments[i+1]); |
119 tt.push_back(t); | 146 tt.push_back(t); |
120 allTemplates.push_back(t); | 147 allTemplates.push_back(t); |
148 if (isString(i)) { | |
149 stringTemplates.push_back(t); | |
150 } | |
151 if (isWind(i)) { | |
152 windTemplates.push_back(t); | |
153 } | |
121 InstrumentPack instr(t.lowestNote, | 154 InstrumentPack instr(t.lowestNote, |
122 t.highestNote, | 155 t.highestNote, |
123 simpleInstruments[i], | 156 simpleInstruments[i], |
124 tt); | 157 tt); |
125 if (isOK(instr)) { | 158 if (isOK(instr)) { |
133 allTemplates); | 166 allTemplates); |
134 if (isOK(all)) { | 167 if (isOK(all)) { |
135 ii.insert(ii.begin(), all); | 168 ii.insert(ii.begin(), all); |
136 } | 169 } |
137 | 170 |
171 InstrumentPack strings(silvet_templates_lowest_note, // cello | |
172 silvet_templates_highest_note, // violin | |
173 "String ensemble", | |
174 stringTemplates); | |
175 if (isOK(strings)) { | |
176 ii.push_back(strings); | |
177 } | |
178 | |
179 InstrumentPack winds(silvet_templates_lowest_note, // basson | |
180 silvet_templates_highest_note, // flute | |
181 "Wind ensemble", | |
182 windTemplates); | |
183 if (isOK(winds)) { | |
184 ii.push_back(winds); | |
185 } | |
186 | |
138 return ii; | 187 return ii; |
139 } | 188 } |
140 | 189 |