Integration with tassaron2 modular design. True Alpha Rendering added, several bug fixes.
This commit is contained in:
parent
fe13268a84
commit
75c1c65c9d
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
''' Original Audio Visualization '''
|
||||||
|
import numpy
|
||||||
|
from PIL import Image, ImageDraw
|
||||||
|
from PyQt4 import uic
|
||||||
|
import os, random
|
||||||
|
|
||||||
|
|
||||||
|
class Component:
|
||||||
|
def widget(self,parent):
|
||||||
|
self.parent = parent
|
||||||
|
|
||||||
|
page = uic.loadUi(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'original.ui'))
|
||||||
|
page.comboBox_visLayout.addItem("Classic")
|
||||||
|
page.comboBox_visLayout.addItem("Split")
|
||||||
|
page.comboBox_visLayout.addItem("Bottom")
|
||||||
|
#visLayoutValue = int(self.settings.value('visLayout'))
|
||||||
|
page.comboBox_visLayout.setCurrentIndex(0)
|
||||||
|
page.comboBox_visLayout.currentIndexChanged.connect(self.update)
|
||||||
|
|
||||||
|
return page
|
||||||
|
def update(self):
|
||||||
|
self.layout = self.page.comboBox_visLayout.currentIndex()
|
||||||
|
print(self.layout)
|
||||||
|
self.parent.drawPreview()
|
||||||
|
|
||||||
|
def previewRender(self, previewWorker, widget):
|
||||||
|
spectrum = numpy.fromfunction(lambda x: 0.008*(x-128)**2, (255,), dtype="int16")
|
||||||
|
width = int(previewWorker.core.settings.value('outputWidth'))
|
||||||
|
height = int(previewWorker.core.settings.value('outputHeight'))
|
||||||
|
return drawBars(width, height, spectrum, (255, 255, 255), self.layout)
|
||||||
|
|
||||||
|
def preFrameRender(self, **kwargs):
|
||||||
|
for kwarg, value in kwargs.items():
|
||||||
|
exec('self.%s = value' % kwarg)
|
||||||
|
self.smoothConstantDown = 0.08
|
||||||
|
self.smoothConstantUp = 0.8
|
||||||
|
self.lastSpectrum = None
|
||||||
|
|
||||||
|
def frameRender(self, moduleNo, frameNo):
|
||||||
|
self.lastSpectrum = transformData(frameNo, self.completeAudioArray, self.sampleSize,
|
||||||
|
self.smoothConstantDown, self.smoothConstantUp, self.lastSpectrum)
|
||||||
|
width = int(self.worker.core.settings.value('outputWidth'))
|
||||||
|
height = int(self.worker.core.settings.value('outputHeight'))
|
||||||
|
return drawBars(width, height, self.lastSpectrum, (255,255,255), self.layout)
|
||||||
|
|
||||||
|
def transformData(i, completeAudioArray, sampleSize, smoothConstantDown, smoothConstantUp, lastSpectrum):
|
||||||
|
if len(completeAudioArray) < (i + sampleSize):
|
||||||
|
sampleSize = len(completeAudioArray) - i
|
||||||
|
numpy.seterr(divide='ignore')
|
||||||
|
window = numpy.hanning(sampleSize)
|
||||||
|
data = completeAudioArray[i:i+sampleSize][::1] * window
|
||||||
|
paddedSampleSize = 2048
|
||||||
|
paddedData = numpy.pad(data, (0, paddedSampleSize - sampleSize), 'constant')
|
||||||
|
spectrum = numpy.fft.fft(paddedData)
|
||||||
|
sample_rate = 44100
|
||||||
|
frequencies = numpy.fft.fftfreq(len(spectrum), 1./sample_rate)
|
||||||
|
|
||||||
|
y = abs(spectrum[0:int(paddedSampleSize/2) - 1])
|
||||||
|
|
||||||
|
# filter the noise away
|
||||||
|
# y[y<80] = 0
|
||||||
|
|
||||||
|
y = 20 * numpy.log10(y)
|
||||||
|
y[numpy.isinf(y)] = 0
|
||||||
|
|
||||||
|
if lastSpectrum is not None:
|
||||||
|
lastSpectrum[y < lastSpectrum] = y[y < lastSpectrum] * smoothConstantDown + lastSpectrum[y < lastSpectrum] * (1 - smoothConstantDown)
|
||||||
|
lastSpectrum[y >= lastSpectrum] = y[y >= lastSpectrum] * smoothConstantUp + lastSpectrum[y >= lastSpectrum] * (1 - smoothConstantUp)
|
||||||
|
else:
|
||||||
|
lastSpectrum = y
|
||||||
|
|
||||||
|
x = frequencies[0:int(paddedSampleSize/2) - 1]
|
||||||
|
|
||||||
|
return lastSpectrum
|
||||||
|
|
||||||
|
def drawBars(width, height, spectrum, color, layout):
|
||||||
|
vH = height-height/8
|
||||||
|
bF = width / 64
|
||||||
|
bH = bF / 2
|
||||||
|
bQ = bF / 4
|
||||||
|
imTop = Image.new("RGBA", (width, height),(0,0,0,0))
|
||||||
|
draw = ImageDraw.Draw(imTop)
|
||||||
|
r, g, b = color
|
||||||
|
color2 = (r, g, b, 125)
|
||||||
|
|
||||||
|
bP = height / 1200
|
||||||
|
|
||||||
|
for j in range(0, 63):
|
||||||
|
draw.rectangle((bH + j * bF, vH+bQ, bH + j * bF + bF, vH + bQ - spectrum[j * 4] * bP - bH), fill=color2)
|
||||||
|
draw.rectangle((bH + bQ + j * bF, vH , bH + bQ + j * bF + bH, vH - spectrum[j * 4] * bP), fill=color)
|
||||||
|
|
||||||
|
|
||||||
|
imBottom = imTop.transpose(Image.FLIP_TOP_BOTTOM)
|
||||||
|
|
||||||
|
im = Image.new("RGBA", (width, height),(0,0,0,0))
|
||||||
|
|
||||||
|
if layout == 0:
|
||||||
|
y = 0 - int(height/100*43)
|
||||||
|
im.paste(imTop, (0, y), mask=imTop)
|
||||||
|
y = 0 + int(height/100*43)
|
||||||
|
im.paste(imBottom, (0, y), mask=imBottom)
|
||||||
|
|
||||||
|
if layout == 1:
|
||||||
|
y = 0 + int(height/100*10)
|
||||||
|
im.paste(imTop, (0, y), mask=imTop)
|
||||||
|
y = 0 - int(height/100*10)
|
||||||
|
im.paste(imBottom, (0, y), mask=imBottom)
|
||||||
|
|
||||||
|
if layout == 2:
|
||||||
|
y = 0 + int(height/100*10)
|
||||||
|
im.paste(imTop, (0, y), mask=imTop)
|
||||||
|
|
||||||
|
return im
|
|
@ -0,0 +1,92 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Form</class>
|
||||||
|
<widget class="QWidget" name="Form">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>584</width>
|
||||||
|
<height>169</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>567</width>
|
||||||
|
<height>29</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_visLayout">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Visualizer Layout</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBox_visLayout"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_5">
|
||||||
|
<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>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_visColor">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="MaximumSize" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_visColor"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -0,0 +1,59 @@
|
||||||
|
''' Title Text '''
|
||||||
|
import numpy
|
||||||
|
from PIL import Image, ImageDraw
|
||||||
|
from PyQt4 import uic
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
class Component:
|
||||||
|
def widget(self,parent):
|
||||||
|
page = uic.loadUi(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'text.ui'))
|
||||||
|
return page
|
||||||
|
def previewRender(self, previewWorker, widget):
|
||||||
|
width = int(previewWorker.core.settings.value('outputWidth'))
|
||||||
|
height = int(previewWorker.core.settings.value('outputHeight'))
|
||||||
|
im = Image.new("RGBA", (width, height),(0,0,0,0))
|
||||||
|
|
||||||
|
return im
|
||||||
|
|
||||||
|
def preFrameRender(self, **kwargs):
|
||||||
|
pass
|
||||||
|
def frameRender(self, moduleNo, frameNo):
|
||||||
|
width = int(previewWorker.core.settings.value('outputWidth'))
|
||||||
|
height = int(previewWorker.core.settings.value('outputHeight'))
|
||||||
|
im = Image.new("RGBA", (width, height),(0,0,0,0))
|
||||||
|
|
||||||
|
return im
|
||||||
|
|
||||||
|
'''
|
||||||
|
self._image = ImageQt(im)
|
||||||
|
|
||||||
|
self._image1 = QtGui.QImage(self._image)
|
||||||
|
painter = QPainter(self._image1)
|
||||||
|
font = titleFont
|
||||||
|
font.setPixelSize(fontSize)
|
||||||
|
painter.setFont(font)
|
||||||
|
painter.setPen(QColor(*textColor))
|
||||||
|
|
||||||
|
yPosition = yOffset
|
||||||
|
|
||||||
|
fm = QtGui.QFontMetrics(font)
|
||||||
|
if alignment == 0: #Left
|
||||||
|
xPosition = xOffset
|
||||||
|
if alignment == 1: #Middle
|
||||||
|
xPosition = xOffset - fm.width(titleText)/2
|
||||||
|
if alignment == 2: #Right
|
||||||
|
xPosition = xOffset - fm.width(titleText)
|
||||||
|
painter.drawText(xPosition, yPosition, titleText)
|
||||||
|
painter.end()
|
||||||
|
|
||||||
|
buffer = QtCore.QBuffer()
|
||||||
|
buffer.open(QtCore.QIODevice.ReadWrite)
|
||||||
|
self._image1.save(buffer, "PNG")
|
||||||
|
|
||||||
|
strio = io.BytesIO()
|
||||||
|
strio.write(buffer.data())
|
||||||
|
buffer.close()
|
||||||
|
strio.seek(0)
|
||||||
|
return Image.open(strio)
|
||||||
|
'''
|
|
@ -0,0 +1,329 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Form</class>
|
||||||
|
<widget class="QWidget" name="Form">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>584</width>
|
||||||
|
<height>169</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>567</width>
|
||||||
|
<height>25</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_title">
|
||||||
|
<property name="text">
|
||||||
|
<string>Title</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_title">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>300</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Testing New GUI</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_6">
|
||||||
|
<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_xTitleAlign">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>X</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinBox_xTextAlign">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>80</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>999999999</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_7">
|
||||||
|
<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_yTitleAlign">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Y</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinBox_yTextAlign">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>80</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>999999999</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>51</y>
|
||||||
|
<width>567</width>
|
||||||
|
<height>29</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Font</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFontComboBox" name="fontComboBox_titleFont">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>140</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_8">
|
||||||
|
<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_fontSize">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Font Size</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinBox_fontSize">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>500</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>86</y>
|
||||||
|
<width>567</width>
|
||||||
|
<height>29</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_textLayout">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Text Layout</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBox_textAlign"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<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_textColor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Text Color</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_textColor">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="MaximumSize" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_textColor"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>121</y>
|
||||||
|
<width>567</width>
|
||||||
|
<height>29</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_9"/>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
107
core.py
107
core.py
|
@ -42,8 +42,7 @@ class Core():
|
||||||
else:
|
else:
|
||||||
return self.getVideoFrames(backgroundImage, preview)
|
return self.getVideoFrames(backgroundImage, preview)
|
||||||
|
|
||||||
def drawBaseImage(self, backgroundFile, titleText, titleFont, fontSize, alignment,\
|
def drawBaseImage(self, backgroundFile):
|
||||||
xOffset, yOffset, textColor, visColor):
|
|
||||||
if backgroundFile == '':
|
if backgroundFile == '':
|
||||||
im = Image.new("RGB", (int(self.settings.value('outputWidth')), int(self.settings.value('outputHeight'))), "black")
|
im = Image.new("RGB", (int(self.settings.value('outputWidth')), int(self.settings.value('outputHeight'))), "black")
|
||||||
else:
|
else:
|
||||||
|
@ -51,81 +50,10 @@ class Core():
|
||||||
|
|
||||||
if self._image == None or not self.lastBackgroundImage == backgroundFile:
|
if self._image == None or not self.lastBackgroundImage == backgroundFile:
|
||||||
self.lastBackgroundImage = backgroundFile
|
self.lastBackgroundImage = backgroundFile
|
||||||
|
|
||||||
# resize if necessary
|
# resize if necessary
|
||||||
if not im.size == (int(self.settings.value('outputWidth')), int(self.settings.value('outputHeight'))):
|
if not im.size == (int(self.settings.value('outputWidth')), int(self.settings.value('outputHeight'))):
|
||||||
im = im.resize((int(self.settings.value('outputWidth')), int(self.settings.value('outputHeight'))), Image.ANTIALIAS)
|
im = im.resize((int(self.settings.value('outputWidth')), int(self.settings.value('outputHeight'))), Image.ANTIALIAS)
|
||||||
|
|
||||||
self._image = ImageQt(im)
|
|
||||||
|
|
||||||
self._image1 = QtGui.QImage(self._image)
|
|
||||||
painter = QPainter(self._image1)
|
|
||||||
font = titleFont
|
|
||||||
font.setPixelSize(fontSize)
|
|
||||||
painter.setFont(font)
|
|
||||||
painter.setPen(QColor(*textColor))
|
|
||||||
|
|
||||||
fm = QtGui.QFontMetrics(font)
|
|
||||||
yPosition = yOffset + fm.height()/6
|
|
||||||
|
|
||||||
if alignment == 0: #Left
|
|
||||||
xPosition = xOffset
|
|
||||||
if alignment == 1: #Middle
|
|
||||||
xPosition = xOffset - fm.width(titleText)/2
|
|
||||||
if alignment == 2: #Right
|
|
||||||
xPosition = xOffset - fm.width(titleText)
|
|
||||||
painter.drawText(xPosition, yPosition, titleText)
|
|
||||||
painter.end()
|
|
||||||
|
|
||||||
buffer = QtCore.QBuffer()
|
|
||||||
buffer.open(QtCore.QIODevice.ReadWrite)
|
|
||||||
self._image1.save(buffer, "PNG")
|
|
||||||
|
|
||||||
strio = io.BytesIO()
|
|
||||||
strio.write(buffer.data())
|
|
||||||
buffer.close()
|
|
||||||
strio.seek(0)
|
|
||||||
return Image.open(strio)
|
|
||||||
|
|
||||||
def drawBars(self, spectrum, image, color):
|
|
||||||
|
|
||||||
width = int(self.settings.value('outputWidth'))
|
|
||||||
height = int(int(self.settings.value('outputHeight'))/2)
|
|
||||||
|
|
||||||
vH = height-height/8
|
|
||||||
bF = int(self.settings.value('outputWidth')) / 64
|
|
||||||
bH = bF / 2
|
|
||||||
bQ = bF / 4
|
|
||||||
imTop = Image.new("RGBA", (width, height))
|
|
||||||
draw = ImageDraw.Draw(imTop)
|
|
||||||
r, g, b = color
|
|
||||||
color2 = (r, g, b, 50)
|
|
||||||
|
|
||||||
bP = int(self.settings.value('outputHeight')) / 800
|
|
||||||
|
|
||||||
for j in range(0, 63):
|
|
||||||
draw.rectangle((bH + j * bF, vH+bQ, bH + j * bF + bF, vH + bQ - spectrum[j * 4] * bP - bH), fill=color2)
|
|
||||||
draw.rectangle((bH + bQ + j * bF, vH , bH + bQ + j * bF + bH, vH - spectrum[j * 4] * bP), fill=color)
|
|
||||||
|
|
||||||
|
|
||||||
imBottom = imTop.transpose(Image.FLIP_TOP_BOTTOM)
|
|
||||||
|
|
||||||
im = Image.new("RGB", (int(self.settings.value('outputWidth')), int(self.settings.value('outputHeight'))), "black")
|
|
||||||
im.paste(image, (0, 0))
|
|
||||||
|
|
||||||
layout = int(self.settings.value('visLayout'))
|
|
||||||
|
|
||||||
if layout == 0:
|
|
||||||
im.paste(imTop, (0, 0), mask=imTop)
|
|
||||||
im.paste(imBottom, (0, int(vH+bF*1.8)), mask=imBottom)
|
|
||||||
|
|
||||||
if layout == 1:
|
|
||||||
im.paste(imTop, (0, int(height+bF*1.5)), mask=imTop)
|
|
||||||
im.paste(imBottom, (0, int(0-bF*1.5)), mask=imBottom)
|
|
||||||
|
|
||||||
if layout == 2:
|
|
||||||
im.paste(imTop, (0, int(height+bF*1.5)), mask=imTop)
|
|
||||||
|
|
||||||
return im
|
return im
|
||||||
|
|
||||||
def readAudioFile(self, filename):
|
def readAudioFile(self, filename):
|
||||||
|
@ -159,41 +87,10 @@ class Core():
|
||||||
|
|
||||||
return completeAudioArray
|
return completeAudioArray
|
||||||
|
|
||||||
def transformData(self, i, completeAudioArray, sampleSize, smoothConstantDown, smoothConstantUp, lastSpectrum):
|
|
||||||
if len(completeAudioArray) < (i + sampleSize):
|
|
||||||
sampleSize = len(completeAudioArray) - i
|
|
||||||
|
|
||||||
window = numpy.hanning(sampleSize)
|
|
||||||
data = completeAudioArray[i:i+sampleSize][::1] * window
|
|
||||||
paddedSampleSize = 2048
|
|
||||||
paddedData = numpy.pad(data, (0, paddedSampleSize - sampleSize), 'constant')
|
|
||||||
spectrum = numpy.fft.fft(paddedData)
|
|
||||||
sample_rate = 44100
|
|
||||||
frequencies = numpy.fft.fftfreq(len(spectrum), 1./sample_rate)
|
|
||||||
|
|
||||||
y = abs(spectrum[0:int(paddedSampleSize/2) - 1])
|
|
||||||
|
|
||||||
# filter the noise away
|
|
||||||
# y[y<80] = 0
|
|
||||||
|
|
||||||
y = 20 * numpy.log10(y)
|
|
||||||
y[numpy.isinf(y)] = 0
|
|
||||||
|
|
||||||
if lastSpectrum is not None:
|
|
||||||
lastSpectrum[y < lastSpectrum] = y[y < lastSpectrum] * smoothConstantDown + lastSpectrum[y < lastSpectrum] * (1 - smoothConstantDown)
|
|
||||||
lastSpectrum[y >= lastSpectrum] = y[y >= lastSpectrum] * smoothConstantUp + lastSpectrum[y >= lastSpectrum] * (1 - smoothConstantUp)
|
|
||||||
else:
|
|
||||||
lastSpectrum = y
|
|
||||||
|
|
||||||
x = frequencies[0:int(paddedSampleSize/2) - 1]
|
|
||||||
|
|
||||||
return lastSpectrum
|
|
||||||
|
|
||||||
def deleteTempDir(self):
|
def deleteTempDir(self):
|
||||||
if self.tempDir and os.path.exists(self.tempDir):
|
if self.tempDir and os.path.exists(self.tempDir):
|
||||||
rmtree(self.tempDir)
|
rmtree(self.tempDir)
|
||||||
|
|
||||||
|
|
||||||
def getVideoFrames(self, videoPath, firstOnly=False):
|
def getVideoFrames(self, videoPath, firstOnly=False):
|
||||||
self.tempDir = os.path.join(tempfile.gettempdir(), 'audio-visualizer-python-data')
|
self.tempDir = os.path.join(tempfile.gettempdir(), 'audio-visualizer-python-data')
|
||||||
# recreate the temporary directory so it is empty
|
# recreate the temporary directory so it is empty
|
||||||
|
|
104
main.py
104
main.py
|
@ -10,15 +10,18 @@ import atexit
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from PyQt4.QtCore import QSettings
|
from PyQt4.QtCore import QSettings
|
||||||
import signal
|
import signal
|
||||||
|
from importlib import import_module
|
||||||
|
|
||||||
import preview_thread, core, video_thread
|
import preview_thread, core, video_thread
|
||||||
|
|
||||||
class Command(QtCore.QObject):
|
class Command(QtCore.QObject):
|
||||||
|
|
||||||
videoTask = QtCore.pyqtSignal(str, str, QFont, int, int, int, int, tuple, tuple, str, str)
|
videoTask = QtCore.pyqtSignal(str, str, QFont, int, int, int, int, tuple, tuple, str, str, list)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
|
self.modules = []
|
||||||
|
self.selectedComponents = []
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
self.parser = argparse.ArgumentParser(description='Create a visualization for an audio file')
|
self.parser = argparse.ArgumentParser(description='Create a visualization for an audio file')
|
||||||
|
@ -90,7 +93,8 @@ class Command(QtCore.QObject):
|
||||||
self.textColor,
|
self.textColor,
|
||||||
self.visColor,
|
self.visColor,
|
||||||
self.args.input,
|
self.args.input,
|
||||||
self.args.output)
|
self.args.output,
|
||||||
|
self.selectedComponents)
|
||||||
|
|
||||||
def videoCreated(self):
|
def videoCreated(self):
|
||||||
self.videoThread.quit()
|
self.videoThread.quit()
|
||||||
|
@ -109,9 +113,9 @@ class Command(QtCore.QObject):
|
||||||
|
|
||||||
class Main(QtCore.QObject):
|
class Main(QtCore.QObject):
|
||||||
|
|
||||||
newTask = QtCore.pyqtSignal(str, str, QFont, int, int, int, int, tuple, tuple)
|
newTask = QtCore.pyqtSignal(str, list)
|
||||||
processTask = QtCore.pyqtSignal()
|
processTask = QtCore.pyqtSignal()
|
||||||
videoTask = QtCore.pyqtSignal(str, str, QFont, int, int, int, int, tuple, tuple, str, str)
|
videoTask = QtCore.pyqtSignal(str, str, str, list)
|
||||||
|
|
||||||
def __init__(self, window):
|
def __init__(self, window):
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
|
@ -121,6 +125,8 @@ class Main(QtCore.QObject):
|
||||||
self.core = core.Core()
|
self.core = core.Core()
|
||||||
self.settings = QSettings('settings.ini', QSettings.IniFormat)
|
self.settings = QSettings('settings.ini', QSettings.IniFormat)
|
||||||
LoadDefaultSettings(self)
|
LoadDefaultSettings(self)
|
||||||
|
|
||||||
|
self.pages = []
|
||||||
|
|
||||||
# load colors as tuples from a comma-separated string
|
# load colors as tuples from a comma-separated string
|
||||||
self.textColor = core.Core.RGBFromString(self.settings.value("textColor", '255, 255, 255'))
|
self.textColor = core.Core.RGBFromString(self.settings.value("textColor", '255, 255, 255'))
|
||||||
|
@ -140,24 +146,26 @@ class Main(QtCore.QObject):
|
||||||
self.timer.timeout.connect(self.processTask.emit)
|
self.timer.timeout.connect(self.processTask.emit)
|
||||||
self.timer.start(500)
|
self.timer.start(500)
|
||||||
|
|
||||||
|
# begin decorating the window and connecting events
|
||||||
window.toolButton_selectAudioFile.clicked.connect(self.openInputFileDialog)
|
window.toolButton_selectAudioFile.clicked.connect(self.openInputFileDialog)
|
||||||
window.toolButton_selectBackground.clicked.connect(self.openBackgroundFileDialog)
|
window.toolButton_selectBackground.clicked.connect(self.openBackgroundFileDialog)
|
||||||
window.toolButton_selectOutputFile.clicked.connect(self.openOutputFileDialog)
|
window.toolButton_selectOutputFile.clicked.connect(self.openOutputFileDialog)
|
||||||
window.progressBar_createVideo.setValue(0)
|
window.progressBar_createVideo.setValue(0)
|
||||||
window.pushButton_createVideo.clicked.connect(self.createAudioVisualisation)
|
window.pushButton_createVideo.clicked.connect(self.createAudioVisualisation)
|
||||||
window.setWindowTitle("Audio Visualizer")
|
window.setWindowTitle("Audio Visualizer")
|
||||||
window.comboBox_textAlign.addItem("Left")
|
|
||||||
window.comboBox_textAlign.addItem("Middle")
|
|
||||||
window.comboBox_textAlign.addItem("Right")
|
|
||||||
window.comboBox_textAlign.setCurrentIndex(1)
|
|
||||||
|
|
||||||
window.comboBox_visLayout.addItem("Classic")
|
self.modules = self.findComponents()
|
||||||
window.comboBox_visLayout.addItem("Split")
|
for component in self.modules:
|
||||||
window.comboBox_visLayout.addItem("Bottom")
|
window.comboBox_componentSelection.addItem(component.__doc__)
|
||||||
visLayoutValue = int(self.settings.value('visLayout'))
|
window.listWidget_componentList.clicked.connect(lambda _: self.changeComponentWidget())
|
||||||
window.comboBox_visLayout.setCurrentIndex(visLayoutValue)
|
self.selectedComponents = []
|
||||||
|
|
||||||
currentRes = self.settings.value('outputWidth')+'x'+self.settings.value('outputHeight')
|
self.window.pushButton_addComponent.clicked.connect( \
|
||||||
|
lambda _: self.addComponent(self.window.comboBox_componentSelection.currentIndex())
|
||||||
|
)
|
||||||
|
self.window.pushButton_removeComponent.clicked.connect(lambda _: self.removeComponent())
|
||||||
|
|
||||||
|
currentRes = str(self.settings.value('outputWidth'))+'x'+str(self.settings.value('outputHeight'))
|
||||||
for i, res in enumerate(self.resolutions):
|
for i, res in enumerate(self.resolutions):
|
||||||
window.comboBox_resolution.addItem(res)
|
window.comboBox_resolution.addItem(res)
|
||||||
if res == currentRes:
|
if res == currentRes:
|
||||||
|
@ -165,8 +173,12 @@ class Main(QtCore.QObject):
|
||||||
window.comboBox_resolution.setCurrentIndex(currentRes)
|
window.comboBox_resolution.setCurrentIndex(currentRes)
|
||||||
window.comboBox_resolution.currentIndexChanged.connect(self.updateResolution)
|
window.comboBox_resolution.currentIndexChanged.connect(self.updateResolution)
|
||||||
|
|
||||||
# FIXME This needs to be changed in a future commit.
|
'''
|
||||||
# We should be setting these values somewhere else.
|
window.comboBox_textAlign.addItem("Left")
|
||||||
|
window.comboBox_textAlign.addItem("Middle")
|
||||||
|
window.comboBox_textAlign.addItem("Right")
|
||||||
|
window.comboBox_textAlign.setCurrentIndex(1)
|
||||||
|
|
||||||
window.spinBox_fontSize.setValue(int(int(self.settings.value("outputHeight")) / 14 ))
|
window.spinBox_fontSize.setValue(int(int(self.settings.value("outputHeight")) / 14 ))
|
||||||
window.spinBox_xTextAlign.setValue(int(int(self.settings.value('outputWidth'))/2))
|
window.spinBox_xTextAlign.setValue(int(int(self.settings.value('outputWidth'))/2))
|
||||||
window.spinBox_yTextAlign.setValue(int(int(self.settings.value('outputHeight'))/2))
|
window.spinBox_yTextAlign.setValue(int(int(self.settings.value('outputHeight'))/2))
|
||||||
|
@ -206,7 +218,7 @@ class Main(QtCore.QObject):
|
||||||
window.spinBox_fontSize.valueChanged.connect(self.drawPreview)
|
window.spinBox_fontSize.valueChanged.connect(self.drawPreview)
|
||||||
window.lineEdit_textColor.textChanged.connect(self.drawPreview)
|
window.lineEdit_textColor.textChanged.connect(self.drawPreview)
|
||||||
window.lineEdit_visColor.textChanged.connect(self.drawPreview)
|
window.lineEdit_visColor.textChanged.connect(self.drawPreview)
|
||||||
|
'''
|
||||||
self.drawPreview()
|
self.drawPreview()
|
||||||
|
|
||||||
window.show()
|
window.show()
|
||||||
|
@ -268,18 +280,10 @@ class Main(QtCore.QObject):
|
||||||
|
|
||||||
self.videoThread.start()
|
self.videoThread.start()
|
||||||
self.videoTask.emit(self.window.lineEdit_background.text(),
|
self.videoTask.emit(self.window.lineEdit_background.text(),
|
||||||
self.window.lineEdit_title.text(),
|
|
||||||
self.window.fontComboBox_titleFont.currentFont(),
|
|
||||||
self.window.spinBox_fontSize.value(),
|
|
||||||
self.window.comboBox_textAlign.currentIndex(),
|
|
||||||
self.window.spinBox_xTextAlign.value(),
|
|
||||||
self.window.spinBox_yTextAlign.value(),
|
|
||||||
core.Core.RGBFromString(self.window.lineEdit_textColor.text()),
|
|
||||||
core.Core.RGBFromString(self.window.lineEdit_visColor.text()),
|
|
||||||
self.window.lineEdit_audioFile.text(),
|
self.window.lineEdit_audioFile.text(),
|
||||||
self.window.lineEdit_outputFile.text())
|
self.window.lineEdit_outputFile.text(),
|
||||||
|
self.selectedComponents)
|
||||||
|
|
||||||
|
|
||||||
def progressBarUpdated(self, value):
|
def progressBarUpdated(self, value):
|
||||||
self.window.progressBar_createVideo.setValue(value)
|
self.window.progressBar_createVideo.setValue(value)
|
||||||
|
|
||||||
|
@ -298,16 +302,8 @@ class Main(QtCore.QObject):
|
||||||
self.drawPreview
|
self.drawPreview
|
||||||
|
|
||||||
def drawPreview(self):
|
def drawPreview(self):
|
||||||
self.settings.setValue('visLayout', self.window.comboBox_visLayout.currentIndex())
|
#self.settings.setValue('visLayout', self.window.comboBox_visLayout.currentIndex())
|
||||||
self.newTask.emit(self.window.lineEdit_background.text(),
|
self.newTask.emit(self.window.lineEdit_background.text(), self.selectedComponents)
|
||||||
self.window.lineEdit_title.text(),
|
|
||||||
self.window.fontComboBox_titleFont.currentFont(),
|
|
||||||
self.window.spinBox_fontSize.value(),
|
|
||||||
self.window.comboBox_textAlign.currentIndex(),
|
|
||||||
self.window.spinBox_xTextAlign.value(),
|
|
||||||
self.window.spinBox_yTextAlign.value(),
|
|
||||||
core.Core.RGBFromString(self.window.lineEdit_textColor.text()),
|
|
||||||
core.Core.RGBFromString(self.window.lineEdit_visColor.text()))
|
|
||||||
# self.processTask.emit()
|
# self.processTask.emit()
|
||||||
|
|
||||||
def showPreviewImage(self, image):
|
def showPreviewImage(self, image):
|
||||||
|
@ -328,6 +324,40 @@ class Main(QtCore.QObject):
|
||||||
self.window.lineEdit_visColor.setText(RGBstring)
|
self.window.lineEdit_visColor.setText(RGBstring)
|
||||||
window.pushButton_visColor.setStyleSheet(btnStyle)
|
window.pushButton_visColor.setStyleSheet(btnStyle)
|
||||||
|
|
||||||
|
def findComponents(self):
|
||||||
|
def findComponents():
|
||||||
|
srcPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'components')
|
||||||
|
if os.path.exists(srcPath):
|
||||||
|
for f in os.listdir(srcPath):
|
||||||
|
name, ext = os.path.splitext(f)
|
||||||
|
if name.startswith("__"):
|
||||||
|
continue
|
||||||
|
elif ext == '.py':
|
||||||
|
yield name
|
||||||
|
return [import_module('components.%s' % name) for name in findComponents()]
|
||||||
|
|
||||||
|
def addComponent(self, moduleIndex):
|
||||||
|
self.window.listWidget_componentList.addItem(self.modules[moduleIndex].__doc__)
|
||||||
|
self.selectedComponents.append(self.modules[moduleIndex].Component())
|
||||||
|
self.selectedComponents[-1].page = self.selectedComponents[-1].widget(self)
|
||||||
|
self.pages.append(self.selectedComponents[-1].page)
|
||||||
|
self.window.stackedWidget.addWidget(self.pages[-1])
|
||||||
|
self.selectedComponents[-1].update()
|
||||||
|
|
||||||
|
def removeComponent(self):
|
||||||
|
for selected in self.window.listWidget_componentList.selectedItems():
|
||||||
|
index = self.window.listWidget_componentList.row(selected)
|
||||||
|
self.window.stackedWidget.removeWidget(self.pages[index])
|
||||||
|
self.window.listWidget_componentList.takeItem(index)
|
||||||
|
self.selectedComponents.pop(index)
|
||||||
|
print(self.selectedComponents)
|
||||||
|
self.drawPreview()
|
||||||
|
|
||||||
|
def changeComponentWidget(self):
|
||||||
|
selected = self.window.listWidget_componentList.selectedItems()
|
||||||
|
index = self.window.listWidget_componentList.row(selected[0])
|
||||||
|
self.window.stackedWidget.setCurrentIndex(index)
|
||||||
|
|
||||||
def LoadDefaultSettings(self):
|
def LoadDefaultSettings(self):
|
||||||
self.resolutions = [
|
self.resolutions = [
|
||||||
'1920x1080',
|
'1920x1080',
|
||||||
|
|
564
main.ui
564
main.ui
|
@ -1,564 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>MainWindow</class>
|
|
||||||
<widget class="QMainWindow" name="MainWindow">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>635</width>
|
|
||||||
<height>600</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>635</width>
|
|
||||||
<height>600</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>MainWindow</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="centralwidget">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_settings">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>200</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
|
||||||
<string>GroupBox</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_selectInput">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>PushButton</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_input">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>2</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::Box</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_selectOutput">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>PushButton</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_output">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>2</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::Box</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_selectBackground">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>PushButton</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_background">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>2</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::Box</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_font">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="baseSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QFontComboBox" name="fontComboBox"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_alignment">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="baseSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="alignmentComboBox"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_fontsize">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="fontsizeSpinBox">
|
|
||||||
<property name="maximum">
|
|
||||||
<number>999</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_textX">
|
|
||||||
<property name="layoutDirection">
|
|
||||||
<enum>Qt::LeftToRight</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>X</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="textXSpinBox">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>-99999</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>99999</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_textY">
|
|
||||||
<property name="text">
|
|
||||||
<string>Y</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="textYSpinBox">
|
|
||||||
<property name="minimum">
|
|
||||||
<number>-99999</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>99999</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_colorOptions">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="baseSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_textColor">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_textColor"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_visColor">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_visColor"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_title">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="baseSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_title"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_preview">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>220</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>220</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
|
||||||
<string>GroupBox</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_preview">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>320</width>
|
|
||||||
<height>180</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>320</width>
|
|
||||||
<height>180</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::Box</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_create">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
|
||||||
<string>GroupBox</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QProgressBar" name="progressBar_create">
|
|
||||||
<property name="value">
|
|
||||||
<number>24</number>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
<property name="textVisible">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_createVideo">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>PushButton</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
1178
mainwindow.ui
1178
mainwindow.ui
File diff suppressed because it is too large
Load Diff
|
@ -18,23 +18,17 @@ class Worker(QtCore.QObject):
|
||||||
self.core = core.Core()
|
self.core = core.Core()
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
self.core.settings = parent.settings
|
self.core.settings = parent.settings
|
||||||
|
self.stackedWidget = parent.window.stackedWidget
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot(str, str, QtGui.QFont, int, int, int, int, tuple, tuple)
|
@pyqtSlot(str, list)
|
||||||
def createPreviewImage(self, backgroundImage, titleText, titleFont, fontSize,\
|
def createPreviewImage(self, backgroundImage, components):
|
||||||
alignment, xOffset, yOffset, textColor, visColor):
|
|
||||||
# print('worker thread id: {}'.format(QtCore.QThread.currentThreadId()))
|
# print('worker thread id: {}'.format(QtCore.QThread.currentThreadId()))
|
||||||
dic = {
|
dic = {
|
||||||
"backgroundImage": backgroundImage,
|
"backgroundImage": backgroundImage,
|
||||||
"titleText": titleText,
|
"components": components,
|
||||||
"titleFont": titleFont,
|
|
||||||
"fontSize": fontSize,
|
|
||||||
"alignment": alignment,
|
|
||||||
"xoffset": xOffset,
|
|
||||||
"yoffset": yOffset,
|
|
||||||
"textColor" : textColor,
|
|
||||||
"visColor" : visColor
|
|
||||||
}
|
}
|
||||||
|
print(components)
|
||||||
self.queue.put(dic)
|
self.queue.put(dic)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
@ -56,21 +50,21 @@ class Worker(QtCore.QObject):
|
||||||
else:
|
else:
|
||||||
bgImage = bgImage[0]
|
bgImage = bgImage[0]
|
||||||
|
|
||||||
im = self.core.drawBaseImage(
|
im = self.core.drawBaseImage(bgImage)
|
||||||
bgImage,
|
frame = Image.new("RGBA", (1280, 720),(0,0,0,255))
|
||||||
nextPreviewInformation["titleText"],
|
frame.paste(im)
|
||||||
nextPreviewInformation["titleFont"],
|
|
||||||
nextPreviewInformation["fontSize"],
|
|
||||||
nextPreviewInformation["alignment"],
|
|
||||||
nextPreviewInformation["xoffset"],
|
|
||||||
nextPreviewInformation["yoffset"],
|
|
||||||
nextPreviewInformation["textColor"],
|
|
||||||
nextPreviewInformation["visColor"])
|
|
||||||
spectrum = numpy.fromfunction(lambda x: 0.008*(x-128)**2, (255,), dtype="int16")
|
|
||||||
|
|
||||||
im = self.core.drawBars(spectrum, im, nextPreviewInformation["visColor"])
|
|
||||||
|
|
||||||
self._image = ImageQt(im)
|
componentWidgets = [self.stackedWidget.widget(i) for i in range(self.stackedWidget.count())]
|
||||||
|
components = nextPreviewInformation["components"]
|
||||||
|
print(components)
|
||||||
|
print(componentWidgets)
|
||||||
|
for component, componentWidget in zip(components, componentWidgets):
|
||||||
|
print('drawing')
|
||||||
|
newFrame = Image.alpha_composite(frame,component.previewRender(self, componentWidget))
|
||||||
|
frame = Image.alpha_composite(frame,newFrame)
|
||||||
|
|
||||||
|
self._image = ImageQt(frame)
|
||||||
self.imageCreated.emit(QtGui.QImage(self._image))
|
self.imageCreated.emit(QtGui.QImage(self._image))
|
||||||
|
|
||||||
except Empty:
|
except Empty:
|
||||||
|
|
|
@ -17,24 +17,15 @@ class Worker(QtCore.QObject):
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
self.core = core.Core()
|
self.core = core.Core()
|
||||||
self.core.settings = parent.settings
|
self.core.settings = parent.settings
|
||||||
|
self.modules = parent.modules
|
||||||
|
self.stackedWidget = parent.window.stackedWidget
|
||||||
parent.videoTask.connect(self.createVideo)
|
parent.videoTask.connect(self.createVideo)
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot(str, str, QtGui.QFont, int, int, int, int, tuple, tuple, str, str)
|
@pyqtSlot(str, str, str, list)
|
||||||
def createVideo(self, backgroundImage, titleText, titleFont, fontSize, alignment,\
|
def createVideo(self, backgroundImage, inputFile, outputFile, components):
|
||||||
xOffset, yOffset, textColor, visColor, inputFile, outputFile):
|
|
||||||
# print('worker thread id: {}'.format(QtCore.QThread.currentThreadId()))
|
# print('worker thread id: {}'.format(QtCore.QThread.currentThreadId()))
|
||||||
def getBackgroundAtIndex(i):
|
def getBackgroundAtIndex(i):
|
||||||
return self.core.drawBaseImage(
|
return self.core.drawBaseImage(backgroundFrames[i])
|
||||||
backgroundFrames[i],
|
|
||||||
titleText,
|
|
||||||
titleFont,
|
|
||||||
fontSize,
|
|
||||||
alignment,
|
|
||||||
xOffset,
|
|
||||||
yOffset,
|
|
||||||
textColor,
|
|
||||||
visColor)
|
|
||||||
|
|
||||||
progressBarValue = 0
|
progressBarValue = 0
|
||||||
self.progressBarUpdate.emit(progressBarValue)
|
self.progressBarUpdate.emit(progressBarValue)
|
||||||
|
@ -84,40 +75,47 @@ class Worker(QtCore.QObject):
|
||||||
out_pipe = sp.Popen(ffmpegCommand,
|
out_pipe = sp.Popen(ffmpegCommand,
|
||||||
stdin=sp.PIPE,stdout=sys.stdout, stderr=sys.stdout)
|
stdin=sp.PIPE,stdout=sys.stdout, stderr=sys.stdout)
|
||||||
|
|
||||||
smoothConstantDown = 0.08
|
# initialize components
|
||||||
smoothConstantUp = 0.8
|
componentWidgets = [self.stackedWidget.widget(i) for i in range(self.stackedWidget.count())]
|
||||||
lastSpectrum = None
|
|
||||||
|
print('######################## Data')
|
||||||
|
print(components)
|
||||||
|
print(componentWidgets)
|
||||||
sampleSize = 1470
|
sampleSize = 1470
|
||||||
|
for component, widget in zip(components, componentWidgets):
|
||||||
|
component.preFrameRender(worker=self, widget=widget, completeAudioArray=completeAudioArray, sampleSize=sampleSize)
|
||||||
|
|
||||||
numpy.seterr(divide='ignore')
|
numpy.seterr(divide='ignore')
|
||||||
|
frame = getBackgroundAtIndex(0)
|
||||||
bgI = 0
|
bgI = 0
|
||||||
|
# create video for output
|
||||||
for i in range(0, len(completeAudioArray), sampleSize):
|
for i in range(0, len(completeAudioArray), sampleSize):
|
||||||
# create video for output
|
newFrame = Image.new("RGBA", (int(self.core.settings.value('outputWidth')), int(self.core.settings.value('outputHeight'))),(0,0,0,255))
|
||||||
lastSpectrum = self.core.transformData(
|
|
||||||
i,
|
|
||||||
completeAudioArray,
|
|
||||||
sampleSize,
|
|
||||||
smoothConstantDown,
|
|
||||||
smoothConstantUp,
|
|
||||||
lastSpectrum)
|
|
||||||
if imBackground != None:
|
|
||||||
im = self.core.drawBars(lastSpectrum, imBackground, visColor)
|
|
||||||
else:
|
|
||||||
im = self.core.drawBars(lastSpectrum, getBackgroundAtIndex(bgI), visColor)
|
|
||||||
if bgI < len(backgroundFrames)-1:
|
|
||||||
bgI += 1
|
|
||||||
|
|
||||||
|
if imBackground:
|
||||||
|
newFrame.paste(imBackground)
|
||||||
|
else:
|
||||||
|
newFrame.paste(getBackgroundAtIndex(bgI))
|
||||||
|
|
||||||
|
for compNo, comp in enumerate(components):
|
||||||
|
newFrame = Image.alpha_composite(newFrame,comp.frameRender(compNo, i))
|
||||||
|
|
||||||
|
if not imBackground:
|
||||||
|
if bgI < len(backgroundFrames)-1:
|
||||||
|
bgI += 1
|
||||||
# write to out_pipe
|
# write to out_pipe
|
||||||
try:
|
try:
|
||||||
out_pipe.stdin.write(im.tobytes())
|
frame = Image.new("RGB", (int(self.core.settings.value('outputWidth')), int(self.core.settings.value('outputHeight'))),(0,0,0))
|
||||||
finally:
|
frame.paste(newFrame)
|
||||||
True
|
out_pipe.stdin.write(frame.tobytes())
|
||||||
|
finally:
|
||||||
|
True
|
||||||
|
|
||||||
# increase progress bar value
|
# increase progress bar value
|
||||||
if progressBarValue + 1 <= (i / len(completeAudioArray)) * 100:
|
if progressBarValue + 1 <= (i / len(completeAudioArray)) * 100:
|
||||||
progressBarValue = numpy.floor((i / len(completeAudioArray)) * 100)
|
progressBarValue = numpy.floor((i / len(completeAudioArray)) * 100)
|
||||||
self.progressBarUpdate.emit(progressBarValue)
|
self.progressBarUpdate.emit(progressBarValue)
|
||||||
self.progressBarSetText.emit('%s%%' % str(int(progressBarValue)))
|
self.progressBarSetText.emit('%s%%' % str(int(progressBarValue)))
|
||||||
|
|
||||||
numpy.seterr(all='print')
|
numpy.seterr(all='print')
|
||||||
|
|
||||||
|
|
Reference in New Issue