int do_test() { shenidam_t processor = shenidam_create(sample_rate,num_threads); shenidam_set_resampling_quality(processor,src_converter); SF_INFO base_info; std::memset(&base_info,0,sizeof(SF_INFO)); SNDFILE* base = sf_open(base_filename.c_str(),SFM_READ,&base_info); if (base == NULL) { return 1; } float* base_b; read_sndfile_average(base,&base_info,&base_b); sf_close(base); size_t total_num_samples = base_info.frames; size_t num_samples_track = (size_t)ceil(size_test_track*base_info.samplerate); if (num_samples_track >= total_num_samples) { fprintf(stderr,"ERROR: Track size larger than base size. Choose smaller track size or longer base."); } double sample_rate = (double)base_info.samplerate; shenidam_set_base_audio(processor,FORMAT_SINGLE,(void*)base_b,base_info.frames,(double)base_info.samplerate); double in = 0.0; double out = 100.0; while(test_n(processor,base_b,total_num_samples,sample_rate,num_samples_track,out,num_tries)) { in = out; out += 100; } while((out - in)>0.01) { double midpoint = (in+out) / 2; if (test_n(processor,base_b,total_num_samples,sample_rate,num_samples_track,midpoint,num_tries)) { in = midpoint; } else { out = midpoint; } } double critical_noise_sd = (in+out)/2; double cnsd_db = 10*log(1/(critical_noise_sd*critical_noise_sd)); printf("Critical noise %g (%g db)\n",critical_noise_sd,cnsd_db); std::free(base_b); shenidam_destroy(processor); return 0; }
int main (void) { test_c ('?'); test_d_i (0xdeadbeef, 0xdeadbeefL); test_x ('?', 0xdead, 0xdeadbeef); test_a_double (0.0); test_e_double (0.0); test_f_double (0.0); test_g_double (0.0); test_a_long_double (); test_e_long_double (0.0); test_f_long_double (); test_g_long_double (); test_s (0); test_n (); test_percent (); if (nfails) { __builtin_printf ("%u out of %u tests failed\n", nfails, ntests); __builtin_abort (); } return 0; }
/** Run all tests on format library. **/ static void run_tests( void ) { test(); test_pc(); test_cC(); test_n(); test_s(); test_p(); test_di(); test_bouxX(); test_eEfFgG(); test_asterisk(); test_cont(); printf( "-----------------------\n" "Overall: %s\n", f ? "FAIL" : "PASS" ); }
/** Run all tests on format library. **/ static void run_tests( void ) { test(); test_pc(); test_cC(); test_n(); test_s(); test_p(); test_di(); test_bouxX(); test_eEfFgG(); test_k(); test_asterisk(); test_cont(); printf( "-----------------------\n" "Summary: %s (%u failures)\n", f ? "FAIL" : "PASS", f ); }