Skip to content

Commit

Permalink
Add Bass and Treble filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Jul 2, 2015
1 parent efd58b8 commit 9744634
Show file tree
Hide file tree
Showing 3 changed files with 268 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/qml/filters/audio_basstreble/meta.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import QtQuick 2.0
import org.shotcut.qml 1.0

Metadata {
type: Metadata.Filter
isAudio: true
name: qsTr("Bass & Treble")
mlt_service: 'ladspa.1901'
qml: 'ui.qml'
}
254 changes: 254 additions & 0 deletions src/qml/filters/audio_basstreble/ui.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
/*
* Copyright (c) 2015 Meltytech, LLC
* Author: Lauren Dennedy
*
* 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 3 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. If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick 2.1
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1
import Shotcut.Controls 1.0

Rectangle {
id: background
width: 500
height: 300
color: 'transparent'

SystemPalette { id: activePalette }

Component.onCompleted: {
if (filter.isNew) {
// Set default parameter values
filter.set('0', 0)
filter.set('1', 0)
filter.set('2', 0)
filter.set('wetness', 1.0)
filter.savePreset(preset.parameters)
}
setControls()
}

function setControls() {
sliderLow.value = filter.getDouble('0')
sliderMid.value = filter.getDouble('1')
sliderHigh.value = filter.getDouble('2')
}

Rectangle {
id: topLine
height: 1
width: lowColumn.width * 3 + 20
color: activePalette.text
opacity: 0.5

anchors {
left: gridLayout.left
leftMargin: gridLayout.leftMargin
top: gridLayout.top
topMargin: presetLayout.height + gridLayout.anchors.margins
}

}

Label {
text: '+12 dB'
font.pointSize: bassLabel.font.pointSize - 1
anchors {
right: topLine.left
rightMargin: 8
verticalCenter: topLine.verticalCenter
}
}

Rectangle {
height: 1
width: lowColumn.width * 3 + gridLayout.anchors.margins * 2
color: activePalette.text
opacity: 0.5

anchors {
left: gridLayout.left
leftMargin: gridLayout.leftMargin
top: topLine.top
topMargin: sliderLow.height * 0.25 + 1
}

}

Rectangle {
id: zeroLine
height: 2
width: lowColumn.width * 3 + gridLayout.anchors.margins * 2
color: activePalette.text
opacity: 0.5

anchors {
left: gridLayout.left
leftMargin: gridLayout.leftMargin
top: topLine.top
topMargin: sliderLow.height * 0.5 - 4
}

}

Label {
text: '0 dB'
font.pointSize: bassLabel.font.pointSize - 1
anchors {
right: zeroLine.left
rightMargin: 8
verticalCenter: zeroLine.verticalCenter
}
}

Rectangle {
height: 1
width: lowColumn.width * 3 + gridLayout.anchors.margins * 2
color: activePalette.text
opacity: 0.5

anchors {
left: gridLayout.left
leftMargin: gridLayout.leftMargin
top: topLine.top
topMargin: sliderLow.height * 0.75 - 8
}

}

Rectangle {
id: bottomLine
height: 1
width: lowColumn.width * 3 + gridLayout.anchors.margins * 2
color: activePalette.text
opacity: 0.5

anchors {
left: gridLayout.left
leftMargin: gridLayout.leftMargin
bottom: gridLayout.bottom
bottomMargin: bassLabel.height + gridLayout.anchors.margins
}

}

Label {
text: '-12 dB'
font.pointSize: bassLabel.font.pointSize - 1
anchors {
right: bottomLine.left
rightMargin: 8
verticalCenter: bottomLine.verticalCenter
}
}

GridLayout {
id: gridLayout
anchors.fill: parent
anchors.margins: 8
columns: 5
property double leftMargin: (width - lowColumn.width * 3 - columnSpacing * 2) / 2

RowLayout {
id: presetLayout
spacing: 8
Layout.columnSpan: parent.columns
Label {
text: qsTr('Preset')
Layout.alignment: Qt.AlignRight
}
Preset {
id: preset
parameters: ['0', '1', '2']
onPresetSelected: setControls()
}
}

Item {
Layout.fillWidth: true
}

ColumnLayout {
id: lowColumn
Layout.minimumWidth: 80
Layout.alignment: Qt.AlignHCenter

Slider {
id: sliderLow
anchors.horizontalCenter: parent.horizontalCenter
Layout.fillHeight: true
orientation: Qt.Vertical
minimumValue: -12
maximumValue: 12
value: filter.getDouble('0')
onValueChanged: filter.set('0', value)
ToolTip { text: '%1 dB'.arg(Math.round(parent.value * 10) / 10) }
}
Label {
id: bassLabel
text: qsTr('Bass')
anchors.horizontalCenter: parent.horizontalCenter
}
}

ColumnLayout {
Layout.minimumWidth: 80
Layout.alignment: Qt.AlignHCenter

Slider {
id: sliderMid
anchors.horizontalCenter: parent.horizontalCenter
Layout.fillHeight: true
orientation: Qt.Vertical
minimumValue: -12
maximumValue: 12
value: filter.getDouble('1')
onValueChanged: filter.set('1', value)
ToolTip { text: '%1 dB'.arg(Math.round(parent.value * 10) / 10) }
}
Label {
text: qsTr('Middle')
anchors.horizontalCenter: parent.horizontalCenter
}
}

ColumnLayout {
Layout.minimumWidth: 80
Layout.alignment: Qt.AlignHCenter

Slider {
id: sliderHigh
anchors.horizontalCenter: parent.horizontalCenter
Layout.fillHeight: true
orientation: Qt.Vertical
minimumValue: -12
maximumValue: 12
value: filter.getDouble('2')
onValueChanged: filter.set('2', value)
ToolTip { text: '%1 dB'.arg(Math.round(parent.value * 10) / 10) }
}
Label {
text: qsTr('Treble')
anchors.horizontalCenter: parent.horizontalCenter
}
}

Item {
Layout.fillWidth: true
}
}
}
4 changes: 4 additions & 0 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ OTHER_FILES += \
qml/filters/oldfilm/ui.qml \
qml/filters/audio_bandpass/meta.qml \
qml/filters/audio_bandpass/ui.qml \
qml/filters/audio_basstreble/meta.qml \
qml/filters/audio_basstreble/ui.qml \
qml/filters/audio_highpass/meta.qml \
qml/filters/audio_highpass/ui.qml \
qml/filters/audio_lowpass/meta.qml \
Expand Down Expand Up @@ -529,6 +531,8 @@ lupdate_hack {
qml/filters/oldfilm/ui.qml \
qml/filters/audio_bandpass/meta.qml \
qml/filters/audio_bandpass/ui.qml \
qml/filters/audio_basstreble/meta.qml \
qml/filters/audio_basstreble/ui.qml \
qml/filters/audio_highpass/meta.qml \
qml/filters/audio_highpass/ui.qml \
qml/filters/audio_lowpass/meta.qml \
Expand Down

0 comments on commit 9744634

Please sign in to comment.