Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
pitch errors verification for Nowhk
#include <cmath> #include <iostream> #include <iomanip> const double C0 = 16.352; const double ln2per12 = std::log(2.) / 12; // your ref and approx frequency values: const int index[] = {46, 623, 954}; const double refFreq[] = {1.33304775683583476286742097727255895733833313, 37.3506591867008808094396954402327537537, 252.719842525523120002617361024022102356}; const double apxFreq[] = {1.33304797524971263555926270782947540283203125, 37.3506628974037084844894707202911376953, 252.719804590087733231484889984130859375}; // ............................................................ void testErrors() { using namespace std; cout.precision(12); const int n = sizeof(index)/sizeof(*index); cout << "pitch index: "; for (int i = 0; i < n; i++) cout << " " << setw(18) << left << index[i]; cout << endl; cout << "relative errors:"; for (int i = 0; i < n; i++) cout << " " << abs(refFreq[i] - apxFreq[i]) / refFreq[i]; cout << endl; cout << "pitch errors: "; for (int i = 0; i < n; i++) { double a = log(refFreq[i] / C0) / ln2per12; double b = log(apxFreq[i] / C0) / ln2per12; cout << " " << abs(a - b); } cout << endl; } // ............................................................ int main() { testErrors(); return 0; }
run
|
edit
|
history
|
help
0
Visual Studio expand modified
!Enum
Is a Union Member's Destructor Called
inherited
Typed enum implicitly casted to integer
Build char string (multibyte) with wchar
MSVC noexcept - works
std::is_same doesn't check for calling convention
delete from list
students grade