Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ install_manifest.txt
!cmake/*.cmake
models/*
pc_nsf_hifigan_44.1k_ONNX/
docs/
# Ignore docs/ except the CopyVocal import guide, which documents the reader in this
# repository. The bundle format itself is defined by CopyVocal.
# Use `docs/*` rather than `docs/` so Git still traverses docs/ for the `!` exception below.
docs/*
!docs/copyvocal-import.md
docs/UserGuide.html
.*/
# .*/ 会忽略点开头的目录;Actions 工作流必须入库
Expand Down
63 changes: 63 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,8 @@ set(OPENTUNE_STANDALONE_SOURCES
Source/Utils/ProjectPersistence.h
Source/Utils/ProjectSession.cpp
Source/Utils/ProjectSession.h
Source/Utils/CopyVocalBundle.cpp
Source/Utils/CopyVocalBundle.h
Source/Utils/PlacementActions.cpp
Source/Utils/PlacementActions.h

Expand Down Expand Up @@ -2026,6 +2028,28 @@ if(OPENTUNE_BUILD_TESTS)
endif()
add_test(NAME VisibleTrackCountTests COMMAND OpenTuneVisibleTrackCountTests)

# CopyVocal .cvf parser + editable-domain builders (JUCE core only).
add_executable(OpenTuneCopyVocalBundleTests
Tests/CopyVocalBundleTests.cpp
Source/Utils/CopyVocalBundle.cpp
Source/Utils/PitchCurve.cpp
Source/Utils/TimeGrid.cpp
Source/Utils/ProjectModel.cpp
Source/Utils/AppLogger.cpp
)
target_include_directories(OpenTuneCopyVocalBundleTests
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Source)
target_link_libraries(OpenTuneCopyVocalBundleTests PRIVATE
juce::juce_audio_basics
juce::juce_core
juce::juce_graphics
)
if(MSVC)
target_compile_options(OpenTuneCopyVocalBundleTests PRIVATE /utf-8 /EHsc)
endif()
add_test(NAME CopyVocalBundleTests COMMAND OpenTuneCopyVocalBundleTests)


# Demo-tour load gate: a not-yet-started open is not a failed open.
add_executable(OpenTuneDemoTourGateTests
Tests/DemoTourGateTests.cpp
Expand Down Expand Up @@ -2178,6 +2202,45 @@ if(OPENTUNE_BUILD_TESTS)
endif()
add_test(NAME StandaloneArrangementMoveTests COMMAND OpenTuneStandaloneArrangementMoveTests)

# CopyVocal .cvf -> PreparedOpen (audio fit, F0 injection, snapshot wiring).
# Links the real Standalone shared code; no inference is started.
add_executable(OpenTuneCopyVocalImportTests
Tests/CopyVocalImportTests.cpp
)
target_include_directories(OpenTuneCopyVocalImportTests
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/Source
${ONNXRUNTIME_INCLUDE_DIR}
${ONNXRUNTIME_DML_GENERATED_INCLUDE_DIR}
${ARA_SDK_PATH})
target_compile_definitions(OpenTuneCopyVocalImportTests PRIVATE
JucePlugin_Build_Standalone=1)
target_link_libraries(OpenTuneCopyVocalImportTests PRIVATE
OpenTuneStandalone
OpenTuneResources
juce::juce_audio_basics
juce::juce_audio_formats
juce::juce_core
juce::juce_events
)
if(MSVC)
target_compile_options(OpenTuneCopyVocalImportTests PRIVATE /utf-8 /EHsc)
endif()
# The Standalone shared code delay-loads ONNX Runtime; the test executable
# needs the same runtime DLLs next to it as the app does.
if(WIN32)
add_custom_command(TARGET OpenTuneCopyVocalImportTests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${ONNXRUNTIME_DLL}"
"$<TARGET_FILE_DIR:OpenTuneCopyVocalImportTests>/${OPENTUNE_ORT_DLL_NAME}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${DIRECTML_DLL}"
"$<TARGET_FILE_DIR:OpenTuneCopyVocalImportTests>/DirectML.dll"
COMMENT "Copying inference runtime DLLs to OpenTuneCopyVocalImportTests..."
VERBATIM)
endif()
add_test(NAME CopyVocalImportTests COMMAND OpenTuneCopyVocalImportTests)

# Render/ARA contract tests use the production objects and their real worker
# threads. They intentionally link the application target instead of
# providing test doubles for the render backends.
Expand Down
115 changes: 114 additions & 1 deletion Source/Standalone/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Audio/AsyncAudioLoader.h"
#include "StandaloneArrangementHelpers.h"
#include "Utils/ProjectSession.h"
#include "Utils/CopyVocalBundle.h"
#include "Utils/PlatformFileDialogs.h"
#include "Utils/DemoProject.h"
#include "Utils/DemoTourGate.h"
Expand Down Expand Up @@ -1507,7 +1508,8 @@ bool OpenTuneAudioProcessorEditor::isInterestedInFileDrag(const juce::StringArra
for (const auto& path : files)
{
const juce::File f(path);
if (f.hasFileExtension(kImportExtensionSpec))
if (f.hasFileExtension(CopyVocalBundle::kFileExtension)
|| f.hasFileExtension(kImportExtensionSpec))
return true;
}
return false;
Expand Down Expand Up @@ -1539,6 +1541,13 @@ void OpenTuneAudioProcessorEditor::filesDropped(const juce::StringArray& files,
if (!file.existsAsFile())
return;

if (file.hasFileExtension(CopyVocalBundle::kFileExtension))
{
clearImportDropPreview();
importCopyVocalBundleFile(file);
return;
}

static const juce::String kImportExtensionSpec = getImportExtensionSpec();
if (!file.hasFileExtension(kImportExtensionSpec))
{
Expand Down Expand Up @@ -2508,6 +2517,110 @@ void OpenTuneAudioProcessorEditor::saveAndReturnRequested()
app->quit();
}

void OpenTuneAudioProcessorEditor::importCopyVocalBundleRequested()
{
if (externalEditActive_)
return;
if (rejectProjectOperationIfBusy())
return;

if (projectSession_.isDirty())
{
juce::Component::SafePointer<OpenTuneAudioProcessorEditor> safeThis(this);
ConfirmDialogContent::launch(
new ConfirmDialogContent(
LOC_RAW("Current project has unsaved changes"),
LOC_RAW("Importing a CopyVocal bundle replaces the current project. Save changes first?"),
{ { LOC_RAW("Save"), [safeThis] {
if (safeThis == nullptr) return;
if (!safeThis->projectSession_.hasProjectPath()) {
safeThis->saveProjectAsThenOpenProject();
return;
}
safeThis->saveProject(juce::File(), true);
}, true },
{ LOC_RAW("Do Not Save"), [safeThis] {
if (safeThis == nullptr) return;
safeThis->launchImportCopyVocalBundleChooser();
}, false },
{ LOC(kCancel), nullptr, false } }),
&contentRoot_);
return;
}

launchImportCopyVocalBundleChooser();
}

void OpenTuneAudioProcessorEditor::launchImportCopyVocalBundleChooser()
{
juce::Component::SafePointer<OpenTuneAudioProcessorEditor> safeThis(this);
const juce::String wildcard = "*.cvf";
PlatformFileDialogs::chooseFilesToOpen(
LOC(kImportCopyVocalDialog), juce::File(), wildcard, false, false, &contentRoot_,
[safeThis](const juce::Array<juce::File>& files) {
if (safeThis == nullptr) return;
safeThis->importCopyVocalBundleFile(files.getFirst());
});
}

void OpenTuneAudioProcessorEditor::importCopyVocalBundleFile(const juce::File& file)
{
if (rejectProjectOperationIfBusy())
return;

projectOperationBusy_ = true;
startImportCopyVocalBundle(file);
}

void OpenTuneAudioProcessorEditor::startImportCopyVocalBundle(const juce::File& file)
{
const auto safeThis = juce::Component::SafePointer<OpenTuneAudioProcessorEditor>(this);
const auto openLanguage = LocalizationManager::getInstance().resolveLanguage();
projectWorkerPool_.addJob(
[this, safeThis, file, openLanguage]() {
auto preparedResult = std::make_shared<Result<ProjectSession::PreparedOpen>>(
projectSession_.prepareCopyVocalBundle(file, openLanguage));
juce::MessageManager::callAsync([safeThis, preparedResult]() mutable {
if (safeThis == nullptr)
return;

if (!preparedResult->ok()) {
ConfirmDialogContent::launch(
new ConfirmDialogContent(
LOC(kImportCopyVocalFailed),
projectErrorMessage(preparedResult->error()),
{ { LOC(kOK), nullptr, true } }),
&safeThis->contentRoot_);
safeThis->projectOperationBusy_ = false;
return;
}

auto commitResult = safeThis->projectSession_.commitPreparedOpen(
std::move(*preparedResult).value());
if (!commitResult.ok()) {
ConfirmDialogContent::launch(
new ConfirmDialogContent(
LOC(kImportCopyVocalFailed),
projectErrorMessage(commitResult.error()),
{ { LOC(kOK), nullptr, true } }),
&safeThis->contentRoot_);
safeThis->projectOperationBusy_ = false;
return;
}

// The bundle is a starting point, not a saved project: opening it
// must not look like an already-persisted .otproj.
safeThis->projectSession_.markDirty();
safeThis->syncRecentProjectsToMenu();
safeThis->updateTitleWithProjectPath();
safeThis->refreshAllUIFromProject();
safeThis->projectOperationBusy_ = false;
safeThis->maybeStartOnboarding();
safeThis->updateDemoTour();
});
});
}

void OpenTuneAudioProcessorEditor::importAudioRequested()
{
if (externalEditActive_)
Expand Down
6 changes: 6 additions & 0 deletions Source/Standalone/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class OpenTuneAudioProcessorEditor : public juce::AudioProcessorEditor,

// MenuBarComponent::Listener
void importAudioRequested() override; // 新版本:不再需要trackId参数
void importCopyVocalBundleRequested() override;
void exportAudioRequested(MenuBarComponent::ExportType exportType) override; // 使用ExportType枚举
void openProjectRequested() override;
void saveProjectRequested() override;
Expand Down Expand Up @@ -235,6 +236,11 @@ class OpenTuneAudioProcessorEditor : public juce::AudioProcessorEditor,
void openProjectFile(const juce::File& file);
void startOpenProject(const juce::File& file);

/// CopyVocal .cvf: replace the current project with an editable view of the bundle.
void launchImportCopyVocalBundleChooser();
void importCopyVocalBundleFile(const juce::File& file);
void startImportCopyVocalBundle(const juce::File& file);

OpenTuneAudioProcessor& processorRef_;
AppPreferences& appPreferences_;
std::unique_ptr<juce::DialogWindow> preferencesDialog_;
Expand Down
5 changes: 5 additions & 0 deletions Source/Standalone/UI/MenuBarComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ juce::PopupMenu MenuBarComponent::getMenuForIndex(int topLevelMenuIndex, const j
{
if (profile_ == Profile::Standalone) {
menu.addItem(ImportAudio, LOC(kImportAudio));
menu.addItem(ImportCopyVocalBundle, LOC(kImportCopyVocalBundle));

juce::PopupMenu exportMenu;
exportMenu.addItem(ExportSelectedClip, LOC(kExportSelectedClip));
Expand Down Expand Up @@ -222,6 +223,10 @@ void MenuBarComponent::menuItemSelected(int menuItemID, int topLevelMenuIndex)
listeners_.call([](Listener& l) { l.importAudioRequested(); });
break;

case ImportCopyVocalBundle:
listeners_.call([](Listener& l) { l.importCopyVocalBundleRequested(); });
break;

// 导出选项 - 使用ExportType枚举
case ExportSelectedClip:
listeners_.call([](Listener& l) { l.exportAudioRequested(ExportType::SelectedClip); });
Expand Down
2 changes: 2 additions & 0 deletions Source/Standalone/UI/MenuBarComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class MenuBarComponent : public juce::Component,
public:
virtual ~Listener() = default;
virtual void importAudioRequested() = 0;
virtual void importCopyVocalBundleRequested() {}
virtual void exportAudioRequested(ExportType exportType) = 0;
virtual void openProjectRequested() = 0;
virtual void saveProjectRequested() = 0;
Expand Down Expand Up @@ -114,6 +115,7 @@ class MenuBarComponent : public juce::Component,
enum MenuItemIDs
{
ImportAudio = 1,
ImportCopyVocalBundle,
ExportSelectedClip,
ExportTrack,
ExportBus,
Expand Down
Loading