Skip to content

Commit f66eb99

Browse files
authored
v2.2.1 - fix #74, fix #92, add optional 64th bar to Classic Visualizer, improve Conway default (#93)
* update gitignore ignore profiling and coverage data * F1 opens help window, create appName variable, move undostack class * fix kaleidoscope effect, increase default Y values by +4 the increased y values allow the cells to continue animating for more than 60 minutes instead of 30 (at default 60f/t) * update version number * add minimumWidth to undo history window * Classic Visualizer: option to include 64th bar * Waveform component: fix #74 - new animation speed option * move shared visualizer code into toolkit * Waveform component: compress audio by default * Waveform component: fix 100% animation speed * new components receive random color * update to Qt 6 * fix pushbutton stylesheet * fix #92: replace ok/cancel with save/discard/cancel * remove obsolete PaintColor subclass * mv common shadow code into addShadow func * add 3rd option of ok/cancel back to showMessage the 3 options are: - ok - ok/cancel - save/discard/cancel * Image component: add shadow option * small test of rgbFromString * fix color tuple string * test another way to get comp names from CLI * rename component tests, add some more * Image component: scale shadow based on resolution * catch AttributeError if previewRender returns None * Text component: fix blur radius only able to increase the relativeWidgets system causes QDoubleSpinbox to only allow increases, because it really only works with integeres, so I changed the blur radius into a normal QSpinBox. I noted where the problem exists within component.py for future reference. This commit also removes an unneeded VerticalLayout from the ui file * remove unnecessary QVBoxLayout * paste shadow at x,y instead of using offset method * fix tests due to shadow change * don't print warning in connectWidget due to QFontComboBox
1 parent 8648984 commit f66eb99

36 files changed

+1556
-1270
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ __pycache__
55
build/
66
dist/
77
env/
8+
prof/
89
.venv/
910
.env/
1011
.vscode/
@@ -24,3 +25,5 @@ ffmpeg
2425
*.goutput*
2526
*.kate-swp
2627
*.code-workspace
28+
.coverage
29+
htmlcov/

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "uv_build"
66
name = "audio-visualizer-python"
77
description = "Create audio visualization videos from a GUI or commandline"
88
readme = "README.md"
9-
version = "2.2.0"
9+
version = "2.2.1"
1010
requires-python = ">= 3.12"
1111
license = "MIT"
1212
classifiers=[

src/avp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44

55

6-
__version__ = "2.2.0"
6+
__version__ = "2.2.1"
77

88

99
class Logger(logging.getLoggerClass()):

src/avp/component.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
setWidgetValue,
1919
connectWidget,
2020
rgbFromString,
21+
randomColor,
2122
blockSignals,
2223
)
2324

@@ -635,9 +636,17 @@ def pickColor_():
635636

636637
self._colorFuncs = {attr: makeColorFunc(attr) for attr in kwargs[kwarg]}
637638
for attr, func in self._colorFuncs.items():
639+
colorText = self._trackedWidgets[attr].text()
640+
if colorText == "":
641+
rndColor = randomColor()
642+
self._trackedWidgets[attr].setText(str(rndColor)[1:-1])
638643
self._colorWidgets[attr].clicked.connect(func)
639644
self._colorWidgets[attr].setStyleSheet(
640-
"QPushButton {" "background-color : #FFFFFF; outline: none; }"
645+
"QPushButton {"
646+
"background-color : %s; outline: none; }"
647+
% QColor(
648+
*rgbFromString(colorText) if colorText else rndColor
649+
).name()
641650
)
642651

