Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
4c7961e1
Commit
4c7961e1
authored
Mar 23, 2020
by
Jean-Baptiste Mardelle
Browse files
Allow aligning several clips to audio reference
parent
bd1d4f09
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/mainwindow.cpp
View file @
4c7961e1
...
...
@@ -1527,7 +1527,7 @@ void MainWindow::setupActions()
QAction
*
alignAudio
=
addAction
(
QStringLiteral
(
"align_audio"
),
i18n
(
"Align Audio to Reference"
),
this
,
SLOT
(
slotAlignAudio
()),
QIcon
(),
QKeySequence
(),
clipActionCategory
);
// "A" as data means this action should only be available for clips with audio
alignAudio
->
setData
(
'A'
);
//
alignAudio->setData('A');
alignAudio
->
setEnabled
(
false
);
QAction
*
act
=
addAction
(
QStringLiteral
(
"edit_item_duration"
),
i18n
(
"Edit Duration"
),
this
,
SLOT
(
slotEditItemDuration
()),
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
4c7961e1
...
...
@@ -2184,28 +2184,59 @@ void TimelineController::alignAudio(int clipId)
return
;
}
const
QString
masterBinClipId
=
getClipBinId
(
m_audioRef
);
std
::
unordered_set
<
int
>
clipsToAnalyse
;
if
(
m_model
->
m_groups
->
isInGroup
(
clipId
))
{
std
::
unordered_set
<
int
>
groupIds
=
m_model
->
getGroupElements
(
clipId
);
// Check that no item is grouped with our audioRef item
// TODO
clipsToAnalyse
=
m_model
->
getGroupElements
(
clipId
);
m_model
->
requestClearSelection
();
}
else
{
clipsToAnalyse
.
insert
(
clipId
);
}
const
QString
otherBinId
=
getClipBinId
(
clipId
);
if
(
otherBinId
==
masterBinClipId
)
{
// easy, same clip.
int
newPos
=
m_model
->
getClipPosition
(
m_audioRef
)
-
m_model
->
getClipIn
(
m_audioRef
)
+
m_model
->
getClipIn
(
clipId
);
if
(
newPos
)
{
bool
result
=
m_model
->
requestClipMove
(
clipId
,
m_model
->
getClipTrackId
(
clipId
),
newPos
,
true
,
true
,
true
);
if
(
!
result
)
{
pCore
->
displayMessage
(
i18n
(
"Cannot move clip to frame %1."
,
newPos
),
InformationMessage
,
500
);
QList
<
int
>
processedGroups
;
int
processed
=
0
;
for
(
int
cid
:
clipsToAnalyse
)
{
if
(
!
m_model
->
isClip
(
cid
)
||
cid
==
m_audioRef
)
{
continue
;
}
const
QString
otherBinId
=
getClipBinId
(
cid
);
if
(
m_model
->
m_groups
->
isInGroup
(
cid
))
{
int
parentGroup
=
m_model
->
m_groups
->
getRootId
(
cid
);
if
(
processedGroups
.
contains
(
parentGroup
))
{
continue
;
}
// Only process one clip from the group
std
::
shared_ptr
<
ProjectClip
>
clip
=
pCore
->
bin
()
->
getBinClip
(
otherBinId
);
if
(
clip
->
hasAudio
())
{
processedGroups
<<
parentGroup
;
}
else
{
continue
;
}
return
;
}
if
(
!
pCore
->
bin
()
->
getBinClip
(
otherBinId
)
->
hasAudio
())
{
// Cannot process non audi clips
continue
;
}
if
(
otherBinId
==
masterBinClipId
)
{
// easy, same clip.
int
newPos
=
m_model
->
getClipPosition
(
m_audioRef
)
-
m_model
->
getClipIn
(
m_audioRef
)
+
m_model
->
getClipIn
(
cid
);
if
(
newPos
)
{
bool
result
=
m_model
->
requestClipMove
(
cid
,
m_model
->
getClipTrackId
(
cid
),
newPos
,
true
,
true
,
true
);
processed
++
;
if
(
!
result
)
{
pCore
->
displayMessage
(
i18n
(
"Cannot move clip to frame %1."
,
newPos
),
InformationMessage
,
500
);
}
continue
;
}
}
processed
++
;
// Perform audio calculation
AudioEnvelope
*
envelope
=
new
AudioEnvelope
(
otherBinId
,
cid
,
(
size_t
)
m_model
->
getClipIn
(
cid
),
(
size_t
)
m_model
->
getClipPlaytime
(
cid
),
(
size_t
)
m_model
->
getClipPosition
(
cid
));
m_audioCorrelator
->
addChild
(
envelope
);
}
if
(
processed
==
0
)
{
//TODO: improve feedback message after freeze
pCore
->
displayMessage
(
i18n
(
"Select a clip to apply an effect"
),
InformationMessage
,
500
);
}
// Perform audio calculation
AudioEnvelope
*
envelope
=
new
AudioEnvelope
(
otherBinId
,
clipId
,
(
size_t
)
m_model
->
getClipIn
(
clipId
),
(
size_t
)
m_model
->
getClipPlaytime
(
clipId
),
(
size_t
)
m_model
->
getClipPosition
(
clipId
));
m_audioCorrelator
->
addChild
(
envelope
);
}
void
TimelineController
::
switchTrackActive
(
int
trackId
)
...
...
Bruno Santos
@bsantos
mentioned in issue
#230 (closed)
·
Mar 23, 2020
mentioned in issue
#230 (closed)
mentioned in issue #230
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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