ГОСТ Р 56047—2014
memset(&moddiffinch1. 0x00. sizeof(struct moddiffin));
memset(&moddiffinch2. 0x00. sizeof(struct moddiffin));
memsel(&bandwidthch1, 0x00. sizeof(struct bandwidthout));
memset(&bar>dwidthch2. 0x00. sizeof(struct bandwidthout));
II ref file
if ((fpref = fopen{fileref.V)) == NULL)
fatalerrTerr: %s". strerror(errno));
if ((rateref = SampleRate(fpref)) == -1)
fatalerr(*err: error in WaveHeader").
if ((numchref = NumOfChan(fpref)) == -1)
fatalerr(’err; error in WaveHeader");
if ((bitsampleref = BitForSample(fpref)) == -1)
fatalerr(*err: error in WaveHeader");
if(FindData(fpref) == -1)
fatalerr(’err: can’t find Data Field");
II test file
if ((fptest = fopen(filetest."r*)) == NULL)
fatalerrTerr: %s". strerror(errno));
if ((ratetest = SampleRate(fptest)) == -1)
fatalerr(*err: error in WaveHeader");
if ({numchtest = NumOfChan(fptest)) == -1)
fatalenTerr: error in WaveHeader");
if ((bitsampletest = BitForSample(fptest)) == -1)
fatalerrTerr: error in WaveHeader");
if(FindData(fptest) — -1)
fatalerrTerr: can’t find Data Field");
fprintf(stdouL’Vi PEAQb Algorithm. Author Giuseppe Gottardi ’oveRet’"
’ <
gottardi@ailinux.org
>\n"):
fprintf(stdout.’ViRef Fite %s“
*\n - Sample Rate: %d"
*\n - Number Of Channel: %d"
*\n - Bits for Sample: %d"
"\n - Level Playback: %d\n\n*. fileref. rateref.
numchref. bitsampleref. Ipref);
fprintf(stdout.*ViTest File %s*
*\n - Sample Rate: %d"
*\n - Number Of Channel: %d"
"\n - Bits for Sample: %d"
"\n - Level Playback: %d\nW. filetest. ratetest.
numchtest. bitsampletest Iptest);
II Processing
if(ratetest != rateref)
fatalerrTerr: Can’t process Wave Files with different Sample Rate");
if{numchref != numchtest)
fatalerrTerr: Can’t process Mono Wave with Stereo Wave"):
II Find delaytime1 for Loudness Threshold
delaytime1 = ceilf((float)THRESHOLDDELAY’ratetest*2/HANN);
// Find delaytime2 for Delayed Averaging
delaytime2 = ceilf((float)AVERAGINGDEALAY’ratetest’2/HANN);
II make fft plan
plan = fftw_create_plan(HANN, FFTW_FORWARD. FFTW_MEASURE);
whilefharmsamples < (Fup/ratetest)*(HANN/2.0V2.0)
harmsamples *= 2;
plan2 = fftw_create_plan(harmsamples. FFTV\’_FОRWARD. FFTW_MEASURE);
54