Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Multimedia
Kdenlive
Commits
e9ad1a7a
Commit
e9ad1a7a
authored
Jun 16, 2020
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement gain and normalize audio stream effects.
Related to
#382
parent
c2ee48cb
Pipeline
#23852
passed with stage
in 26 minutes and 18 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
19 deletions
+60
-19
src/mltcontroller/clippropertiescontroller.cpp
src/mltcontroller/clippropertiescontroller.cpp
+56
-18
src/mltcontroller/clippropertiescontroller.h
src/mltcontroller/clippropertiescontroller.h
+4
-1
No files found.
src/mltcontroller/clippropertiescontroller.cpp
View file @
e9ad1a7a
...
...
@@ -664,11 +664,23 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
QListWidgetItem
*
item
=
m_audioStreamsView
->
item
(
row
);
m_activeAudioStreams
=
item
->
data
(
Qt
::
UserRole
).
toInt
();
QStringList
effects
=
m_controller
->
getAudioStreamEffect
(
m_activeAudioStreams
);
QSignalBlocker
bk
(
m_swapChanels
);
QSignalBlocker
bk
(
m_swapChan
n
els
);
QSignalBlocker
bk1
(
m_copyChannelGroup
);
m_swapChanels
->
setChecked
(
effects
.
contains
(
QLatin1String
(
"channelswap"
)));
QSignalBlocker
bk2
(
m_normalize
);
m_swapChannels
->
setChecked
(
effects
.
contains
(
QLatin1String
(
"channelswap"
)));
m_copyChannel1
->
setChecked
(
effects
.
contains
(
QStringLiteral
(
"channelcopy from=0 to=1"
)));
m_copyChannel2
->
setChecked
(
effects
.
contains
(
QStringLiteral
(
"channelcopy from=1 to=0"
)));
m_normalize
->
setChecked
(
effects
.
contains
(
QStringLiteral
(
"dynamic_loudness"
)));
int
gain
=
0
;
for
(
const
QString
st
:
effects
)
{
if
(
st
.
startsWith
(
QLatin1String
(
"volume "
)))
{
QSignalBlocker
bk3
(
m_gain
);
gain
=
st
.
section
(
QLatin1Char
(
'='
),
1
).
toInt
();
break
;
}
}
QSignalBlocker
bk3
(
m_gain
);
m_gain
->
setValue
(
gain
);
}
else
{
m_activeAudioStreams
=
-
1
;
m_audioEffectGroup
->
setEnabled
(
false
);
...
...
@@ -741,8 +753,27 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
m_audioEffectGroup
=
new
QGroupBox
(
this
);
m_audioEffectGroup
->
setEnabled
(
false
);
QVBoxLayout
*
vbox
=
new
QVBoxLayout
;
m_swapChanels
=
new
QCheckBox
(
i18n
(
"Swap Channels"
),
this
);
connect
(
m_swapChanels
,
&
QCheckBox
::
stateChanged
,
[
this
]
(
int
state
)
{
// Normalize
m_normalize
=
new
QCheckBox
(
i18n
(
"Normalize"
),
this
);
connect
(
m_normalize
,
&
QCheckBox
::
stateChanged
,
[
this
]
(
int
state
)
{
if
(
m_activeAudioStreams
==
-
1
)
{
// No stream selected, abort
return
;
}
if
(
state
==
Qt
::
Checked
)
{
// Add swap channels effect
m_controller
->
addAudioStreamEffect
(
m_activeAudioStreams
,
QStringLiteral
(
"dynamic_loudness"
));
}
else
{
// Remove swap channels effect
m_controller
->
removeAudioStreamEffect
(
m_activeAudioStreams
,
QStringLiteral
(
"dynamic_loudness"
));
}
updateStreamIcon
(
m_audioStreamsView
->
currentRow
(),
m_activeAudioStreams
);
});
vbox
->
addWidget
(
m_normalize
);
// Swap channels
m_swapChannels
=
new
QCheckBox
(
i18n
(
"Swap Channels"
),
this
);
connect
(
m_swapChannels
,
&
QCheckBox
::
stateChanged
,
[
this
]
(
int
state
)
{
if
(
m_activeAudioStreams
==
-
1
)
{
// No stream selected, abort
return
;
...
...
@@ -750,14 +781,13 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
if
(
state
==
Qt
::
Checked
)
{
// Add swap channels effect
m_controller
->
addAudioStreamEffect
(
m_activeAudioStreams
,
QStringLiteral
(
"channelswap"
));
updateStreamIcon
(
m_audioStreamsView
->
currentRow
(),
m_activeAudioStreams
);
}
else
{
// Remove swap channels effect
m_controller
->
removeAudioStreamEffect
(
m_activeAudioStreams
,
QStringLiteral
(
"channelswap"
));
updateStreamIcon
(
m_audioStreamsView
->
currentRow
(),
m_activeAudioStreams
);
}
updateStreamIcon
(
m_audioStreamsView
->
currentRow
(),
m_activeAudioStreams
);
});
vbox
->
addWidget
(
m_swapChanels
);
vbox
->
addWidget
(
m_swapChan
n
els
);
// Copy channel
QHBoxLayout
*
copyLay
=
new
QHBoxLayout
;
copyLay
->
addWidget
(
new
QLabel
(
i18n
(
"Copy Channel"
),
this
));
...
...
@@ -773,37 +803,45 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
vbox
->
addLayout
(
copyLay
);
connect
(
m_copyChannelGroup
,
QOverload
<
QAbstractButton
*
,
bool
>::
of
(
&
QButtonGroup
::
buttonToggled
),
[
this
]
(
QAbstractButton
*
but
,
bool
)
{
if
(
but
==
m_copyChannel1
)
{
qDebug
()
<<
"=== BUTTON 1 CLKD"
;
QSignalBlocker
bk
(
m_copyChannelGroup
);
m_copyChannel2
->
setChecked
(
false
);
}
else
{
qDebug
()
<<
"=== BUTTON 2 CLKD"
;
QSignalBlocker
bk
(
m_copyChannelGroup
);
m_copyChannel1
->
setChecked
(
false
);
}
if
(
m_copyChannel1
->
isChecked
())
{
m_controller
->
addAudioStreamEffect
(
m_activeAudioStreams
,
QStringLiteral
(
"channelcopy from=0 to=1"
));
updateStreamIcon
(
m_audioStreamsView
->
currentRow
(),
m_activeAudioStreams
);
}
else
if
(
m_copyChannel2
->
isChecked
())
{
m_controller
->
addAudioStreamEffect
(
m_activeAudioStreams
,
QStringLiteral
(
"channelcopy from=1 to=0"
));
updateStreamIcon
(
m_audioStreamsView
->
currentRow
(),
m_activeAudioStreams
);
}
else
{
// Remove swap channels effect
m_controller
->
removeAudioStreamEffect
(
m_activeAudioStreams
,
QStringLiteral
(
"channelcopy"
));
updateStreamIcon
(
m_audioStreamsView
->
currentRow
(),
m_activeAudioStreams
);
}
updateStreamIcon
(
m_audioStreamsView
->
currentRow
(),
m_activeAudioStreams
);
});
// Gain
QHBoxLayout
*
gainLay
=
new
QHBoxLayout
;
gainLay
->
addWidget
(
new
QLabel
(
i18n
(
"Gain"
),
this
));
QSpinBox
*
spinGain
=
new
QSpinBox
(
this
);
spinGain
->
setRange
(
-
10
,
10
);
spinGain
->
setSuffix
(
i18n
(
"dB"
));
gainLay
->
addWidget
(
spinGain
);
m_gain
=
new
QSpinBox
(
this
);
m_gain
->
setRange
(
-
100
,
60
);
m_gain
->
setSuffix
(
i18n
(
"dB"
));
connect
(
m_gain
,
QOverload
<
int
>::
of
(
&
QSpinBox
::
valueChanged
),
[
this
]
(
int
value
)
{
if
(
m_activeAudioStreams
==
-
1
)
{
// No stream selected, abort
return
;
}
if
(
value
==
0
)
{
// Remove effect
m_controller
->
removeAudioStreamEffect
(
m_activeAudioStreams
,
QStringLiteral
(
"volume"
));
}
else
{
m_controller
->
addAudioStreamEffect
(
m_activeAudioStreams
,
QString
(
"volume level=%1"
).
arg
(
value
));
}
updateStreamIcon
(
m_audioStreamsView
->
currentRow
(),
m_activeAudioStreams
);
});
gainLay
->
addWidget
(
m_gain
);
gainLay
->
addStretch
(
1
);
vbox
->
addLayout
(
gainLay
);
// Normalize
vbox
->
addWidget
(
new
QCheckBox
(
i18n
(
"Normalize"
),
this
));
vbox
->
addStretch
(
1
);
m_audioEffectGroup
->
setLayout
(
vbox
);
audioVbox
->
addWidget
(
m_audioEffectGroup
);
...
...
src/mltcontroller/clippropertiescontroller.h
View file @
e9ad1a7a
...
...
@@ -39,6 +39,7 @@ class QListWidget;
class
QGroupBox
;
class
QCheckBox
;
class
QButtonGroup
;
class
QSpinBox
;
class
AnalysisTree
:
public
QTreeWidget
{
...
...
@@ -121,10 +122,12 @@ private:
QTextEdit
*
m_textEdit
;
QListWidget
*
m_audioStreamsView
;
QGroupBox
*
m_audioEffectGroup
;
QCheckBox
*
m_swapChanels
;
QCheckBox
*
m_swapChannels
;
QCheckBox
*
m_normalize
;
QButtonGroup
*
m_copyChannelGroup
;
QCheckBox
*
m_copyChannel1
;
QCheckBox
*
m_copyChannel2
;
QSpinBox
*
m_gain
;
/** @brief The selected audio stream. */
int
m_activeAudioStreams
;
void
fillProperties
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment