From 4477b5e841bd663d54a32a783a4639294e2eb66b Mon Sep 17 00:00:00 2001 From: CrSjimo Date: Tue, 28 Oct 2025 10:05:23 +0800 Subject: [PATCH 01/18] Refactor project structure --- .gitignore | 118 ++++- CMakeLists.txt | 166 +++--- cmake/winrc.cmake | 18 +- include/opendspx/audioclip.h | 12 + include/opendspx/buscontrol.h | 14 + include/opendspx/clip.h | 29 ++ include/opendspx/cliptime.h | 15 + include/opendspx/content.h | 24 + include/opendspx/converter.h | 18 - include/opendspx/converters/midi.h | 42 -- include/opendspx/converters/opensvip.h | 16 - include/opendspx/converters/svip.h | 16 - include/opendspx/converters/ust.h | 16 - include/opendspx/global.h | 18 + include/opendspx/label.h | 15 + include/opendspx/master.h | 14 + include/opendspx/model.h | 18 + include/opendspx/opendspx_global.h | 27 - include/opendspx/qdspxbase.h | 76 --- include/opendspx/qdspxmodel.h | 70 --- include/opendspx/qdspxnote.h | 91 ---- include/opendspx/qdspxparam.h | 83 --- include/opendspx/qdspxtimeline.h | 57 -- include/opendspx/qdspxtrack.h | 102 ---- include/opendspx/singingclip.h | 12 + include/opendspx/tempo.h | 13 + include/opendspx/timeline.h | 20 + include/opendspx/timesignature.h | 14 + include/opendspx/track.h | 22 + include/opendspx/trackcontrol.h | 15 + include/opendspx/workspace.h | 13 + .../opendspxconverterglobal.h | 18 + .../opendspxserializerglobal.h | 18 + src/converter/midi.cpp | 1 + src/converters/midi.cpp | 487 ------------------ src/converters/opensvip.cpp | 14 - src/converters/svip.cpp | 56 -- src/converters/ust.cpp | 43 -- src/qdspxmodel.cpp | 51 -- src/qdspxparam.cpp | 45 -- src/qdspxtrack.cpp | 45 -- src/serializer/serializer.cpp | 0 tests/CMakeLists.txt | 16 - tests/main.cpp | 46 -- 44 files changed, 515 insertions(+), 1509 deletions(-) create mode 100644 include/opendspx/audioclip.h create mode 100644 include/opendspx/buscontrol.h create mode 100644 include/opendspx/clip.h create mode 100644 include/opendspx/cliptime.h create mode 100644 include/opendspx/content.h delete mode 100644 include/opendspx/converter.h delete mode 100644 include/opendspx/converters/midi.h delete mode 100644 include/opendspx/converters/opensvip.h delete mode 100644 include/opendspx/converters/svip.h delete mode 100644 include/opendspx/converters/ust.h create mode 100644 include/opendspx/global.h create mode 100644 include/opendspx/label.h create mode 100644 include/opendspx/master.h create mode 100644 include/opendspx/model.h delete mode 100644 include/opendspx/opendspx_global.h delete mode 100644 include/opendspx/qdspxbase.h delete mode 100644 include/opendspx/qdspxmodel.h delete mode 100644 include/opendspx/qdspxnote.h delete mode 100644 include/opendspx/qdspxparam.h delete mode 100644 include/opendspx/qdspxtimeline.h delete mode 100644 include/opendspx/qdspxtrack.h create mode 100644 include/opendspx/singingclip.h create mode 100644 include/opendspx/tempo.h create mode 100644 include/opendspx/timeline.h create mode 100644 include/opendspx/timesignature.h create mode 100644 include/opendspx/track.h create mode 100644 include/opendspx/trackcontrol.h create mode 100644 include/opendspx/workspace.h create mode 100644 include/opendspxconverter/opendspxconverterglobal.h create mode 100644 include/opendspxserializer/opendspxserializerglobal.h create mode 100644 src/converter/midi.cpp delete mode 100644 src/converters/midi.cpp delete mode 100644 src/converters/opensvip.cpp delete mode 100644 src/converters/svip.cpp delete mode 100644 src/converters/ust.cpp delete mode 100644 src/qdspxmodel.cpp delete mode 100644 src/qdspxparam.cpp delete mode 100644 src/qdspxtrack.cpp create mode 100644 src/serializer/serializer.cpp delete mode 100644 tests/main.cpp diff --git a/.gitignore b/.gitignore index 259148f..d41a831 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,104 @@ -# Prerequisites -*.d +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- -# Compiled Object files -*.slo -*.lo +*~ +*.log +*.autosave +*.a +*.core +*.moc *.o *.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +# *.res +# *.rc +/.qmake.cache +/.qmake.stash -# Precompiled Headers -*.gch -*.pch +# qtcreator generated files +*.pro.user* -# Compiled Dynamic libraries -*.so -*.dylib -*.dll +# xemacs temporary files +*.flc -# Fortran module files -*.mod -*.smod +# Vim temporary files +.*.swp -# Compiled Static libraries -*.lai -*.la -*.a -*.lib +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +__pycache__ +*.pyc -# Executables +# Binaries +# -------- +*.dll *.exe -*.out -*.app + +.DS_Store +*/.DS_Store + +build-src* +build/ +cmake-build* +*.user +*.lnk +_workingDir* +.vscode +.idea +.cache +cache +.vs +out/ +CMakeSettings.json +/vcpkg +/data +/*.natvis + +*.sublime-* +setup-vcpkg.json +setup-vcpkg-temp* +setup-inno* + +node_modules/ + +qasc_*.cpp +ckaec_*.cpp \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index c11c702..7532673 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ project(opendspx VERSION 0.0.1.5 LANGUAGES C CXX) # ---------------------------------- option(OPENDSPX_BUILD_STATIC "Build static library" OFF) option(OPENDSPX_BUILD_TESTS "Build test cases" OFF) +option(OPENDSPX_BUILD_SERIALIZER "Build serializer" ON) +option(OPENDSPX_BUILD_CONVERTER "Build converter" ON) option(OPENDSPX_INSTALL "Install library" ON) # ---------------------------------- @@ -55,79 +57,119 @@ set(OPENDSPX_INSTALL_NAME ${PROJECT_NAME}) # ---------------------------------- set(CMAKE_POSITION_INDEPENDENT_CODE on) +set(OPENDSPX_MODEL_TARGET ${PROJECT_NAME}model) +set(OPENDSPX_SERIALIZER_TARGET ${PROJECT_NAME}serializer) +set(OPENDSPX_CONVERTER_TARGET ${PROJECT_NAME}converter) +set(CURRENT_YEAR) +string(TIMESTAMP CURRENT_YEAR "%Y") + +find_package(QT NAMES Qt6 COMPONENTS Core REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) +if (WIN32) + include(cmake/winrc.cmake) +endif() + if (TRUE) # Add library + add_library(${OPENDSPX_MODEL_TARGET} INTERFACE) + + # Add features + target_compile_features(${OPENDSPX_MODEL_TARGET} INTERFACE cxx_std_20 cxx_std_17) + + # Include directories + target_include_directories(${OPENDSPX_MODEL_TARGET} INTERFACE + "$" + ) + + # Link libraries + target_link_libraries(${OPENDSPX_MODEL_TARGET} INTERFACE Qt${QT_VERSION_MAJOR}::Core) + + if (OPENDSPX_INSTALL) + target_include_directories(${OPENDSPX_MODEL_TARGET} INTERFACE + "$" + ) + + install(TARGETS ${OPENDSPX_MODEL_TARGET} + EXPORT ${OPENDSPX_INSTALL_NAME}Targets + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL + ) + endif () +endif () + +macro(_opendspx_add_library identifier) + string(TOUPPER "${identifier}" IDENTIFIER) if (OPENDSPX_BUILD_STATIC) - add_library(${PROJECT_NAME} STATIC) - target_compile_definitions(${PROJECT_NAME} PUBLIC OPENDSPX_STATIC) + add_library(${OPENDSPX_${IDENTIFIER}_TARGET} STATIC) + target_compile_definitions(${OPENDSPX_${IDENTIFIER}_TARGET} PUBLIC OPENDSPX_${IDENTIFIER}_STATIC) else () - add_library(${PROJECT_NAME} SHARED) + add_library(${OPENDSPX_${IDENTIFIER}_TARGET} SHARED) endif () - add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + add_library(${PROJECT_NAME}::${identifier} ALIAS ${OPENDSPX_${IDENTIFIER}_TARGET}) # Add sources - file(GLOB_RECURSE _src include/opendspx/*.h src/*.h src/*.cpp) - target_sources(${PROJECT_NAME} PRIVATE ${_src}) + file(GLOB_RECURSE _src include/opendspx${identifier}/*.h src/${identifier}/*.h src/${identifier}/*.cpp) + target_sources(${OPENDSPX_${IDENTIFIER}_TARGET} PRIVATE ${_src}) # Add features - target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20 cxx_std_17) + target_compile_features(${OPENDSPX_${IDENTIFIER}_TARGET} PRIVATE cxx_std_20 cxx_std_17) # Add options - target_compile_definitions(${PROJECT_NAME} PRIVATE OPENDSPX_LIBRARY) + target_compile_definitions(${OPENDSPX_${IDENTIFIER}_TARGET} PRIVATE OPENDSPX_${IDENTIFIER}_LIBRARY) # Include directories - target_include_directories(${PROJECT_NAME} PUBLIC - "$" + target_include_directories(${OPENDSPX_${IDENTIFIER}_TARGET} PUBLIC + "$" ) - target_include_directories(${PROJECT_NAME} PRIVATE include/opendspx) - - # Link libraries - find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) - find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) - target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core) + target_include_directories(${OPENDSPX_${IDENTIFIER}_TARGET} PRIVATE include/opendspx${identifier}) - find_package(QNrbf REQUIRED) - target_link_libraries(${PROJECT_NAME} PRIVATE QNrbfFormat) - - find_package(stdutau REQUIRED) - target_link_libraries(${PROJECT_NAME} PRIVATE stdutau::stdutau) - - find_package(wolf-midi CONFIG REQUIRED) - target_link_libraries(${PROJECT_NAME} PRIVATE wolf-midi::wolf-midi) - - if (QT_VERSION_MAJOR GREATER_EQUAL 6) - find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core5Compat REQUIRED) - target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core5Compat) - endif () - - # Add pre-build actions - find_package(QasTool REQUIRED) - file(GLOB_RECURSE _json_headers include/opendspx/qdspx*.h) - qas_wrap_cpp(_qasc_src ${_json_headers} TARGET ${PROJECT_NAME}) - target_sources(${PROJECT_NAME} PRIVATE ${_qasc_src}) - target_link_libraries(${PROJECT_NAME} PUBLIC qastool::core) + target_link_libraries(${OPENDSPX_${IDENTIFIER}_TARGET} PUBLIC Qt${QT_VERSION_MAJOR}::Core) + target_link_libraries(${OPENDSPX_${IDENTIFIER}_TARGET} PUBLIC ${OPENDSPX_MODEL_TARGET}) # Add platform specific if (WIN32) - set(RC_DESCRIPTION "DiffScope Data Exchange Format") - set(RC_COPYRIGHT "Copyright 2023-2024 Team OpenVPI") - include("cmake/winrc.cmake") + add_winrc(${OPENDSPX_${IDENTIFIER}_TARGET} + NAME "${PROJECT_NAME}${identifier}" + DESCRIPTION "${PROJECT_NAME} ${identifier}" + COPYRIGHT "Copyright 2023-2024 Team OpenVPI" + ) endif () if (OPENDSPX_INSTALL) - target_include_directories(${PROJECT_NAME} PUBLIC - "$" + target_include_directories(${OPENDSPX_${IDENTIFIER}_TARGET} PUBLIC + "$" ) - install(TARGETS ${PROJECT_NAME} - EXPORT ${OPENDSPX_INSTALL_NAME}Targets - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL + install(TARGETS ${OPENDSPX_${IDENTIFIER}_TARGET} + EXPORT ${OPENDSPX_INSTALL_NAME}Targets + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL ) endif () -endif () +endmacro() + +if (OPENDSPX_BUILD_SERIALIZER) + _opendspx_add_library(serializer) +endif() + +if (OPENDSPX_BUILD_CONVERTER) + find_package(QNrbf REQUIRED) + find_package(stdutau REQUIRED) + find_package(wolf-midi CONFIG REQUIRED) + + _opendspx_add_library(converter) + + if (QT_VERSION_MAJOR GREATER_EQUAL 6) + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core5Compat REQUIRED) + target_link_libraries(${OPENDSPX_CONVERTER_TARGET} PUBLIC Qt${QT_VERSION_MAJOR}::Core5Compat) + endif () + target_link_libraries(${OPENDSPX_CONVERTER_TARGET} PRIVATE QNrbfFormat) + target_link_libraries(${OPENDSPX_CONVERTER_TARGET} PRIVATE stdutau::stdutau) + target_link_libraries(${OPENDSPX_CONVERTER_TARGET} PRIVATE wolf-midi::wolf-midi) +endif() if (OPENDSPX_BUILD_TESTS) add_subdirectory(tests) @@ -139,35 +181,35 @@ if (OPENDSPX_INSTALL) # Add version file write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/${OPENDSPX_INSTALL_NAME}ConfigVersion.cmake" - VERSION ${PROJECT_VERSION} - COMPATIBILITY AnyNewerVersion + "${CMAKE_CURRENT_BINARY_DIR}/${OPENDSPX_INSTALL_NAME}ConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion ) # Add configuration file configure_package_config_file( - ${CMAKE_CURRENT_LIST_DIR}/${OPENDSPX_INSTALL_NAME}Config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/${OPENDSPX_INSTALL_NAME}Config.cmake" - INSTALL_DESTINATION ${_install_dir} - NO_CHECK_REQUIRED_COMPONENTS_MACRO + ${CMAKE_CURRENT_LIST_DIR}/${OPENDSPX_INSTALL_NAME}Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/${OPENDSPX_INSTALL_NAME}Config.cmake" + INSTALL_DESTINATION ${_install_dir} + NO_CHECK_REQUIRED_COMPONENTS_MACRO ) # Install cmake files install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/${OPENDSPX_INSTALL_NAME}Config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/${OPENDSPX_INSTALL_NAME}ConfigVersion.cmake" - DESTINATION ${_install_dir} + "${CMAKE_CURRENT_BINARY_DIR}/${OPENDSPX_INSTALL_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${OPENDSPX_INSTALL_NAME}ConfigVersion.cmake" + DESTINATION ${_install_dir} ) # Install cmake targets files install(EXPORT ${OPENDSPX_INSTALL_NAME}Targets - FILE "${OPENDSPX_INSTALL_NAME}Targets.cmake" - NAMESPACE opendspx:: - DESTINATION ${_install_dir} + FILE "${OPENDSPX_INSTALL_NAME}Targets.cmake" + NAMESPACE opendspx:: + DESTINATION ${_install_dir} ) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING PATTERN "*.h" + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING PATTERN "*.h" ) endif () \ No newline at end of file diff --git a/cmake/winrc.cmake b/cmake/winrc.cmake index 5886ba6..1948f57 100644 --- a/cmake/winrc.cmake +++ b/cmake/winrc.cmake @@ -1,4 +1,7 @@ -set(_rc_content "#include +macro(add_winrc target) + cmake_parse_arguments(ARG "" "NAME;DESCRIPTION;COPYRIGHT" "" ${ARGN}) + + set(_rc_content "#include #ifndef VS_VERSION_INFO #define VS_VERSION_INFO 1 @@ -16,11 +19,11 @@ VS_VERSION_INFO VERSIONINFO // U.S. English - Windows, Multilingual BLOCK \"040904E4\" { - VALUE \"FileDescription\", STRINGIFY(${RC_DESCRIPTION}) + VALUE \"FileDescription\", STRINGIFY(${ARG_DESCRIPTION}) VALUE \"FileVersion\", STRINGIFY(${PROJECT_VERSION}) - VALUE \"ProductName\", STRINGIFY(${PROJECT_NAME}) + VALUE \"ProductName\", STRINGIFY(${ARG_NAME}) VALUE \"ProductVersion\", STRINGIFY(${PROJECT_VERSION}) - VALUE \"LegalCopyright\", STRINGIFY(${RC_COPYRIGHT}) + VALUE \"LegalCopyright\", STRINGIFY(${ARG_COPYRIGHT}) } } BLOCK \"VarFileInfo\" @@ -29,6 +32,7 @@ VS_VERSION_INFO VERSIONINFO } }") -set(_rc_file ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_res.rc) -file(WRITE ${_rc_file} ${_rc_content}) -target_sources(${PROJECT_NAME} PRIVATE ${_rc_file}) \ No newline at end of file + set(_rc_file ${CMAKE_CURRENT_BINARY_DIR}/${target}_res.rc) + file(WRITE ${_rc_file} ${_rc_content}) + target_sources(${target} PRIVATE ${_rc_file}) +endmacro() \ No newline at end of file diff --git a/include/opendspx/audioclip.h b/include/opendspx/audioclip.h new file mode 100644 index 0000000..f2bc46d --- /dev/null +++ b/include/opendspx/audioclip.h @@ -0,0 +1,12 @@ +#ifndef OPENDSPX_MODEL_AUDIOCLIP_H +#define OPENDSPX_MODEL_AUDIOCLIP_H + +namespace QDspx { + + struct AudioClip { + + }; + +} + +#endif //OPENDSPX_MODEL_AUDIOCLIP_H \ No newline at end of file diff --git a/include/opendspx/buscontrol.h b/include/opendspx/buscontrol.h new file mode 100644 index 0000000..4279d06 --- /dev/null +++ b/include/opendspx/buscontrol.h @@ -0,0 +1,14 @@ +#ifndef OPENDSPX_MODEL_BUSCONTROL_H +#define OPENDSPX_MODEL_BUSCONTROL_H + +namespace QDspx { + + struct BusControl { + double gain{1.0}; + double pan{0.0}; + bool mute{false}; + }; + +} + +#endif //OPENDSPX_MODEL_BUSCONTROL_H diff --git a/include/opendspx/clip.h b/include/opendspx/clip.h new file mode 100644 index 0000000..ffb91c1 --- /dev/null +++ b/include/opendspx/clip.h @@ -0,0 +1,29 @@ +#ifndef OPENDSPX_MODEL_CLIP_H +#define OPENDSPX_MODEL_CLIP_H + +#include +#include + +#include +#include +#include + +namespace QDspx { + + struct Clip { + enum Type { + Audio, + Singing, + }; + Type type; + QString name; + BusControl control; + ClipTime time; + Workspace workspace; + }; + + using ClipRef = QSharedPointer; + +} + +#endif //OPENDSPX_MODEL_CLIP_H \ No newline at end of file diff --git a/include/opendspx/cliptime.h b/include/opendspx/cliptime.h new file mode 100644 index 0000000..e9801f2 --- /dev/null +++ b/include/opendspx/cliptime.h @@ -0,0 +1,15 @@ +#ifndef OPENDSPX_MODEL_CLIPTIME_H +#define OPENDSPX_MODEL_CLIPTIME_H + +namespace QDspx { + + struct ClipTime { + int start{0}; + int length{0}; + int clipStart{0}; + int clipLen{0}; + }; + +} + +#endif //OPENDSPX_MODEL_CLIPTIME_H diff --git a/include/opendspx/content.h b/include/opendspx/content.h new file mode 100644 index 0000000..5d579d1 --- /dev/null +++ b/include/opendspx/content.h @@ -0,0 +1,24 @@ +#ifndef OPENDSPX_MODEL_CONTENT_H +#define OPENDSPX_MODEL_CONTENT_H + +#include + +#include +#include +#include +#include +#include + +namespace QDspx{ + + struct Content { + Global global; + Master master; + Timeline timeline; + QList tracks; + Workspace workspace; + }; + +} + +#endif //OPENDSPX_MODEL_CONTENT_H diff --git a/include/opendspx/converter.h b/include/opendspx/converter.h deleted file mode 100644 index b748866..0000000 --- a/include/opendspx/converter.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CONVERTER_H -#define CONVERTER_H - -#include - -namespace QDspx { - - class OPENDSPX_EXPORT Converter { - public: - virtual ~Converter() = default; - - virtual Result load(const QString &path, Model *out, const QVariantMap &args) = 0; - virtual Result save(const QString &path, const Model &in, const QVariantMap &args) = 0; - }; - -} - -#endif // CONVERTER_H diff --git a/include/opendspx/converters/midi.h b/include/opendspx/converters/midi.h deleted file mode 100644 index f8744d6..0000000 --- a/include/opendspx/converters/midi.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef OPENDSPX_MIDI_H -#define OPENDSPX_MIDI_H - -#include - -#include - -namespace QDspx { - - class OPENDSPX_EXPORT MidiConverter : public Converter { - public: - enum Error { - NoTrack = Result::User + 1, - UnsupportedType, - NoteEventInconsistent, - }; - - struct TrackInfo { - QByteArray title; - QList lyrics; - bool selectable; - int channelIndex; - int noteCount; - QString keyRange; - TrackInfo() : TrackInfo({}, {}){}; - TrackInfo(QByteArray title, const QList &lyrics) - : title(std::move(title)), lyrics(lyrics), selectable(true), channelIndex(0), - noteCount(0) { - } - }; - - // selector: bool (const QList &, const QList &, QList *, - // QTextCodec **); - Result load(const QString &path, Model *out, const QVariantMap &args) override; - - // overlapHandler: bool (); - Result save(const QString &path, const Model &in, const QVariantMap &args) override; - }; - -} - -#endif // OPENDSPX_MIDI_H diff --git a/include/opendspx/converters/opensvip.h b/include/opendspx/converters/opensvip.h deleted file mode 100644 index 14233a4..0000000 --- a/include/opendspx/converters/opensvip.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef OPENDSPX_OPENSVIP_H -#define OPENDSPX_OPENSVIP_H - -#include - -namespace QDspx { - - class OPENDSPX_EXPORT OpenSvipConverter : public Converter { - public: - Result load(const QString &path, Model *out, const QVariantMap &args) override; - Result save(const QString &path, const Model &in, const QVariantMap &args) override; - }; - -} - -#endif // OPENDSPX_OPENSVIP_H diff --git a/include/opendspx/converters/svip.h b/include/opendspx/converters/svip.h deleted file mode 100644 index f8964fd..0000000 --- a/include/opendspx/converters/svip.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef OPENDSPX_SVIP_H -#define OPENDSPX_SVIP_H - -#include - -namespace QDspx { - - class OPENDSPX_EXPORT SvipConverter : public Converter { - public: - Result load(const QString &path, Model *out, const QVariantMap &args) override; - Result save(const QString &path, const Model &in, const QVariantMap &args) override; - }; - -} - -#endif // OPENDSPX_SVIP_H diff --git a/include/opendspx/converters/ust.h b/include/opendspx/converters/ust.h deleted file mode 100644 index 67ddc09..0000000 --- a/include/opendspx/converters/ust.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef OPENDSPX_UST_H -#define OPENDSPX_UST_H - -#include - -namespace QDspx { - - class OPENDSPX_EXPORT UstConverter : public Converter { - public: - Result load(const QString &path, Model *out, const QVariantMap &args) override; - Result save(const QString &path, const Model &in, const QVariantMap &args) override; - }; - -} - -#endif // OPENDSPX_UST_H diff --git a/include/opendspx/global.h b/include/opendspx/global.h new file mode 100644 index 0000000..3606e7d --- /dev/null +++ b/include/opendspx/global.h @@ -0,0 +1,18 @@ +#ifndef OPENDSPX_MODEL_GLOBAL_H +#define OPENDSPX_MODEL_GLOBAL_H + +#include + +namespace QDspx { + + struct Global { + QString author; + QString name; + int centShift{0}; + QString editorId; + QString editorName; + }; + +} + +#endif //OPENDSPX_MODEL_GLOBAL_H diff --git a/include/opendspx/label.h b/include/opendspx/label.h new file mode 100644 index 0000000..17746e8 --- /dev/null +++ b/include/opendspx/label.h @@ -0,0 +1,15 @@ +#ifndef OPENDSPX_MODEL_LABEL_H +#define OPENDSPX_MODEL_LABEL_H + +#include + +namespace QDspx { + + struct Label { + int pos{0}; + QString text; + }; + +} + +#endif //OPENDSPX_MODEL_LABEL_H \ No newline at end of file diff --git a/include/opendspx/master.h b/include/opendspx/master.h new file mode 100644 index 0000000..eb3e404 --- /dev/null +++ b/include/opendspx/master.h @@ -0,0 +1,14 @@ +#ifndef OPENDSPX_MODEL_MASTER_H +#define OPENDSPX_MODEL_MASTER_H + +#include + +namespace QDspx{ + + struct Master { + BusControl control; + }; + +} + +#endif //OPENDSPX_MODEL_MASTER_H diff --git a/include/opendspx/model.h b/include/opendspx/model.h new file mode 100644 index 0000000..8dff522 --- /dev/null +++ b/include/opendspx/model.h @@ -0,0 +1,18 @@ +#ifndef OPENDSPX_MODEL_MODEL_H +#define OPENDSPX_MODEL_MODEL_H + +#include + +namespace QDspx { + + struct Model { + enum Version { + V1_0_0, + }; + Version version{V1_0_0}; + Content content; + }; + +} + +#endif //OPENDSPX_MODEL_MODEL_H diff --git a/include/opendspx/opendspx_global.h b/include/opendspx/opendspx_global.h deleted file mode 100644 index 0b6068d..0000000 --- a/include/opendspx/opendspx_global.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef OPENDSPX_GLOBAL_H -#define OPENDSPX_GLOBAL_H - -#include - -#ifndef OPENDSPX_EXPORT -# ifdef OPENDSPX_STATIC -# define OPENDSPX_EXPORT -# else -# ifdef OPENDSPX_LIBRARY -# define OPENDSPX_EXPORT Q_DECL_EXPORT -# else -# define OPENDSPX_EXPORT Q_DECL_IMPORT -# endif -# endif -#endif - -#ifndef QAS_QASC_RUN -# ifdef QAS_JSON_NS -# undef QAS_JSON_NS -# endif -# define QAS_JSON_NS(TYPE) \ - OPENDSPX_EXPORT QAS::JsonStream &operator>>(QAS::JsonStream &stream, TYPE &var); \ - OPENDSPX_EXPORT QAS::JsonStream &operator<<(QAS::JsonStream &stream, const TYPE &var); -#endif - -#endif // OPENDSPX_GLOBAL_H diff --git a/include/opendspx/qdspxbase.h b/include/opendspx/qdspxbase.h deleted file mode 100644 index 59fae4f..0000000 --- a/include/opendspx/qdspxbase.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef QDSPXBASE_H -#define QDSPXBASE_H - -#include - -#include - -namespace QDspx { - - using Extra = QMap; // 其他参数,不定长 - using Workspace = QMap; // 状态信息,不定长 - using SourceInfo = QMap; // 外部资源信息,不定长 - - // 主控 - struct Control { - double gain; - double pan; - bool mute; - - // 构造器 - inline Control() : Control(0, 0, false){}; - inline Control(double gain, double pan, bool mute) : gain(gain), pan(pan), mute(mute){}; - }; - - // 音轨主控 - struct TrackControl : public Control { - bool solo; - - // 构造器 - inline TrackControl() : TrackControl(false){}; - inline TrackControl(bool solo) : solo(solo){}; - inline TrackControl(double gain, double pan, bool mute, bool solo) - : Control(gain, pan, mute), solo(solo){}; - }; - - // 泛型点 - template - struct Point { - T x; - T y; - - Point() : Point(0, 0){}; - Point(T x, T y) : x(x), y(y){}; - }; - - using IntPoint = Point; - using DoublePoint = Point; - - // 控制点 - struct AnchorPoint : public IntPoint { - enum Interpolation { - __qas_attr__("none") // - None, - __qas_attr__("linear") // - Linear, - __qas_attr__("hermite") // - Hermite, - }; - QAS_JSON(Interpolation) - - Interpolation interp; - - // 构造器 - inline AnchorPoint() : interp(Linear){}; - inline AnchorPoint(int x, int y, Interpolation i = Linear) : IntPoint(x, y), interp(i){}; - }; - - QAS_JSON_NS(Control) - QAS_JSON_NS(TrackControl) - QAS_JSON_NS(IntPoint) - QAS_JSON_NS(DoublePoint) - QAS_JSON_NS(AnchorPoint) - -} - -#endif // QDSPXBASE_H diff --git a/include/opendspx/qdspxmodel.h b/include/opendspx/qdspxmodel.h deleted file mode 100644 index a3ab268..0000000 --- a/include/opendspx/qdspxmodel.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef QDSPXMODEL_H -#define QDSPXMODEL_H - -#include -#include - -namespace QDspx { - - struct Result { - enum Type { - Success, - File, - InvalidFormat, - Empty, - Aborted, - User = 1024, - }; - - int type; - int code; - - inline Result(int type = Success, int code = 0) : type(type), code(code) {}; - }; - - // 文件的元信息,包括版本号、工程名、作者等 - struct Global { - QString name; - QString author; - int centShift; - }; - - // 总线控制 - struct Master { - Control control; - }; - - // 工程可编辑区域 - struct Content { - Global global; - Master master; - Timeline timeline; - QList tracks; - Workspace workspace; - }; - - // 工程 - struct OPENDSPX_EXPORT Model { - QString version; - Content content; - - Result load(const QString &filename); - Result save(const QString &filename) const; - - Result loadData(const QByteArray &data); - QByteArray saveData() const; - }; - - QAS_JSON_NS(Global) - - QAS_JSON_NS(Master) - - QAS_JSON_NS(Content) - - QAS_JSON_NS(Model) - -} - -using QDspxModel = QDspx::Model; - -#endif // QDSPXMODEL_H diff --git a/include/opendspx/qdspxnote.h b/include/opendspx/qdspxnote.h deleted file mode 100644 index 71000b7..0000000 --- a/include/opendspx/qdspxnote.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef QDSPXNOTE_H -#define QDSPXNOTE_H - -#include - -namespace QDspx -{ - // 音素 - struct Phoneme { - enum Type { - __qas_attr__("ahead") // - Ahead, - __qas_attr__("normal") // - Normal, - __qas_attr__("final") // - Final, - }; - - QAS_JSON(Type) - - Type type; - QString token; - int start; - - // 不定长信息 - Extra extra; - Workspace workspace; - - // 构造器 - inline Phoneme() : type(Normal), start(0) {}; - }; - - // 音素信息 - struct PhonemeInfo { - __qas_attr__("original") - QList org; - - QList edited; - }; - - // 颤音信息 - struct VibratoInfo { - double start; - double end; - double freq; - double phase; - double amp; - double offset; - QList points; - - // 构造器 - inline VibratoInfo() : start(0), end(1), freq(2), phase(0), amp(1), offset(0) {}; - }; - - // 发音 - struct Pronunciation { - __qas_attr__("original") - QString org; - QString edited; - }; - - // 音符 - struct Note { - int pos; - int length; - int keyNum; - int centShift; - QString language; - QString lyric; - QString g2pId; - Pronunciation pronunciation; - PhonemeInfo phonemes; - VibratoInfo vibrato; - - // 不定长信息 - Extra extra; - Workspace workspace; - - // 构造器 - inline Note() : Note(0, 480, 60) {}; - inline Note(int pos, int length, int keyNum) : pos(pos), length(length), keyNum(keyNum) {}; - }; - - QAS_JSON_NS(Phoneme) - QAS_JSON_NS(PhonemeInfo) - QAS_JSON_NS(VibratoInfo) - QAS_JSON_NS(Pronunciation) - QAS_JSON_NS(Note) -} - -#endif // QDSPXNOTE_H diff --git a/include/opendspx/qdspxparam.h b/include/opendspx/qdspxparam.h deleted file mode 100644 index 573b7f3..0000000 --- a/include/opendspx/qdspxparam.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef QDSPXPARAM_H -#define QDSPXPARAM_H - -#include - -namespace QDspx -{ - // 参数曲线基类 - struct ParamCurve { - enum Type { - __qas_attr__("anchor") // - Anchor, - __qas_attr__("free") // - Free, - }; - - QAS_JSON(Type) - - Type type; - - // 构造器 - ParamCurve() : ParamCurve(Anchor) {}; - inline explicit ParamCurve(Type type) : type(type) {}; - virtual ~ParamCurve() = default; - }; - - using ParamCurveRef = QSharedPointer; - - // 手绘参数 - struct ParamFree : public ParamCurve { - int start; - int step; - QList values; - - // 构造器 - inline ParamFree() : ParamFree(0) {}; - inline explicit ParamFree(int start) : ParamCurve(Free), start(start), step(5) {}; - }; - - using ParamFreeRef = QSharedPointer; - - // 锚点参数 - struct ParamAnchor : public ParamCurve { - int start; - QList nodes; - - // 构造器 - inline ParamAnchor() : ParamCurve(Anchor) {}; - }; - - using ParamAnchorRef = QSharedPointer; - - // 参数结构 - struct ParamInfo { - __qas_attr__("original") - QList org; - - QList edited; - - QList envelope; - }; - - // 单线条参数 - struct SingleParam { - ParamInfo pitch; - ParamInfo energy; - ParamInfo tension; - ParamInfo voicing; - ParamInfo breathiness; - ParamInfo velocity; - ParamInfo gender; - ParamInfo expressiveness; - }; - - QAS_JSON_NS(ParamCurve) - QAS_JSON_NS(ParamFree) - QAS_JSON_NS(ParamAnchor) - QAS_JSON_NS(ParamInfo) - QAS_JSON_NS(SingleParam) - QAS_JSON_NS_IMPL(ParamCurveRef) -} - -#endif // QDSPXPARAM_H diff --git a/include/opendspx/qdspxtimeline.h b/include/opendspx/qdspxtimeline.h deleted file mode 100644 index d4f2004..0000000 --- a/include/opendspx/qdspxtimeline.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef QDSPXTIMELINE_H -#define QDSPXTIMELINE_H - -#include - -namespace QDspx { - - // 拍号 - struct TimeSignature { - int pos; - - __qas_attr__("numerator") - int num; - - __qas_attr__("denominator") - int den; - - // 构造器 - inline TimeSignature() : TimeSignature(0, 4, 4){}; - inline TimeSignature(int pos, int num, int den) : pos(pos), num(num), den(den){}; - }; - - // 曲速 - struct Tempo { - int pos; - double value; - - // 构造器 - inline Tempo() : Tempo(0, 120){}; - inline Tempo(int pos, double value) : pos(pos), value(value){}; - }; - - // 曲速 - struct Label { - int pos; - QString text; - - // 构造器 - inline Label() : Label(0){}; - inline Label(int pos, const QString &text = QString()) : pos(pos), text(text){}; - }; - - // 时间线 - struct Timeline { - QList timeSignatures; - QList tempos; - QList