mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-29 15:12:34 +02:00
2021-02-25 Fred Gleason <fredg@paravelsystems.com>
* Fixed regressions in metering code that caused visual artifacts. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
776e3ca842
commit
7ed04f1392
@ -21200,3 +21200,7 @@
|
||||
groups.
|
||||
2021-02-25 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Fixed various regressions in rdadmin(1).
|
||||
2021-02-25 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Fixed a regression in 'RDCae' that broke audio play-out.
|
||||
2021-02-25 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Fixed regressions in metering code that caused visual artifacts.
|
||||
|
@ -157,7 +157,7 @@ bool RDCae::loadPlay(int card,QString name,int *stream,int *handle)
|
||||
{
|
||||
int count=0;
|
||||
|
||||
SendCommand("LP "+QString().sprintf(" %d ",card)+name);
|
||||
SendCommand("LP "+QString().sprintf(" %d ",card)+name+"!");
|
||||
|
||||
//
|
||||
// This is really warty, but needed to make the method 'synchronous'
|
||||
|
@ -909,7 +909,7 @@ void RDEditAudio::xFullIn()
|
||||
(1.0-edit_factor_x/edit_max_factor_x)));
|
||||
CenterDisplay();
|
||||
DrawMaps();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -928,7 +928,7 @@ void RDEditAudio::xUp()
|
||||
}
|
||||
CenterDisplay();
|
||||
DrawMaps();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -947,7 +947,7 @@ void RDEditAudio::xDown()
|
||||
}
|
||||
CenterDisplay();
|
||||
DrawMaps();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -959,7 +959,7 @@ void RDEditAudio::xFullOut()
|
||||
edit_hscroll->setRange(0,0);
|
||||
CenterDisplay();
|
||||
DrawMaps();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -969,7 +969,7 @@ void RDEditAudio::yUp()
|
||||
if(edit_gain>-21) {
|
||||
edit_gain-=3;
|
||||
DrawMaps();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -979,7 +979,7 @@ void RDEditAudio::yDown()
|
||||
if(edit_gain<0) {
|
||||
edit_gain+=3;
|
||||
DrawMaps();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1007,7 +1007,7 @@ void RDEditAudio::gotoEndData()
|
||||
void RDEditAudio::hscrollData(int value)
|
||||
{
|
||||
DrawMaps();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -1489,7 +1489,7 @@ void RDEditAudio::gainChangedData()
|
||||
setText(QString().sprintf("%4.1f ",
|
||||
(double)edit_gain_control->value()/100.0)+tr("dB"));
|
||||
DrawMaps();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -1529,7 +1529,7 @@ void RDEditAudio::gainTimerData()
|
||||
setText(QString().sprintf("%4.1f ",
|
||||
(double)edit_gain_control->value()/100.0)+tr("dB"));
|
||||
DrawMaps();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// This implements a widget that represents a stereo audio level meter,
|
||||
// complete with labels and scale.
|
||||
//
|
||||
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License
|
||||
@ -19,10 +19,12 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "rdplaymeter.h"
|
||||
|
||||
RDPlayMeter::RDPlayMeter(RDSegMeter::Orientation orient,QWidget *parent)
|
||||
: RDWidget(parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
meter_label=QString("");
|
||||
orientation=orient;
|
||||
@ -30,6 +32,13 @@ RDPlayMeter::RDPlayMeter(RDSegMeter::Orientation orient,QWidget *parent)
|
||||
meter=new RDSegMeter(orientation,this);
|
||||
meter->setSegmentSize(5);
|
||||
meter->setSegmentGap(1);
|
||||
|
||||
//
|
||||
// Set Colors
|
||||
//
|
||||
QPalette p=palette();
|
||||
p.setColor(QPalette::Window,Qt::black);
|
||||
setPalette(p);
|
||||
}
|
||||
|
||||
|
||||
@ -121,26 +130,29 @@ void RDPlayMeter::setGeometry(int x,int y,int w,int h)
|
||||
}
|
||||
else {
|
||||
switch(orientation) {
|
||||
case RDSegMeter::Left:
|
||||
meter->setGeometry(2,2,w-4-h,h-4);
|
||||
label_font=QFont(font().family(),height()-2,QFont::Bold);
|
||||
label_font.setPixelSize(height()-2);
|
||||
break;
|
||||
case RDSegMeter::Right:
|
||||
meter->setGeometry(2+h,2,w-4-h,h-4);
|
||||
label_font=QFont(font().family(),height()-2,QFont::Bold);
|
||||
label_font.setPixelSize(height()-2);
|
||||
break;
|
||||
case RDSegMeter::Up:
|
||||
meter->setGeometry(2,2,w-4,h-4-w);
|
||||
label_font=QFont(font().family(),width()-2,QFont::Bold);
|
||||
label_font.setPixelSize(width()-2);
|
||||
break;
|
||||
case RDSegMeter::Down:
|
||||
meter->setGeometry(2,2+width(),w-4,h-4-w);
|
||||
label_font=QFont(font().family(),width()-2,QFont::Bold);
|
||||
label_font.setPixelSize(width()-2);
|
||||
break;
|
||||
case RDSegMeter::Left:
|
||||
meter->setGeometry(2,2,w-4-h,h-4);
|
||||
label_font=QFont("helvetica",height()-2,QFont::Bold);
|
||||
label_font.setPixelSize(height()-2);
|
||||
break;
|
||||
|
||||
case RDSegMeter::Right:
|
||||
meter->setGeometry(2+h,2,w-4-h,h-4);
|
||||
label_font=QFont("helvetica",height()-2,QFont::Bold);
|
||||
label_font.setPixelSize(height()-2);
|
||||
break;
|
||||
|
||||
case RDSegMeter::Up:
|
||||
meter->setGeometry(2,2,w-4,h-4-w);
|
||||
label_font=QFont("helvetica",width()-2,QFont::Bold);
|
||||
label_font.setPixelSize(width()-2);
|
||||
break;
|
||||
|
||||
case RDSegMeter::Down:
|
||||
meter->setGeometry(2,2+width(),w-4,h-4-w);
|
||||
label_font=QFont("helvetica",width()-2,QFont::Bold);
|
||||
label_font.setPixelSize(width()-2);
|
||||
break;
|
||||
}
|
||||
makeFont();
|
||||
}
|
||||
@ -201,7 +213,7 @@ void RDPlayMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
// Setup
|
||||
//
|
||||
QPainter *p=new QPainter(this);
|
||||
p->fillRect(0,0,width(),height(),Qt::black);
|
||||
p->fillRect(0,0,size().width(),size().height(),Qt::black);
|
||||
p->setFont(label_font);
|
||||
p->setPen(Qt::white);
|
||||
if(!meter_label.isEmpty()) {
|
||||
@ -224,35 +236,39 @@ void RDPlayMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
}
|
||||
}
|
||||
p->end();
|
||||
delete p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RDPlayMeter::makeFont()
|
||||
{
|
||||
switch(orientation) {
|
||||
case RDSegMeter::Left:
|
||||
label_font=QFont(font().family(),height()-2,QFont::Bold);
|
||||
label_font=QFont("helvetica",height()-2,QFont::Bold);
|
||||
label_font.setPixelSize(height()-2);
|
||||
meter_label_x=(height()-QFontMetrics(label_font).width(meter_label))/2;
|
||||
meter_label_x=(height()-QFontMetrics(label_font).
|
||||
width(meter_label))/2;
|
||||
break;
|
||||
|
||||
case RDSegMeter::Right:
|
||||
label_font=QFont(font().family(),height()-2,QFont::Bold);
|
||||
label_font=QFont("helvetica",height()-2,QFont::Bold);
|
||||
label_font.setPixelSize(height()-2);
|
||||
meter_label_x=(height()-QFontMetrics(label_font).width(meter_label))/2;
|
||||
meter_label_x=(height()-QFontMetrics(label_font).
|
||||
width(meter_label))/2;
|
||||
break;
|
||||
|
||||
case RDSegMeter::Up:
|
||||
label_font=QFont(font().family(),width()-2,QFont::Bold);
|
||||
label_font=QFont("helvetica",width()-2,QFont::Bold);
|
||||
label_font.setPixelSize(width()-2);
|
||||
meter_label_x=(width()-QFontMetrics(label_font).width(meter_label))/2;
|
||||
meter_label_x=(width()-QFontMetrics(label_font).
|
||||
width(meter_label))/2;
|
||||
break;
|
||||
|
||||
case RDSegMeter::Down:
|
||||
label_font=QFont(font().family(),width()-2,QFont::Bold);
|
||||
label_font=QFont("helvetica",width()-2,QFont::Bold);
|
||||
label_font.setPixelSize(width()-2);
|
||||
meter_label_x=(width()-QFontMetrics(label_font).width(meter_label))/2;
|
||||
meter_label_x=(width()-QFontMetrics(label_font).
|
||||
width(meter_label))/2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// A playback audio meter widget.
|
||||
//
|
||||
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License
|
||||
@ -21,10 +21,12 @@
|
||||
#ifndef RDPLAYMETER_H
|
||||
#define RDPLAYMETER_H
|
||||
|
||||
#include <rdsegmeter.h>
|
||||
#include <rdwidget.h>
|
||||
#include <QWidget>
|
||||
|
||||
class RDPlayMeter : public RDWidget
|
||||
#include <rdsegmeter.h>
|
||||
|
||||
|
||||
class RDPlayMeter : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -17,6 +17,18 @@
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
//
|
||||
|
||||
#include <QString>
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
#include <QPixmap>
|
||||
#include <QPaintEvent>
|
||||
#include <stdio.h>
|
||||
#include <QSlider>
|
||||
#include <QSizePolicy>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "rdsegmeter.h"
|
||||
|
||||
@ -24,9 +36,6 @@ RDSegMeter::RDSegMeter(RDSegMeter::Orientation o,QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
orient=o;
|
||||
QPalette pal=palette();
|
||||
pal.setColor(QPalette::Background,Qt::black);
|
||||
setPalette(pal);
|
||||
dark_low_color=QColor(DEFAULT_DARK_LOW_COLOR);
|
||||
dark_high_color=QColor(DEFAULT_DARK_HIGH_COLOR);
|
||||
dark_clip_color=QColor(DEFAULT_DARK_CLIP_COLOR);
|
||||
@ -64,7 +73,7 @@ void RDSegMeter::setRange(int min,int max)
|
||||
{
|
||||
range_min=min;
|
||||
range_max=max;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -72,7 +81,7 @@ void RDSegMeter::setDarkLowColor(QColor color)
|
||||
{
|
||||
if(dark_low_color!=color) {
|
||||
dark_low_color=color;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +90,7 @@ void RDSegMeter::setDarkHighColor(QColor color)
|
||||
{
|
||||
if(dark_high_color!=color) {
|
||||
dark_high_color=color;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +99,7 @@ void RDSegMeter::setDarkClipColor(QColor color)
|
||||
{
|
||||
if(dark_clip_color!=color) {
|
||||
dark_clip_color=color;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +108,7 @@ void RDSegMeter::setLowColor(QColor color)
|
||||
{
|
||||
if(low_color!=color) {
|
||||
low_color=color;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +117,7 @@ void RDSegMeter::setHighColor(QColor color)
|
||||
{
|
||||
if(high_color!=color) {
|
||||
high_color=color;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +126,7 @@ void RDSegMeter::setClipColor(QColor color)
|
||||
{
|
||||
if(clip_color!=color) {
|
||||
clip_color=color;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,7 +135,7 @@ void RDSegMeter::setHighThreshold(int level)
|
||||
{
|
||||
if(high_threshold!=level) {
|
||||
high_threshold=level;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +144,7 @@ void RDSegMeter::setClipThreshold(int level)
|
||||
{
|
||||
if(clip_threshold!=level) {
|
||||
clip_threshold=level;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,16 +159,16 @@ void RDSegMeter::setMode(RDSegMeter::Mode mode)
|
||||
{
|
||||
seg_mode=mode;
|
||||
switch(seg_mode) {
|
||||
case RDSegMeter::Independent:
|
||||
if(peak_timer->isActive()) {
|
||||
peak_timer->stop();
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Peak:
|
||||
if(!peak_timer->isActive()) {
|
||||
peak_timer->start(PEAK_HOLD_TIME);
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Independent:
|
||||
if(peak_timer->isActive()) {
|
||||
peak_timer->stop();
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Peak:
|
||||
if(!peak_timer->isActive()) {
|
||||
peak_timer->start(PEAK_HOLD_TIME);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +177,7 @@ void RDSegMeter::setSolidBar(int level)
|
||||
{
|
||||
if((seg_mode==RDSegMeter::Independent)&&(solid_bar!=level)) {
|
||||
solid_bar=level;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,7 +186,7 @@ void RDSegMeter::setFloatingBar(int level)
|
||||
{
|
||||
if((seg_mode==RDSegMeter::Independent)&&(solid_bar!=level)) {
|
||||
floating_bar=level;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,7 +202,7 @@ void RDSegMeter::setPeakBar(int level)
|
||||
if(solid_bar<range_min) {
|
||||
floating_bar=solid_bar;
|
||||
}
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,7 +211,7 @@ void RDSegMeter::setSegmentSize(int size)
|
||||
{
|
||||
if(seg_size!=size) {
|
||||
seg_size=size;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,7 +220,6 @@ void RDSegMeter::setSegmentGap(int gap)
|
||||
{
|
||||
if(seg_gap!=gap) {
|
||||
seg_gap=gap;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,10 +237,10 @@ void RDSegMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
// Setup
|
||||
//
|
||||
QPixmap pix(this->size());
|
||||
pix.fill(this,0,0);
|
||||
|
||||
int seg_total=seg_size+seg_gap;
|
||||
QPainter *p=new QPainter(&pix);
|
||||
p->fillRect(0,0,width(),height(),Qt::black);
|
||||
|
||||
low_region=0;
|
||||
high_region=0;
|
||||
clip_region=0;
|
||||
@ -243,14 +251,14 @@ void RDSegMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
// Set Orientation
|
||||
//
|
||||
switch(orient) {
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Up:
|
||||
p->translate(width(),height());
|
||||
p->rotate(180);
|
||||
break;
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Up:
|
||||
p->translate(width(),height());
|
||||
p->rotate(180);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
@ -263,26 +271,27 @@ void RDSegMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
op_pt=solid_bar;
|
||||
}
|
||||
switch(orient) {
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
low_region=(int)((double)(op_pt-range_min)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(op_pt>range_min) {
|
||||
for(int i=0;i<low_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),low_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
low_region=(int)((double)(op_pt-range_min)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(op_pt>range_min) {
|
||||
for(int i=0;i<low_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,low_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
low_region=(int)((double)(op_pt-range_min)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(op_pt>range_min) {
|
||||
for(int i=0;i<low_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),low_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
low_region=(int)((double)(op_pt-range_min)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(op_pt>range_min) {
|
||||
for(int i=0;i<low_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,low_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
@ -295,26 +304,27 @@ void RDSegMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
op_pt=solid_bar;
|
||||
}
|
||||
switch(orient) {
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
high_region=(int)((double)(op_pt-high_threshold)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(op_pt>high_threshold) {
|
||||
for(int i=low_region;i<low_region+high_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),high_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
high_region=(int)((double)(op_pt-high_threshold)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(op_pt>high_threshold) {
|
||||
for(int i=low_region;i<low_region+high_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,high_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
high_region=(int)((double)(op_pt-high_threshold)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(op_pt>high_threshold) {
|
||||
for(int i=low_region;i<low_region+high_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),high_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
high_region=(int)((double)(op_pt-high_threshold)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(op_pt>high_threshold) {
|
||||
for(int i=low_region;i<low_region+high_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,high_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
@ -327,54 +337,56 @@ void RDSegMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
op_pt=solid_bar;
|
||||
}
|
||||
switch(orient) {
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
clip_region=(int)((double)(op_pt-clip_threshold)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(op_pt>clip_threshold) {
|
||||
for(int i=low_region+high_region;
|
||||
i<low_region+high_region+clip_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),clip_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
clip_region=(int)((double)(op_pt-range_min)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(op_pt>clip_threshold) {
|
||||
for(int i=low_region+high_region;
|
||||
i<low_region+high_region+clip_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,clip_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
clip_region=(int)((double)(op_pt-clip_threshold)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(op_pt>clip_threshold) {
|
||||
for(int i=low_region+high_region;
|
||||
i<low_region+high_region+clip_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),clip_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
clip_region=(int)((double)(op_pt-range_min)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(op_pt>clip_threshold) {
|
||||
for(int i=low_region+high_region;
|
||||
i<low_region+high_region+clip_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,clip_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// The dark low range
|
||||
//
|
||||
switch(orient) {
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
dark_low_region=(int)((double)(high_threshold-range_min)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(op_pt<high_threshold) {
|
||||
for(int i=low_region;i<dark_low_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),dark_low_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
dark_low_region=(int)((double)(high_threshold-range_min)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(op_pt<high_threshold) {
|
||||
for(int i=low_region;i<dark_low_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,dark_low_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
dark_low_region=(int)((double)(high_threshold-range_min)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(op_pt<high_threshold) {
|
||||
for(int i=low_region;i<dark_low_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),dark_low_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
dark_low_region=(int)((double)(high_threshold-range_min)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(op_pt<high_threshold) {
|
||||
for(int i=low_region;i<dark_low_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,dark_low_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
@ -387,27 +399,28 @@ void RDSegMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
op_pt=dark_low_region;
|
||||
}
|
||||
switch(orient) {
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
dark_high_region=(int)((double)(clip_threshold-range_min)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(solid_bar<clip_threshold) {
|
||||
for(int i=op_pt;
|
||||
i<dark_high_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),dark_high_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
dark_high_region=(int)((double)(clip_threshold-range_min)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(solid_bar<clip_threshold) {
|
||||
for(int i=op_pt;i<dark_high_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,dark_high_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
dark_high_region=(int)((double)(clip_threshold-range_min)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(solid_bar<clip_threshold) {
|
||||
for(int i=op_pt;
|
||||
i<dark_high_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),dark_high_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
dark_high_region=(int)((double)(clip_threshold-range_min)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(solid_bar<clip_threshold) {
|
||||
for(int i=op_pt;i<dark_high_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,dark_high_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
@ -420,27 +433,28 @@ void RDSegMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
op_pt=dark_high_region;
|
||||
}
|
||||
switch(orient) {
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
dark_clip_region=(int)((double)(range_max-range_min)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(solid_bar<range_max) {
|
||||
for(int i=op_pt;i<dark_clip_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),dark_clip_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
dark_clip_region=(int)((double)(range_max-range_min)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(solid_bar<range_max) {
|
||||
for(int i=op_pt;
|
||||
i<dark_clip_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,dark_clip_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
dark_clip_region=(int)((double)(range_max-range_min)/
|
||||
(double)(range_max-range_min)*width()/seg_total);
|
||||
if(solid_bar<range_max) {
|
||||
for(int i=op_pt;i<dark_clip_region;i++) {
|
||||
p->fillRect(i*seg_total,0,seg_size,height(),dark_clip_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
dark_clip_region=(int)((double)(range_max-range_min)/
|
||||
(double)(range_max-range_min)*height()/seg_total);
|
||||
if(solid_bar<range_max) {
|
||||
for(int i=op_pt;
|
||||
i<dark_clip_region;i++) {
|
||||
p->fillRect(0,i*seg_total,width(),seg_size,dark_clip_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
@ -457,21 +471,21 @@ void RDSegMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
float_color=clip_color;
|
||||
}
|
||||
switch(orient) {
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
float_region=(int)((double)(floating_bar-range_min)/
|
||||
(double)(range_max-range_min)*width());
|
||||
float_region=seg_total*(float_region/seg_total);
|
||||
p->fillRect(float_region,0,seg_size,height(),float_color);
|
||||
break;
|
||||
case RDSegMeter::Left:
|
||||
case RDSegMeter::Right:
|
||||
float_region=(int)((double)(floating_bar-range_min)/
|
||||
(double)(range_max-range_min)*width());
|
||||
float_region=seg_total*(float_region/seg_total);
|
||||
p->fillRect(float_region,0,seg_size,height(),float_color);
|
||||
break;
|
||||
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
float_region=(int)((double)(floating_bar-range_min)/
|
||||
(double)(range_max-range_min)*height());
|
||||
float_region=seg_total*(float_region/seg_total);
|
||||
p->fillRect(0,float_region,width(),seg_size,float_color);
|
||||
break;
|
||||
case RDSegMeter::Down:
|
||||
case RDSegMeter::Up:
|
||||
float_region=(int)((double)(floating_bar-range_min)/
|
||||
(double)(range_max-range_min)*height());
|
||||
float_region=seg_total*(float_region/seg_total);
|
||||
p->fillRect(0,float_region,width(),seg_size,float_color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -486,8 +500,5 @@ void RDSegMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
void RDSegMeter::peakData()
|
||||
{
|
||||
floating_bar=solid_bar;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -17,11 +17,15 @@
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef RDSEGMETER_H
|
||||
#define RDSEGMETER_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
#include <QSizePolicy>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
@ -40,7 +44,6 @@
|
||||
*/
|
||||
#define PEAK_HOLD_TIME 750
|
||||
|
||||
|
||||
class RDSegMeter : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -3,7 +3,7 @@
|
||||
// This implements a widget that represents a stereo audio level meter,
|
||||
// complete with labels and scale.
|
||||
//
|
||||
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License
|
||||
@ -19,24 +19,10 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <qwidget.h>
|
||||
#include <qstring.h>
|
||||
#include <qfont.h>
|
||||
#include <qfontmetrics.h>
|
||||
#include <qcolor.h>
|
||||
#include <qpainter.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qsize.h>
|
||||
//Added by qt3to4:
|
||||
#include <QPixmap>
|
||||
#include <QPaintEvent>
|
||||
#include <stdio.h>
|
||||
#include <qslider.h>
|
||||
#include <qsizepolicy.h>
|
||||
#include <qmessagebox.h>
|
||||
|
||||
#include <rdsegmeter.h>
|
||||
#include <rdstereometer.h>
|
||||
#include "rdsegmeter.h"
|
||||
#include "rdstereometer.h"
|
||||
|
||||
RDStereoMeter::RDStereoMeter(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@ -46,9 +32,6 @@ RDStereoMeter::RDStereoMeter(QWidget *parent)
|
||||
clip_light_on=false;
|
||||
label_x=0;
|
||||
meter_label=QString("");
|
||||
QPalette pal=palette();
|
||||
pal.setColor(QPalette::Background,Qt::black);
|
||||
setPalette(pal);
|
||||
left_meter=new RDSegMeter(RDSegMeter::Right,this);
|
||||
left_meter->setGeometry(25,10,300,10);
|
||||
left_meter->setRange(-4600,-800);
|
||||
@ -76,6 +59,13 @@ RDStereoMeter::RDStereoMeter(QWidget *parent)
|
||||
meter_label_font.setPixelSize(18);
|
||||
meter_scale_font=QFont("System",12,QFont::Bold);
|
||||
meter_scale_font.setPixelSize(12);
|
||||
|
||||
//
|
||||
// Set Colors
|
||||
//
|
||||
QPalette p=palette();
|
||||
p.setColor(QPalette::Window,Qt::black);
|
||||
setPalette(p);
|
||||
}
|
||||
|
||||
|
||||
@ -286,21 +276,21 @@ void RDStereoMeter::paintEvent(QPaintEvent *paintEvent)
|
||||
// Setup
|
||||
//
|
||||
QPixmap pix(this->size());
|
||||
pix.fill(this,0,0);
|
||||
QPainter *p=new QPainter(&pix);
|
||||
p->fillRect(0,0,width(),height(),Qt::black);
|
||||
p->setBrush(QColor(Qt::white));
|
||||
p->setPen(QColor(Qt::white));
|
||||
p->setFont(meter_scale_font);
|
||||
p->drawText(10,20,tr("L"));
|
||||
p->drawText(10,50,tr("R"));
|
||||
p->drawText(12,35,"-30");
|
||||
p->drawText(48,35,"-25");
|
||||
p->drawText(88,35,"-20");
|
||||
p->drawText(126,35,"-15");
|
||||
p->drawText(167,35,"-10");
|
||||
p->drawText(207,35,"-5");
|
||||
p->drawText(255,35,"0");
|
||||
p->drawText(314,35,"+8");
|
||||
p->drawText(38,35,"-35");
|
||||
p->drawText(77,35,"-30");
|
||||
p->drawText(116,35,"-25");
|
||||
p->drawText(153,35,"-20");
|
||||
p->drawText(191,35,"-15");
|
||||
p->drawText(229,35,"-10");
|
||||
p->drawText(267,35,"-5");
|
||||
p->drawText(317,35,"0");
|
||||
if(meter_label!=QString("")) {
|
||||
p->setFont(meter_label_font);
|
||||
p->drawText(label_x,72,meter_label);
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// A Stereo Audio Meter Widget
|
||||
//
|
||||
// (C) Copyright 2002,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License
|
||||
@ -17,19 +17,14 @@
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef RDSTEREOMETER_H
|
||||
#define RDSTEREOMETER_H
|
||||
|
||||
#include <qwidget.h>
|
||||
#include <qcolor.h>
|
||||
#include <qpainter.h>
|
||||
#include <qsize.h>
|
||||
#include <qsizepolicy.h>
|
||||
#include <qstring.h>
|
||||
//Added by qt3to4:
|
||||
#include <QPaintEvent>
|
||||
#include <rdsegmeter.h>
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
#include "rdsegmeter.h"
|
||||
|
||||
#define CLIP_LIGHT_COLOR Qt::red
|
||||
|
||||
|
@ -159,7 +159,7 @@ void PieCounter::start(int offset)
|
||||
{
|
||||
pie_time=pie_length-offset;
|
||||
pie_running=true;
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
|
||||
void PieCounter::setLogline(RDLogLine *logline)
|
||||
@ -173,7 +173,7 @@ void PieCounter::stop()
|
||||
pie_running=false;
|
||||
pie_time_label->hide();
|
||||
pie_talk_label->hide();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -218,7 +218,7 @@ void PieCounter::tickCounter()
|
||||
}
|
||||
else {
|
||||
pie_time_label->setText(QString().sprintf(":%02d",(1000+pie_time)/1000));
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user