comparison src/LiveInstruments.cpp @ 301:00fab71b80ec livemode

More tweaking of frequencies
author Chris Cannam
date Mon, 01 Dec 2014 17:12:19 +0000
parents ba5f3b084466
children cac0be04c43c
comparison
equal deleted inserted replaced
300:ba5f3b084466 301:00fab71b80ec
15 15
16 #include "LiveInstruments.h" 16 #include "LiveInstruments.h"
17 17
18 #include "data/include/templates.h" 18 #include "data/include/templates.h"
19 19
20 #include <iostream>
21
20 using namespace std; 22 using namespace std;
21 23
22 InstrumentPack 24 InstrumentPack
23 LiveAdapter::adapt(const InstrumentPack &original) 25 LiveAdapter::adapt(const InstrumentPack &original)
24 { 26 {
25 vector<InstrumentPack::Templates> templates; 27 vector<InstrumentPack::Templates> templates;
26 28
29 cerr << "LiveAdapter: reduced template height is " << SILVET_TEMPLATE_HEIGHT/5 << endl;
30
27 for (vector<InstrumentPack::Templates>::const_iterator i = 31 for (vector<InstrumentPack::Templates>::const_iterator i =
28 original.templates.begin(); 32 original.templates.begin();
29 i != original.templates.end(); ++i) { 33 i != original.templates.end(); ++i) {
30 34
31 InstrumentPack::Templates t; 35 InstrumentPack::Templates t;
32 t.lowestNote = i->lowestNote; 36 t.lowestNote = i->lowestNote;
33 t.highestNote = i->highestNote; 37 t.highestNote = i->highestNote;
34 t.data.resize(i->data.size()); 38 t.data.resize(i->data.size());
35 39
36 for (int j = 0; j < int(i->data.size()); ++j) { 40 for (int j = 0; j < int(i->data.size()); ++j) {
41
37 t.data[j].resize(SILVET_TEMPLATE_HEIGHT/5); 42 t.data[j].resize(SILVET_TEMPLATE_HEIGHT/5);
43
38 float sum = 0.f; 44 float sum = 0.f;
45
39 for (int k = 0; k < SILVET_TEMPLATE_HEIGHT/5; ++k) { 46 for (int k = 0; k < SILVET_TEMPLATE_HEIGHT/5; ++k) {
40 t.data[j][k] = i->data[j][k * 5 + 2 - SILVET_TEMPLATE_MAX_SHIFT]; 47
48 t.data[j][k] = 0.f;
49
50 for (int m = 0; m < 5; ++m) {
51 t.data[j][k] += i->data[j][k * 5 + m + 2];
52 }
53
41 sum += t.data[j][k]; 54 sum += t.data[j][k];
42 } 55 }
56
43 // re-normalise 57 // re-normalise
44 for (int k = 0; k < (int)t.data[j].size(); ++k) { 58 for (int k = 0; k < (int)t.data[j].size(); ++k) {
45 t.data[j][k] *= 1.f / sum; 59 t.data[j][k] *= 1.f / sum;
46 } 60 }
47 } 61 }