Mercurial > hg > silvet
diff 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 |
line wrap: on
line diff
--- a/src/Instruments.cpp Wed May 21 14:42:00 2014 +0100 +++ b/src/Instruments.cpp Wed May 21 15:03:12 2014 +0100 @@ -30,6 +30,8 @@ using std::endl; const char *simpleInstruments[] = { + // Each instrument has two consecutive slots, one for the pack + // name and one for the template to look up "Guitar", "guitar", "Violin", "violin", "Cello", "cello", @@ -41,6 +43,28 @@ "Bassoon", "bassoon", }; +static bool +isString(int i) +{ + string tname(simpleInstruments[i+1]); + return tname == "violin" + || tname == "cello" + ; +} + +static bool +isWind(int i) +{ + string tname(simpleInstruments[i+1]); + return tname == "horn" + || tname == "flute" + || tname == "oboe" + || tname == "clarinet" + || tname == "tenorsax" + || tname == "bassoon" + ; +} + static InstrumentPack::Templates templatesFor(string name) { @@ -111,6 +135,9 @@ ii.push_back(piano); } + vector<Templates> stringTemplates; + vector<Templates> windTemplates; + for (int i = 0; i < int(sizeof(simpleInstruments)/sizeof(simpleInstruments[0])); i += 2) { @@ -118,6 +145,12 @@ Templates t = templatesFor(simpleInstruments[i+1]); tt.push_back(t); allTemplates.push_back(t); + if (isString(i)) { + stringTemplates.push_back(t); + } + if (isWind(i)) { + windTemplates.push_back(t); + } InstrumentPack instr(t.lowestNote, t.highestNote, simpleInstruments[i], @@ -135,6 +168,22 @@ ii.insert(ii.begin(), all); } + InstrumentPack strings(silvet_templates_lowest_note, // cello + silvet_templates_highest_note, // violin + "String ensemble", + stringTemplates); + if (isOK(strings)) { + ii.push_back(strings); + } + + InstrumentPack winds(silvet_templates_lowest_note, // basson + silvet_templates_highest_note, // flute + "Wind ensemble", + windTemplates); + if (isOK(winds)) { + ii.push_back(winds); + } + return ii; }