643652
if kwarg == "relativeWidgets":
@@ -798,6 +807,7 @@ def updateRelativeWidget(self, attr):
798807
if oldUserValue == newUserValue and oldRelativeVal != newRelativeVal:
799808
# Float changed without pixel value changing, which
800809
# means the pixel value needs to be updated
810+
# TODO QDoubleSpinBox doesn't work with relativeWidgets because of this
801811
log.debug(
802812
"Updating %s #%s's relative widget: %s",
803813
self.__class__.name,

src/avp/components/color.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33

44
from ..component import Component
5-
from ..toolkit.frame import BlankFrame, FloodFrame, FramePainter, PaintColor
5+
from ..toolkit.frame import BlankFrame, FloodFrame, FramePainter
66

77

88
log = logging.getLogger("AVP.Components.Color")
@@ -152,13 +152,13 @@ def drawFrame(self, width, height):
152152
elif self.spread == 2:
153153
spread = QtGui.QGradient.Spread.RepeatSpread
154154
brush.setSpread(spread)
155-
brush.setColorAt(0.0, PaintColor(*self.color1))
155+
brush.setColorAt(0.0, QtGui.QColor(*self.color1))
156156
if self.trans:
157-
brush.setColorAt(1.0, PaintColor(0, 0, 0, 0))
157+
brush.setColorAt(1.0, QtGui.QColor(0, 0, 0, 0))
158158
elif self.fillType == 1 and self.stretch:
159-
brush.setColorAt(0.2, PaintColor(*self.color2))
159+
brush.setColorAt(0.2, QtGui.QColor(*self.color2))
160160
else:
161-
brush.setColorAt(1.0, PaintColor(*self.color2))
161+
brush.setColorAt(1.0, QtGui.QColor(*self.color2))
162162
image.setBrush(brush)
163163
image.drawRect(self.x, self.y, self.sizeWidth, self.sizeHeight)
164164

src/avp/components/color.ui

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</size>
7575
</property>
7676
<property name="text">
77-
<string>0,0,0</string>
77+
<string/>
7878
</property>
7979
<property name="maxLength">
8080
<number>12</number>
@@ -84,10 +84,10 @@
8484
<item>
8585
<spacer name="horizontalSpacer_9">
8686
<property name="orientation">
87-
<enum>Qt::Horizontal</enum>
87+
<enum>Qt::Orientation::Horizontal</enum>
8888
</property>
8989
<property name="sizeType">
90-
<enum>QSizePolicy::Fixed</enum>
90+
<enum>QSizePolicy::Policy::Fixed</enum>
9191
</property>
9292
<property name="sizeHint" stdset="0">
9393
<size>
@@ -176,7 +176,7 @@
176176
<string>Width</string>
177177
</property>
178178
<property name="alignment">
179-
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
179+
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
180180
</property>
181181
</widget>
182182
</item>
@@ -246,10 +246,10 @@
246246
<item>
247247
<spacer name="horizontalSpacer_7">
248248
<property name="orientation">
249-
<enum>Qt::Horizontal</enum>
249+
<enum>Qt::Orientation::Horizontal</enum>
250250
</property>
251251
<property name="sizeType">
252-
<enum>QSizePolicy::Fixed</enum>
252+
<enum>QSizePolicy::Policy::Fixed</enum>
253253
</property>
254254
<property name="sizeHint" stdset="0">
255255
<size>
@@ -370,7 +370,7 @@
370370
<number>-1</number>
371371
</property>
372372
<property name="sizeAdjustPolicy">
373-
<enum>QComboBox::AdjustToContentsOnFirstShow</enum>
373+
<enum>QComboBox::SizeAdjustPolicy::AdjustToContentsOnFirstShow</enum>
374374
</property>
375375
</widget>
376376
</item>
@@ -422,10 +422,10 @@
422422
<item>
423423
<spacer name="horizontalSpacer_2">
424424
<property name="orientation">
425-
<enum>Qt::Horizontal</enum>
425+
<enum>Qt::Orientation::Horizontal</enum>
426426
</property>
427427
<property name="sizeType">
428-
<enum>QSizePolicy::Minimum</enum>
428+
<enum>QSizePolicy::Policy::Minimum</enum>
429429
</property>
430430
<property name="sizeHint" stdset="0">
431431
<size>
@@ -461,7 +461,7 @@
461461
<x>-1</x>
462462
<y>0</y>
463463
<width>561</width>
464-
<height>31</height>
464+
<height>34</height>
465465
</rect>
466466
</property>
467467
<layout class="QHBoxLayout" name="horizontalLayout">
@@ -503,7 +503,7 @@
503503
<string>End</string>
504504
</property>
505505
<property name="alignment">
506-
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
506+
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
507507
</property>
508508
</widget>
509509
</item>
@@ -523,7 +523,7 @@
523523
<item>
524524
<spacer name="horizontalSpacer">
525525
<property name="orientation">
526-
<enum>Qt::Horizontal</enum>
526+
<enum>Qt::Orientation::Horizontal</enum>
527527
</property>
528528
<property name="sizeHint" stdset="0">
529529
<size>
@@ -543,7 +543,7 @@
543543
<x>-1</x>
544544
<y>-1</y>
545545
<width>561</width>
546-
<height>31</height>
546+
<height>34</height>
547547
</rect>
548548
</property>
549549
<layout class="QHBoxLayout" name="horizontalLayout_3">
@@ -559,7 +559,7 @@
559559
<string>Start</string>
560560
</property>
561561
<property name="alignment">
562-
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
562+
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
563563
</property>
564564
</widget>
565565
</item>
@@ -588,7 +588,7 @@
588588
<string>End</string>
589589
</property>
590590
<property name="alignment">
591-
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
591+
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
592592
</property>
593593
</widget>
594594
</item>
@@ -617,14 +617,14 @@
617617
<string>Centre</string>
618618
</property>
619619
<property name="alignment">
620-
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
620+
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
621621
</property>
622622
</widget>
623623
</item>
624624
<item>
625625
<widget class="QSpinBox" name="spinBox_radialGradient_spread">
626626
<property name="buttonSymbols">
627-
<enum>QAbstractSpinBox::PlusMinus</enum>
627+
<enum>QAbstractSpinBox::ButtonSymbols::PlusMinus</enum>
628628
</property>
629629
<property name="minimum">
630630
<number>-10000</number>
@@ -640,7 +640,7 @@
640640
<item>
641641
<spacer name="horizontalSpacer_3">
642642
<property name="orientation">
643-
<enum>Qt::Horizontal</enum>
643+
<enum>Qt::Orientation::Horizontal</enum>
644644
</property>
645645
<property name="sizeHint" stdset="0">
646646
<size>

src/avp/components/image.py

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from copy import copy
55

66
from ..component import Component
7-
from ..toolkit.frame import BlankFrame
8-
from .original import Component as Visualizer
7+
from ..toolkit.frame import BlankFrame, addShadow
8+
from ..toolkit.visualizer import createSpectrumArray
99

1010

1111
class Component(Component):
1212
name = "Image"
13-
version = "2.0.0"
13+
version = "2.1.0"
1414

1515
def widget(self, *args):
1616
super().widget(*args)
@@ -35,6 +35,7 @@ def widget(self, *args):
3535
"mirror": self.page.checkBox_mirror,
3636
"respondToAudio": self.page.checkBox_respondToAudio,
3737
"sensitivity": self.page.spinBox_sensitivity,
38+
"shadow": self.page.checkBox_shadow,
3839
},
3940
presetNames={
4041
"imagePath": "image",
@@ -75,31 +76,16 @@ def preFrameRender(self, **kwargs):
7576
# Trigger creation of new base image
7677
self.existingImage = None
7778

78-
smoothConstantDown = 0.08 + 0
79-
smoothConstantUp = 0.8 - 0
80-
self.lastSpectrum = None
81-
self.spectrumArray = {}
82-
83-
for i in range(0, len(self.completeAudioArray), self.sampleSize):
84-
if self.canceled:
85-
break
86-
self.lastSpectrum = Visualizer.transformData(
87-
i,
88-
self.completeAudioArray,
89-
self.sampleSize,
90-
smoothConstantDown,
91-
smoothConstantUp,
92-
self.lastSpectrum,
93-
self.sensitivity,
94-
)
95-
self.spectrumArray[i] = copy(self.lastSpectrum)
96-
97-
progress = int(100 * (i / len(self.completeAudioArray)))
98-
if progress >= 100:
99-
progress = 100
100-
pStr = "Analyzing audio: " + str(progress) + "%"
101-
self.progressBarSetText.emit(pStr)
102-
self.progressBarUpdate.emit(int(progress))
79+
self.spectrumArray = createSpectrumArray(
80+
self,
81+
self.completeAudioArray,
82+
self.sampleSize,
83+
0.08,
84+
0.8,
85+
self.sensitivity,
86+
self.progressBarUpdate,
87+
self.progressBarSetText,
88+
)
10389

10490
def frameRender(self, frameNo):
10591
return self.drawFrame(
@@ -139,9 +125,16 @@ def drawFrame(self, width, height, dynamicScale):
139125
self.existingImage = image
140126

141127
# Respond to audio
128+
resolutionFactor = height / 1080
129+
shadX = int(resolutionFactor * 1)
130+
shadY = int(resolutionFactor * -1)
131+
shadBlur = resolutionFactor * 3.50
142132
scale = 0
143133
if dynamicScale is not None:
144134
scale = dynamicScale[36 * 4] / 4
135+
shadX += int((scale / 4) * resolutionFactor)
136+
shadY += int((scale / 2) * resolutionFactor)
137+
shadBlur += (scale / 8) * resolutionFactor
145138
image = ImageOps.contain(
146139
image,
147140
(
@@ -161,6 +154,8 @@ def drawFrame(self, width, height, dynamicScale):
161154
)
162155
if self.rotate != 0:
163156
frame = frame.rotate(self.rotate)
157+
if self.shadow:
158+
frame = addShadow(frame, shadBlur, shadX, shadY)
164159

165160
return frame
166161

src/avp/components/image.ui

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,16 @@
306306
</property>
307307
</spacer>
308308
</item>
309+
<item>
310+
<widget class="QCheckBox" name="checkBox_shadow">
311+
<property name="layoutDirection">
312+
<enum>Qt::LayoutDirection::RightToLeft</enum>
313+
</property>
314+
<property name="text">
315+
<string>Shadow</string>
316+
</property>
317+
</widget>
318+
</item>
309319
<item>
310320
<widget class="QLabel" name="label_3">
311321
<property name="sizePolicy">

0 commit comments

Comments
 (0)