⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vumeter.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        if (m_fallTimerLeft->isActive())            drawMeterLevel(&paint);        else {            meterStop();            drawFrame(&paint);            drawContents(&paint);        }    } else {        if (m_fallTimerLeft->isActive()) {            paint.setPen(m_background);            paint.setBrush(m_background);            paint.drawRect(0, 0, width(), height());            drawMeterLevel(&paint);        } else {            meterStop();            drawFrame(&paint);            drawContents(&paint);        }    }}voidVUMeter::drawColouredBar(QPainter *paint, int channel,                         int x, int y, int w, int h){    if (m_type == AudioPeakHoldLong ||            m_type == AudioPeakHoldShort ||            m_type == AudioPeakHoldIEC ||            m_type == AudioPeakHoldIECLong) {        Qt::BrushStyle style = Qt::SolidPattern;        int medium = m_velocityColour->getMediumKnee(),                     loud = m_velocityColour->getLoudKnee();        if (m_alignment == Vertical) {            if (h > loud) {                paint->setPen(m_velocityColour->getLoudColour());                paint->setBrush(QBrush(m_velocityColour->getLoudColour(),                                       style));                paint->drawRect(x, y, w, h - loud);            }        } else {            if (w > loud) {                paint->setPen(m_velocityColour->getLoudColour());                paint->setBrush(QBrush(m_velocityColour->getLoudColour(),                                       style));                paint->drawRect(x + loud, y, w - loud, h);            }        }        if (m_alignment == Vertical) {            if (h > medium) {                paint->setPen(m_velocityColour->getMediumColour());                paint->setBrush(QBrush(m_velocityColour->getMediumColour(),                                       style));                paint->drawRect(x, y + (h > loud ? (h - loud) : 0),                                w, std::min(h - medium, loud - medium));            }        } else {            if (w > medium) {                paint->setPen(m_velocityColour->getMediumColour());                paint->setBrush(QBrush(m_velocityColour->getMediumColour(),                                       style));                paint->drawRect(x + medium, y,                                std::min(w - medium, loud - medium), h);            }        }        if (m_alignment == Vertical) {            paint->setPen(m_velocityColour->getQuietColour());            paint->setBrush(QBrush(m_velocityColour->getQuietColour(),                                   style));            paint->drawRect(x, y + (h > medium ? (h - medium) : 0),                            w, std::min(h, medium));        } else {            paint->setPen(m_velocityColour->getQuietColour());            paint->setBrush(QBrush(m_velocityColour->getQuietColour(),                                   style));            paint->drawRect(x, y, std::min(w, medium), h);        }    } else {        if (channel == 0) {            QColor mixedColour = m_velocityColour->getColour(m_levelLeft);            paint->setPen(mixedColour);            paint->setBrush(mixedColour);        } else {            QColor mixedColour = m_velocityColour->getColour(m_levelRight);            paint->setPen(mixedColour);            paint->setBrush(mixedColour);        }        //        RG_DEBUG << "VUMeter::drawColouredBar - level = " << m_levelLeft << endl;        paint->drawRect(x, y, w, h);    }}voidVUMeter::drawMeterLevel(QPainter* paint){    int medium = m_velocityColour->getMediumKnee(),                 loud = m_velocityColour->getLoudKnee();    if (m_stereo) {        if (m_alignment == VUMeter::Vertical) {            int hW = width() / 2;            int midWidth = 1;            if (m_hasRecord) {                if (width() > 10) {                    midWidth = 2;                }            }            // Draw the left bar            //            int y = height() - (m_levelLeft * height()) / m_maxLevel;            int ry = height() - (m_recordLevelLeft * height()) / m_maxLevel;            drawColouredBar(paint, 0, 0, y, hW - midWidth, height() - y);            if (m_hasRecord) {                drawColouredBar(paint, 0, hW - midWidth, ry, midWidth + 1, height() - ry);            }            paint->setPen(m_background);            paint->setBrush(m_background);            paint->drawRect(0, 0, hW - midWidth, y);            if (m_hasRecord) {                paint->drawRect(hW - midWidth, 0, midWidth + 1, ry);            }            if (m_showPeakLevel) {                int h = (m_peakLevelLeft * height()) / m_maxLevel;                y = height() - h;                if (h > loud) {                    paint->setPen(Qt::red); // brighter than the red meter bar                    paint->drawLine(0, y - 1, hW - midWidth - 1, y - 1);                    paint->drawLine(0, y + 1, hW - midWidth - 1, y + 1);                }                paint->setPen(Qt::white);                paint->drawLine(0, y, hW - midWidth - 1, y);            }            // Draw the right bar            //            y = height() - (m_levelRight * height()) / m_maxLevel;            ry = height() - (m_recordLevelRight * height()) / m_maxLevel;            drawColouredBar(paint, 1, hW + midWidth, y, hW - midWidth, height() - y);            if (m_hasRecord) {                drawColouredBar(paint, 1, hW, ry, midWidth + 1, height() - ry);            }            paint->setPen(m_background);            paint->setBrush(m_background);            paint->drawRect(hW + midWidth, 0, hW - midWidth + 1, y);            if (m_hasRecord) {                paint->drawRect(hW, 0, midWidth, ry);            }            if (m_showPeakLevel) {                int h = (m_peakLevelRight * height()) / m_maxLevel;                y = height() - h;                if (h > loud) {                    paint->setPen(Qt::red); // brighter than the red meter bar                    paint->drawLine(hW + midWidth, y - 1, width(), y - 1);                    paint->drawLine(hW + midWidth, y + 1, width(), y + 1);                }                paint->setPen(Qt::white);                paint->setBrush(Qt::white);                paint->drawLine(hW + midWidth, y, width(), y);            }        } else // horizontal        {            paint->setPen(m_background);            paint->setBrush(m_background);            paint->drawRect(0, 0, width(), height());            int x = (m_levelLeft * width()) / m_maxLevel;            if (x > 0)                paint->drawRect(0, 0, x, height());            if (m_showPeakLevel) {                paint->setPen(Qt::white);                paint->setBrush(Qt::white);                // show peak level                x = m_peakLevelLeft * width() / m_maxLevel;                if (x < (width() - 1))                    x++;                else                    x = width() - 1;                paint->drawLine(x, 0, x, height());            }        }    } else {        // Paint a vertical meter according to type        //        if (m_alignment == VUMeter::Vertical) {            int y = height() - (m_levelLeft * height()) / m_maxLevel;            drawColouredBar(paint, 0, 0, y, width(), height());            paint->setPen(m_background);            paint->setBrush(m_background);            paint->drawRect(0, 0, width(), y);            /*            RG_DEBUG << "VUMeter::drawMeterLevel - height = " << height()                      << ", vertical rect height = " << y << endl;                     */            if (m_showPeakLevel) {                paint->setPen(Qt::white);                paint->setBrush(Qt::white);                y = height() - (m_peakLevelLeft * height()) / m_maxLevel;                paint->drawLine(0, y, width(), y);            }        } else {            int x = (m_levelLeft * width()) / m_maxLevel;            if (x > 0)                drawColouredBar(paint, 0, 0, 0, x, height());            paint->setPen(m_background);            paint->setBrush(m_background);            paint->drawRect(x, 0, width() - x, height());            if (m_showPeakLevel) {                paint->setPen(Qt::white);                paint->setBrush(Qt::white);                // show peak level                x = (m_peakLevelLeft * width()) / m_maxLevel;                if (x < (width() - 1))                    x++;                else                    x = width() - 1;                paint->drawLine(x, 0, x, height());            }        }    }}voidVUMeter::slotReduceLevelRight(){    m_levelStepRight = int(m_levelRight) * m_baseLevelStep / 100 + 1;    if (m_levelStepRight < 1)        m_levelStepRight = 1;    m_recordLevelStepRight = int(m_recordLevelRight) * m_baseLevelStep / 100 + 1;    if (m_recordLevelStepRight < 1)        m_recordLevelStepRight = 1;    if (m_levelRight > 0)        m_levelRight -= m_levelStepRight;    if (m_recordLevelRight > 0)        m_recordLevelRight -= m_recordLevelStepRight;    if (m_levelRight <= 0) {        m_levelRight = 0;        m_peakLevelRight = 0;    }    if (m_recordLevelRight <= 0)        m_recordLevelRight = 0;    if (m_levelRight == 0 && m_recordLevelRight == 0) {        // Always stop the timer when we don't need it        if (m_fallTimerRight)            m_fallTimerRight->stop();        meterStop();    }    QPainter paint(this);    drawMeterLevel(&paint);}voidVUMeter::slotReduceLevelLeft(){    m_levelStepLeft = int(m_levelLeft) * m_baseLevelStep / 100 + 1;    if (m_levelStepLeft < 1)        m_levelStepLeft = 1;    m_recordLevelStepLeft = int(m_recordLevelLeft) * m_baseLevelStep / 100 + 1;    if (m_recordLevelStepLeft < 1)        m_recordLevelStepLeft = 1;    if (m_levelLeft > 0)        m_levelLeft -= m_levelStepLeft;    if (m_recordLevelLeft > 0)        m_recordLevelLeft -= m_recordLevelStepLeft;    if (m_levelLeft <= 0) {        m_levelLeft = 0;        m_peakLevelLeft = 0;    }    if (m_recordLevelLeft <= 0)        m_recordLevelLeft = 0;    if (m_levelLeft == 0 && m_recordLevelLeft == 0) {        // Always stop the timer when we don't need it        if (m_fallTimerLeft)            m_fallTimerLeft->stop();        meterStop();    }    QPainter paint(this);    drawMeterLevel(&paint);}voidVUMeter::slotStopShowingPeakRight(){    m_peakLevelRight = 0;}voidVUMeter::slotStopShowingPeakLeft(){    m_peakLevelLeft = 0;}}#include "VUMeter.moc"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -