aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortassaron2017-06-26 19:07:49 -0400
committertassaron2017-06-26 19:07:49 -0400
commita95ecd7e42b3e6b199f7bcdbe363faa8e765f869 (patch)
tree9ef6aaf8ba61eb0acd5706456528229c52b7ba62 /src
parent0c394d77e388adb91beee210a9b66652db9d17cb (diff)
added visualizer options + invalid presets get ignored
Diffstat (limited to 'src')
-rw-r--r--src/components/__base__.py1
-rw-r--r--src/components/original.py81
-rw-r--r--src/components/original.ui89
-rw-r--r--src/mainwindow.py1
-rw-r--r--src/presetmanager.py2
5 files changed, 148 insertions, 26 deletions
diff --git a/src/components/__base__.py b/src/components/__base__.py
index 9b04157..00601e7 100644
--- a/src/components/__base__.py
+++ b/src/components/__base__.py
@@ -11,6 +11,7 @@ class Component(QtCore.QObject):
def __init__(self, moduleIndex, compPos, core):
super().__init__()
self.currentPreset = None
+ self.canceled = False
self.moduleIndex = moduleIndex
self.compPos = compPos
self.core = core
diff --git a/src/components/original.py b/src/components/original.py
index 8450aa1..1aa72c9 100644
--- a/src/components/original.py
+++ b/src/components/original.py
@@ -20,11 +20,15 @@ class Component(__base__.Component):
def widget(self, parent):
self.parent = parent
self.visColor = (255, 255, 255)
+ self.scale = 20
+ self.y = 0
+ self.canceled = False
page = self.loadUi('original.ui')
page.comboBox_visLayout.addItem("Classic")
page.comboBox_visLayout.addItem("Split")
page.comboBox_visLayout.addItem("Bottom")
+ page.comboBox_visLayout.addItem("Top")
page.comboBox_visLayout.setCurrentIndex(0)
page.comboBox_visLayout.currentIndexChanged.connect(self.update)
page.lineEdit_visColor.setText('%s,%s,%s' % self.visColor)
@@ -33,13 +37,17 @@ class Component(__base__.Component):
% QColor(*self.visColor).name()
page.pushButton_visColor.setStyleSheet(btnStyle)
page.lineEdit_visColor.textChanged.connect(self.update)
+ page.spinBox_scale.valueChanged.connect(self.update)
+ page.spinBox_y.valueChanged.connect(self.update)
+
self.page = page
- self.canceled = False
return page
def update(self):
self.layout = self.page.comboBox_visLayout.currentIndex()
self.visColor = self.RGBFromString(self.page.lineEdit_visColor.text())
+ self.scale = self.page.spinBox_scale.value()
+ self.y = self.page.spinBox_y.value()
self.parent.drawPreview()
super().update()
@@ -51,21 +59,26 @@ class Component(__base__.Component):
% QColor(*pr['visColor']).name()
self.page.pushButton_visColor.setStyleSheet(btnStyle)
self.page.comboBox_visLayout.setCurrentIndex(pr['layout'])
+ self.page.spinBox_scale.setValue(pr['scale'])
+ self.page.spinBox_y.setValue(pr['y'])
def savePreset(self):
return {
'preset': self.currentPreset,
'layout': self.layout,
'visColor': self.visColor,
+ 'scale': self.scale,
+ 'y': self.y,
}
def previewRender(self, previewWorker):
spectrum = numpy.fromfunction(
- lambda x: 0.008*(x-128)**2, (255,), dtype="int16")
+ lambda x: float(self.scale)/2500*(x-128)**2, (255,), dtype="int16")
width = int(previewWorker.core.settings.value('outputWidth'))
height = int(previewWorker.core.settings.value('outputHeight'))
return self.drawBars(
- width, height, spectrum, self.visColor, self.layout)
+ width, height, spectrum, self.visColor, self.layout
+ )
def preFrameRender(self, **kwargs):
super().preFrameRender(**kwargs)
@@ -125,7 +138,7 @@ class Component(__base__.Component):
# filter the noise away
# y[y<80] = 0
- y = 20 * numpy.log10(y)
+ y = self.scale * numpy.log10(y)
y[numpy.isinf(y)] = 0
if lastSpectrum is not None:
@@ -168,40 +181,60 @@ class Component(__base__.Component):
im = self.blankFrame(width, height)
- if layout == 0:
- y = 0 - int(height/100*43)
+ if layout == 0: # Classic
+ y = self.y - int(height/100*43)
im.paste(imTop, (0, y), mask=imTop)
- y = 0 + int(height/100*43)
+ y = self.y + int(height/100*43)
im.paste(imBottom, (0, y), mask=imBottom)
- if layout == 1:
- y = 0 + int(height/100*10)
+ if layout == 1: # Split
+ y = self.y + int(height/100*10)
im.paste(imTop, (0, y), mask=imTop)
- y = 0 - int(height/100*10)
+ y = self.y - int(height/100*10)
im.paste(imBottom, (0, y), mask=imBottom)
- if layout == 2:
- y = 0 + int(height/100*10)
+ if layout == 2: # Bottom
+ y = self.y + int(height/100*10)
im.paste(imTop, (0, y), mask=imTop)
+ if layout == 3: # Top
+ y = self.y - int(height/100*10)
+ im.paste(imBottom, (0, y), mask=imBottom)
+
return im
def command(self, arg):
if not arg.startswith('preset=') and '=' in arg:
key, arg = arg.split('=', 1)
- if key == 'color':
- self.page.lineEdit_visColor.setText(arg)
- return
- elif key == 'layout':
- if arg == 'classic':
- self.page.comboBox_visLayout.setCurrentIndex(0)
- elif arg == 'split':
- self.page.comboBox_visLayout.setCurrentIndex(1)
- elif arg == 'bottom':
- self.page.comboBox_visLayout.setCurrentIndex(2)
- return
+ try:
+ if key == 'color':
+ self.page.lineEdit_visColor.setText(arg)
+ return
+ elif key == 'layout':
+ if arg == 'classic':
+ self.page.comboBox_visLayout.setCurrentIndex(0)
+ elif arg == 'split':
+ self.page.comboBox_visLayout.setCurrentIndex(1)
+ elif arg == 'bottom':
+ self.page.comboBox_visLayout.setCurrentIndex(2)
+ elif arg == 'top':
+ self.page.comboBox_visLayout.setCurrentIndex(3)
+ return
+ elif key == 'scale':
+ arg = int(arg)
+ self.page.spinBox_scale.setValue(arg)
+ return
+ elif key == 'y':
+ arg = int(arg)
+ self.page.spinBox_y.setValue(arg)
+ return
+ except ValueError:
+ print('You must enter a number.')
+ quit(1)
super().command(arg)
def commandHelp(self):
- print('Give a layout name:\n layout=[classic/split/bottom]')
+ print('Give a layout name:\n layout=[classic/split/bottom/top]')
print('Specify a color:\n color=255,255,255')
+ print('Visualizer scale (20 is default):\n scale=number')
+ print('Y position:\n y=number')
diff --git a/src/components/original.ui b/src/components/original.ui
index 5808653..8fa9b2b 100644
--- a/src/components/original.ui
+++ b/src/components/original.ui
@@ -34,7 +34,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Visualizer Layout</string>
+ <string>Layout</string>
</property>
</widget>
</item>
@@ -58,9 +58,45 @@
</spacer>
</item>
<item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Scale</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinBox_scale">
+ <property name="buttonSymbols">
+ <enum>QAbstractSpinBox::PlusMinus</enum>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="value">
+ <number>20</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>5</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
<widget class="QLabel" name="label_visColor">
<property name="text">
- <string>Visualizer Color</string>
+ <string>Color</string>
</property>
</widget>
</item>
@@ -89,6 +125,55 @@
</layout>
</item>
<item>
+ <layout class="QHBoxLayout" name="horizontalLayout_10">
+ <property name="leftMargin">
+ <number>4</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Y</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinBox_y">
+ <property name="buttonSymbols">
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="minimum">
+ <number>-5000</number>
+ </property>
+ <property name="maximum">
+ <number>5000</number>
+ </property>
+ <property name="singleStep">
+ <number>10</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>5</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/src/mainwindow.py b/src/mainwindow.py
index a406a7d..5068108 100644
--- a/src/mainwindow.py
+++ b/src/mainwindow.py
@@ -13,6 +13,7 @@ import video_thread
from presetmanager import PresetManager
from main import LoadDefaultSettings, disableWhenEncoding
+
class PreviewWindow(QtWidgets.QLabel):
def __init__(self, parent, img):
super(PreviewWindow, self).__init__()
diff --git a/src/presetmanager.py b/src/presetmanager.py
index 300b534..68679ec 100644
--- a/src/presetmanager.py
+++ b/src/presetmanager.py
@@ -79,6 +79,8 @@ class PresetManager(QtWidgets.QDialog):
continue
for preset in filenames:
compName = os.path.basename(os.path.dirname(dirpath))
+ if compName not in self.core.compNames:
+ continue
compVers = os.path.basename(dirpath)
try:
parseList.append((compName, int(compVers), preset))