static void
setup_peak_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
{
  g_return_if_fail (GST_AUDIO_FILTER (equ)->format.rate);

  {
    gdouble gain, omega, bw;
    gdouble alpha, alpha1, alpha2, b0;

    gain = arg_to_scale (band->gain);
    omega = calculate_omega (band->freq, GST_AUDIO_FILTER (equ)->format.rate);
    bw = calculate_bw (band, GST_AUDIO_FILTER (equ)->format.rate);
    if (bw == 0.0)
      goto out;

    alpha = tan (bw / 2.0);

    alpha1 = alpha * gain;
    alpha2 = alpha / gain;

    b0 = (1.0 + alpha2);

    band->a0 = (1.0 + alpha1) / b0;
    band->a1 = (-2.0 * cos (omega)) / b0;
    band->a2 = (1.0 - alpha1) / b0;
    band->b1 = (2.0 * cos (omega)) / b0;
    band->b2 = -(1.0 - alpha2) / b0;

  out:
    GST_INFO
        ("gain = %5.1f, width= %7.2f, freq = %7.2f, a0 = %7.5g, a1 = %7.5g, a2=%7.5g b1 = %7.5g, b2 = %7.5g",
        band->gain, band->width, band->freq, band->a0, band->a1, band->a2,
        band->b1, band->b2);
  }
}
    // Draw this UE.
    void draw() {
        // Fixed fields (rnti, type, ueid) won't change during lifetime of UE entry.

        // Calculate bw now.
        double UL_bw = calculate_bw(&ul_time_start_,
                                    &ul_time_stop_,
                                    ul_bytes_);
        double DL_bw = calculate_bw(&dl_time_start_,
                                    &dl_time_stop_,
                                    dl_bytes_);

        // Set columns with current values.
        setText(col_ul_frames_, QString::number(ul_frames_));
        setText(col_ul_bytes_, QString::number(ul_bytes_));
        setText(col_ul_mb_s_, QString::number(UL_bw));
        setData(col_ul_padding_percent_, Qt::UserRole,
                QVariant::fromValue<double>(ul_raw_bytes_ ?
                                                (((double)ul_padding_bytes_ / (double)ul_raw_bytes_) * 100.0) :
                                                0.0));
        setText(col_ul_retx_, QString::number(ul_retx_));

        setText(col_dl_frames_, QString::number(dl_frames_));
        setText(col_dl_bytes_, QString::number(dl_bytes_));
        setText(col_dl_mb_s_, QString::number(DL_bw));

        setData(col_dl_padding_percent_, Qt::UserRole,
                QVariant::fromValue<double>(dl_raw_bytes_ ?
                                                (((double)dl_padding_bytes_ / (double)dl_raw_bytes_) * 100.0) :
                                                0.0));
        setText(col_dl_crc_failed_, QString::number(dl_crc_failed_));
        setText(col_dl_retx_, QString::number(dl_retx_));

        // Draw child items with per-channel counts.
        ul_frames_item_->draw();
        ul_bytes_item_->draw();
        dl_frames_item_->draw();
        dl_bytes_item_->draw();
    }
    // Return the UE-specific fields.
    QList<QVariant> rowData() const
    {
        QList<QVariant> row_data;

        // Key fields
        row_data << rnti_ << (type_ == C_RNTI ? QObject::tr("C-RNTI") : QObject::tr("SPS-RNTI")) << ueid_;

        // UL
        row_data << ul_frames_ << ul_bytes_
                 << calculate_bw(&ul_time_start_, &ul_time_stop_, ul_bytes_)
                 << QVariant::fromValue<double>(ul_raw_bytes_ ?
                                                    (((double)ul_padding_bytes_ / (double)ul_raw_bytes_) * 100.0) :
                                                    0.0)
                 << ul_retx_;

        // DL
        row_data << dl_frames_ << dl_bytes_
                 << calculate_bw(&dl_time_start_, &dl_time_stop_, dl_bytes_)
                 << QVariant::fromValue<double>(dl_raw_bytes_ ?
                                                    (((double)dl_padding_bytes_ / (double)dl_raw_bytes_) * 100.0) :
                                                    0.0)
                 << dl_crc_failed_ << dl_retx_;
        return row_data;
    }
Exemple #4
0
static void
setup_high_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
{
    gint rate = GST_AUDIO_FILTER_RATE (equ);

    g_return_if_fail (rate);

    {
        gdouble gain, omega, bw;
        gdouble alpha, delta, b0;
        gdouble egp, egm;

        gain = arg_to_scale (band->gain);
        omega = calculate_omega (band->freq, rate);
        bw = calculate_bw (band, rate);
        if (bw == 0.0)
            goto out;

        egm = gain - 1.0;
        egp = gain + 1.0;
        alpha = tan (bw / 2.0);

        delta = 2.0 * sqrt (gain) * alpha;
        b0 = egp - egm * cos (omega) + delta;

        band->a0 = ((egp + egm * cos (omega) + delta) * gain) / b0;
        band->a1 = ((egm + egp * cos (omega)) * -2.0 * gain) / b0;
        band->a2 = ((egp + egm * cos (omega) - delta) * gain) / b0;
        band->b1 = ((egm - egp * cos (omega)) * -2.0) / b0;
        band->b2 = -((egp - egm * cos (omega) - delta)) / b0;


out:
        GST_INFO
        ("gain = %5.1f, width= %7.2f, freq = %7.2f, a0 = %7.5g, a1 = %7.5g, a2=%7.5g b1 = %7.5g, b2 = %7.5g",
         band->gain, band->width, band->freq, band->a0, band->a1, band->a2,
         band->b1, band->b2);
    }
}