comparison src/vamp-hostsdk/PluginSummarisingAdapter.cpp @ 444:7bab0c5422f4 vampipe

Make single/double-precision selectable for input domain adapter windowing and FFTs. Double precision is necessary to pass Sonic Annotator regression tests, though in practice most real-world methods would be fine with single precision.
author Chris Cannam
date Thu, 18 Aug 2016 14:43:52 +0100
parents 35fa4733bc5d
children 5d9af3140f05
comparison
equal deleted inserted replaced
443:d3f676c07359 444:7bab0c5422f4
866 cerr << "median = " << summary.median << endl; 866 cerr << "median = " << summary.median << endl;
867 #endif 867 #endif
868 868
869 map<float, int> distribution; 869 map<float, int> distribution;
870 870
871 #ifdef DEBUG_PLUGIN_SUMMARISING_ADAPTER
872 cerr << "summing (discrete): ";
873 #endif
871 for (int k = 0; k < sz; ++k) { 874 for (int k = 0; k < sz; ++k) {
875 #ifdef DEBUG_PLUGIN_SUMMARISING_ADAPTER
876 cerr << accumulator.results[k].values[bin] << " ";
877 #endif
872 summary.sum += accumulator.results[k].values[bin]; 878 summary.sum += accumulator.results[k].values[bin];
873 distribution[accumulator.results[k].values[bin]] += 1; 879 distribution[accumulator.results[k].values[bin]] += 1;
874 } 880 }
881 #ifdef DEBUG_PLUGIN_SUMMARISING_ADAPTER
882 cerr << endl;
883 #endif
875 884
876 int md = 0; 885 int md = 0;
877 886
878 for (map<float, int>::iterator di = distribution.begin(); 887 for (map<float, int>::iterator di = distribution.begin();
879 di != distribution.end(); ++di) { 888 di != distribution.end(); ++di) {
906 915
907 if (totalDuration > 0.0) { 916 if (totalDuration > 0.0) {
908 917
909 double sum_c = 0.0; 918 double sum_c = 0.0;
910 919
920 #ifdef DEBUG_PLUGIN_SUMMARISING_ADAPTER
921 cerr << "summing (continuous): ";
922 #endif
911 for (int k = 0; k < sz; ++k) { 923 for (int k = 0; k < sz; ++k) {
924 #ifdef DEBUG_PLUGIN_SUMMARISING_ADAPTER
925 cerr << accumulator.results[k].values[bin] << "*"
926 << toSec(accumulator.results[k].duration) << " ";
927 #endif
912 double value = accumulator.results[k].values[bin] 928 double value = accumulator.results[k].values[bin]
913 * toSec(accumulator.results[k].duration); 929 * toSec(accumulator.results[k].duration);
914 sum_c += value; 930 sum_c += value;
915 } 931 }
932 #ifdef DEBUG_PLUGIN_SUMMARISING_ADAPTER
933 cerr << endl;
934 #endif
916 935
917 #ifdef DEBUG_PLUGIN_SUMMARISING_ADAPTER 936 #ifdef DEBUG_PLUGIN_SUMMARISING_ADAPTER
918 cerr << "mean_c = " << sum_c << " / " << totalDuration << " = " 937 cerr << "mean_c = " << sum_c << " / " << totalDuration << " = "
919 << sum_c / totalDuration << " (sz = " << sz << ")" << endl; 938 << sum_c / totalDuration << " (sz = " << sz << ")" << endl;
920 #endif 939 #endif