-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
891 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
project(TalcsDspx VERSION ${TALCS_VERSION} LANGUAGES CXX) | ||
|
||
file(GLOB_RECURSE _src *.h *.cpp) | ||
|
||
talcs_add_library(${PROJECT_NAME} AUTOGEN | ||
SOURCES ${_src} | ||
LINKS talcs::Core talcs::Format | ||
QT_INCLUDE_PRIVATE Core | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2024 CrSjimo * | ||
* * | ||
* This file is part of TALCS. * | ||
* * | ||
* TALCS is free software: you can redistribute it and/or modify it under the * | ||
* terms of the GNU Lesser General Public License as published by the Free * | ||
* Software Foundation, either version 3 of the License, or (at your option) * | ||
* any later version. * | ||
* * | ||
* TALCS 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 Lesser General Public License for * | ||
* more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with TALCS. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
#include "DspxAudioClipContext.h" | ||
#include "DspxAudioClipContext_p.h" | ||
|
||
#include <TalcsCore/PositionableMixerAudioSource.h> | ||
#include <TalcsCore/BufferingAudioSource.h> | ||
|
||
#include <TalcsFormat/FormatManager.h> | ||
#include <TalcsFormat/FormatEntry.h> | ||
#include <TalcsFormat/AudioFormatInputSource.h> | ||
|
||
#include <TalcsDspx/DspxTrackContext.h> | ||
#include <TalcsDspx/DspxProjectContext.h> | ||
|
||
namespace talcs { | ||
|
||
DspxAudioClipContext::DspxAudioClipContext(DspxTrackContext *trackContext) : QObject(trackContext), d_ptr(new DspxAudioClipContextPrivate) { | ||
Q_D(DspxAudioClipContext); | ||
d->q_ptr = this; | ||
|
||
d->controlMixer = std::make_unique<PositionableMixerAudioSource>(); | ||
d->clipMixer = std::make_unique<PositionableMixerAudioSource>(); | ||
|
||
d->controlMixer->addSource(d->clipMixer.get()); | ||
|
||
d->trackContext = trackContext; | ||
} | ||
|
||
DspxAudioClipContext::~DspxAudioClipContext() { | ||
|
||
} | ||
|
||
PositionableMixerAudioSource *DspxAudioClipContext::controlMixer() const { | ||
Q_D(const DspxAudioClipContext); | ||
return d->controlMixer.get(); | ||
} | ||
|
||
PositionableMixerAudioSource *DspxAudioClipContext::clipMixer() const { | ||
Q_D(const DspxAudioClipContext); | ||
return d->clipMixer.get(); | ||
} | ||
|
||
BufferingAudioSource *DspxAudioClipContext::contentSource() const { | ||
Q_D(const DspxAudioClipContext); | ||
return d->contentSource.get(); | ||
} | ||
|
||
DspxTrackContext *DspxAudioClipContext::trackContext() const { | ||
Q_D(const DspxAudioClipContext); | ||
return d->trackContext; | ||
} | ||
|
||
void DspxAudioClipContext::setStart(int tick) { | ||
Q_D(DspxAudioClipContext); | ||
if (d->startTick != tick) { | ||
d->startTick = tick; | ||
updatePosition(); | ||
} | ||
} | ||
|
||
int DspxAudioClipContext::start() const { | ||
Q_D(const DspxAudioClipContext); | ||
return d->startTick; | ||
} | ||
|
||
void DspxAudioClipContext::setClipStart(int tick) { | ||
Q_D(DspxAudioClipContext); | ||
if (d->clipStartTick != tick) { | ||
d->clipStartTick = tick; | ||
updatePosition(); | ||
} | ||
} | ||
|
||
int DspxAudioClipContext::clipStart() const { | ||
Q_D(const DspxAudioClipContext); | ||
return d->clipStartTick; | ||
} | ||
|
||
void DspxAudioClipContext::setClipLen(int tick) { | ||
Q_D(DspxAudioClipContext); | ||
if (d->clipLenTick != tick) { | ||
d->clipLenTick = tick; | ||
updatePosition(); | ||
} | ||
} | ||
|
||
int DspxAudioClipContext::clipLen() const { | ||
Q_D(const DspxAudioClipContext); | ||
return d->clipLenTick; | ||
} | ||
|
||
void DspxAudioClipContextPrivate::handleIO(AbstractAudioFormatIO *io) { | ||
auto rawSource_ = std::make_unique<AudioFormatInputSource>(io, true); | ||
if (contentSource) | ||
clipMixer->removeSource(contentSource.get()); | ||
contentSource.reset(trackContext->projectContext()->makeBufferable(rawSource_.get(), 2)); | ||
rawSource = std::move(rawSource_); | ||
clipMixer->prependSource(contentSource.get()); | ||
} | ||
|
||
bool DspxAudioClipContext::setPathLoad(const QString &path, const QVariant &data) { | ||
Q_D(DspxAudioClipContext); | ||
auto formatManager = d->trackContext->projectContext()->formatManager(); | ||
if (!formatManager) | ||
return false; | ||
auto io = formatManager->getFormatLoad(path, data); | ||
if (!io) | ||
return false; | ||
d->handleIO(io); | ||
d->path = path; | ||
return true; | ||
} | ||
|
||
bool DspxAudioClipContext::setPathOpen(const QString &path, const QString &filter, QVariant &data) { | ||
Q_D(DspxAudioClipContext); | ||
auto formatManager = d->trackContext->projectContext()->formatManager(); | ||
if (!formatManager) | ||
return false; | ||
AbstractAudioFormatIO *io = nullptr; | ||
for (auto entry : formatManager->entries()) { | ||
if (filter.isEmpty() || entry->filters().contains(filter)) { | ||
io = entry->getFormatLoad(path, data); | ||
if (io) | ||
break; | ||
} | ||
} | ||
if (!io) | ||
return false; | ||
d->handleIO(io); | ||
d->path = path; | ||
return true; | ||
} | ||
|
||
QString DspxAudioClipContext::path() const { | ||
Q_D(const DspxAudioClipContext); | ||
return d->path; | ||
} | ||
|
||
void DspxAudioClipContext::updatePosition() { | ||
Q_D(DspxAudioClipContext); | ||
auto clipSeries = d->trackContext->clipSeries(); | ||
auto convertTime = d->trackContext->projectContext()->timeConverter(); | ||
auto startSample = convertTime(d->clipStartTick); | ||
clipSeries->setClipStartPos(d->clipView, startSample); | ||
auto firstSample = convertTime(d->startTick + d->clipStartTick); | ||
auto lastSample = convertTime(d->startTick + d->clipStartTick + d->clipLenTick); | ||
clipSeries->setClipRange(d->clipView, firstSample, qMax(qint64(1), lastSample - firstSample)); | ||
} | ||
|
||
void DspxAudioClipContext::setData(const QVariant &data) { | ||
Q_D(DspxAudioClipContext); | ||
d->data = data; | ||
} | ||
|
||
QVariant DspxAudioClipContext::data() const { | ||
Q_D(const DspxAudioClipContext); | ||
return d->data; | ||
} | ||
|
||
} // talcs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2024 CrSjimo * | ||
* * | ||
* This file is part of TALCS. * | ||
* * | ||
* TALCS is free software: you can redistribute it and/or modify it under the * | ||
* terms of the GNU Lesser General Public License as published by the Free * | ||
* Software Foundation, either version 3 of the License, or (at your option) * | ||
* any later version. * | ||
* * | ||
* TALCS 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 Lesser General Public License for * | ||
* more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with TALCS. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
#ifndef TALCS_DSPXAUDIOCLIPCONTEXT_H | ||
#define TALCS_DSPXAUDIOCLIPCONTEXT_H | ||
|
||
#include <QObject> | ||
#include <QVariant> | ||
|
||
#include <TalcsDspx/TalcsDspxGlobal.h> | ||
|
||
namespace talcs { | ||
|
||
class PositionableMixerAudioSource; | ||
class BufferingAudioSource; | ||
|
||
class DspxTrackContext; | ||
|
||
class DspxAudioClipContextPrivate; | ||
|
||
class TALCSDSPX_EXPORT DspxAudioClipContext : public QObject { | ||
Q_OBJECT | ||
Q_DECLARE_PRIVATE(DspxAudioClipContext) | ||
friend class DspxTrackContext; | ||
public: | ||
explicit DspxAudioClipContext(DspxTrackContext *trackContext); | ||
~DspxAudioClipContext() override; | ||
|
||
PositionableMixerAudioSource *controlMixer() const; | ||
PositionableMixerAudioSource *clipMixer() const; | ||
BufferingAudioSource *contentSource() const; | ||
|
||
DspxTrackContext *trackContext() const; | ||
|
||
void setStart(int tick); | ||
int start() const; | ||
|
||
void setClipStart(int tick); | ||
int clipStart() const; | ||
|
||
void setClipLen(int tick); | ||
int clipLen() const; | ||
|
||
bool setPathLoad(const QString &path, const QVariant &data = {}); | ||
bool setPathOpen(const QString &path, const QString &selectedFilter, QVariant &data); | ||
QString path() const; | ||
|
||
void updatePosition(); | ||
|
||
void setData(const QVariant &data); | ||
QVariant data() const; | ||
|
||
private: | ||
QScopedPointer<DspxAudioClipContextPrivate> d_ptr; | ||
|
||
}; | ||
|
||
} // talcs | ||
|
||
#endif //TALCS_DSPXAUDIOCLIPCONTEXT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2024 CrSjimo * | ||
* * | ||
* This file is part of TALCS. * | ||
* * | ||
* TALCS is free software: you can redistribute it and/or modify it under the * | ||
* terms of the GNU Lesser General Public License as published by the Free * | ||
* Software Foundation, either version 3 of the License, or (at your option) * | ||
* any later version. * | ||
* * | ||
* TALCS 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 Lesser General Public License for * | ||
* more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with TALCS. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
#ifndef TALCS_DSPXAUDIOCLIPCONTEXT_P_H | ||
#define TALCS_DSPXAUDIOCLIPCONTEXT_P_H | ||
|
||
#include <memory> | ||
|
||
#include <TalcsCore/AudioSourceClipSeries.h> | ||
|
||
#include <TalcsDspx/DspxAudioClipContext.h> | ||
|
||
namespace talcs { | ||
|
||
class AbstractAudioFormatIO; | ||
|
||
class DspxAudioClipContextPrivate { | ||
Q_DECLARE_PUBLIC(DspxAudioClipContext); | ||
public: | ||
DspxAudioClipContext *q_ptr; | ||
|
||
std::unique_ptr<PositionableAudioSource> rawSource; | ||
std::unique_ptr<BufferingAudioSource> contentSource; | ||
std::unique_ptr<PositionableMixerAudioSource> clipMixer; | ||
std::unique_ptr<PositionableMixerAudioSource> controlMixer; | ||
|
||
DspxTrackContext *trackContext; | ||
|
||
AudioSourceClipSeries::ClipView clipView; | ||
|
||
int startTick = 0; | ||
int clipStartTick = 0; | ||
int clipLenTick = 0; | ||
QString path; | ||
|
||
QVariant data; | ||
|
||
void handleIO(AbstractAudioFormatIO *io); | ||
|
||
}; | ||
} | ||
|
||
#endif //TALCS_DSPXAUDIOCLIPCONTEXT_P_H |
Oops, something went wrong.