aboutsummaryrefslogtreecommitdiff
path: root/src/avp/components/original.py
diff options
context:
space:
mode:
authorBrianna Rainey2026-01-22 16:29:46 -0500
committerGitHub2026-01-22 16:29:46 -0500
commita12be862e22bdec6a243a3f0b5f4f28d69084a2a (patch)
tree7f2b21f58cf54deb81bfe77d7ef45358c80454f0 /src/avp/components/original.py
parent36760579a0ae604074034c4b78cda2e3f3b001de (diff)
fix #89 with Image component v2.0 + 23 tests (#90)
* qtbot is needed in any test that uses a QObject previously these tests would fail if they ran before qtbot was initialized by another test. I'm now running tests in a random order * add tests for drawBars, readAudioFile, BlankFrame * replace numpy.seterr with numpy.errstate * fix incorrect comment * add MockVideoWorker and imageDataSum * test further into visualization (less likely to be a false positive) * test FloodFrame function * add failing test for Image component one step towards fixing #89 * test component name CLI parsing * prevent log warning when 1 setting changed * correct tests to use widgets when needed * test undo and blockSignals * remove stretch_scale (use scale only) * image ignores scale if stretch checkbox checked fixes #89 * test Title Text component, ffmpeg command * Image v2: replace stretched setting with resizeMode 3 resize modes are scale, cover, and stretch. Scale only applies when resizeMode is set to scale. Cover uses ImageOps.fit() to stretch while maintaining aspect ratio. Also, spinBox_scale was moved to be underneath comboBox_resizeMode. * change transformData into staticmethod the purpose is to allow easier reuse in other components * add respondToAudio option to Image component this causes the image to scale up and down slightly based on the input audio file * cache static portion of image when animating increases rendering speed of a 1-minute video by 12 seconds (based on two manual tests anyway)
Diffstat (limited to 'src/avp/components/original.py')
-rw-r--r--src/avp/components/original.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/avp/components/original.py b/src/avp/components/original.py
index 1e7ef86..64eba4d 100644
--- a/src/avp/components/original.py
+++ b/src/avp/components/original.py
@@ -57,8 +57,8 @@ class Component(Component):
def preFrameRender(self, **kwargs):
super().preFrameRender(**kwargs)
- self.smoothConstantDown = 0.08 + 0 if not self.smooth else self.smooth / 15
- self.smoothConstantUp = 0.8 - 0 if not self.smooth else self.smooth / 15
+ smoothConstantDown = 0.08 if not self.smooth else self.smooth / 15
+ smoothConstantUp = 0.8 if not self.smooth else self.smooth / 15
self.lastSpectrum = None
self.spectrumArray = {}
@@ -69,9 +69,10 @@ class Component(Component):
i,
self.completeAudioArray,
self.sampleSize,
- self.smoothConstantDown,
- self.smoothConstantUp,
+ smoothConstantDown,
+ smoothConstantUp,
self.lastSpectrum,
+ self.scale,
)
self.spectrumArray[i] = copy(self.lastSpectrum)
@@ -92,14 +93,15 @@ class Component(Component):
self.layout,
)
+ @staticmethod
def transformData(
- self,
i,
completeAudioArray,
sampleSize,
smoothConstantDown,
smoothConstantUp,
lastSpectrum,
+ scale,
):
if len(completeAudioArray) < (i + sampleSize):
sampleSize = len(completeAudioArray) - i
@@ -117,7 +119,9 @@ class Component(Component):
# filter the noise away
# y[y<80] = 0
- y = self.scale * numpy.log10(y)
+ with numpy.errstate(divide="ignore"):
+ y = scale * numpy.log10(y)
+
y[numpy.isinf(y)] = 0
if lastSpectrum is not None: