comparison tests/TestGetKeyMode.cpp @ 470:dd132354ea02

Expand tests a bit, make them fail if they fail
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 30 May 2019 14:10:33 +0100
parents 3f913390bcf2
children 2adcd94c2079
comparison
equal deleted inserted replaced
469:8d84e5d16314 470:dd132354ea02
68 double concertA = 440.0; 68 double concertA = 440.0;
69 int sampleRate = 44100; 69 int sampleRate = 44100;
70 70
71 for (int midiPitch = 48; midiPitch < 96; ++midiPitch) { 71 for (int midiPitch = 48; midiPitch < 96; ++midiPitch) {
72 72
73 cout << endl;
74
75 GetKeyMode gkm(sampleRate, concertA, 10, 10); 73 GetKeyMode gkm(sampleRate, concertA, 10, 10);
76 int blockSize = gkm.getBlockSize(); 74 int blockSize = gkm.getBlockSize();
77 int hopSize = gkm.getHopSize(); 75 int hopSize = gkm.getHopSize();
78 cerr << "blockSize = " << blockSize
79 << ", hopSize = " << hopSize << endl;
80 76
81 double frequency = concertA * pow(2.0, (midiPitch - 69.0) / 12.0); 77 double frequency = concertA * pow(2.0, (midiPitch - 69.0) / 12.0);
78 /*
82 cout << "midiPitch = " << midiPitch 79 cout << "midiPitch = " << midiPitch
83 << ", name = " << midiPitchName(midiPitch) 80 << ", name = " << midiPitchName(midiPitch)
84 << ", frequency = " << frequency << endl; 81 << ", frequency = " << frequency << endl;
85 82 */
86 int blocks = 4; 83 int blocks = 4;
87 int totalLength = blockSize * blocks; 84 int totalLength = blockSize * blocks;
88 vector<double> signal = generateSinusoid(frequency, sampleRate, 85 vector<double> signal = generateSinusoid(frequency, sampleRate,
89 totalLength); 86 totalLength);
90 87
103 bool minor = (key > 12); 100 bool minor = (key > 12);
104 101
105 int tonic = key; 102 int tonic = key;
106 if (minor) tonic -= 12; 103 if (minor) tonic -= 12;
107 104
108 string name = keyName(tonic, minor); 105 BOOST_CHECK_EQUAL(tonic, 1 + (midiPitch % 12));
109 cout << "key value = " << key << ", name = " << name << endl; 106
107 // string name = keyName(tonic, minor);
108 // cout << "key value = " << key << ", name = " << name << endl;
110 } 109 }
111 } 110 }
112 111
113 BOOST_AUTO_TEST_SUITE_END() 112 BOOST_AUTO_TEST_SUITE_END()