diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..8d040da --- /dev/null +++ b/.clang-format @@ -0,0 +1,252 @@ +Language: Cpp +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: BlockIndent +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false +AlignConsecutiveDeclarations: + Enabled: false +AlignConsecutiveMacros: + Enabled: false +AlignConsecutiveShortCaseStatements: + Enabled: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + Kind: Never +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowBreakBeforeNoexceptSpecifier: Never +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +AttributeMacros: + - __capability +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Attach +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: [foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE] +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Regroup +IncludeCategories: + # Local headers + - Regex: '^".*\.h"$' + Priority: -999 + # Qt public + - Regex: '^<(Q[a-zA-Z0-9_]+|qt_[a-zA-Z0-9_]+\.h|qqml_[a-zA-Z0-9_]+\.h)>$' + Priority: 201 + # Qt qpa + - Regex: '^$' + Priority: 202 + # Qt private + - Regex: '^$' + Priority: 203 + # Windows platform-specific + - Regex: '^<[a-zA-Z0-9_]+\.h>$' + Priority: 1 + # C++ standard library + - Regex: '^<[a-z0-9_]+>$' + Priority: 2 + # Boost + - Regex: '^" + ) + + # 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) - - 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 () + target_include_directories(${OPENDSPX_${IDENTIFIER}_TARGET} PRIVATE include/opendspx${identifier}) - # 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(wolf-midi CONFIG REQUIRED) + _opendspx_add_library(converter) + target_link_libraries(${OPENDSPX_CONVERTER_TARGET} PRIVATE wolf-midi::wolf-midi) +endif() if (OPENDSPX_BUILD_TESTS) add_subdirectory(tests) @@ -139,35 +172,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/anchornode.h b/include/opendspx/anchornode.h new file mode 100644 index 0000000..2cfc441 --- /dev/null +++ b/include/opendspx/anchornode.h @@ -0,0 +1,19 @@ +#ifndef OPENDSPX_MODEL_ANCHORNODE_H +#define OPENDSPX_MODEL_ANCHORNODE_H + +namespace QDspx { + + struct AnchorNode { + enum Interpolation { + None, + Linear, + Hermite, + }; + Interpolation interp{None}; + int x{0}; + int y{0}; + }; + +} + +#endif //OPENDSPX_MODEL_ANCHORNODE_H \ No newline at end of file diff --git a/include/opendspx/audioclip.h b/include/opendspx/audioclip.h new file mode 100644 index 0000000..08a74e2 --- /dev/null +++ b/include/opendspx/audioclip.h @@ -0,0 +1,19 @@ +#ifndef OPENDSPX_MODEL_AUDIOCLIP_H +#define OPENDSPX_MODEL_AUDIOCLIP_H + +#include + +namespace QDspx { + + struct AudioClip : Clip { + AudioClip(const QString &name = {}, const BusControl &control = {}, const ClipTime &time = {}, const Workspace &workspace = {}, const QString &path = {}) + : Clip(Audio, name, control, time, workspace), path(path) { + } + + QString path; + }; + using AudioClipRef = QSharedPointer; + +} + +#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..b5097ad --- /dev/null +++ b/include/opendspx/clip.h @@ -0,0 +1,34 @@ +#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; + + protected: + Clip(Type type, const QString &name = {}, const BusControl &control = {}, const ClipTime &time = {}, const Workspace &workspace = {}) + : type(type), name(name), control(control), time(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/controlpoint.h b/include/opendspx/controlpoint.h new file mode 100644 index 0000000..0e02d15 --- /dev/null +++ b/include/opendspx/controlpoint.h @@ -0,0 +1,13 @@ +#ifndef OPENDSPX_MODEL_CONTROLPOINT_H +#define OPENDSPX_MODEL_CONTROLPOINT_H + +namespace QDspx { + + struct ControlPoint { + double x{0.0}; + double y{0.0}; + }; + +} + +#endif //OPENDSPX_MODEL_CONTROLPOINT_H \ No newline at end of file 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..c447ef0 --- /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, + }; + Version version{V1}; + Content content; + }; + +} + +#endif //OPENDSPX_MODEL_MODEL_H diff --git a/include/opendspx/note.h b/include/opendspx/note.h new file mode 100644 index 0000000..78ddb4b --- /dev/null +++ b/include/opendspx/note.h @@ -0,0 +1,28 @@ +#ifndef OPENDSPX_MODEL_NOTE_H +#define OPENDSPX_MODEL_NOTE_H + +#include + +#include +#include +#include +#include + +namespace QDspx { + + struct Note { + int pos{0}; + int length{0}; + int keyNum{0}; + int centShift{0}; + QString language; + QString lyric; + Pronunciation pronunciation; + Phonemes phonemes; + Vibrato vibrato; + Workspace workspace; + }; + +} + +#endif //OPENDSPX_MODEL_NOTE_H \ No newline at end of file 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/param.h b/include/opendspx/param.h new file mode 100644 index 0000000..c079b0d --- /dev/null +++ b/include/opendspx/param.h @@ -0,0 +1,20 @@ +#ifndef OPENDSPX_MODEL_PARAM_H +#define OPENDSPX_MODEL_PARAM_H + +#include + +#include +#include +#include + +namespace QDspx { + + struct Param { + QList original; + QList transform; + QList edited; + }; + +} + +#endif //OPENDSPX_MODEL_PARAM_H \ No newline at end of file diff --git a/include/opendspx/paramcurve.h b/include/opendspx/paramcurve.h new file mode 100644 index 0000000..3ebad2d --- /dev/null +++ b/include/opendspx/paramcurve.h @@ -0,0 +1,26 @@ +#ifndef OPENDSPX_MODEL_PARAMCURVE_H +#define OPENDSPX_MODEL_PARAMCURVE_H + +#include + +namespace QDspx { + + struct ParamCurve { + enum Type { + Anchor, + Free, + }; + Type type; + int start; + + protected: + ParamCurve(Type type, int start = 0) + : type(type), start(start) { + } + }; + + using ParamCurveRef = QSharedPointer; + +} + +#endif //OPENDSPX_MODEL_PARAMCURVE_H \ No newline at end of file diff --git a/include/opendspx/paramcurveanchor.h b/include/opendspx/paramcurveanchor.h new file mode 100644 index 0000000..74c59c4 --- /dev/null +++ b/include/opendspx/paramcurveanchor.h @@ -0,0 +1,23 @@ +#ifndef OPENDSPX_MODEL_PARAMCURVEANCHOR_H +#define OPENDSPX_MODEL_PARAMCURVEANCHOR_H + +#include + +#include +#include + +namespace QDspx { + + struct ParamCurveAnchor : ParamCurve { + ParamCurveAnchor(int start = 0, const QList &nodes = {}) + : ParamCurve(Anchor, start), nodes(nodes) { + } + + QList nodes; + }; + + using ParamCurveAnchorRef = QSharedPointer; + +} + +#endif //OPENDSPX_MODEL_PARAMCURVEANCHOR_H \ No newline at end of file diff --git a/include/opendspx/paramcurvefree.h b/include/opendspx/paramcurvefree.h new file mode 100644 index 0000000..dd09867 --- /dev/null +++ b/include/opendspx/paramcurvefree.h @@ -0,0 +1,23 @@ +#ifndef OPENDSPX_MODEL_PARAMCURVEFREE_H +#define OPENDSPX_MODEL_PARAMCURVEFREE_H + +#include + +#include + +namespace QDspx { + + struct ParamCurveFree : ParamCurve { + ParamCurveFree(int start = 0, int step = 5, const QList &values = {}) + : ParamCurve(Free, start), step(step), values(values) { + } + + int step; + QList values; + }; + + using ParamCurveFreeRef = QSharedPointer; + +} + +#endif //OPENDSPX_MODEL_PARAMCURVEFREE_H \ No newline at end of file diff --git a/include/opendspx/params.h b/include/opendspx/params.h new file mode 100644 index 0000000..5856ea7 --- /dev/null +++ b/include/opendspx/params.h @@ -0,0 +1,15 @@ +#ifndef OPENDSPX_MODEL_PARAMS_H +#define OPENDSPX_MODEL_PARAMS_H + +#include +#include + +#include + +namespace QDspx { + + using Params = QMap; + +} + +#endif //OPENDSPX_MODEL_PARAMS_H \ No newline at end of file diff --git a/include/opendspx/phoneme.h b/include/opendspx/phoneme.h new file mode 100644 index 0000000..8c41dab --- /dev/null +++ b/include/opendspx/phoneme.h @@ -0,0 +1,17 @@ +#ifndef OPENDSPX_MODEL_PHONEME_H +#define OPENDSPX_MODEL_PHONEME_H + +#include + +namespace QDspx { + + struct Phoneme { + QString language; + QString token; + int start{0}; + bool onset{false}; + }; + +} + +#endif //OPENDSPX_MODEL_PHONEME_H \ No newline at end of file diff --git a/include/opendspx/phonemes.h b/include/opendspx/phonemes.h new file mode 100644 index 0000000..721a64a --- /dev/null +++ b/include/opendspx/phonemes.h @@ -0,0 +1,17 @@ +#ifndef OPENDSPX_MODEL_PHONEMES_H +#define OPENDSPX_MODEL_PHONEMES_H + +#include + +#include + +namespace QDspx { + + struct Phonemes { + QList original; + QList edited; + }; + +} + +#endif //OPENDSPX_MODEL_PHONEMES_H \ No newline at end of file diff --git a/include/opendspx/pronunciation.h b/include/opendspx/pronunciation.h new file mode 100644 index 0000000..8f49469 --- /dev/null +++ b/include/opendspx/pronunciation.h @@ -0,0 +1,15 @@ +#ifndef OPENDSPX_MODEL_PRONUNCIATION_H +#define OPENDSPX_MODEL_PRONUNCIATION_H + +#include + +namespace QDspx { + + struct Pronunciation { + QString original; + QString edited; + }; + +} + +#endif //OPENDSPX_MODEL_PRONUNCIATION_H \ No newline at end of file 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