From ef1e7a75a3d181912f032eb224d91b4055736f77 Mon Sep 17 00:00:00 2001 From: Dragos Daian Date: Sun, 19 Nov 2023 11:06:27 +0100 Subject: [PATCH] small changes --- SCsub => SConstruct | 27 +++++++++- bin/addons/v-sekai.whisper/plugin.cfg | 0 .../v-sekai.whisper.gdextension | 1 + register_types.h | 36 ------------- register_types.cpp => src/register_types.cpp | 16 +++++- src/register_types.h | 12 +++++ speech.cpp => src/speech.cpp | 30 ----------- speech.h => src/speech.h | 30 ----------- .../speech_processor.cpp | 0 speech_processor.h => src/speech_processor.h | 52 ++++--------------- 10 files changed, 65 insertions(+), 139 deletions(-) rename SCsub => SConstruct (69%) create mode 100644 bin/addons/v-sekai.whisper/plugin.cfg delete mode 100644 register_types.h rename register_types.cpp => src/register_types.cpp (82%) create mode 100644 src/register_types.h rename speech.cpp => src/speech.cpp (92%) rename speech.h => src/speech.h (73%) rename speech_processor.cpp => src/speech_processor.cpp (100%) rename speech_processor.h => src/speech_processor.h (67%) diff --git a/SCsub b/SConstruct similarity index 69% rename from SCsub rename to SConstruct index 2fd9a72b..21465c2e 100644 --- a/SCsub +++ b/SConstruct @@ -1,4 +1,8 @@ -Import("env") +#!/usr/bin/env python +import os +import sys + +env = SConscript("thirdparty/godot-cpp/SConstruct") module_env = env.Clone() @@ -51,3 +55,24 @@ env_thirdparty.add_source_files(env.modules_sources, Glob("thirdparty/whisper.cp env_thirdparty.Append(CPPPATH=['thirdparty/whisper.cpp']) env_thirdparty.Append(CPPDEFINES=['WHISPER_SHARED', 'GGML_SHARED']) module_env.add_source_files(env.modules_sources, "*.cpp") + +# For the reference: +# - CCFLAGS are compilation flags shared between C and C++ +# tweak this if you want to use different folders, or more folders, to store your source code in. +env.Append(CPPPATH=["src/"]) +sources = [Glob("src/*.cpp")] +sources.extend([box2d_folder + 'src/' + box2d_src_file for box2d_src_file in box2d_src]) + +if env["platform"] == "macos": + library = env.SharedLibrary( + "bin/addons/godot-box2d/bin/libgodot-box2d.{}.{}.framework/libgodot-box2d.{}.{}".format( + env["platform"], env["target"], env["platform"], env["target"] + ), + source=sources, + ) +else: + library = env.SharedLibrary( + "bin/addons/godot-box2d/bin/libgodot-box2d{}{}".format(env["suffix"], env["SHLIBSUFFIX"]), + source=sources, + ) +Default(library) diff --git a/bin/addons/v-sekai.whisper/plugin.cfg b/bin/addons/v-sekai.whisper/plugin.cfg new file mode 100644 index 00000000..e69de29b diff --git a/bin/addons/v-sekai.whisper/v-sekai.whisper.gdextension b/bin/addons/v-sekai.whisper/v-sekai.whisper.gdextension index 98640515..a50eee30 100644 --- a/bin/addons/v-sekai.whisper/v-sekai.whisper.gdextension +++ b/bin/addons/v-sekai.whisper/v-sekai.whisper.gdextension @@ -2,6 +2,7 @@ entry_symbol = "TODO" compatibility_minimum = 4.1 +reloadable = true [libraries] diff --git a/register_types.h b/register_types.h deleted file mode 100644 index ba3fc4af..00000000 --- a/register_types.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************/ -/* register_types.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#pragma once - -#include "modules/register_module_types.h" - -void initialize_whisper_module(ModuleInitializationLevel p_level); -void uninitialize_whisper_module(ModuleInitializationLevel p_level); diff --git a/register_types.cpp b/src/register_types.cpp similarity index 82% rename from register_types.cpp rename to src/register_types.cpp index ad1f7ab1..06231d10 100644 --- a/register_types.cpp +++ b/src/register_types.cpp @@ -30,7 +30,6 @@ #include "register_types.h" -#include "core/object/class_db.h" #include "speech.h" #include "speech_processor.h" @@ -49,3 +48,18 @@ void uninitialize_whisper_module(ModuleInitializationLevel p_level) { return; } } + +extern "C" { + +// Initialization. + +GDExtensionBool GDE_EXPORT vsekai_whisper_library_init(const GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) { + godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); + + init_obj.register_initializer(initialize_whisper_module); + init_obj.register_terminator(uninitialize_whisper_module); + init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); + + return init_obj.init(); +} +} diff --git a/src/register_types.h b/src/register_types.h new file mode 100644 index 00000000..45fa64c0 --- /dev/null +++ b/src/register_types.h @@ -0,0 +1,12 @@ +#ifndef REGISTER_TYPES_H +#define REGISTER_TYPES_H + +#include + +using namespace godot; + + +void initialize_whisper_module(ModuleInitializationLevel p_level); +void uninitialize_whisper_module(ModuleInitializationLevel p_level); + +#endif // REGISTER_TYPES_H diff --git a/speech.cpp b/src/speech.cpp similarity index 92% rename from speech.cpp rename to src/speech.cpp index fd38a01f..e6ca96c6 100644 --- a/speech.cpp +++ b/src/speech.cpp @@ -1,33 +1,3 @@ -/**************************************************************************/ -/* speech.cpp */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - #include "core/error/error_macros.h" #include "core/string/print_string.h" #include "core/variant/variant.h" diff --git a/speech.h b/src/speech.h similarity index 73% rename from speech.h rename to src/speech.h index 8d211fe2..dfd3affe 100644 --- a/speech.h +++ b/src/speech.h @@ -1,33 +1,3 @@ -/**************************************************************************/ -/* speech.h */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - #ifndef SPEECH_H #define SPEECH_H diff --git a/speech_processor.cpp b/src/speech_processor.cpp similarity index 100% rename from speech_processor.cpp rename to src/speech_processor.cpp diff --git a/speech_processor.h b/src/speech_processor.h similarity index 67% rename from speech_processor.h rename to src/speech_processor.h index 77a27ffb..26e8d7c3 100644 --- a/speech_processor.h +++ b/src/speech_processor.h @@ -1,47 +1,17 @@ -/**************************************************************************/ -/* speech_processor.h */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - #ifndef SPEECH_PROCESSOR_H #define SPEECH_PROCESSOR_H -#include "scene/main/node.h" - -#include "core/config/engine.h" -#include "core/config/project_settings.h" -#include "core/object/class_db.h" -#include "core/object/ref_counted.h" -#include "core/os/mutex.h" -#include "scene/audio/audio_stream_player.h" -#include "servers/audio/audio_stream.h" -#include "servers/audio/effects/audio_effect_capture.h" -#include "servers/audio_server.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include