Commit aafe89da authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Split audio now extracts audio on audio tracks

parent 30d5daff
......@@ -120,7 +120,7 @@ enum MonitorSceneType {
enum MessageType { DefaultMessage, ProcessingJobMessage, OperationCompletedMessage, InformationMessage, ErrorMessage, MltError };
enum TrackType { AudioTrack = 0, VideoTrack = 1 };
enum TrackType { AudioTrack = 0, VideoTrack = 1, AnyTrack = 2 };
enum CacheType { SystemCacheRoot = -1, CacheRoot = 0, CacheBase = 1, CachePreview = 2, CacheProxy = 3, CacheAudio = 4, CacheThumbs = 5 };
......
......@@ -380,7 +380,13 @@ bool TimelineFunctions::requestSplitAudio(std::shared_ptr<TimelineItemModel> tim
int position = timeline->getClipPosition(cid);
int duration = timeline->getClipPlaytime(cid);
int track = timeline->getClipTrackId(cid);
int newTrack = timeline->getNextTrackId(track);
int newTrack = timeline->getLowerTrackId(track, TrackType::AudioTrack);
if (newTrack == -1) {
// No available audio track for splitting, abort
undo();
pCore->displayMessage(i18n("No available audio track for split operation"), ErrorMessage);
return false;
}
int newId;
TimelineFunctions::changeClipState(timeline, clipId, PlaylistState::VideoOnly);
bool res = copyClip(timeline, cid, newId, PlaylistState::AudioOnly, undo, redo);
......
......@@ -249,13 +249,29 @@ int TimelineModel::getTrackMltIndex(int trackId) const
return getTrackPosition(trackId) + 1;
}
int TimelineModel::getNextTrackId(int trackId) const
int TimelineModel::getLowerTrackId(int trackId, TrackType type) const
{
READ_LOCK();
Q_ASSERT(isTrack(trackId));
auto it = m_iteratorTable.at(trackId);
while (it != m_allTracks.begin()) {
--it;
return (it != m_allTracks.begin()) ? (*it)->getId() : -1;
if (it == m_allTracks.begin()) {
// no track available
return -1;
}
if (type == TrackType::AnyTrack) {
return (*it)->getId();
}
int audioTrack = (*it)->getProperty("kdenlive:audio_track").toInt();
if (type == TrackType::AudioTrack && audioTrack == 1) {
return (*it)->getId();
}
if (type == TrackType::VideoTrack && audioTrack == 0) {
return (*it)->getId();
}
}
return -1;
}
int TimelineModel::getPreviousVideoTrackPos(int trackId) const
......
......@@ -245,7 +245,7 @@ public:
Return -1 if we give the last track
@param trackId Id of the track to test
*/
int getNextTrackId(int trackId) const;
int getLowerTrackId(int trackId, TrackType type = TrackType::AnyTrack) const;
/* @brief Returns the MLT track index of the video track just below the given trackC
@param trackId Id of the track to test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment