-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vectorscope #5328
Merged
Merged
Vectorscope #5328
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f5b1e1d
first rough vectorscope structure draft
he29-net 11a0a62
Working prototype
he29-net e8fbae6
Finished HQ rendering mode and most of the basics
he29-net 5afa2ee
Add log scale, fine-tune interface, clean up code
he29-net dee9624
Final cleanup
he29-net 1b33965
Fix class and file name in VectorView.cpp header comment
he29-net 2d6efec
Code style changes
he29-net b4ca675
Optimizations
he29-net 763eae6
Allow color changes
he29-net 9f12710
Implement mouse wheel zoom
he29-net 84b4418
Check color validity when setting new color
he29-net 447c6b0
Forward key release to parent (by CYBERDEViLNL)
he29-net 48cfb33
* ColorChooser: initial color.
4c8884a
Merge pull request #1 from CYBERDEViLNL/he29_vectorscope
he29-net b043792
TEMP: print debug info around locks with explicit unlocks
he29-net 5d1e06e
Revert "TEMP: print debug info around locks with explicit unlocks"
he29-net 51b0178
fix locking of the useless_lock in LocklessRingBuffer.h
he29-net 0e3359e
Fix tabs in SaControls.h and VecControls.h
he29-net File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ SET(LMMS_PLUGIN_LIST | |
VstEffect | ||
watsyn | ||
waveshaper | ||
Vectorscope | ||
vibed | ||
Xpressive | ||
zynaddsubfx | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* ColorChooser.h - declaration and definition of ColorChooser class. | ||
* | ||
* Copyright (c) 2019 CYBERDEViLNL <cyberdevilnl/at/protonmail/dot/ch> | ||
* | ||
* This file is part of LMMS - https://lmms.io | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
|
||
#include <QColorDialog> | ||
#include <QApplication> | ||
#include <QKeyEvent> | ||
|
||
class ColorChooser: public QColorDialog | ||
{ | ||
public: | ||
ColorChooser(const QColor &initial, QWidget *parent): QColorDialog(initial, parent) {}; | ||
ColorChooser(QWidget *parent): QColorDialog(parent) {}; | ||
|
||
protected: | ||
// Forward key events to the parent to prevent stuck notes when the dialog gets focus | ||
void keyReleaseEvent(QKeyEvent *event) override | ||
{ | ||
QKeyEvent ke(*event); | ||
QApplication::sendEvent(parentWidget(), &ke); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
INCLUDE(BuildPlugin) | ||
BUILD_PLUGIN(vectorscope Vectorscope.cpp VecControls.cpp VecControlsDialog.cpp VectorView.cpp | ||
MOCFILES VecControls.h VecControlsDialog.h VectorView.h EMBEDDED_RESOURCES logo.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Vectorscope plugin | ||
|
||
## Overview | ||
|
||
Vectorscope is a simple stereo field visualizer. Samples are plotted into a graph, with left and right channels providing the coordinates. Previously drawn samples quickly fade away and are continuously replaced by new samples, creating a real-time plot of the most recently played samples. | ||
|
||
Similar to other effect plugins, the top-level widget is VecControlDialog. It displays configuration knobs and the main VectorView widget. The back-end configuration class is VecControls, which holds all models and configuration values. | ||
|
||
VectorView computes and shows the plot. It gets data for processing from the Vectorscope class, which handles the interface with LMMS. In order to avoid any stalling of the realtime-sensitive audio thread, data are exchanged through a lockless ring buffer. | ||
|
||
## Changelog | ||
|
||
1.0.0 2019-11-21 | ||
- initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* VecControls.cpp - definition of VecControls class. | ||
* | ||
* Copyright (c) 2019 Martin Pavelek <he29/dot/HS/at/gmail/dot/com> | ||
* | ||
* This file is part of LMMS - https://lmms.io | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
|
||
#include "VecControls.h" | ||
|
||
#include <QtXml/QDomElement> | ||
|
||
#include "VecControlsDialog.h" | ||
#include "Vectorscope.h" | ||
|
||
|
||
VecControls::VecControls(Vectorscope *effect) : | ||
EffectControls(effect), | ||
m_effect(effect), | ||
|
||
// initialize models and set default values | ||
m_persistenceModel(0.5f, 0.0f, 1.0f, 0.05f, this, tr("Display persistence amount")), | ||
m_logarithmicModel(false, this, tr("Logarithmic scale")), | ||
m_highQualityModel(false, this, tr("High quality")) | ||
{ | ||
// Colors (percentages include sRGB gamma correction) | ||
m_colorFG = QColor(60, 255, 130, 255); // ~LMMS green | ||
m_colorGrid = QColor(76, 80, 84, 128); // ~60 % gray (slightly cold / blue), 50 % transparent | ||
m_colorLabels = QColor(76, 80, 84, 255); // ~60 % gray (slightly cold / blue) | ||
m_colorOutline = QColor(30, 34, 38, 255); // ~40 % gray (slightly cold / blue) | ||
} | ||
|
||
|
||
// Create the VecControlDialog widget which handles display of GUI elements. | ||
EffectControlDialog* VecControls::createView() | ||
{ | ||
return new VecControlsDialog(this); | ||
} | ||
|
||
|
||
void VecControls::loadSettings(const QDomElement &element) | ||
{ | ||
m_persistenceModel.loadSettings(element, "Persistence"); | ||
m_logarithmicModel.loadSettings(element, "Logarithmic"); | ||
m_highQualityModel.loadSettings(element, "HighQuality"); | ||
} | ||
|
||
|
||
void VecControls::saveSettings(QDomDocument &document, QDomElement &element) | ||
{ | ||
m_persistenceModel.saveSettings(document, element, "Persistence"); | ||
m_logarithmicModel.saveSettings(document, element, "Logarithmic"); | ||
m_highQualityModel.saveSettings(document, element, "HighQuality"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* VecControls.h - declaration of VecControls class. | ||
* | ||
* Copyright (c) 2019 Martin Pavelek <he29/dot/HS/at/gmail/dot/com> | ||
* | ||
* This file is part of LMMS - https://lmms.io | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
|
||
#ifndef VECCONTROLS_H | ||
#define VECCONTROLS_H | ||
|
||
#include <QColor> | ||
|
||
#include "EffectControls.h" | ||
|
||
|
||
class Vectorscope; | ||
|
||
// Holds all the configuration values | ||
class VecControls : public EffectControls | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit VecControls(Vectorscope *effect); | ||
virtual ~VecControls() {} | ||
|
||
EffectControlDialog *createView() override; | ||
|
||
void saveSettings (QDomDocument &document, QDomElement &element) override; | ||
void loadSettings (const QDomElement &element) override; | ||
|
||
QString nodeName() const override {return "Vectorscope";} | ||
int controlCount() override {return 3;} | ||
|
||
private: | ||
Vectorscope *m_effect; | ||
|
||
FloatModel m_persistenceModel; | ||
BoolModel m_logarithmicModel; | ||
BoolModel m_highQualityModel; | ||
|
||
QColor m_colorFG; | ||
QColor m_colorGrid; | ||
QColor m_colorLabels; | ||
QColor m_colorOutline; | ||
|
||
friend class VecControlsDialog; | ||
friend class VectorView; | ||
}; | ||
#endif // VECCONTROLS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* VecControlsDialog.cpp - definition of VecControlsDialog class. | ||
* | ||
* Copyright (c) 2019 Martin Pavelek <he29/dot/HS/at/gmail/dot/com> | ||
* | ||
* This file is part of LMMS - https://lmms.io | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
|
||
#include "VecControlsDialog.h" | ||
|
||
#include <QGridLayout> | ||
#include <QLabel> | ||
#include <QResizeEvent> | ||
#include <QSizePolicy> | ||
#include <QWidget> | ||
|
||
#include "embed.h" | ||
#include "LedCheckbox.h" | ||
#include "VecControls.h" | ||
#include "Vectorscope.h" | ||
#include "VectorView.h" | ||
|
||
|
||
// The entire GUI layout is built here. | ||
VecControlsDialog::VecControlsDialog(VecControls *controls) : | ||
EffectControlDialog(controls), | ||
m_controls(controls) | ||
{ | ||
QVBoxLayout *master_layout = new QVBoxLayout; | ||
master_layout->setContentsMargins(0, 2, 0, 0); | ||
setLayout(master_layout); | ||
|
||
// Visualizer widget | ||
// The size of 768 pixels seems to offer a good balance of speed, accuracy and trace thickness. | ||
VectorView *display = new VectorView(controls, m_controls->m_effect->getBuffer(), 768, this); | ||
master_layout->addWidget(display); | ||
|
||
// Config area located inside visualizer | ||
QVBoxLayout *internal_layout = new QVBoxLayout(display); | ||
QHBoxLayout *config_layout = new QHBoxLayout(); | ||
QVBoxLayout *switch_layout = new QVBoxLayout(); | ||
internal_layout->addStretch(); | ||
internal_layout->addLayout(config_layout); | ||
config_layout->addLayout(switch_layout); | ||
|
||
// High-quality switch | ||
LedCheckBox *highQualityButton = new LedCheckBox(tr("HQ"), this); | ||
highQualityButton->setToolTip(tr("Double the resolution and simulate continuous analog-like trace.")); | ||
highQualityButton->setCheckable(true); | ||
highQualityButton->setMinimumSize(70, 12); | ||
highQualityButton->setModel(&controls->m_highQualityModel); | ||
switch_layout->addWidget(highQualityButton); | ||
|
||
// Log. scale switch | ||
LedCheckBox *logarithmicButton = new LedCheckBox(tr("Log. scale"), this); | ||
logarithmicButton->setToolTip(tr("Display amplitude on logarithmic scale to better see small values.")); | ||
logarithmicButton->setCheckable(true); | ||
logarithmicButton->setMinimumSize(70, 12); | ||
logarithmicButton->setModel(&controls->m_logarithmicModel); | ||
switch_layout->addWidget(logarithmicButton); | ||
|
||
config_layout->addStretch(); | ||
|
||
// Persistence knob | ||
Knob *persistenceKnob = new Knob(knobSmall_17, this); | ||
persistenceKnob->setModel(&controls->m_persistenceModel); | ||
persistenceKnob->setLabel(tr("Persist.")); | ||
persistenceKnob->setToolTip(tr("Trace persistence: higher amount means the trace will stay bright for longer time.")); | ||
persistenceKnob->setHintText(tr("Trace persistence"), ""); | ||
config_layout->addWidget(persistenceKnob); | ||
} | ||
|
||
|
||
// Suggest the best widget size. | ||
QSize VecControlsDialog::sizeHint() const | ||
{ | ||
return QSize(275, 300); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* VecControlsDialog.h - declatation of VecControlsDialog class. | ||
* | ||
* Copyright (c) 2019 Martin Pavelek <he29/dot/HS/at/gmail/dot/com> | ||
* | ||
* This file is part of LMMS - https://lmms.io | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
|
||
#ifndef VECCONTROLSDIALOG_H | ||
#define VECCONTROLSDIALOG_H | ||
|
||
#include "EffectControlDialog.h" | ||
|
||
class VecControls; | ||
|
||
//! Top-level widget holding the configuration GUI and vector display | ||
class VecControlsDialog : public EffectControlDialog | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit VecControlsDialog(VecControls *controls); | ||
virtual ~VecControlsDialog() {} | ||
|
||
bool isResizable() const override {return true;} | ||
QSize sizeHint() const override; | ||
|
||
private: | ||
VecControls *m_controls; | ||
}; | ||
|
||
#endif // VECCONTROLSDIALOG_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you use tabs after
QColor
intentionally?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh; probably not, I'm used to align signal definitions in VHDL so I may have done this without even realizing it. :))
I will fix it here and also in
SaControls.h
(where it originally came from). Good catch, thanks. :)