Mercurial > hg > svcore
comparison base/test/TestPitch.h @ 1027:ce1077bd663a cxx11
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 09 Feb 2015 10:31:07 +0000 |
parents | 88b54a185a0a |
children | bbc4e4ee15d5 |
comparison
equal
deleted
inserted
replaced
1011:dbb7f0ab011e | 1027:ce1077bd663a |
---|---|
70 QCOMPARE(Pitch::getPitchLabelForFrequency(440, 440, false), QString("A4")); | 70 QCOMPARE(Pitch::getPitchLabelForFrequency(440, 440, false), QString("A4")); |
71 QCOMPARE(Pitch::getPitchLabelForFrequency(440, 220, false), QString("A5")); | 71 QCOMPARE(Pitch::getPitchLabelForFrequency(440, 220, false), QString("A5")); |
72 QCOMPARE(Pitch::getPitchLabelForFrequency(261.63, 440, false), QString("C4")); | 72 QCOMPARE(Pitch::getPitchLabelForFrequency(261.63, 440, false), QString("C4")); |
73 } | 73 } |
74 | 74 |
75 #define MIDDLE_C 261.6255653f | 75 #define MIDDLE_C 261.6255653005986 |
76 | 76 |
77 void frequencyForPitch() | 77 void frequencyForPitch() |
78 { | 78 { |
79 QCOMPARE(Pitch::getFrequencyForPitch(60, 0), MIDDLE_C); | 79 QCOMPARE(Pitch::getFrequencyForPitch(60, 0), MIDDLE_C); |
80 QCOMPARE(Pitch::getFrequencyForPitch(69, 0), 440.f); | 80 QCOMPARE(Pitch::getFrequencyForPitch(69, 0), 440.0); |
81 QCOMPARE(Pitch::getFrequencyForPitch(60, 0, 220), MIDDLE_C / 2.f); | 81 QCOMPARE(Pitch::getFrequencyForPitch(60, 0, 220), MIDDLE_C / 2.0); |
82 QCOMPARE(Pitch::getFrequencyForPitch(69, 0, 220), 220.f); | 82 QCOMPARE(Pitch::getFrequencyForPitch(69, 0, 220), 220.0); |
83 } | 83 } |
84 | 84 |
85 void pitchForFrequency() | 85 void pitchForFrequency() |
86 { | |
87 double centsOffset = 0.0; | |
88 QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, ¢sOffset), 60); | |
89 QCOMPARE(centsOffset, 0.0); | |
90 QCOMPARE(Pitch::getPitchForFrequency(261.0, ¢sOffset), 60); | |
91 QCOMPARE(int(centsOffset), -4); | |
92 QCOMPARE(Pitch::getPitchForFrequency(440.0, ¢sOffset), 69); | |
93 QCOMPARE(centsOffset, 0.0); | |
94 } | |
95 | |
96 void pitchForFrequencyF() | |
86 { | 97 { |
87 float centsOffset = 0.f; | 98 float centsOffset = 0.f; |
88 QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, ¢sOffset), 60); | 99 QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, ¢sOffset), 60); |
89 QCOMPARE(centsOffset, 0.f); | 100 QCOMPARE(centsOffset, 0.f); |
90 QCOMPARE(Pitch::getPitchForFrequency(261.0, ¢sOffset), 60); | 101 QCOMPARE(Pitch::getPitchForFrequency(261.0, ¢sOffset), 60); |