static void streaming_up_down_test(const SRCParams ¶ms) { // Source noise Samples noise(noise_size); RNG(seed).fill_samples(noise, noise_size); // Upsampled buffer Samples buf1(size_t(double(noise_size + 1) * params.fd / params.fs) + 1); // Downsampled buffer Samples buf2(noise_size + 100); StreamingSRC src; BOOST_REQUIRE(src.open(params)); size_t buf1_data = resample(src, noise, noise_size, buf1, buf1.size()); BOOST_REQUIRE(src.open(SRCParams(params.fd, params.fs, params.a, params.q))); size_t buf2_data = resample(src, buf1, buf1_data, buf2, buf2.size()); BOOST_CHECK(abs(int(buf2_data) - int(noise_size)) <= 1); // Resample introduces not more than -A dB of noise. // 2 resamples introduces twice more noise, -A + 6dB sample_t diff = diff_resampled(params, noise, buf2, MIN(noise_size, buf2_data)); BOOST_MESSAGE("Transform: " << params.fs << "Hz <-> " << params.fd << "Hz Diff: " << value2db(diff) << " dB"); BOOST_CHECK_LE(value2db(diff), -params.a + 7); }
void TvolumePage::TvolumeTbr::getEditMinMaxVal(const TffdshowParamInfo &info, int *min, int *max, int *val) { if (isdb) { *min = -30; *max = 30; *val = ff_round(value2db(self->deci->getParam2(info.id) / 100.0)); } else { TwidgetSubclassTbr::getEditMinMaxVal(info, min, max, val); } }
void TvolumePage::normalize2dlg(void) { setCheck(IDC_CHB_VOLUME_NORMALIZE, cfgGet(IDFF_volumeNormalize)); int val = cfgGet(IDFF_maxNormalization); if (isdb) { val = limit(ff_round(value2db(val / 100.0)), 0, 30); } SetDlgItemInt(m_hwnd, IDC_ED_VOLUME_NORMALIZE_MAX, val, FALSE); setCheck(IDC_CHB_NORMALIZE_RESETONSEEK, cfgGet(IDFF_volumeNormalizeResetOnSeek)); setCheck(IDC_CHB_NORMALIZE_REGAINVOLUME, cfgGet(IDFF_volumeNormalizeRegainVolume)); }
string BassRedir::info() const { std::stringstream s; s << std::boolalpha << std::fixed << std::setprecision(1); s << "Enabled: " << enabled << (is_active()? " (active)": " (inactive)") << nl; s << "Crossover frequency: " << freq << "Hz" << nl; s << "Bass destination: "; if (ch_mask == MODE_STEREO) s << "front channels"; else if (ch_mask == CH_MASK_LFE) s << "subwoofer"; else s << "0x" << std::hex << ch_mask << std::dec; s << nl; s << "Bass gain: " << value2db(gain) << "dB" << nl; return s.str(); }
void LevelsHistogram::add_levels(sample_t levels[NCHANNELS]) { for (int ch = 0; ch < NCHANNELS; ch++) if (levels[ch] > 1e-50) { if (levels[ch] > max_level[ch]) max_level[ch] = levels[ch]; int level = -int(value2db(levels[ch]) / dbpb); if (level < 0) level = 0; if (level < MAX_HISTOGRAM) histogram[ch][level]++; } n++; }
string AudioProcessor::info() const { double level = dithering_level(); std::stringstream s; s << std::boolalpha << std::fixed << std::setprecision(1); s << "User format: " << user_spk.print() << nl; s << "Dithering mode: "; switch (dithering) { case DITHER_NONE: s << "no dithering"; break; case DITHER_AUTO: s << (level == 0? "auto (disabled)": "auto (enabled)"); break; case DITHER_ALWAYS: s << "always dither"; break; default: s << "unknown"; break; } s << nl; if (level != 0) s << "Dithering level: " << std::setprecision(0) << value2db(level) << "dB" << nl; s << "Filter chain:\n" << chain.info(); return s.str(); }
void TvolumePage::cfg2volTbr(int tbr, int lbl, int idff, int lbltran, int mult) { int x = cfgGet(idff); if (isdb) { int db = ff_round(value2db(x / 100.0)); tbrSet(tbr, mult * db); if (lbltran) { setText(lbl, _l("%s %i dB"), _(lbltran), db); } else { setText(lbl, _l("%i dB"), db); } } else { if (!isIn(x, 0, 300)) { cfgSet(idff, x = limit(x, 0, 300)); } tbrSet(tbr, mult * x); if (lbltran) { setText(lbl, _l("%s %i%%"), _(lbltran), x); } else { setText(lbl, _l("%i%%"), x); } } }
void TvolumePage::onFrame(void) { int amp = (filter && getCheck(IDC_CHB_VOLUME_NORMALIZE) && getCheck(IDC_CHB_VOLUME)) ? filter->getCurrentNormalization() : 100; if (isdb) { setText(IDC_LBL_VOLUME_NORMALIZE_CURRENT, _l("%s %4.1f dB"), _(IDC_LBL_VOLUME_NORMALIZE_CURRENT), value2db(amp / 100.0)); } else { setText(IDC_LBL_VOLUME_NORMALIZE_CURRENT, _l("%s %i%%"), _(IDC_LBL_VOLUME_NORMALIZE_CURRENT), amp); } if (getCheck(IDC_CHB_VOLUME_SHOWCURRENT)) { unsigned int numchannels; int channels[8], volumes[8]; if (filter && filter->getVolumeData(&numchannels, channels, volumes) == S_OK) { bool isPbr[8]; memset(isPbr, 0, sizeof(isPbr)); for (unsigned int i = 0; i < numchannels; i++) { int pbr; if (channels[i]&SPEAKER_FRONT_LEFT) { pbr = IDC_PBR_VOLUME_L; isPbr[0] = true; } else if (channels[i]&SPEAKER_FRONT_RIGHT) { pbr = IDC_PBR_VOLUME_R; isPbr[2] = true; } else if (channels[i]&SPEAKER_FRONT_CENTER) { pbr = IDC_PBR_VOLUME_C; isPbr[1] = true; } else if (channels[i] & (SPEAKER_BACK_LEFT | SPEAKER_BACK_CENTER)) { pbr = IDC_PBR_VOLUME_SL; isPbr[3] = true; } else if (channels[i]&SPEAKER_BACK_RIGHT) { pbr = IDC_PBR_VOLUME_SR; isPbr[4] = true; } else if (channels[i]&SPEAKER_SIDE_LEFT) { pbr = IDC_PBR_VOLUME_AL; isPbr[5] = true; } else if (channels[i]&SPEAKER_SIDE_RIGHT) { pbr = IDC_PBR_VOLUME_AR; isPbr[6] = true; } else if (channels[i]&SPEAKER_LOW_FREQUENCY) { pbr = IDC_PBR_VOLUME_LFE; isPbr[7] = true; } else { continue; } SendDlgItemMessage(m_hwnd, pbr, PBM_SETPOS, volumes[i] ? 50 + ff_round(value2db(volumes[i] / 65536.0)) : 0, 0); //SendDlgItemMessage(m_hwnd,pbr,PBM_SETBARCOLOR,0,LPARAM(CLR_DEFAULT)); } for (unsigned int i = 0; i < countof(isPbr); i++) if (!isPbr[i]) { SendDlgItemMessage(m_hwnd, pbrs[i], PBM_SETPOS, 0, 0); //SendDlgItemMessage(m_hwnd,pbrs[i],PBM_SETBARCOLOR,0,LPARAM(CLR_NONE)); } return; } } for (int i = 0; i < 6; i++) { SendDlgItemMessage(m_hwnd, pbrs[i], PBM_SETPOS, 0, 0); } }