diff options
476 files changed, 2477 insertions, 25865 deletions
diff --git a/.gitignore b/.gitignore index abbda17ee2..f7eac1122d 100644 --- a/.gitignore +++ b/.gitignore @@ -144,7 +144,9 @@ ipch/ *.sdf *.cachefile *.VC.db +*.VC.opendb *.VC.VC.opendb +enc_temp_folder/ # Visual Studio profiler *.psess diff --git a/.travis.yml b/.travis.yml index 12b49f4c07..ca110a3073 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ os: - osx env: - #- GODOT_TARGET=iphone + - GODOT_TARGET=iphone - GODOT_TARGET=osx - GODOT_TARGET=x11 #- GODOT_TARGET=android diff --git a/core/array.cpp b/core/array.cpp index b9c8f543da..16598a044d 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "array.h" + #include "vector.h" #include "hashfuncs.h" #include "variant.h" diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 657f527a51..d4f61b7ffc 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -592,28 +592,20 @@ uint64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const { static const unsigned int SECONDS_PER_MINUTE = 60; static const unsigned int MINUTES_PER_HOUR = 60; static const unsigned int HOURS_PER_DAY = 24; - static const unsigned int SECONDS_PER_HOUR = MINUTES_PER_HOUR * - SECONDS_PER_MINUTE; + static const unsigned int SECONDS_PER_HOUR = MINUTES_PER_HOUR * SECONDS_PER_MINUTE; static const unsigned int SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY; // Get all time values from the dictionary, set to zero if it doesn't exist. // Risk incorrect calculation over throwing errors - unsigned int second = ((datetime.has(SECOND_KEY))? - static_cast<unsigned int>(datetime[SECOND_KEY]): 0); - unsigned int minute = ((datetime.has(MINUTE_KEY))? - static_cast<unsigned int>(datetime[MINUTE_KEY]): 0); - unsigned int hour = ((datetime.has(HOUR_KEY))? - static_cast<unsigned int>(datetime[HOUR_KEY]): 0); - unsigned int day = ((datetime.has(DAY_KEY))? - static_cast<unsigned int>(datetime[DAY_KEY]): 0); - unsigned int month = ((datetime.has(MONTH_KEY))? - static_cast<unsigned int>(datetime[MONTH_KEY]) -1: 0); - unsigned int year = ((datetime.has(YEAR_KEY))? - static_cast<unsigned int>(datetime[YEAR_KEY]):0); + unsigned int second = ((datetime.has(SECOND_KEY)) ? static_cast<unsigned int>(datetime[SECOND_KEY]): 0); + unsigned int minute = ((datetime.has(MINUTE_KEY)) ? static_cast<unsigned int>(datetime[MINUTE_KEY]): 0); + unsigned int hour = ((datetime.has(HOUR_KEY)) ? static_cast<unsigned int>(datetime[HOUR_KEY]): 0); + unsigned int day = ((datetime.has(DAY_KEY)) ? static_cast<unsigned int>(datetime[DAY_KEY]): 0); + unsigned int month = ((datetime.has(MONTH_KEY)) ? static_cast<unsigned int>(datetime[MONTH_KEY]) -1: 0); + unsigned int year = ((datetime.has(YEAR_KEY)) ? static_cast<unsigned int>(datetime[YEAR_KEY]):0); /// How many days come before each month (0-12) - static const unsigned short int DAYS_PAST_THIS_YEAR_TABLE[2][13] = - { + static const unsigned short int DAYS_PAST_THIS_YEAR_TABLE[2][13] = { /* Normal years. */ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, /* Leap years. */ @@ -633,19 +625,16 @@ uint64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const { ERR_FAIL_COND_V( month+1 > 12, 0); // Do this check after month is tested as valid - ERR_EXPLAIN("Invalid day value of: " + itos(day) + " which is larger " - "than "+ itos(MONTH_DAYS_TABLE[LEAPYEAR(year)][month])); + ERR_EXPLAIN("Invalid day value of: " + itos(day) + " which is larger than "+ itos(MONTH_DAYS_TABLE[LEAPYEAR(year)][month])); ERR_FAIL_COND_V( day > MONTH_DAYS_TABLE[LEAPYEAR(year)][month], 0); // Calculate all the seconds from months past in this year - uint64_t SECONDS_FROM_MONTHS_PAST_THIS_YEAR = - DAYS_PAST_THIS_YEAR_TABLE[LEAPYEAR(year)][month] * SECONDS_PER_DAY; + uint64_t SECONDS_FROM_MONTHS_PAST_THIS_YEAR = DAYS_PAST_THIS_YEAR_TABLE[LEAPYEAR(year)][month] * SECONDS_PER_DAY; uint64_t SECONDS_FROM_YEARS_PAST = 0; for(unsigned int iyear = EPOCH_YR; iyear < year; iyear++) { - SECONDS_FROM_YEARS_PAST += YEARSIZE(iyear) * - SECONDS_PER_DAY; + SECONDS_FROM_YEARS_PAST += YEARSIZE(iyear) * SECONDS_PER_DAY; } uint64_t epoch = @@ -676,8 +665,7 @@ Dictionary _OS::get_datetime_from_unix_time( uint64_t unix_time_val) const { // Just fail if unix time is negative (when interpreted as an int). // This means the user passed in a negative value by accident - ERR_EXPLAIN("unix_time_val was really huge!"+ itos(unix_time_val) + - " You probably passed in a negative value!"); + ERR_EXPLAIN("unix_time_val was really huge!"+ itos(unix_time_val) + " You probably passed in a negative value!"); ERR_FAIL_COND_V( (int64_t)unix_time_val < 0, Dictionary()); OS::Date date; diff --git a/core/object_type_db.cpp b/core/class_db.cpp index 24b9c26e71..bb3368c128 100644 --- a/core/object_type_db.cpp +++ b/core/class_db.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* object_type_db.cpp */ +/* class_db.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,7 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "object_type_db.h" +#include "class_db.h" + #include "os/mutex.h" #ifdef NO_THREADS diff --git a/core/object_type_db.h b/core/class_db.h index f745e3d5fd..a09a42423b 100644 --- a/core/object_type_db.h +++ b/core/class_db.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* object_type_db.h */ +/* class_db.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,12 +26,13 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef OBJECT_TYPE_DB_H -#define OBJECT_TYPE_DB_H +#ifndef CLASS_DB_H +#define CLASS_DB_H #include "object.h" #include "method_bind.h" #include "print_string.h" + /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -537,4 +538,4 @@ public: -#endif +#endif // CLASS_DB_H diff --git a/core/color.cpp b/core/color.cpp index 89accbb6d2..80a98da252 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "color.h" + #include "math_funcs.h" #include "print_string.h" #include "map.h" diff --git a/core/color_names.inc b/core/color_names.inc index 7b674bb289..b05684acc6 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -1,4 +1,6 @@ // Names from https://en.wikipedia.org/wiki/List_of_colors (through https://raw.githubusercontent.com/SuperUserNameMan/color_to_name/616a7cddafefda91478b7bc26167de97fb5badb1/godot_version.gd), slightly edited and normalized +#include "map.h" + static Map<String, Color> _named_colors; static void _populate_named_colors() { if(!_named_colors.empty()) return; diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp index 9b1c052eb9..6d50ed8d9a 100644 --- a/core/command_queue_mt.cpp +++ b/core/command_queue_mt.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "command_queue_mt.h" + #include "os/os.h" void CommandQueueMT::lock() { diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index 779bbe1b58..3975df7658 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -179,7 +179,7 @@ class CommandQueueMT { R* ret; SyncSemaphore *sync; - virtual void call() { *ret = (instance->*method)(); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { *ret = (instance->*method)(); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class R> @@ -204,7 +204,7 @@ class CommandQueueMT { R* ret; SyncSemaphore *sync; - virtual void call() { *ret = (instance->*method)(p1,p2); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { *ret = (instance->*method)(p1,p2); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3,class R> @@ -218,7 +218,7 @@ class CommandQueueMT { R* ret; SyncSemaphore *sync; - virtual void call() { *ret = (instance->*method)(p1,p2,p3); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { *ret = (instance->*method)(p1,p2,p3); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3,class P4,class R> @@ -233,7 +233,7 @@ class CommandQueueMT { R* ret; SyncSemaphore *sync; - virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3,class P4,class P5,class R> @@ -249,7 +249,7 @@ class CommandQueueMT { R* ret; SyncSemaphore *sync; - virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class R> @@ -266,7 +266,7 @@ class CommandQueueMT { R* ret; SyncSemaphore *sync; - virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class R> @@ -284,7 +284,7 @@ class CommandQueueMT { R* ret; SyncSemaphore *sync; - virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class P8,class R> @@ -303,7 +303,7 @@ class CommandQueueMT { R* ret; SyncSemaphore *sync; - virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; } }; /** commands that don't return but sync */ @@ -318,7 +318,7 @@ class CommandQueueMT { SyncSemaphore *sync; - virtual void call() { (instance->*method)(); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { (instance->*method)(); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1> @@ -330,7 +330,7 @@ class CommandQueueMT { SyncSemaphore *sync; - virtual void call() { (instance->*method)(p1); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { (instance->*method)(p1); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2> @@ -343,7 +343,7 @@ class CommandQueueMT { SyncSemaphore *sync; - virtual void call() { (instance->*method)(p1,p2); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { (instance->*method)(p1,p2); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3> @@ -357,7 +357,7 @@ class CommandQueueMT { SyncSemaphore *sync; - virtual void call() { (instance->*method)(p1,p2,p3); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { (instance->*method)(p1,p2,p3); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3,class P4> @@ -372,7 +372,7 @@ class CommandQueueMT { SyncSemaphore *sync; - virtual void call() { (instance->*method)(p1,p2,p3,p4); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { (instance->*method)(p1,p2,p3,p4); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3,class P4,class P5> @@ -388,7 +388,7 @@ class CommandQueueMT { SyncSemaphore *sync; - virtual void call() { (instance->*method)(p1,p2,p3,p4,p5); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { (instance->*method)(p1,p2,p3,p4,p5); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6> @@ -405,7 +405,7 @@ class CommandQueueMT { SyncSemaphore *sync; - virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7> @@ -423,7 +423,7 @@ class CommandQueueMT { SyncSemaphore *sync; - virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class P8> @@ -442,7 +442,7 @@ class CommandQueueMT { SyncSemaphore *sync; - virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; } }; /***** BASE *******/ diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index 1e3a51fede..d39db5044b 100644 --- a/core/compressed_translation.cpp +++ b/core/compressed_translation.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "compressed_translation.h" + #include "pair.h" #include <string.h> diff --git a/core/dictionary.cpp b/core/dictionary.cpp index 3b4d3b65d0..1176b9be3b 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "dictionary.h" + #include "safe_refcount.h" #include "variant.h" diff --git a/core/engine.cpp b/core/engine.cpp index eb6d8a3478..b017e77275 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "engine.h" + #include "version.h" void Engine::set_iterations_per_second(int p_ips) { diff --git a/core/error_macros.cpp b/core/error_macros.cpp index 53a361fa3a..e963f6122b 100644 --- a/core/error_macros.cpp +++ b/core/error_macros.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "error_macros.h" + #include "os/os.h" diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 936facdd23..be619d9ee3 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "global_constants.h" + #include "variant.h" #include "os/keyboard.h" #include "object.h" diff --git a/core/globals.cpp b/core/globals.cpp index 96daf55276..af3ec403d5 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -27,9 +27,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "globals.h" + #include "os/dir_access.h" #include "os/file_access.h" - #include "os/keyboard.h" #include "io/marshalls.h" #include "bind/core_bind.h" @@ -37,6 +37,7 @@ #include "io/file_access_pack.h" #include "io/file_access_network.h" #include "variant_parser.h" + GlobalConfig *GlobalConfig::singleton=NULL; GlobalConfig *GlobalConfig::get_singleton() { diff --git a/core/image.cpp b/core/image.cpp index d769e6a0b3..ed505b0f77 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -27,11 +27,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "image.h" + #include "hash_map.h" #include "core/io/image_loader.h" #include "core/os/copymem.h" #include "hq2x.h" #include "print_string.h" + #include <stdio.h> @@ -762,7 +764,7 @@ void Image::flip_y() { bool gm=mipmaps; if (gm) - clear_mipmaps();; + clear_mipmaps(); @@ -789,7 +791,7 @@ void Image::flip_y() { if (gm) - generate_mipmaps();; + generate_mipmaps(); } @@ -802,7 +804,7 @@ void Image::flip_x() { bool gm=mipmaps; if (gm) - clear_mipmaps();; + clear_mipmaps(); { @@ -827,7 +829,7 @@ void Image::flip_x() { } if (gm) - generate_mipmaps();; + generate_mipmaps(); } diff --git a/core/input_map.cpp b/core/input_map.cpp index bcae630c76..8473bce806 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "input_map.h" + #include "globals.h" #include "os/keyboard.h" @@ -198,7 +199,7 @@ Array InputMap::_get_action_list(const StringName& p_action) { if (al) { for(const List<InputEvent>::Element *E=al->front();E;E=E->next()) { - ret.push_back(E->get());; + ret.push_back(E->get()); } } @@ -238,7 +239,7 @@ const Map<StringName, InputMap::Action>& InputMap::get_action_map() const { void InputMap::load_from_globals() { - input_map.clear();; + input_map.clear(); List<PropertyInfo> pinfo; GlobalConfig::get_singleton()->get_property_list(&pinfo); @@ -253,7 +254,7 @@ void InputMap::load_from_globals() { add_action(name); - Array va = GlobalConfig::get_singleton()->get(pi.name);; + Array va = GlobalConfig::get_singleton()->get(pi.name); for(int i=0;i<va.size();i++) { diff --git a/core/io/aes256.cpp b/core/io/aes256.cpp index cfdac0214d..dc271928b4 100644 --- a/core/io/aes256.cpp +++ b/core/io/aes256.cpp @@ -44,8 +44,7 @@ static uint8_t rj_sbox_inv(uint8_t); #ifdef BACK_TO_TABLES -static const uint8_t sbox[256] = -{ +static const uint8_t sbox[256] = { 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, @@ -79,8 +78,7 @@ static const uint8_t sbox[256] = 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; -static const uint8_t sboxinv[256] = -{ +static const uint8_t sboxinv[256] = { 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, diff --git a/core/io/base64.c b/core/io/base64.c index 0c799e9f07..0929ae5db5 100644 --- a/core/io/base64.c +++ b/core/io/base64.c @@ -1,3 +1,11 @@ +/* + * File: base64.c + * Description: Simple BASE64 conversion methods + * Author: Ari Edelkind + * License: Public Domain + * Website: http://episec.com/people/edelkind/c.html + */ + #include <string.h> char b64string[] = diff --git a/core/io/base64.h b/core/io/base64.h index b70b387983..456ef1811b 100644 --- a/core/io/base64.h +++ b/core/io/base64.h @@ -1,3 +1,11 @@ +/* + * File: base64.h + * Description: Simple BASE64 conversion methods + * Author: Ari Edelkind + * License: Public Domain + * Website: http://episec.com/people/edelkind/c.html + */ + #ifndef BASE64_H #define BASE64_H diff --git a/core/io/compression.cpp b/core/io/compression.cpp index 0d3b494106..6fda7d52f3 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -59,7 +59,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,M return -1; strm.avail_in=p_src_size; - int aout = deflateBound(&strm,p_src_size);; + int aout = deflateBound(&strm,p_src_size); /*if (aout>p_src_size) { deflateEnd(&strm); return -1; diff --git a/core/io/json.cpp b/core/io/json.cpp index c0aa530a12..ac5b8f1e5f 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -100,7 +100,7 @@ String JSON::print(const Variant& p_var) { Error JSON::_get_token(const CharType *p_str, int &idx, int p_len, Token& r_token,int &line,String &r_err_str) { - while (true) { + while (p_len > 0) { switch(p_str[idx]) { case '\n': { diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp index 6133401a8c..2981307af6 100644 --- a/core/io/networked_multiplayer_peer.cpp +++ b/core/io/networked_multiplayer_peer.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* networked_multiplayer_peer.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 "networked_multiplayer_peer.h" diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h index a59d9367d1..5d859a2f25 100644 --- a/core/io/networked_multiplayer_peer.h +++ b/core/io/networked_multiplayer_peer.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* networked_multiplayer_peer.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 NETWORKED_MULTIPLAYER_PEER_H #define NETWORKED_MULTIPLAYER_PEER_H diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index a9f357a7c8..fb5875e4cc 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* pkc_packer.cpp */ +/* pck_packer.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/core/map.h b/core/map.h index 9448389169..d1a4c209ad 100644 --- a/core/map.h +++ b/core/map.h @@ -428,7 +428,7 @@ private: Element *aux=node->parent->left; if (aux->color==RED) { _set_color(aux,BLACK); - _set_color(node->parent,RED);; + _set_color(node->parent,RED); _rotate_right(node->parent); aux=node->parent->left; } diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 0d6997183f..2c45009a60 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* a_star.cpp */ +/* a_star.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/core/math/audio_frame.cpp b/core/math/audio_frame.cpp new file mode 100644 index 0000000000..566ba23992 --- /dev/null +++ b/core/math/audio_frame.cpp @@ -0,0 +1,2 @@ +#include "audio_frame.h" + diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h new file mode 100644 index 0000000000..dbababf762 --- /dev/null +++ b/core/math/audio_frame.h @@ -0,0 +1,28 @@ +#ifndef AUDIOFRAME_H +#define AUDIOFRAME_H + +#include "typedefs.h" + +struct AudioFrame { + + float l,r; + + _ALWAYS_INLINE_ const float& operator[](int idx) const { return idx==0?l:r; } + _ALWAYS_INLINE_ float& operator[](int idx) { return idx==0?l:r; } + + _ALWAYS_INLINE_ AudioFrame operator+(const AudioFrame& p_frame) const { return AudioFrame(l+p_frame.l,r+p_frame.r); } + _ALWAYS_INLINE_ AudioFrame operator-(const AudioFrame& p_frame) const { return AudioFrame(l-p_frame.l,r-p_frame.r); } + _ALWAYS_INLINE_ AudioFrame operator*(const AudioFrame& p_frame) const { return AudioFrame(l*p_frame.l,r*p_frame.r); } + _ALWAYS_INLINE_ AudioFrame operator/(const AudioFrame& p_frame) const { return AudioFrame(l/p_frame.l,r/p_frame.r); } + + _ALWAYS_INLINE_ void operator+=(const AudioFrame& p_frame) { l+=p_frame.l; r+=p_frame.r; } + _ALWAYS_INLINE_ void operator-=(const AudioFrame& p_frame) { l-=p_frame.l; r-=p_frame.r; } + _ALWAYS_INLINE_ void operator*=(const AudioFrame& p_frame) { l*=p_frame.l; r*=p_frame.r; } + _ALWAYS_INLINE_ void operator/=(const AudioFrame& p_frame) { l/=p_frame.l; r/=p_frame.r; } + + _ALWAYS_INLINE_ AudioFrame(float p_l, float p_r) {l=p_l; r=p_r;} + _ALWAYS_INLINE_ AudioFrame(const AudioFrame& p_frame) {l=p_frame.l; r=p_frame.r;} + +}; + +#endif diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h index e01df96555..a64fffcb78 100644 --- a/core/math/bsp_tree.h +++ b/core/math/bsp_tree.h @@ -30,7 +30,7 @@ #define BSP_TREE_H #include "plane.h" -#include "aabb.h" +#include "rect3.h" #include "face3.h" #include "vector.h" #include "dvector.h" diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index c44ff4682a..7669356f5e 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -143,10 +143,22 @@ void CameraMatrix::set_frustum(float p_left, float p_right, float p_bottom, floa float c = - ( p_far + p_near ) / ( p_far - p_near ); float d = - 2 * p_far * p_near / ( p_far - p_near ); - te[0] = x; te[4] = 0; te[8] = a; te[12] = 0; - te[1] = 0; te[5] = y; te[9] = b; te[13] = 0; - te[2] = 0; te[6] = 0; te[10] = c; te[14] = d; - te[3] = 0; te[7] = 0; te[11] = - 1; te[15] = 0; + te[0] = x; + te[1] = 0; + te[2] = 0; + te[3] = 0; + te[4] = 0; + te[5] = y; + te[6] = 0; + te[7] = 0; + te[8] = a; + te[9] = b; + te[10] = c; + te[11] = -1; + te[12] = 0; + te[13] = 0; + te[14] = d; + te[15] = 0; #endif @@ -186,18 +198,21 @@ void CameraMatrix::get_viewport_size(float& r_width, float& r_height) const { Plane near_plane=Plane(matrix[ 3] + matrix[ 2], matrix[ 7] + matrix[ 6], matrix[11] + matrix[10], - -matrix[15] - matrix[14]).normalized(); + -matrix[15] - matrix[14]); + near_plane.normalize(); ///////--- Right Plane ---/////// Plane right_plane=Plane(matrix[ 3] - matrix[ 0], matrix[ 7] - matrix[ 4], matrix[11] - matrix[ 8], - - matrix[15] + matrix[12]).normalized(); + - matrix[15] + matrix[12]); + right_plane.normalize(); Plane top_plane=Plane(matrix[ 3] - matrix[ 1], matrix[ 7] - matrix[ 5], matrix[11] - matrix[ 9], - -matrix[15] + matrix[13]).normalized(); + -matrix[15] + matrix[13]); + top_plane.normalize(); Vector3 res; near_plane.intersect_3(right_plane,top_plane,&res); @@ -214,26 +229,29 @@ bool CameraMatrix::get_endpoints(const Transform& p_transform, Vector3 *p_8point Plane near_plane=Plane(matrix[ 3] + matrix[ 2], matrix[ 7] + matrix[ 6], matrix[11] + matrix[10], - -matrix[15] - matrix[14]).normalized(); + -matrix[15] - matrix[14]); + near_plane.normalize(); ///////--- Far Plane ---/////// Plane far_plane=Plane(matrix[ 2] - matrix[ 3], matrix[ 6] - matrix[ 7], matrix[10] - matrix[11], - matrix[15] - matrix[14]).normalized(); - + matrix[15] - matrix[14]); + far_plane.normalize(); ///////--- Right Plane ---/////// Plane right_plane=Plane(matrix[ 0] - matrix[ 3], matrix[ 4] - matrix[ 7], matrix[8] - matrix[ 11], - - matrix[15] + matrix[12]).normalized(); + - matrix[15] + matrix[12]); + right_plane.normalize(); ///////--- Top Plane ---/////// Plane top_plane=Plane(matrix[ 1] - matrix[ 3], matrix[ 5] - matrix[ 7], matrix[9] - matrix[ 11], - -matrix[15] + matrix[13]).normalized(); + -matrix[15] + matrix[13]); + top_plane.normalize(); Vector3 near_endpoint; Vector3 far_endpoint; @@ -549,7 +567,8 @@ float CameraMatrix::get_fov() const { Plane right_plane=Plane(matrix[ 3] - matrix[ 0], matrix[ 7] - matrix[ 4], matrix[11] - matrix[ 8], - - matrix[15] + matrix[12]).normalized(); + - matrix[15] + matrix[12]); + right_plane.normalize(); return Math::rad2deg(Math::acos(Math::abs(right_plane.normal.x)))*2.0; } diff --git a/core/math/face3.h b/core/math/face3.h index f08eb227b1..e957f64320 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -31,7 +31,7 @@ #include "vector3.h" #include "plane.h" -#include "aabb.h" +#include "rect3.h" #include "transform.h" class Face3 { diff --git a/core/math/geometry.h b/core/math/geometry.h index d5b3a3068c..25f5e11fcf 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -297,7 +297,7 @@ public: if (inters_d<0 || inters_d>rel_l) return false; - Vector3 result=p_from+normal*inters_d;; + Vector3 result=p_from+normal*inters_d; if (r_res) *r_res=result; diff --git a/core/math/octree.h b/core/math/octree.h index 483ba1d510..3630922d10 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -30,7 +30,7 @@ #define OCTREE_H #include "vector3.h" -#include "aabb.h" +#include "rect3.h" #include "list.h" #include "variant.h" #include "map.h" diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h index 04d25fef18..7bd23d31f2 100644 --- a/core/math/quick_hull.h +++ b/core/math/quick_hull.h @@ -29,7 +29,7 @@ #ifndef QUICK_HULL_H #define QUICK_HULL_H -#include "aabb.h" +#include "rect3.h" #include "set.h" #include "list.h" #include "geometry.h" diff --git a/core/math/aabb.cpp b/core/math/rect3.cpp index 3518eea7ac..e0b0646505 100644 --- a/core/math/aabb.cpp +++ b/core/math/rect3.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* aabb.cpp */ +/* rect3.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "aabb.h" +#include "rect3.h" #include "print_string.h" diff --git a/core/math/aabb.h b/core/math/rect3.h index 2816d1f012..80c67200f4 100644 --- a/core/math/aabb.h +++ b/core/math/rect3.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* aabb.h */ +/* rect3.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/core/math/transform.h b/core/math/transform.h index d65e87cc6a..45d7b2a12c 100644 --- a/core/math/transform.h +++ b/core/math/transform.h @@ -31,7 +31,7 @@ #include "matrix3.h" #include "plane.h" -#include "aabb.h" +#include "rect3.h" /** @author Juan Linietsky <reduzio@gmail.com> */ diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index 74c4656771..86f8bf29e7 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -236,21 +236,22 @@ Vector3 TriangleMesh::get_area_normal(const Rect3& p_aabb) const { stack[level]=(VISIT_LEFT_BIT<<VISITED_BIT_SHIFT)|node; } } - - } continue; + continue; + } case VISIT_LEFT_BIT: { stack[level]=(VISIT_RIGHT_BIT<<VISITED_BIT_SHIFT)|node; stack[level+1]=b.left|TEST_AABB_BIT; level++; - - } continue; + continue; + } case VISIT_RIGHT_BIT: { stack[level]=(VISIT_DONE_BIT<<VISITED_BIT_SHIFT)|node; stack[level+1]=b.right|TEST_AABB_BIT; level++; - } continue; + continue; + } case VISIT_DONE_BIT: { if (level==0) { @@ -258,8 +259,8 @@ Vector3 TriangleMesh::get_area_normal(const Rect3& p_aabb) const { break; } else level--; - - } continue; + continue; + } } @@ -357,21 +358,22 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end stack[level]=(VISIT_LEFT_BIT<<VISITED_BIT_SHIFT)|node; } } - - } continue; + continue; + } case VISIT_LEFT_BIT: { stack[level]=(VISIT_RIGHT_BIT<<VISITED_BIT_SHIFT)|node; stack[level+1]=b.left|TEST_AABB_BIT; level++; - - } continue; + continue; + } case VISIT_RIGHT_BIT: { stack[level]=(VISIT_DONE_BIT<<VISITED_BIT_SHIFT)|node; stack[level+1]=b.right|TEST_AABB_BIT; level++; - } continue; + continue; + } case VISIT_DONE_BIT: { if (level==0) { @@ -379,8 +381,8 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end break; } else level--; - - } continue; + continue; + } } @@ -478,21 +480,22 @@ bool TriangleMesh::intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vec stack[level]=(VISIT_LEFT_BIT<<VISITED_BIT_SHIFT)|node; } } - - } continue; + continue; + } case VISIT_LEFT_BIT: { stack[level]=(VISIT_RIGHT_BIT<<VISITED_BIT_SHIFT)|node; stack[level+1]=b.left|TEST_AABB_BIT; level++; - - } continue; + continue; + } case VISIT_RIGHT_BIT: { stack[level]=(VISIT_DONE_BIT<<VISITED_BIT_SHIFT)|node; stack[level+1]=b.right|TEST_AABB_BIT; level++; - } continue; + continue; + } case VISIT_DONE_BIT: { if (level==0) { @@ -500,8 +503,8 @@ bool TriangleMesh::intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vec break; } else level--; - - } continue; + continue; + } } diff --git a/core/message_queue.cpp b/core/message_queue.cpp index fe46e1671c..668d321e05 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -27,8 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "message_queue.h" + #include "globals.h" #include "script_language.h" + MessageQueue *MessageQueue::singleton=NULL; MessageQueue *MessageQueue::get_singleton() { diff --git a/core/object.cpp b/core/object.cpp index 8af088122e..26308dc64f 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -27,8 +27,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "object.h" + #include "print_string.h" -#include "object_type_db.h" +#include "class_db.h" #include "script_language.h" #include "message_queue.h" #include "core_string_names.h" diff --git a/core/object.h b/core/object.h index 6ce579ea99..b9a800afc4 100644 --- a/core/object.h +++ b/core/object.h @@ -721,6 +721,6 @@ public: }; //needed by macros -#include "object_type_db.h" +#include "class_db.h" #endif diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index 3cc595208f..4ef99558ad 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -39,6 +39,8 @@ bool InputEvent::operator==(const InputEvent &p_event) const { } switch(type) { + /** Current clang-format style doesn't play well with the aligned return values of that switch. */ + /* clang-format off */ case NONE: return true; case KEY: @@ -80,6 +82,7 @@ bool InputEvent::operator==(const InputEvent &p_event) const { case ACTION: return action.action == p_event.action.action && action.pressed == p_event.action.pressed; + /* clang-format on */ default: ERR_PRINT("No logic to compare InputEvents of this type, this shouldn't happen."); } diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index 309348ea31..40fa86d09f 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -36,6 +36,7 @@ struct _KeyCodeText { static const _KeyCodeText _keycodes[]={ + /* clang-format off */ {KEY_ESCAPE ,"Escape"}, {KEY_TAB ,"Tab"}, {KEY_BACKTAB ,"BackTab"}, @@ -281,7 +282,8 @@ static const _KeyCodeText _keycodes[]={ {KEY_DIVISION ,"Division"}, {KEY_YDIAERESIS ,"Ydiaeresis"}, - {0 ,0} + {0 ,0} + /* clang-format on */ }; bool keycode_has_unicode(uint32_t p_keycode) { @@ -299,7 +301,8 @@ bool keycode_has_unicode(uint32_t p_keycode) { case KEY_MEDIAPREVIOUS: case KEY_MEDIANEXT: case KEY_MEDIARECORD: case KEY_HOMEPAGE: case KEY_FAVORITES: case KEY_SEARCH: case KEY_STANDBY: case KEY_OPENURL: case KEY_LAUNCHMAIL: case KEY_LAUNCHMEDIA: case KEY_LAUNCH0: case KEY_LAUNCH1: case KEY_LAUNCH2: case KEY_LAUNCH3: case KEY_LAUNCH4: case KEY_LAUNCH5: case KEY_LAUNCH6: case KEY_LAUNCH7: case KEY_LAUNCH8: case KEY_LAUNCH9: case KEY_LAUNCHA: case KEY_LAUNCHB: case KEY_LAUNCHC: case KEY_LAUNCHD: - case KEY_LAUNCHE: case KEY_LAUNCHF: return false; + case KEY_LAUNCHE: case KEY_LAUNCHF: + return false; } return true; diff --git a/core/os/mutex.cpp b/core/os/mutex.cpp index f5f7f757c3..acdcb492d9 100644 --- a/core/os/mutex.cpp +++ b/core/os/mutex.cpp @@ -47,7 +47,7 @@ Mutex::~Mutex() { } -Mutex *_global_mutex=NULL;; +Mutex *_global_mutex=NULL; void _global_lock() { diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index 5f3b877822..d3bb03ab5e 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -27,11 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "packed_data_container.h" + #include "io/marshalls.h" #include "core_string_names.h" - Variant PackedDataContainer::getvar(const Variant& p_key, bool *r_valid) const { bool err=false; diff --git a/core/path_db.cpp b/core/path_db.cpp index 25f62ed951..679372898c 100644 --- a/core/path_db.cpp +++ b/core/path_db.cpp @@ -27,8 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "path_db.h" -#include "print_string.h" +#include "print_string.h" uint32_t NodePath::hash() const { @@ -334,7 +334,7 @@ NodePath::NodePath(const String& p_path) { StringName property; Vector<StringName> subpath; - int absolute=(path[0]=='/')?1:0;; + int absolute=(path[0]=='/')?1:0; bool last_is_slash=true; int slices=0; int subpath_pos=path.find(":"); diff --git a/core/path_remap.cpp b/core/path_remap.cpp index 646c1c497b..ed77fd8840 100644 --- a/core/path_remap.cpp +++ b/core/path_remap.cpp @@ -27,9 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "path_remap.h" + #include "globals.h" #include "os/os.h" #include "translation.h" + PathRemap* PathRemap::singleton=NULL; PathRemap* PathRemap::get_singleton() { diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp index e425218060..b1417dd107 100644 --- a/core/pool_allocator.cpp +++ b/core/pool_allocator.cpp @@ -27,12 +27,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "pool_allocator.h" + #include "error_macros.h" #include "core/os/os.h" #include "os/memory.h" #include "os/copymem.h" #include "print_string.h" + #include <assert.h> + #define COMPACT_CHUNK( m_entry , m_to_pos ) \ do { \ void *_dst=&((unsigned char*)pool)[m_to_pos]; \ diff --git a/core/print_string.cpp b/core/print_string.cpp index 3faed62bb4..36316af619 100644 --- a/core/print_string.cpp +++ b/core/print_string.cpp @@ -27,7 +27,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "print_string.h" + #include "os/os.h" + #include <stdio.h> static PrintHandlerList *print_handler_list=NULL; diff --git a/core/profile_clock.cpp b/core/profile_clock.cpp deleted file mode 100644 index 0806275463..0000000000 --- a/core/profile_clock.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "profile_clock.h" - - diff --git a/core/profile_clock.h b/core/profile_clock.h deleted file mode 100644 index e254580249..0000000000 --- a/core/profile_clock.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef PROFILE_CLOCK_H -#define PROFILE_CLOCK_H - - - - -#endif // PROFILE_CLOCK_H diff --git a/core/ref_ptr.cpp b/core/ref_ptr.cpp index e781bae496..29ffe974d2 100644 --- a/core/ref_ptr.cpp +++ b/core/ref_ptr.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "ref_ptr.h" + #include "reference.h" #include "resource.h" diff --git a/core/reference.cpp b/core/reference.cpp index 69e053cc1a..d21caf0839 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "reference.h" + #include "script_language.h" diff --git a/core/reference.h b/core/reference.h index ce196801bb..e130b4c2b4 100644 --- a/core/reference.h +++ b/core/reference.h @@ -32,7 +32,7 @@ #include "object.h" #include "safe_refcount.h" #include "ref_ptr.h" -#include "object_type_db.h" +#include "class_db.h" /** @author Juan Linietsky <reduzio@gmail.com> diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 85fa5d27c0..242d36042d 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -36,7 +36,7 @@ #include "math/a_star.h" #include "math/triangle_mesh.h" #include "globals.h" -#include "object_type_db.h" +#include "class_db.h" #include "geometry.h" #include "bind/core_bind.h" #include "core_string_names.h" diff --git a/core/resource.cpp b/core/resource.cpp index 3369e4a5a2..4b09a506ff 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -27,12 +27,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resource.h" + #include "core_string_names.h" -#include <stdio.h> #include "os/file_access.h" #include "io/resource_loader.h" #include "script_language.h" +#include <stdio.h> + void ResourceImportMetadata::set_editor(const String& p_editor) { editor=p_editor; @@ -198,7 +200,7 @@ void Resource::set_path(const String& p_path, bool p_take_over) { if (path_cache!="") { ResourceCache::lock->write_lock(); - ResourceCache::resources[path_cache]=this;; + ResourceCache::resources[path_cache]=this; ResourceCache::lock->write_unlock(); } @@ -532,9 +534,9 @@ void ResourceCache::reload_externals() { bool ResourceCache::has(const String& p_path) { - lock->read_lock();; + lock->read_lock(); bool b = resources.has(p_path); - lock->read_unlock();; + lock->read_unlock(); return b; diff --git a/core/resource.h b/core/resource.h index 284c59e1a8..2b071c8e1c 100644 --- a/core/resource.h +++ b/core/resource.h @@ -33,7 +33,7 @@ #include "safe_refcount.h" #include "ref_ptr.h" #include "reference.h" -#include "object_type_db.h" +#include "class_db.h" /** @author Juan Linietsky <reduzio@gmail.com> diff --git a/core/script_debugger_local.cpp b/core/script_debugger_local.cpp index a8d77668f5..22aceac4c5 100644 --- a/core/script_debugger_local.cpp +++ b/core/script_debugger_local.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_debugger_local.h" + #include "os/os.h" void ScriptDebuggerLocal::debug(ScriptLanguage *p_script,bool p_can_continue) { @@ -286,7 +287,7 @@ void ScriptDebuggerLocal::profiling_end() { for(int i=0;i<ofs;i++) { print_line(itos(i)+":"+pinfo[i].signature); - float tt=USEC_TO_SEC(pinfo[i].total_time);; + float tt=USEC_TO_SEC(pinfo[i].total_time); float st=USEC_TO_SEC(pinfo[i].self_time); print_line("\ttotal_ms: "+rtos(tt)+"\tself_ms: "+rtos(st)+"total%: "+itos(tt*100/total_time)+"\tself%: "+itos(st*100/total_time)+"\tcalls: "+itos(pinfo[i].call_count)); } diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index bb0109467e..62d14c4e5a 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -27,10 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_debugger_remote.h" + #include "os/os.h" #include "io/ip.h" #include "globals.h" #include "os/input.h" + void ScriptDebuggerRemote::_send_video_memory() { List<ResourceUsage> usage; diff --git a/core/set.h b/core/set.h index 13c2b3a4f6..a921fc661f 100644 --- a/core/set.h +++ b/core/set.h @@ -416,7 +416,7 @@ private: Element *aux=node->parent->left; if (aux->color==RED) { _set_color(aux,BLACK); - _set_color(node->parent,RED);; + _set_color(node->parent,RED); _rotate_right(node->parent); aux=node->parent->left; } diff --git a/core/string_db.cpp b/core/string_db.cpp index be35a44ed1..004b07b9e5 100644 --- a/core/string_db.cpp +++ b/core/string_db.cpp @@ -27,8 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "string_db.h" + #include "print_string.h" #include "os/os.h" + StaticCString StaticCString::create(const char *p_ptr) { StaticCString scs; scs.ptr=p_ptr; return scs; } diff --git a/core/translation.cpp b/core/translation.cpp index 5215e5f6d1..d5ec61b8d6 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "translation.h" + #include "globals.h" #include "io/resource_loader.h" #include "os/os.h" diff --git a/core/typedefs.h b/core/typedefs.h index 176c77570d..c630887924 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -40,41 +40,39 @@ #define _STR(m_x) #m_x #define _MKSTR(m_x) _STR(m_x) #endif -// have to include version.h for this to work, include it in the .cpp not the .h + +/** + * Version macros - it is necessary to include "version.h" for those to work. + * Include it in the .cpp file, not the header. + */ #ifdef VERSION_PATCH -#define VERSION_MKSTRING _MKSTR(VERSION_MAJOR)"." _MKSTR(VERSION_MINOR)"." _MKSTR(VERSION_PATCH)"." _MKSTR(VERSION_STATUS)"." _MKSTR(VERSION_REVISION) +#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION) #else -#define VERSION_MKSTRING _MKSTR(VERSION_MAJOR)"." _MKSTR(VERSION_MINOR)"." _MKSTR(VERSION_STATUS)"." _MKSTR(VERSION_REVISION) +#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION) #endif // VERSION_PATCH -#define VERSION_FULL_NAME _MKSTR(VERSION_NAME)" v" VERSION_MKSTRING +#define VERSION_FULL_NAME "" _MKSTR(VERSION_NAME) " v" VERSION_MKSTRING #ifndef _ALWAYS_INLINE_ #if defined(__GNUC__) && (__GNUC__ >= 4 ) -# define _ALWAYS_INLINE_ __attribute__((always_inline)) inline +#define _ALWAYS_INLINE_ __attribute__((always_inline)) inline #elif defined(__llvm__) -# define _ALWAYS_INLINE_ __attribute__((always_inline)) inline +#define _ALWAYS_INLINE_ __attribute__((always_inline)) inline #elif defined(_MSC_VER) -# define _ALWAYS_INLINE_ __forceinline +#define _ALWAYS_INLINE_ __forceinline #else -# define _ALWAYS_INLINE_ inline +#define _ALWAYS_INLINE_ inline #endif #endif #ifndef _FORCE_INLINE_ - #ifdef DEBUG_ENABLED - #define _FORCE_INLINE_ inline - #else - #define _FORCE_INLINE_ _ALWAYS_INLINE_ - #endif - #endif @@ -97,16 +95,16 @@ T *_nullptr() { T*t=NULL; return t; } */ #ifdef _WIN32 -# undef min // override standard definition -# undef max // override standard definition -# undef ERROR // override (really stupid) wingdi.h standard definition -# undef DELETE // override (another really stupid) winnt.h standard definition -# undef MessageBox // override winuser.h standard definition -# undef MIN // override standard definition -# undef MAX // override standard definition -# undef CLAMP // override standard definition -# undef Error -# undef OK +#undef min // override standard definition +#undef max // override standard definition +#undef ERROR // override (really stupid) wingdi.h standard definition +#undef DELETE // override (another really stupid) winnt.h standard definition +#undef MessageBox // override winuser.h standard definition +#undef MIN // override standard definition +#undef MAX // override standard definition +#undef CLAMP // override standard definition +#undef Error +#undef OK #endif #include "error_macros.h" @@ -150,30 +148,30 @@ inline void __swap_tmpl(T &x, T &y ) { #endif //swap -#define HEX2CHR( m_hex ) ( (m_hex>='0' && m_hex<='9')?(m_hex-'0'):\ - ((m_hex>='A' && m_hex<='F')?(10+m_hex-'A'):\ - ((m_hex>='a' && m_hex<='f')?(10+m_hex-'a'):0))) +/* clang-format off */ +#define HEX2CHR(m_hex) \ + ((m_hex >= '0' && m_hex <= '9') ? (m_hex - '0') : \ + ((m_hex >= 'A' && m_hex <= 'F') ? (10 + m_hex - 'A') : \ + ((m_hex >= 'a' && m_hex <= 'f') ? (10 + m_hex - 'a') : 0))) +/* clang-format on */ // Macro to check whether we are compiled by clang // and we have a specific builtin #if defined(__llvm__) && defined(__has_builtin) - #define _llvm_has_builtin(x) __has_builtin(x) +#define _llvm_has_builtin(x) __has_builtin(x) #else - #define _llvm_has_builtin(x) 0 +#define _llvm_has_builtin(x) 0 #endif #if (defined(__GNUC__) && (__GNUC__ >= 5)) || _llvm_has_builtin(__builtin_mul_overflow) -# define _mul_overflow __builtin_mul_overflow +#define _mul_overflow __builtin_mul_overflow #endif #if (defined(__GNUC__) && (__GNUC__ >= 5)) || _llvm_has_builtin(__builtin_add_overflow) -# define _add_overflow __builtin_add_overflow +#define _add_overflow __builtin_add_overflow #endif - - - /** Function to find the nearest (bigger) power of 2 to an integer */ static _FORCE_INLINE_ unsigned int nearest_power_of_2(unsigned int x) { @@ -276,14 +274,11 @@ struct _GlobalLock { }; #define GLOBAL_LOCK_FUNCTION _GlobalLock _global_lock_; -#ifdef NO_SAFE_CAST +#ifdef NO_SAFE_CAST #define SAFE_CAST static_cast - #else - #define SAFE_CAST dynamic_cast - #endif #define MT_SAFE @@ -291,7 +286,4 @@ struct _GlobalLock { #define __STRX(m_index) #m_index #define __STR(m_index) __STRX(m_index) - - #endif /* typedefs.h */ - diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index acb262d400..1a0ccc4a7e 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "undo_redo.h" + #include "os/os.h" void UndoRedo::_discard_redo() { diff --git a/core/ustring.cpp b/core/ustring.cpp index 66608379be..71934b2955 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <wchar.h> #include "ustring.h" + #include "os/memory.h" #include "print_string.h" #include "math_funcs.h" @@ -36,10 +36,8 @@ #include "ucaps.h" #include "color.h" #include "variant.h" -#define MAX_DIGITS 6 -#define UPPERCASE(m_c) (((m_c)>='a' && (m_c)<='z')?((m_c)-('a'-'A')):(m_c)) -#define LOWERCASE(m_c) (((m_c)>='A' && (m_c)<='Z')?((m_c)+('a'-'A')):(m_c)) +#include <wchar.h> #ifndef NO_USE_STDLIB #include <stdlib.h> @@ -50,6 +48,10 @@ #define snprintf _snprintf #endif +#define MAX_DIGITS 6 +#define UPPERCASE(m_c) (((m_c)>='a' && (m_c)<='z')?((m_c)-('a'-'A')):(m_c)) +#define LOWERCASE(m_c) (((m_c)>='A' && (m_c)<='Z')?((m_c)+('a'-'A')):(m_c)) + /** STRING **/ const char *CharString::get_data() const { @@ -1255,7 +1257,7 @@ _FORCE_INLINE static int parse_utf8_char(const char *p_utf8,unsigned int *p_ucs4 unichar=*p_utf8; else { - unichar=(0xFF >> (len +1)) & *p_utf8;; + unichar=(0xFF >> (len +1)) & *p_utf8; for (int i=1;i<len;i++) { @@ -1404,7 +1406,7 @@ bool String::parse_utf8(const char* p_utf8,int p_len) { unichar=*p_utf8; else { - unichar=(0xFF >> (len +1)) & *p_utf8;; + unichar=(0xFF >> (len +1)) & *p_utf8; for (int i=1;i<len;i++) { diff --git a/core/variant.cpp b/core/variant.cpp index 5a670a2786..103c8f6746 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "variant.h" + #include "resource.h" #include "print_string.h" #include "scene/main/node.h" @@ -1764,7 +1765,7 @@ Variant::operator Transform() const { if (type==TRANSFORM2D) { return *_data._transform2d; } else if (type==TRANSFORM) { - const Transform& t = *_data._transform;; + const Transform& t = *_data._transform; Transform2D m; m.elements[0][0]=t.basis.elements[0][0]; m.elements[0][1]=t.basis.elements[1][0]; diff --git a/core/variant.h b/core/variant.h index 9d29fd64c3..5936325c1b 100644 --- a/core/variant.h +++ b/core/variant.h @@ -33,7 +33,7 @@ @author Juan Linietsky <reduzio@gmail.com> */ -#include "aabb.h" +#include "rect3.h" #include "ustring.h" #include "vector3.h" #include "plane.h" diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 51ad115d46..022faede1e 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "variant.h" + #include "object.h" #include "os/os.h" #include "core_string_names.h" @@ -1052,32 +1053,32 @@ Variant Variant::construct(const Variant::Type p_type, const Variant** p_args, i // math types - case VECTOR2: return Vector2(); // 5 + case VECTOR2: return Vector2(); // 5 case RECT2: return Rect2(); case VECTOR3: return Vector3(); case TRANSFORM2D: return Transform2D(); case PLANE: return Plane(); case QUAT: return Quat(); - case RECT3: return Rect3(); //sorry naming convention fail :( not like it's used often // 10 + case RECT3: return Rect3(); // 10 case BASIS: return Basis(); case TRANSFORM: return Transform(); // misc types case COLOR: return Color(); - case IMAGE: return Image();; - case NODE_PATH: return NodePath();; // 15 - case _RID: return RID();; + case IMAGE: return Image(); + case NODE_PATH: return NodePath(); // 15 + case _RID: return RID(); case OBJECT: return (Object*)NULL; - case INPUT_EVENT: return InputEvent();; - case DICTIONARY: return Dictionary();; - case ARRAY: return Array();; // 20 - case POOL_BYTE_ARRAY: return PoolByteArray();; - case POOL_INT_ARRAY: return PoolIntArray();; - case POOL_REAL_ARRAY: return PoolRealArray();; - case POOL_STRING_ARRAY: return PoolStringArray();; - case POOL_VECTOR2_ARRAY: return PoolVector2Array();; // 25 - case POOL_VECTOR3_ARRAY: return PoolVector3Array();; // 25 - case POOL_COLOR_ARRAY: return PoolColorArray();; + case INPUT_EVENT: return InputEvent(); + case DICTIONARY: return Dictionary(); + case ARRAY: return Array(); // 20 + case POOL_BYTE_ARRAY: return PoolByteArray(); + case POOL_INT_ARRAY: return PoolIntArray(); + case POOL_REAL_ARRAY: return PoolRealArray(); + case POOL_STRING_ARRAY: return PoolStringArray(); + case POOL_VECTOR2_ARRAY: return PoolVector2Array(); // 25 + case POOL_VECTOR3_ARRAY: return PoolVector3Array(); + case POOL_COLOR_ARRAY: return PoolColorArray(); default: return Variant(); } @@ -1126,27 +1127,27 @@ Variant Variant::construct(const Variant::Type p_type, const Variant** p_args, i case VECTOR3: return (Vector3(*p_args[0])); case PLANE: return (Plane(*p_args[0])); case QUAT: return (Quat(*p_args[0])); - case RECT3: return (Rect3(*p_args[0])); //sorry naming convention fail :( not like it's used often // 10 + case RECT3: return (Rect3(*p_args[0])); // 10 case BASIS: return (Basis(p_args[0]->operator Basis())); case TRANSFORM: return (Transform(p_args[0]->operator Transform())); // misc types case COLOR: return p_args[0]->type == Variant::STRING ? Color::html(*p_args[0]) : Color::hex(*p_args[0]); case IMAGE: return (Image(*p_args[0])); - case NODE_PATH: return (NodePath(p_args[0]->operator NodePath())); // 15 + case NODE_PATH: return (NodePath(p_args[0]->operator NodePath())); // 15 case _RID: return (RID(*p_args[0])); case OBJECT: return ((Object*)(p_args[0]->operator Object *())); case INPUT_EVENT: return (InputEvent(*p_args[0])); case DICTIONARY: return p_args[0]->operator Dictionary(); - case ARRAY: return p_args[0]->operator Array(); + case ARRAY: return p_args[0]->operator Array(); // 20 // arrays case POOL_BYTE_ARRAY: return (PoolByteArray(*p_args[0])); case POOL_INT_ARRAY: return (PoolIntArray(*p_args[0])); case POOL_REAL_ARRAY: return (PoolRealArray(*p_args[0])); case POOL_STRING_ARRAY: return (PoolStringArray(*p_args[0])); - case POOL_VECTOR2_ARRAY: return (PoolVector2Array(*p_args[0])); // 25 - case POOL_VECTOR3_ARRAY: return (PoolVector3Array(*p_args[0])); // 25 + case POOL_VECTOR2_ARRAY: return (PoolVector2Array(*p_args[0])); // 25 + case POOL_VECTOR3_ARRAY: return (PoolVector3Array(*p_args[0])); case POOL_COLOR_ARRAY: return (PoolColorArray(*p_args[0])); default: return Variant(); } diff --git a/core/variant_construct_string.cpp b/core/variant_construct_string.cpp index 8db756aa79..56aa9891fb 100644 --- a/core/variant_construct_string.cpp +++ b/core/variant_construct_string.cpp @@ -169,7 +169,7 @@ Error VariantConstruct::_get_token(const CharType *p_str, int &idx, int p_len, T case 'r': res=13; break; case '\"': res='\"'; break; case '\\': res='\\'; break; - case '/': res='/'; break; //wtf + case '/': res='/'; break; case 'u': { //hexnumbarh - oct is deprecated diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 50f0b96715..6ed8a3dd85 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -27,9 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "variant.h" + #include "object.h" #include "script_language.h" #include "core_string_names.h" + Variant::operator bool() const { bool b; diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index ca748b7fd3..a833a275df 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -27,11 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "variant_parser.h" + #include "io/resource_loader.h" #include "os/keyboard.h" - CharType VariantParser::StreamFile::get_char() { return f->get_8(); @@ -1989,7 +1989,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str PoolVector<uint8_t> data = img.get_data(); int len = data.size(); PoolVector<uint8_t>::Read r = data.read(); - const uint8_t *ptr=r.ptr();; + const uint8_t *ptr=r.ptr(); for (int i=0;i<len;i++) { if (i>0) @@ -2133,7 +2133,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str PoolVector<uint8_t> data = p_variant; int len = data.size(); PoolVector<uint8_t>::Read r = data.read(); - const uint8_t *ptr=r.ptr();; + const uint8_t *ptr=r.ptr(); for (int i=0;i<len;i++) { if (i>0) @@ -2152,7 +2152,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str PoolVector<int> data = p_variant; int len = data.size(); PoolVector<int>::Read r = data.read(); - const int *ptr=r.ptr();; + const int *ptr=r.ptr(); for (int i=0;i<len;i++) { @@ -2172,7 +2172,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str PoolVector<real_t> data = p_variant; int len = data.size(); PoolVector<real_t>::Read r = data.read(); - const real_t *ptr=r.ptr();; + const real_t *ptr=r.ptr(); for (int i=0;i<len;i++) { @@ -2190,7 +2190,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str PoolVector<String> data = p_variant; int len = data.size(); PoolVector<String>::Read r = data.read(); - const String *ptr=r.ptr();; + const String *ptr=r.ptr(); String s; //write_string("\n"); @@ -2213,7 +2213,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str PoolVector<Vector2> data = p_variant; int len = data.size(); PoolVector<Vector2>::Read r = data.read(); - const Vector2 *ptr=r.ptr();; + const Vector2 *ptr=r.ptr(); for (int i=0;i<len;i++) { @@ -2231,7 +2231,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str PoolVector<Vector3> data = p_variant; int len = data.size(); PoolVector<Vector3>::Read r = data.read(); - const Vector3 *ptr=r.ptr();; + const Vector3 *ptr=r.ptr(); for (int i=0;i<len;i++) { @@ -2250,7 +2250,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str PoolVector<Color> data = p_variant; int len = data.size(); PoolVector<Color>::Read r = data.read(); - const Color *ptr=r.ptr();; + const Color *ptr=r.ptr(); for (int i=0;i<len;i++) { diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index b026241579..8984d412a3 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -30,11 +30,9 @@ #ifdef ALSA_ENABLED -#include <errno.h> #include "globals.h" - - +#include <errno.h> Error AudioDriverALSA::init() { @@ -46,7 +44,7 @@ Error AudioDriverALSA::init() { samples_out = NULL; mix_rate = GLOBAL_DEF("audio/mix_rate",44100); - output_format = OUTPUT_STEREO; + speaker_mode = SPEAKER_MODE_STEREO; channels = 2; @@ -205,16 +203,18 @@ int AudioDriverALSA::get_mix_rate() const { return mix_rate; }; -AudioDriverSW::OutputFormat AudioDriverALSA::get_output_format() const { +AudioDriver::SpeakerMode AudioDriverALSA::get_speaker_mode() const { - return output_format; + return speaker_mode; }; + void AudioDriverALSA::lock() { if (!thread || !mutex) return; mutex->lock(); }; + void AudioDriverALSA::unlock() { if (!thread || !mutex) diff --git a/drivers/alsa/audio_driver_alsa.h b/drivers/alsa/audio_driver_alsa.h index df28294f56..6ab98312b2 100644 --- a/drivers/alsa/audio_driver_alsa.h +++ b/drivers/alsa/audio_driver_alsa.h @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #ifdef ALSA_ENABLED @@ -35,7 +35,7 @@ #include <alsa/asoundlib.h> -class AudioDriverALSA : public AudioDriverSW { +class AudioDriverALSA : public AudioDriver { Thread* thread; Mutex* mutex; @@ -48,7 +48,7 @@ class AudioDriverALSA : public AudioDriverSW { static void thread_func(void* p_udata); unsigned int mix_rate; - OutputFormat output_format; + SpeakerMode speaker_mode; snd_pcm_uframes_t buffer_size; snd_pcm_uframes_t period_size; @@ -68,7 +68,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/drivers/convex_decomp/b2Polygon.cpp b/drivers/convex_decomp/b2Polygon.cpp index f45d98250a..b6ead62c63 100644 --- a/drivers/convex_decomp/b2Polygon.cpp +++ b/drivers/convex_decomp/b2Polygon.cpp @@ -353,7 +353,7 @@ bool b2Polygon::IsUsable(bool printErrors){ b2Vec2 centroid = PolyCentroid(vertices,nVertices); b2Vec2 n1 = normals[iminus]; b2Vec2 n2 = normals[i]; - b2Vec2 v = vertices[i] - centroid;; + b2Vec2 v = vertices[i] - centroid; b2Vec2 d; d.x = b2Dot(n1, v) - toiSlop; diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 760af5100c..1486e85a04 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -3259,7 +3259,7 @@ void RasterizerGLES2::particles_set_emitting(RID p_particles, bool p_emitting) { Particles* particles = particles_owner.get( p_particles ); ERR_FAIL_COND(!particles); - particles->data.emitting=p_emitting;; + particles->data.emitting=p_emitting; } bool RasterizerGLES2::particles_is_emitting(RID p_particles) const { @@ -3468,7 +3468,7 @@ void RasterizerGLES2::particles_set_attractor_pos(RID p_particles, int p_attract Particles* particles = particles_owner.get( p_particles ); ERR_FAIL_COND(!particles); ERR_FAIL_INDEX(p_attractor,particles->data.attractor_count); - particles->data.attractors[p_attractor].pos=p_pos;; + particles->data.attractors[p_attractor].pos=p_pos; } Vector3 RasterizerGLES2::particles_get_attractor_pos(RID p_particles,int p_attractor) const { diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index f04b035560..ddcd97ec4a 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -1429,7 +1429,7 @@ public: virtual void multimesh_instance_set_color(RID p_multimesh,int p_index,const Color& p_color); virtual RID multimesh_get_mesh(RID p_multimesh) const; - virtual AABB multimesh_get_aabb(RID p_multimesh) const;; + virtual AABB multimesh_get_aabb(RID p_multimesh) const; virtual Transform multimesh_instance_get_transform(RID p_multimesh,int p_index) const; virtual Color multimesh_instance_get_color(RID p_multimesh,int p_index) const; diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 247a35141e..a5aa570e33 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -441,7 +441,8 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a } else if (custom_h && callfunc=="cosh_custom") { if (!cosh_used) { - global_code= "float cosh_custom(float val)\n"\ + global_code= + "float cosh_custom(float val)\n"\ "{\n"\ " float tmp = exp(val);\n"\ " float cosH = (tmp + 1.0 / tmp) / 2.0;\n"\ @@ -453,7 +454,8 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a } else if (custom_h && callfunc=="sinh_custom") { if (!sinh_used) { - global_code= "float sinh_custom(float val)\n"\ + global_code= + "float sinh_custom(float val)\n"\ "{\n"\ " float tmp = exp(val);\n"\ " float sinH = (tmp - 1.0 / tmp) / 2.0;\n"\ @@ -465,7 +467,8 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a } else if (custom_h && callfunc=="tanh_custom") { if (!tanh_used) { - global_code= "float tanh_custom(float val)\n"\ + global_code= + "float tanh_custom(float val)\n"\ "{\n"\ " float tmp = exp(val);\n"\ " float tanH = (tmp - 1.0 / tmp) / (tmp + 1.0 / tmp);\n"\ diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index c10611c961..458da85e74 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1,6 +1,11 @@ #include "rasterizer_canvas_gles3.h" #include "os/os.h" +#ifdef IPHONE_ENABLED +// for some reason glClearDepth seems to have been removed in iOS ES3.h +#define glClearDepth glClearDepthf +#endif + static _FORCE_INLINE_ void store_transform2d(const Transform2D& p_mtx, float* p_array) { p_array[ 0]=p_mtx.elements[0][0]; @@ -87,7 +92,7 @@ void RasterizerCanvasGLES3::light_internal_update(RID p_rid, Light* p_light) { if (p_light->radius_cache==0) li->ubo_data.shadow_gradient=0; else - li->ubo_data.shadow_gradient=p_light->shadow_gradient_length/(p_light->radius_cache*1.1);; + li->ubo_data.shadow_gradient=p_light->shadow_gradient_length/(p_light->radius_cache*1.1); li->ubo_data.shadow_distance_mult=(p_light->radius_cache*1.1); diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index b7616db8b1..5c6b9c5410 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -237,7 +237,7 @@ void RasterizerGLES3::set_current_render_target(RID p_render_target){ storage->frame.current_rt=NULL; storage->frame.clear_request=false; glViewport(0,0,OS::get_singleton()->get_window_size().width,OS::get_singleton()->get_window_size().height); - glBindFramebuffer(GL_FRAMEBUFFER,storage->config.system_fbo); + glBindFramebuffer(GL_FRAMEBUFFER,RasterizerStorageGLES3::system_fbo); } } @@ -268,7 +268,7 @@ void RasterizerGLES3::blit_render_target_to_screen(RID p_render_target,const Rec canvas->canvas_begin(); glDisable(GL_BLEND); - glBindFramebuffer(GL_FRAMEBUFFER,storage->config.system_fbo); + glBindFramebuffer(GL_FRAMEBUFFER,RasterizerStorageGLES3::system_fbo); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D,rt->color); canvas->draw_generic_textured_rect(p_screen_rect,Rect2(0,0,1,-1)); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 1b531a69b9..f47fcfcd9b 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -3,6 +3,11 @@ #include "os/os.h" #include "rasterizer_canvas_gles3.h" +#ifdef IPHONE_ENABLED +// for some reason glClearDepth seems to have been removed in iOS ES3.h +#define glClearDepth glClearDepthf +#endif + static const GLenum _cube_side_enum[6]={ GL_TEXTURE_CUBE_MAP_NEGATIVE_X, @@ -141,7 +146,7 @@ void RasterizerSceneGLES3::shadow_atlas_set_size(RID p_atlas,int p_size){ GL_TEXTURE_2D, shadow_atlas->depth, 0); glViewport(0,0,shadow_atlas->size,shadow_atlas->size); - glClearDepth(0); + glClearDepth(0.0f); glClear(GL_DEPTH_BUFFER_BIT); } @@ -2270,9 +2275,9 @@ void RasterizerSceneGLES3::_setup_directional_light(int p_index,const Transform& float sign = li->light_ptr->negative?-1:1; Color linear_col = li->light_ptr->color.to_linear(); - ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];; - ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];; - ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];; + ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; + ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; + ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; ubo_data.light_color_energy[3]=0; //omni, keep at 0 @@ -2427,9 +2432,9 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu float sign = li->light_ptr->negative?-1:1; Color linear_col = li->light_ptr->color.to_linear(); - ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];; - ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];; - ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];; + ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; + ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; + ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; ubo_data.light_color_energy[3]=0; @@ -2520,9 +2525,9 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu float sign = li->light_ptr->negative?-1:1; Color linear_col = li->light_ptr->color.to_linear(); - ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];; - ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];; - ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];; + ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; + ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; + ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; ubo_data.light_color_energy[3]=0; Vector3 pos = p_camera_inverse_transform.xform(li->transform.origin); @@ -3753,8 +3758,7 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C glViewport(0,0,storage->frame.current_rt->width,storage->frame.current_rt->height); glColorMask(0,0,0,0); - - glClearDepth(1.0); + glClearDepth(1.0f); glClear(GL_DEPTH_BUFFER_BIT); @@ -3866,7 +3870,7 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C } if (!fb_cleared) { - glClearDepth(1.0); + glClearDepth(1.0f); glClear(GL_DEPTH_BUFFER_BIT); } @@ -3973,7 +3977,6 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C _render_mrts(env,p_cam_projection); } - glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); glEnable(GL_BLEND); glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); @@ -4419,7 +4422,7 @@ void RasterizerSceneGLES3::render_shadow(RID p_light,RID p_shadow_atlas,int p_pa } glEnable(GL_SCISSOR_TEST); - glClearDepth(1.0); + glClearDepth(1.0f); glClear(GL_DEPTH_BUFFER_BIT); glDisable(GL_SCISSOR_TEST); @@ -4472,7 +4475,7 @@ void RasterizerSceneGLES3::render_shadow(RID p_light,RID p_shadow_atlas,int p_pa glViewport(local_x,local_y,local_width,local_height); glScissor(local_x,local_y,local_width,local_height); glEnable(GL_SCISSOR_TEST); - glClearDepth(1.0); + glClearDepth(1.0f); glClear(GL_DEPTH_BUFFER_BIT); glDisable(GL_SCISSOR_TEST); //glDisable(GL_DEPTH_TEST); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index f096719988..9f1ff396f1 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -78,6 +78,8 @@ #define _EXT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E #define _EXT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +GLuint RasterizerStorageGLES3::system_fbo = 0; + Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Image::Format p_format, uint32_t p_flags,GLenum& r_gl_format,GLenum& r_gl_internal_format,GLenum &r_gl_type,bool &r_compressed,bool &srgb) { @@ -133,8 +135,12 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima } break; case Image::FORMAT_RGB565: { +#ifdef IPHONE_ENABLED + r_gl_internal_format=GL_RGB565; +#else //#warning TODO: Convert tod 555 if 565 is not supported (GLES3.3-) r_gl_internal_format=GL_RGB5; +#endif //r_gl_internal_format=GL_RGB565; r_gl_format=GL_RGB; r_gl_type=GL_UNSIGNED_SHORT_5_6_5; @@ -1186,7 +1192,7 @@ RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source,int p_r glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo); glDeleteFramebuffers(1, &tmp_fb); Texture * ctex = memnew( Texture ); @@ -1351,7 +1357,7 @@ void RasterizerStorageGLES3::skybox_set_texture(RID p_skybox, RID p_cube_map, in glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo); glDeleteFramebuffers(1, &tmp_fb); } @@ -5523,7 +5529,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->color, 0); GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo); ERR_FAIL_COND( status != GL_FRAMEBUFFER_COMPLETE ); @@ -5610,7 +5616,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo); if (status != GL_FRAMEBUFFER_COMPLETE) { printf("err status: %x\n",status); @@ -5643,7 +5649,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ ERR_FAIL_COND( status != GL_FRAMEBUFFER_COMPLETE ); } - glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo); if (status != GL_FRAMEBUFFER_COMPLETE) { _render_target_clear(rt); @@ -5712,7 +5718,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ } - glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo); rt->effects.mip_maps[i].levels=level; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -5941,7 +5947,7 @@ RID RasterizerStorageGLES3::canvas_light_shadow_buffer_create(int p_width) { GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); //printf("errnum: %x\n",status); - glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo); ERR_FAIL_COND_V( status != GL_FRAMEBUFFER_COMPLETE, RID() ); @@ -6296,7 +6302,7 @@ void RasterizerStorageGLES3::initialize() { config.render_arch=RENDER_ARCH_DESKTOP; //config.fbo_deferred=int(Globals::get_singleton()->get("rendering/gles3/lighting_technique")); - config.system_fbo=0; + RasterizerStorageGLES3::system_fbo=0; //// extensions config @@ -6463,7 +6469,7 @@ void RasterizerStorageGLES3::initialize() { glBufferData(GL_ARRAY_BUFFER,xf_feedback_size*1024,NULL,GL_STREAM_DRAW); } - shaders.blend_shapes.init();; + shaders.blend_shapes.init(); glGenVertexArrays(1,&resources.transform_feedback_array); diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index f9e440288f..c8f04f72c1 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -24,6 +24,7 @@ public: RasterizerCanvasGLES3 *canvas; RasterizerSceneGLES3 *scene; + static GLuint system_fbo; //on some devices, such as apple, screen is rendered to yet another fbo. enum RenderArchitecture { RENDER_ARCH_MOBILE, @@ -34,8 +35,6 @@ public: RenderArchitecture render_arch; - GLuint system_fbo; //on some devices, such as apple, screen is rendered to yet another fbo. - bool shrink_textures_x2; bool use_fast_texture_filter; bool use_anisotropic_filter; @@ -1011,7 +1010,7 @@ public: Particles() : particle_element(this) { emitting=false; amount=0; - lifetime=1.0;; + lifetime=1.0; pre_process_time=0.0; explosiveness=0.0; randomness=0.0; diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index 3a1317cbf6..14b1b229b2 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -44,7 +44,7 @@ Error AudioDriverPulseAudio::init() { samples_out = NULL; mix_rate = GLOBAL_DEF("audio/mix_rate",44100); - output_format = OUTPUT_STEREO; + speaker_mode = SPEAKER_MODE_STEREO; channels = 2; pa_sample_spec spec; @@ -149,9 +149,9 @@ int AudioDriverPulseAudio::get_mix_rate() const { return mix_rate; } -AudioDriverSW::OutputFormat AudioDriverPulseAudio::get_output_format() const { +AudioDriver::SpeakerMode AudioDriverPulseAudio::get_speaker_mode() const { - return output_format; + return speaker_mode; } void AudioDriverPulseAudio::lock() { diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h index aa7b7a9188..36ae8c2e53 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.h +++ b/drivers/pulseaudio/audio_driver_pulseaudio.h @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #ifdef PULSEAUDIO_ENABLED @@ -35,7 +35,7 @@ #include <pulse/simple.h> -class AudioDriverPulseAudio : public AudioDriverSW { +class AudioDriverPulseAudio : public AudioDriver{ Thread* thread; Mutex* mutex; @@ -48,7 +48,7 @@ class AudioDriverPulseAudio : public AudioDriverSW { static void thread_func(void* p_udata); unsigned int mix_rate; - OutputFormat output_format; + SpeakerMode speaker_mode; unsigned int buffer_size; int channels; @@ -69,7 +69,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp index 850e5ab053..6ada0aaa68 100644 --- a/drivers/rtaudio/audio_driver_rtaudio.cpp +++ b/drivers/rtaudio/audio_driver_rtaudio.cpp @@ -71,7 +71,7 @@ int AudioDriverRtAudio::callback( void *outputBuffer, void *inputBuffer, unsigne self->audio_server_process(nBufferFrames,buffer); - self->mutex->unlock();; + self->mutex->unlock(); return 0; } @@ -85,6 +85,8 @@ Error AudioDriverRtAudio::init() { ERR_EXPLAIN("Cannot initialize RtAudio audio driver: No devices present.") ERR_FAIL_COND_V( dac->getDeviceCount() < 1, ERR_UNAVAILABLE ); + // FIXME: Adapt to the OutputFormat -> SpeakerMode change + /* String channels = GLOBAL_DEF("audio/output","stereo"); if (channels=="5.1") @@ -95,6 +97,7 @@ Error AudioDriverRtAudio::init() { output_format=OUTPUT_MONO; else output_format=OUTPUT_STEREO; + */ RtAudio::StreamParameters parameters; parameters.deviceId = dac->getDefaultOutputDevice(); @@ -125,11 +128,10 @@ Error AudioDriverRtAudio::init() { while(true) { while( true) { - switch(output_format) { - case OUTPUT_MONO: parameters.nChannels = 1; break; - case OUTPUT_STEREO: parameters.nChannels = 2; break; - case OUTPUT_QUAD: parameters.nChannels = 4; break; - case OUTPUT_5_1: parameters.nChannels = 6; break; + switch(speaker_mode) { + case SPEAKER_MODE_STEREO: parameters.nChannels = 2; break; + case SPEAKER_SURROUND_51: parameters.nChannels = 6; break; + case SPEAKER_SURROUND_71: parameters.nChannels = 8; break; }; try { @@ -142,11 +144,10 @@ Error AudioDriverRtAudio::init() { // try with less channels ERR_PRINT("Unable to open audio, retrying with fewer channels.."); - switch(output_format) { - case OUTPUT_MONO: ERR_EXPLAIN("Unable to open audio."); ERR_FAIL_V( ERR_UNAVAILABLE ); break; - case OUTPUT_STEREO: output_format=OUTPUT_MONO; break; - case OUTPUT_QUAD: output_format=OUTPUT_STEREO; break; - case OUTPUT_5_1: output_format=OUTPUT_QUAD; break; + switch(speaker_mode) { + case SPEAKER_MODE_STEREO: speaker_mode=SPEAKER_MODE_STEREO; break; + case SPEAKER_SURROUND_51: speaker_mode=SPEAKER_SURROUND_51; break; + case SPEAKER_SURROUND_71: speaker_mode=SPEAKER_SURROUND_71; break; }; } } @@ -189,9 +190,9 @@ int AudioDriverRtAudio::get_mix_rate() const { return mix_rate; } -AudioDriverSW::OutputFormat AudioDriverRtAudio::get_output_format() const { +AudioDriver::SpeakerMode AudioDriverRtAudio::get_speaker_mode() const { - return output_format; + return speaker_mode; } void AudioDriverRtAudio::start() { @@ -229,7 +230,7 @@ AudioDriverRtAudio::AudioDriverRtAudio() mutex=NULL; mix_rate=44100; - output_format=OUTPUT_STEREO; + speaker_mode=SPEAKER_MODE_STEREO; } diff --git a/drivers/rtaudio/audio_driver_rtaudio.h b/drivers/rtaudio/audio_driver_rtaudio.h index aa7fae038a..3f293db6a6 100644 --- a/drivers/rtaudio/audio_driver_rtaudio.h +++ b/drivers/rtaudio/audio_driver_rtaudio.h @@ -31,16 +31,16 @@ #ifdef RTAUDIO_ENABLED -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include <RtAudio.h> -class AudioDriverRtAudio : public AudioDriverSW { +class AudioDriverRtAudio : public AudioDriver { static int callback( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void *userData ); - OutputFormat output_format; + SpeakerMode speaker_mode; Mutex *mutex; RtAudio *dac; int mix_rate; @@ -53,7 +53,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const ; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 183cec96ec..894b49231b 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -50,7 +50,7 @@ void FileAccessWindows::check_errors() const { if (feof(f)) { - last_error=ERR_FILE_EOF;; + last_error=ERR_FILE_EOF; } } diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp index 5be857164c..fa55c97325 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.cpp +++ b/drivers/xaudio2/audio_driver_xaudio2.cpp @@ -46,7 +46,8 @@ Error AudioDriverXAudio2::init() { mix_rate = 48000; - output_format = OUTPUT_STEREO; + // FIXME: speaker_mode seems unused in the Xaudio2 driver so far + speaker_mode = SPEAKER_MODE_STEREO; channels = 2; int latency = GLOBAL_DEF("audio/output_latency", 25); @@ -156,9 +157,9 @@ int AudioDriverXAudio2::get_mix_rate() const { return mix_rate; }; -AudioDriverSW::OutputFormat AudioDriverXAudio2::get_output_format() const { +AudioDriver::SpeakerMode AudioDriverXAudio2::get_speaker_mode() const { - return output_format; + return speaker_mode; }; float AudioDriverXAudio2::get_latency() { diff --git a/drivers/xaudio2/audio_driver_xaudio2.h b/drivers/xaudio2/audio_driver_xaudio2.h index ad880b24d5..afafb84c23 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.h +++ b/drivers/xaudio2/audio_driver_xaudio2.h @@ -29,8 +29,7 @@ #ifndef AUDIO_DRIVER_XAUDIO2_H #define AUDIO_DRIVER_XAUDIO2_H -#include "servers/audio/audio_server_sw.h" - +#include "servers/audio_server.h" #include "core/os/thread.h" #include "core/os/mutex.h" @@ -40,7 +39,7 @@ #include <xaudio2.h> #include <wrl/client.h> -class AudioDriverXAudio2 : public AudioDriverSW { +class AudioDriverXAudio2 : public AudioDriver { enum { AUDIO_BUFFERS = 2 @@ -72,7 +71,7 @@ class AudioDriverXAudio2 : public AudioDriverSW { int buffer_size; unsigned int mix_rate; - OutputFormat output_format; + SpeakerMode speaker_mode; int channels; @@ -96,7 +95,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual float get_latency(); virtual void lock(); virtual void unlock(); diff --git a/main/input_default.cpp b/main/input_default.cpp index a7d06dbdbe..ea4e3f9505 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -568,8 +568,7 @@ void InputDefault::set_mouse_in_window(bool p_in_window) { } // from github.com/gabomdq/SDL_GameControllerDB -static const char *s_ControllerMappings [] = -{ +static const char *s_ControllerMappings [] = { #ifdef WINDOWS_ENABLED "00f00300000000000000504944564944,RetroUSB.com RetroPad,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,", "00f0f100000000000000504944564944,RetroUSB.com Super RetroPort,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,", diff --git a/main/main.cpp b/main/main.cpp index e7dca04c2a..559f5e359b 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -42,7 +42,7 @@ #include "input_map.h" #include "io/resource_loader.h" #include "scene/main/scene_main_loop.h" - +#include "servers/audio_server.h" #include "script_language.h" #include "io/resource_loader.h" @@ -63,8 +63,6 @@ #include "tools/doc/doc_data.h" -#include "servers/spatial_sound_server.h" -#include "servers/spatial_sound_2d_server.h" #include "servers/physics_2d_server.h" @@ -83,6 +81,7 @@ static Engine *engine=NULL; static InputMap *input_map=NULL; static bool _start_success=false; static ScriptDebugger *script_debugger=NULL; +AudioServer *audio_server=NULL; static MessageQueue *message_queue=NULL; static Performance *performance = NULL; @@ -908,6 +907,11 @@ Error Main::setup2() { OS::get_singleton()->set_window_position(init_custom_pos); } + //right moment to create and initialize the audio server + + audio_server = memnew( AudioServer ); + audio_server->init(); + OS::get_singleton()->set_use_vsync(use_vsync); register_core_singletons(); @@ -1374,7 +1378,7 @@ bool Main::start() { DirAccess *da = DirAccess::open(local_game_path.substr(0,sep)); if (da) { - local_game_path=da->get_current_dir()+"/"+local_game_path.substr(sep+1,local_game_path.length());; + local_game_path=da->get_current_dir()+"/"+local_game_path.substr(sep+1,local_game_path.length()); memdelete(da); } } @@ -1522,7 +1526,7 @@ bool Main::start() { //sml->get_root()->add_child(scene); sml->add_current_scene(scene); - String iconpath = GLOBAL_DEF("application/icon","Variant()"""); + String iconpath = GLOBAL_DEF("application/icon","Variant()"); if (iconpath!="") { Image icon; if (icon.load(iconpath)==OK) @@ -1657,11 +1661,6 @@ bool Main::iteration() { OS::get_singleton()->get_main_loop()->idle( step*time_scale ); message_queue->flush(); - if (SpatialSoundServer::get_singleton()) - SpatialSoundServer::get_singleton()->update( step*time_scale ); - if (SpatialSound2DServer::get_singleton()) - SpatialSound2DServer::get_singleton()->update( step*time_scale ); - VisualServer::get_singleton()->sync(); //sync if still drawing from previous frames. @@ -1764,6 +1763,11 @@ void Main::cleanup() { OS::get_singleton()->_execpath=""; OS::get_singleton()->_local_clipboard=""; + if (audio_server) { + memdelete(audio_server); + } + + #ifdef TOOLS_ENABLED EditorNode::unregister_editor_types(); #endif @@ -1775,6 +1779,7 @@ void Main::cleanup() { OS::get_singleton()->finalize(); + if (packed_data) memdelete(packed_data); if (file_access_network_client) diff --git a/main/performance.cpp b/main/performance.cpp index 91df55a21c..50ca594f8e 100644 --- a/main/performance.cpp +++ b/main/performance.cpp @@ -141,9 +141,9 @@ float Performance::get_monitor(Monitor p_monitor) const { }; case RENDER_OBJECTS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_OBJECTS_IN_FRAME); case RENDER_VERTICES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_VERTICES_IN_FRAME); - case RENDER_MATERIAL_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME);; - case RENDER_SHADER_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME);; - case RENDER_SURFACE_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME);; + case RENDER_MATERIAL_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME); + case RENDER_SHADER_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME); + case RENDER_SURFACE_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME); case RENDER_DRAW_CALLS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_DRAW_CALLS_IN_FRAME); case RENDER_VIDEO_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_VIDEO_MEM_USED); case RENDER_TEXTURE_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED); diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index 4f4e76d517..7fdfef5f3c 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -219,7 +219,7 @@ static String _parser_expr(const GDParser::Node *p_expr) { case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: { txt=_parser_expr(c_node->arguments[0])+"&="+_parser_expr(c_node->arguments[1]); } break; case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: { txt=_parser_expr(c_node->arguments[0])+"|="+_parser_expr(c_node->arguments[1]); } break; case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: { txt=_parser_expr(c_node->arguments[0])+"^="+_parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_BIT_AND: { txt=_parser_expr(c_node->arguments[0])+"&"+_parser_expr(c_node->arguments[1]); } break;; + case GDParser::OperatorNode::OP_BIT_AND: { txt=_parser_expr(c_node->arguments[0])+"&"+_parser_expr(c_node->arguments[1]); } break; case GDParser::OperatorNode::OP_BIT_OR: { txt=_parser_expr(c_node->arguments[0])+"|"+_parser_expr(c_node->arguments[1]); } break; case GDParser::OperatorNode::OP_BIT_XOR: { txt=_parser_expr(c_node->arguments[0])+"^"+_parser_expr(c_node->arguments[1]); } break; default: {} @@ -947,7 +947,7 @@ MainLoop* test(TestType p_test) { if (tk.get_token_line()!=line) { int from=line+1; - line = tk.get_token_line();; + line = tk.get_token_line(); for(int i=from;i<=line;i++) { int l=i-1; diff --git a/main/tests/test_gui.cpp b/main/tests/test_gui.cpp index b0ebc20180..899bdc37b9 100644 --- a/main/tests/test_gui.cpp +++ b/main/tests/test_gui.cpp @@ -353,14 +353,14 @@ public: label = memnew( Label ); label->set_text("Some Label"); label->set_pos( Point2(20,20) ); - ctl->add_child(label);; + ctl->add_child(label); ctl= memnew( Control ); ctl->set_name("tab 3"); button = memnew( Button ); button->set_text("Some Button"); button->set_pos( Point2(30,50) ); - ctl->add_child(button);; + ctl->add_child(button); tabc->add_child(ctl); diff --git a/main/tests/test_main.cpp b/main/tests/test_main.cpp index 1f7f2d7dda..763616dd46 100644 --- a/main/tests/test_main.cpp +++ b/main/tests/test_main.cpp @@ -104,10 +104,10 @@ MainLoop* test_main(String p_test,const List<String>& p_args) { } #endif - if (p_test=="sound") { + //if (p_test=="sound") { - return TestSound::test(); - } + // return TestSound::test(); + //} if (p_test=="io") { diff --git a/main/tests/test_physics.cpp b/main/tests/test_physics.cpp index ea98da34ca..95ce540b16 100644 --- a/main/tests/test_physics.cpp +++ b/main/tests/test_physics.cpp @@ -111,7 +111,7 @@ protected: PhysicsServer * ps = PhysicsServer::get_singleton(); - RID plane_shape = ps->shape_create(PhysicsServer::SHAPE_PLANE);; + RID plane_shape = ps->shape_create(PhysicsServer::SHAPE_PLANE); ps->shape_set_data( plane_shape, p_plane ); RID b = ps->body_create( PhysicsServer::BODY_MODE_STATIC ); @@ -345,11 +345,16 @@ public: /* CAMERA */ camera = vs->camera_create(); + RID viewport = vs->viewport_create(); + Size2i screen_size = OS::get_singleton()->get_window_size(); + vs->viewport_set_size(viewport,screen_size.x,screen_size.y); + vs->viewport_attach_to_screen(viewport,Rect2(Vector2(),screen_size)); + vs->viewport_set_active(viewport,true); vs->viewport_attach_camera( viewport, camera ); - vs->viewport_attach_to_screen(viewport); vs->viewport_set_scenario( viewport, scenario ); + vs->camera_set_perspective(camera,60,0.1,40.0); vs->camera_set_transform(camera,Transform( Basis(), Vector3(0,9,12))); //vs->scenario_set_debug(scenario,VS::SCENARIO_DEBUG_WIREFRAME); diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp index 8a6a8c78f9..76d1afd2ac 100644 --- a/main/tests/test_physics_2d.cpp +++ b/main/tests/test_physics_2d.cpp @@ -63,7 +63,7 @@ class TestPhysics2DMainLoop : public MainLoop { }; - BodyShapeData body_shape_data[6]; + BodyShapeData body_shape_data[8]; void _create_body_shape_data() { @@ -191,7 +191,7 @@ class TestPhysics2DMainLoop : public MainLoop { Image image(convex_png); - body_shape_data[Physics2DServer::SHAPE_CUSTOM+1].image=vs->texture_create_from_image(image); + body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].image=vs->texture_create_from_image(image); RID convex_polygon_shape = ps->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON); @@ -206,7 +206,7 @@ class TestPhysics2DMainLoop : public MainLoop { arr.push_back(Point2(11,7)-sb); ps->shape_set_data(convex_polygon_shape,arr); - body_shape_data[Physics2DServer::SHAPE_CUSTOM+1].shape = convex_polygon_shape; + body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].shape = convex_polygon_shape; } @@ -382,8 +382,13 @@ public: RID vp = vs->viewport_create(); canvas = vs->canvas_create(); + + Size2i screen_size = OS::get_singleton()->get_window_size(); vs->viewport_attach_canvas(vp,canvas); - vs->viewport_attach_to_screen(vp,Rect2(Vector2(),OS::get_singleton()->get_window_size())); + vs->viewport_set_size(vp,screen_size.x,screen_size.y); + vs->viewport_attach_to_screen(vp,Rect2(Vector2(),screen_size)); + vs->viewport_set_active(vp,true); + Transform2D smaller; //smaller.scale(Vector2(0.6,0.6)); //smaller.elements[2]=Vector2(100,0); diff --git a/main/tests/test_sound.cpp b/main/tests/test_sound.cpp index 44cc117e02..6b0cf0a324 100644 --- a/main/tests/test_sound.cpp +++ b/main/tests/test_sound.cpp @@ -30,11 +30,13 @@ #include "servers/visual_server.h" #include "os/main_loop.h" #include "math_funcs.h" -#include "scene/resources/sample.h" + #include "io/resource_loader.h" #include "print_string.h" #include "servers/audio_server.h" #include "os/os.h" + +#if 0 namespace TestSound { @@ -93,3 +95,4 @@ MainLoop* test() { } } +#endif diff --git a/modules/chibi/SCsub b/modules/chibi/SCsub deleted file mode 100644 index dffd966753..0000000000 --- a/modules/chibi/SCsub +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python - -Import('env') -Import('env_modules') - -env_chibi = env_modules.Clone() - -# Godot source files -env_chibi.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/chibi/config.py b/modules/chibi/config.py deleted file mode 100644 index fb920482f5..0000000000 --- a/modules/chibi/config.py +++ /dev/null @@ -1,7 +0,0 @@ - -def can_build(platform): - return True - - -def configure(env): - pass diff --git a/modules/chibi/cp_config.h b/modules/chibi/cp_config.h deleted file mode 100644 index 35312b68be..0000000000 --- a/modules/chibi/cp_config.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************/ -/* cp_config.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_CONFIG_H -#define CP_CONFIG_H - - -#include "typedefs.h" -#include "error_macros.h" -#include "math_funcs.h" -#include "os/memory.h" -#include "os/copymem.h" - -#define CP_PRINTERR(m_err) ERR_PRINT(m_err) -#define CP_ERR_COND(m_cond) ERR_FAIL_COND(m_cond) -#define CP_ERR_COND_V(m_cond,m_ret) ERR_FAIL_COND_V(m_cond,m_ret) -#define CP_FAIL_INDEX(m_index,m_size) ERR_FAIL_INDEX(m_index,m_size) -#define CP_FAIL_INDEX_V(m_index,m_size,m_ret) ERR_FAIL_INDEX_V(m_index,m_size,m_ret) -#define cp_intabs(m_val) ABS(m_val) - -#define CP_ALLOC(m_mem) memalloc(m_mem) -#define CP_REALLOC(m_mem,m_size) memrealloc(m_mem,m_size) -#define CP_FREE(m_mem) memfree(m_mem) - -#define cp_memzero(m_mem,m_size) zeromem(m_mem,m_size) - -#endif // CP_CONFIG_H diff --git a/modules/chibi/cp_envelope.cpp b/modules/chibi/cp_envelope.cpp deleted file mode 100644 index 36259e8d63..0000000000 --- a/modules/chibi/cp_envelope.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/*************************************************************************/ -/* cp_envelope.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_envelope.h" - - -CPEnvelope::CPEnvelope() { - - - reset(); -} - -void CPEnvelope::reset() { - - - - on=false; - carry=false; - loop_on=false; - loop_begin_node=0; - loop_end_node=0; - sustain_loop_on=false; - sustain_loop_begin_node=0; - sustain_loop_end_node=0; - node_count=0; - -} - -int CPEnvelope::get_height_at_pos(int pos) { - - if (node_count && pos>node[node_count-1].tick_offset) - return node[node_count-1].value; - - int begin_x,begin_y; - int end_x,end_y,xdif; - int count=0; - int limit=-1; - - if (node_count<2) return NO_POINT; - - while ((count<node_count) && (limit==-1)) { - - if (node[count].tick_offset>=pos) limit=count; - count++; - } - - if (pos==0) return node[0].value; - - if (limit==-1) return NO_POINT; - - begin_x=node[limit-1].tick_offset; - end_x=node[limit].tick_offset; - begin_y=node[limit-1].value; - end_y=node[limit].value; - - xdif=end_x-begin_x; - return begin_y+((pos-begin_x)*(end_y-begin_y))/(xdif?xdif:1); -} - -/* -int CPEnvelope::get_fx_height_at_pos(int pos) { - - if (node_count && pos>node[node_count-1].tick_offset) - return node[node_count-1].value<<FX_HEIGHT_BITS; - - int begin_x,begin_y; - int end_x,end_y,xdif; - int count=0; - int limit=-1; - - if (node_count<2) return NO_POINT; - - while ((count<node_count) && (limit==-1)) { - - if (node[count].tick_offset>=pos) limit=count; - count++; - } - - if (pos==0) return node[0].value<<FX_HEIGHT_BITS; - - if (limit==-1) return NO_POINT; - - begin_x=node[limit-1].tick_offset; - end_x=node[limit].tick_offset; - begin_y=node[limit-1].value; - end_y=node[limit].value; - - xdif=end_x-begin_x; - return (begin_y<<FX_HEIGHT_BITS)+((pos-begin_x)*(end_y-begin_y)*(int)(1<<FX_HEIGHT_BITS))/(xdif?xdif:1); -} -*/ - -float CPEnvelope::get_interp_height_at_pos(float pos) { - - if (node_count && pos>node[node_count-1].tick_offset) - return node[node_count-1].value; - - int begin_x,begin_y; - int end_x,end_y,xdif; - int count=0; - int limit=-1; - - if (node_count<2) return NO_POINT; - - while ((count<node_count) && (limit==-1)) { - - if (node[count].tick_offset>=pos) limit=count; - count++; - } - - if (pos==0) return node[0].value; - - if (limit==-1) return NO_POINT; - - begin_x=node[limit-1].tick_offset; - end_x=node[limit].tick_offset; - begin_y=node[limit-1].value; - end_y=node[limit].value; - - xdif=end_x-begin_x; - return begin_y+((pos-begin_x)*(end_y-begin_y))/(xdif?xdif:1); -} - -void CPEnvelope::set_position(int p_node,int p_x,int p_y) { - - if (p_node>=node_count) return; - - - - if (p_node==0) { - - p_x=0; - - } else if (p_x<=node[p_node-1].tick_offset) { - - p_x=node[p_node-1].tick_offset+1; - - } else if ((p_node<(node_count-1)) && (p_x>=node[p_node+1].tick_offset)) { - - p_x=node[p_node+1].tick_offset-1; - } - - if (p_x>=9999) p_x=9999; - - if (p_y>max_value) p_y=max_value; - if (p_y<min_value) p_y=min_value; - - - node[p_node].tick_offset=p_x; - node[p_node].value=p_y; - - - -} - -int CPEnvelope::add_position(int p_x,int p_y,bool p_move_loops) { - - if (node_count==MAX_POINTS) return -1; - - - int i,new_node; - - // if this is assigning an existing node, let's quit. - for (i=0;i<node_count;i++) if (p_x==node[i].tick_offset) return -1; - - - i=0; - while ((i<node_count) && (p_x>=node[i].tick_offset)) i++; - - new_node=i; - node_count++; - - if (p_move_loops) { - if (loop_begin_node>=new_node) loop_begin_node++; - if (loop_end_node>=new_node) loop_end_node++; - if (sustain_loop_begin_node>=new_node) sustain_loop_begin_node++; - if (sustain_loop_end_node>=new_node) sustain_loop_end_node++; - } - for (i=node_count-1;i>new_node;i--) node[i]=node[i-1]; - - - - set_position(new_node,p_x,p_y); - - - - return new_node; - -} - -void CPEnvelope::set_loop_begin(int pos) { - - if ((pos<0) || (pos>=node_count)) return; - - - - loop_begin_node=pos; - - if (loop_end_node<loop_begin_node) loop_end_node=loop_begin_node; - - - -} - -void CPEnvelope::set_loop_end(int pos) { - - if ((pos<0) || (pos>=node_count)) return; - - - - loop_end_node=pos; - - if (loop_end_node<loop_begin_node) loop_begin_node=loop_end_node; - - - - -} - - -void CPEnvelope::set_sustain_loop_begin(int pos) { - - if ((pos<0) || (pos>=node_count)) return; - - - - sustain_loop_begin_node=pos; - - if (sustain_loop_end_node<sustain_loop_begin_node) sustain_loop_end_node=sustain_loop_begin_node; - - - -} - -void CPEnvelope::set_sustain_loop_end(int pos) { - - if ((pos<0) || (pos>=node_count)) return; - - - - sustain_loop_end_node=pos; - - if (sustain_loop_end_node<sustain_loop_begin_node) sustain_loop_begin_node=sustain_loop_end_node; - - - -} - -void CPEnvelope::set_loop_enabled(bool p_enabled) { - - loop_on=p_enabled; -} -bool CPEnvelope::is_loop_enabled() { - - return loop_on; -} - - -void CPEnvelope::set_sustain_loop_enabled(bool p_enabled) { - - sustain_loop_on=p_enabled; -} -bool CPEnvelope::is_sustain_loop_enabled() { - - return sustain_loop_on; -} - -void CPEnvelope::del_position(int p_node) { - - if ((node_count<3) || (p_node<=0) || (p_node>=node_count)) return; - - - - int i; - - if (loop_begin_node>=p_node) loop_begin_node--; - if (loop_end_node>=p_node) loop_end_node--; - if (sustain_loop_begin_node>=p_node) sustain_loop_begin_node--; - if (sustain_loop_end_node>=p_node) sustain_loop_end_node--; - - for (i=p_node;i<node_count-1;i++) node[i]=node[i+1]; - - node_count--; - - - -} - -uint8_t CPEnvelope::get_loop_begin() { - - - return loop_begin_node; -} -uint8_t CPEnvelope::get_loop_end() { - - return loop_end_node; -} - -uint8_t CPEnvelope::get_sustain_loop_begin() { - - - return sustain_loop_begin_node; -} -uint8_t CPEnvelope::get_sustain_loop_end() { - - return sustain_loop_end_node; -} - - - -void CPEnvelope::set_enabled(bool p_enabled) { - - on=p_enabled; -} - -bool CPEnvelope::is_enabled() { - - return on; -} - -void CPEnvelope::set_carry_enabled(bool p_enabled) { - - carry=p_enabled; -} -bool CPEnvelope::is_carry_enabled() { - - return carry; -} - -uint8_t CPEnvelope::get_node_count() { - - return node_count; -} - -const CPEnvelope::Point& CPEnvelope::get_node(int p_idx) { - - if (p_idx<0 || p_idx>=node_count) - return node[node_count-1]; - - return node[p_idx]; - -} - - diff --git a/modules/chibi/cp_envelope.h b/modules/chibi/cp_envelope.h deleted file mode 100644 index af27f5f185..0000000000 --- a/modules/chibi/cp_envelope.h +++ /dev/null @@ -1,129 +0,0 @@ -/*************************************************************************/ -/* cp_envelope.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_ENVELOPE_H -#define CP_ENVELOPE_H - -#include "cp_config.h" - -/**envelope? - *@author Juan Linietsky - */ - -/****************************** - envelope.h - ---------- - -Proovides an envelope, and basic functions -for it that can be used for both player -and interface -********************************/ - - -class CPEnvelope { - enum { - - MAX_POINTS=25 - }; - - struct Point { - - uint16_t tick_offset; - int16_t value; - }; - - Point node[MAX_POINTS]; - - int8_t node_count; - - bool on; - bool carry; - - bool loop_on; - - uint8_t loop_begin_node; - uint8_t loop_end_node; - - bool sustain_loop_on; - uint8_t sustain_loop_begin_node; - uint8_t sustain_loop_end_node; - - - int8_t max_value; - int8_t min_value; - - -public: - enum { - - NO_POINT=-5000, - }; - - void set_max(int8_t p_max) { max_value=p_max; } - int8_t get_max() { return max_value; } - void set_min(int8_t p_min) { min_value=p_min; } - int8_t get_min() { return min_value; } - - uint8_t get_node_count(); - const Point& get_node(int p_idx); - - void set_position(int p_node,int p_x,int p_y); - int add_position(int p_x,int p_y,bool p_move_loops=true); - void del_position(int p_node); - - void set_loop_enabled(bool p_enabled); - bool is_loop_enabled(); - void set_loop_begin(int pos); - void set_loop_end(int pos); - uint8_t get_loop_begin(); - uint8_t get_loop_end(); - - void set_sustain_loop_enabled(bool p_enabled); - bool is_sustain_loop_enabled(); - void set_sustain_loop_begin(int pos); - void set_sustain_loop_end(int pos); - uint8_t get_sustain_loop_begin(); - uint8_t get_sustain_loop_end(); - - void set_enabled(bool p_enabled); - bool is_enabled(); - - void set_carry_enabled(bool p_enabled); - bool is_carry_enabled(); - - void reset(); - int get_height_at_pos(int pos); - float get_interp_height_at_pos(float pos); - - - CPEnvelope(); - -}; - -#endif diff --git a/modules/chibi/cp_file_access_wrapper.h b/modules/chibi/cp_file_access_wrapper.h deleted file mode 100644 index ade077c1ef..0000000000 --- a/modules/chibi/cp_file_access_wrapper.h +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************/ -/* cp_file_access_wrapper.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_FILE_ACCESS_WRAPPER_H -#define CP_FILE_ACCESS_WRAPPER_H - -#include "cp_config.h" - -class CPFileAccessWrapper { -public: - - enum ModeFlags { - - READ=1, - WRITE=2, - READ_WRITE=3, - }; - - enum Error { - - OK, - ERROR_FILE_NOT_FOUND, - ERROR_FILE_BAD_DRIVE, - ERROR_FILE_BAD_PATH, - ERROR_FILE_NO_PERMISSION, - ERROR_ALREADY_IN_USE, - ERROR_INVALID_PARAMETERS, - ERROR_OPENING_FILE, - ERROR_READING_FILE, - ERROR_WRITING_FILE - }; - - virtual Error open(const char *p_filename, int p_mode_flags)=0; - virtual void close()=0; - - virtual void seek(uint32_t p_position)=0; - virtual void seek_end()=0; - virtual uint32_t get_pos()=0; - - virtual bool eof_reached()=0; - - virtual uint8_t get_byte()=0; - virtual void get_byte_array(uint8_t *p_dest,int p_elements)=0; - virtual void get_word_array(uint16_t *p_dest,int p_elements)=0; - - virtual uint16_t get_word()=0; - virtual uint32_t get_dword()=0; - - // use this for files WRITTEN in _big_ endian machines (ie, amiga/mac) - // It's not about the current CPU type but file formats. - // this flags get reset to false (little endian) on each open - virtual void set_endian_conversion(bool p_swap)=0; - virtual bool is_open()=0; - - virtual Error get_error()=0; - - virtual void store_byte(uint8_t p_dest)=0; - virtual void store_byte_array(const uint8_t *p_dest,int p_elements)=0; - - virtual void store_word(uint16_t p_dest)=0; - virtual void store_dword(uint32_t p_dest)=0; - - - - virtual ~CPFileAccessWrapper(){} - -}; - - - -#endif diff --git a/modules/chibi/cp_instrument.cpp b/modules/chibi/cp_instrument.cpp deleted file mode 100644 index 606a4217e0..0000000000 --- a/modules/chibi/cp_instrument.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/*************************************************************************/ -/* cp_instrument.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_instrument.h" -#include "cp_song.h" -#include "cp_note.h" - - - -const char *CPInstrument::get_name() { - - return name; - -} -void CPInstrument::set_name(const char *p_name) { - - - if (p_name==NULL) { - name[0]=0; - return; - } - - - bool done=false; - for (int i=0;i<MAX_NAME_LEN;i++) { - - - name[i]=done?0:p_name[i]; - if (!done && p_name[i]==0) - done=true; - } - - name[MAX_NAME_LEN-1]=0; /* just in case */ - - -} - -void CPInstrument::set_sample_number(uint8_t p_note,uint8_t p_sample_id) { - - CP_ERR_COND(p_note>=CPNote::NOTES); - CP_ERR_COND(p_sample_id>CPSong::MAX_SAMPLES && p_sample_id!=CPNote::EMPTY); - data.sample_number[p_note]=p_sample_id; - - -} -uint8_t CPInstrument::get_sample_number(uint8_t p_note) { - - CP_ERR_COND_V(p_note>=CPNote::NOTES,0); - return data.sample_number[p_note]; -} - -void CPInstrument::set_note_number(uint8_t p_note,uint8_t p_note_id) { - - CP_ERR_COND(p_note>=CPNote::NOTES); - CP_ERR_COND(p_note_id>=CPNote::NOTES && p_note_id!=CPNote::EMPTY); - data.note_number[p_note]=p_note_id; - -} -uint8_t CPInstrument::get_note_number(uint8_t p_note) { - - CP_ERR_COND_V(p_note>=CPNote::NOTES,0); - return data.note_number[p_note]; - -} - -void CPInstrument::set_NNA_type(NNA_Type p_NNA_type) { - - data.NNA_type=p_NNA_type; -} -CPInstrument::NNA_Type CPInstrument::get_NNA_type() { - - return data.NNA_type; -} - -void CPInstrument::set_DC_type(DC_Type p_DC_type) { - - data.DC_type=p_DC_type; -} -CPInstrument::DC_Type CPInstrument::get_DC_type() { - - return data.DC_type; - -} - -void CPInstrument::set_DC_action(DC_Action p_DC_action) { - - data.DC_action=p_DC_action; -} -CPInstrument::DC_Action CPInstrument::get_DC_action() { - - return data.DC_action; -} - -/* Volume */ - -void CPInstrument::set_volume_global_amount(uint8_t p_amount) { - - CP_ERR_COND(p_amount>MAX_VOLUME); - data.volume.global_amount=p_amount; - -} -uint8_t CPInstrument::get_volume_global_amount() { - - return data.volume.global_amount; -} - -void CPInstrument::set_volume_fadeout(uint16_t p_amount) { - CP_ERR_COND(p_amount>MAX_FADEOUT); - data.volume.fadeout=p_amount; -} -uint16_t CPInstrument::get_volume_fadeout() { - - return data.volume.fadeout; -} -void CPInstrument::set_volume_random_variation(uint8_t p_amount) { - - CP_ERR_COND(p_amount>MAX_VOLUME_RANDOM); - data.volume.random_variation=p_amount; -} -uint8_t CPInstrument::get_volume_random_variation() { - - return data.volume.random_variation; -} - -/* Panning */ - -void CPInstrument::set_pan_default_amount(uint8_t p_amount) { - - CP_ERR_COND(p_amount>MAX_PAN); - data.pan.default_amount=p_amount; -} -uint8_t CPInstrument::get_pan_default_amount() { - - return data.pan.default_amount; -} - -void CPInstrument::set_pan_default_enabled(bool p_enabled) { - - data.pan.use_default=p_enabled; -} -bool CPInstrument::is_pan_default_enabled() { - - return data.pan.use_default; - -} - -void CPInstrument::set_pan_pitch_separation(int8_t p_amount) { - - CP_ERR_COND(p_amount<-32); - CP_ERR_COND(p_amount>32); - data.pan.pitch_separation=p_amount; -} -int8_t CPInstrument::get_pan_pitch_separation() { - - return data.pan.pitch_separation; -} - -void CPInstrument::set_pan_pitch_center(uint8_t p_amount) { - - CP_ERR_COND(p_amount>=CPNote::NOTES); - data.pan.pitch_center=p_amount; -} -uint8_t CPInstrument::get_pan_pitch_center() { - - return data.pan.pitch_center; -} - -void CPInstrument::set_pan_random_variation(uint8_t p_amount) { - - CP_ERR_COND(p_amount>MAX_PAN_RANDOM); - data.pan.random_variation=p_amount; -} -uint8_t CPInstrument::get_pan_random_variation() { - - return data.pan.random_variation; -} - -/* Pitch / Filter */ - -void CPInstrument::set_pitch_use_as_filter(bool p_enabled) { - - data.pitch.use_as_filter=p_enabled; -} -bool CPInstrument::is_pitch_use_as_filter() { - - return data.pitch.use_as_filter; -} - -void CPInstrument::set_filter_use_default_cutoff(bool p_enabled) { - - data.pitch.use_default_cutoff=p_enabled; - -} -bool CPInstrument::filter_use_default_cutoff() { - - return data.pitch.use_default_cutoff; -} - -void CPInstrument::set_filter_default_cutoff(uint8_t p_amount) { - - CP_ERR_COND(p_amount>MAX_FILTER_CUTOFF); - data.pitch.default_cutoff=p_amount; -} -uint8_t CPInstrument::get_filter_default_cutoff() { - - return data.pitch.default_cutoff; -} - -void CPInstrument::set_filter_use_default_resonance(bool p_enabled) { - - data.pitch.use_default_resonance=p_enabled; -} -bool CPInstrument::filter_use_default_resonance() { - - return data.pitch.use_default_resonance; -} - -void CPInstrument::set_filter_default_resonance(uint8_t p_amount) { - - CP_ERR_COND(p_amount>MAX_FILTER_RESONANCE); - data.pitch.default_resonance=p_amount; - -} -uint8_t CPInstrument::get_filter_default_resonance() { - - return data.pitch.default_resonance; -} - -/* Envelopes */ - - -CPEnvelope* CPInstrument::get_volume_envelope() { - - return &data.volume.envelope; -} -CPEnvelope* CPInstrument::get_pan_envelope() { - - return &data.pan.envelope; -} -CPEnvelope* CPInstrument::get_pitch_filter_envelope() { - - return &data.pitch.envelope; - - -} - - -void CPInstrument::reset() { - - name[0]=0; - - data.NNA_type=NNA_NOTE_CUT; - data.DC_action=DCA_NOTE_CUT; - data.DC_type=DCT_DISABLED; - - for (int i=0;i<CPNote::NOTES;i++) { - - data.sample_number[i]=CPNote::EMPTY; - data.note_number[i]=i; - } - - data.volume.envelope.reset(); - data.volume.envelope.set_max(64); - data.volume.envelope.set_min(0); - data.volume.envelope.add_position(0,64,false); - data.volume.envelope.add_position(30,64,false); - - data.volume.global_amount=MAX_VOLUME; - data.volume.fadeout=0; - data.volume.random_variation=0; - - data.pan.envelope.reset(); - data.pan.envelope.set_max(32); - data.pan.envelope.set_min(-32); - data.pan.envelope.add_position(0,0,false); - data.pan.envelope.add_position(30,0,false); - - data.pan.default_amount=32; - data.pan.pitch_center=48; - data.pan.pitch_separation=0; - data.pan.use_default=false; - data.pan.random_variation=0; - - - data.pitch.envelope.reset(); - data.pitch.envelope.set_max(32); - data.pitch.envelope.set_min(-32); - data.pitch.envelope.add_position(0,0,false); - data.pitch.envelope.add_position(30,0,false); - data.pitch.use_as_filter=false; - data.pitch.use_default_cutoff=false; - data.pitch.use_default_resonance=false; - data.pitch.default_cutoff=0; - data.pitch.default_resonance=0; - -} - -bool CPInstrument::is_empty() { - - bool has_sample=false; - - for (int i=0;i<CPNote::NOTES;i++) { - - if (data.sample_number[i]!=CPNote::EMPTY) { - - has_sample=true; - break; - } - } - - return !has_sample; -} - -CPInstrument::CPInstrument() { - - reset(); - -} - diff --git a/modules/chibi/cp_instrument.h b/modules/chibi/cp_instrument.h deleted file mode 100644 index e51612a38d..0000000000 --- a/modules/chibi/cp_instrument.h +++ /dev/null @@ -1,219 +0,0 @@ -/*************************************************************************/ -/* cp_instrument.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_INSTRUMENT_H -#define CP_INSTRUMENT_H - - -#include "cp_config.h" -#include "cp_note.h" -#include "cp_envelope.h" - -class CPInstrument { -public: - - - enum NNA_Type { - - NNA_NOTE_CUT, - NNA_NOTE_CONTINUE, - NNA_NOTE_OFF, - NNA_NOTE_FADE - }; - - enum DC_Type { - - DCT_DISABLED, - DCT_NOTE, - DCT_SAMPLE, - DCT_INSTRUMENT - }; - - enum DC_Action - { - - DCA_NOTE_CUT, - DCA_NOTE_OFF, - DCA_NOTE_FADE, - }; - - enum EnvelopeType { - VOLUME_ENVELOPE, - PAN_ENVELOPE, - PITCH_ENVELOPE - }; - - - enum { - MAX_NAME_LEN=26, - MAX_ENVELOPE_NODES=25, - ENVELOPE_FRAC_BITS=8, - MAX_VOLUME=128, - MAX_FADEOUT=256, - MAX_PAN=128, - MAX_VOLUME_RANDOM=100, - MAX_PAN_RANDOM=64, //what did this guy have inside his head? - - MAX_FILTER_CUTOFF=127, - MAX_FILTER_RESONANCE=127 - - }; - - - struct Data { - - - uint8_t sample_number[CPNote::NOTES]; - uint8_t note_number[CPNote::NOTES]; - - NNA_Type NNA_type; - DC_Type DC_type; - DC_Action DC_action; - - struct Volume { - - CPEnvelope envelope; - uint8_t global_amount; - uint16_t fadeout; - uint8_t random_variation; - - } volume; - - struct Pan { - - CPEnvelope envelope; - bool use_default; - uint8_t default_amount; - int8_t pitch_separation; - uint8_t pitch_center; - uint8_t random_variation; - - } pan; - - struct Pitch { - - CPEnvelope envelope; - bool use_as_filter; - bool use_default_cutoff; - uint8_t default_cutoff; - bool use_default_resonance; - uint8_t default_resonance; - } pitch; - - }; - -private: - - - - Data data; - char name[MAX_NAME_LEN]; - -public: - - /* CPInstrument General */ - - const char *get_name(); - void set_name(const char *p_name); - - void set_sample_number(uint8_t p_note,uint8_t p_sample_id); - uint8_t get_sample_number(uint8_t p_note); - - void set_note_number(uint8_t p_note,uint8_t p_note_id); - uint8_t get_note_number(uint8_t p_note); - - void set_NNA_type(NNA_Type p_NNA_type); - NNA_Type get_NNA_type(); - - void set_DC_type(DC_Type p_DC_type); - DC_Type get_DC_type(); - - void set_DC_action(DC_Action p_DC_action); - DC_Action get_DC_action(); - - /* Volume */ - - void set_volume_global_amount(uint8_t p_amount); - uint8_t get_volume_global_amount(); - - void set_volume_fadeout(uint16_t p_amount); - uint16_t get_volume_fadeout(); - - void set_volume_random_variation(uint8_t p_amount); - uint8_t get_volume_random_variation(); - - /* Panning */ - - void set_pan_default_amount(uint8_t p_amount); - uint8_t get_pan_default_amount(); - - void set_pan_default_enabled(bool p_enabled); - bool is_pan_default_enabled(); - - void set_pan_pitch_separation(int8_t p_amount); - int8_t get_pan_pitch_separation(); - - void set_pan_pitch_center(uint8_t p_amount); - uint8_t get_pan_pitch_center(); - - void set_pan_random_variation(uint8_t p_amount); - uint8_t get_pan_random_variation(); - - /* Pitch / Filter */ - - void set_pitch_use_as_filter(bool p_enabled); - bool is_pitch_use_as_filter(); - - void set_filter_use_default_cutoff(bool p_enabled); - bool filter_use_default_cutoff(); - - void set_filter_default_cutoff(uint8_t p_amount); - uint8_t get_filter_default_cutoff(); - - void set_filter_use_default_resonance(bool p_enabled); - bool filter_use_default_resonance(); - - void set_filter_default_resonance(uint8_t p_amount); - uint8_t get_filter_default_resonance(); - - CPEnvelope* get_volume_envelope(); - CPEnvelope* get_pan_envelope(); - CPEnvelope* get_pitch_filter_envelope(); - - bool is_empty(); - - void reset(); - CPInstrument(); - -}; - - - -#endif - - diff --git a/modules/chibi/cp_loader.h b/modules/chibi/cp_loader.h deleted file mode 100644 index 1630444481..0000000000 --- a/modules/chibi/cp_loader.h +++ /dev/null @@ -1,64 +0,0 @@ -/*************************************************************************/ -/* cp_loader.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_LOADER_H -#define CP_LOADER_H - - -#include "cp_song.h" -#include "cp_file_access_wrapper.h" -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ -class CPLoader { - -public: - - enum Error { - FILE_OK, - FILE_UNRECOGNIZED, - FILE_CANNOT_OPEN, - FILE_CORRUPTED, - FILE_OUT_OF_MEMORY, - }; - - - virtual bool can_load_song()=0; - virtual bool can_load_sample()=0; - virtual bool can_load_instrument()=0; - - virtual Error load_song(const char *p_file,CPSong *p_song,bool p_sampleset)=0; - virtual Error load_sample(const char *p_file,CPSample *p_sample)=0; - virtual Error load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx)=0; - - - virtual ~CPLoader() {} - -}; - -#endif diff --git a/modules/chibi/cp_loader_it.cpp b/modules/chibi/cp_loader_it.cpp deleted file mode 100644 index bfffd9b509..0000000000 --- a/modules/chibi/cp_loader_it.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/*************************************************************************/ -/* cp_loader_it.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_loader_it.h" - -bool CPLoader_IT::can_load_song() { return true; } -bool CPLoader_IT::can_load_sample() { return true; } -bool CPLoader_IT::can_load_instrument() { return true; } - -CPLoader::Error CPLoader_IT::load_song(const char *p_file,CPSong *p_song, bool p_sampleset) { - - - song=p_song; - - if (file->open( p_file, CPFileAccessWrapper::READ )!=CPFileAccessWrapper::OK) - return CPLoader::FILE_CANNOT_OPEN; - - - Error err; - - char aux_identifier[4]; - file->get_byte_array((uint8_t*)aux_identifier,4); - - if ( aux_identifier[0]!='I' || - aux_identifier[1]!='M' || - aux_identifier[2]!='P' || - aux_identifier[3]!='M') { - - - CP_PRINTERR("IT CPLoader CPSong: Failed Identifier"); - return FILE_UNRECOGNIZED; - } - - - if (p_sampleset) { - - song->reset(false,true,true,false); - - if ((err=load_header(true))) { - file->close(); - return err; - } - - if ((err=load_samples())) { - file->close(); - return err; - } - - if ((err=load_instruments())) { - file->close(); - return err; - } - - return FILE_OK; - } - - song->reset(); - - if ((err=load_header(false))) { - file->close(); - return err; - } - - if ((err=load_orders())) { - file->close(); - return err; - } - - if ((err=load_patterns())) { - file->close(); - return err; - } - - if ((err=load_samples())) { - file->close(); - return err; - } - - if ((err=load_effects())) { - file->close(); - return err; - } - - if ((err=load_instruments())) { - file->close(); - return err; - } - - if ((err=load_message())) { - file->close(); - return err; - } - - file->close(); - return FILE_OK; - -} - - - - -CPLoader::Error CPLoader_IT::load_sample(const char *p_file,CPSample *p_sample) { - - if (file->open( p_file, CPFileAccessWrapper::READ )!=CPFileAccessWrapper::OK) - return CPLoader::FILE_CANNOT_OPEN; - - p_sample->reset(); - CPLoader::Error res=load_sample(p_sample); - - file->close(); - - return res; -} -CPLoader::Error CPLoader_IT::load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx) { - - CP_FAIL_INDEX_V(p_instr_idx,CPSong::MAX_INSTRUMENTS,CPLoader::FILE_CANNOT_OPEN); - - if (file->open( p_file, CPFileAccessWrapper::READ )!=CPFileAccessWrapper::OK) - return CPLoader::FILE_CANNOT_OPEN; - - - p_song->get_instrument( p_instr_idx )->reset(); - - - int samples=0; - CPLoader::Error res=load_instrument( p_song->get_instrument( p_instr_idx ), &samples ); - - if (res) { - file->close(); - return res; - } - - - char exchange[CPSong::MAX_SAMPLES]; - for (int i=0;i<CPSong::MAX_SAMPLES;i++) - exchange[i]=0; - - for (int i=0;i<samples;i++) { - - file->seek( 554+i*80 ); //i think this should work?! seems to.. but i'm not sure - - /* find free sample */ - - int free_idx=-1; - for (int s=0;s<CPSong::MAX_SAMPLES;s++) { - - if (p_song->get_sample( s )->get_sample_data().is_null()) { - free_idx=s; - break; - } - } - if (free_idx==-1) - break; //can't seem to be able to load more samples - - exchange[i]=free_idx; - res=load_sample( p_song->get_sample( free_idx ) ); - - if (res) { - - file->close(); - return res; - } - } - - for (int i=0;i<CPNote::NOTES;i++) { - - int smp=song->get_instrument(p_instr_idx)->get_sample_number(i); - - if (smp>=CPSong::MAX_SAMPLES) - continue; - - if (smp<0) - continue; - - smp=exchange[smp]; - - song->get_instrument(p_instr_idx)->set_sample_number(i,smp); - - } - - file->close(); - - return res; - -} - -CPLoader_IT::CPLoader_IT(CPFileAccessWrapper *p_file) { - - file=p_file; - -} diff --git a/modules/chibi/cp_loader_it.h b/modules/chibi/cp_loader_it.h deleted file mode 100644 index 5ce62a6a49..0000000000 --- a/modules/chibi/cp_loader_it.h +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************/ -/* cp_loader_it.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_LOADER_IT_H -#define CP_LOADER_IT_H - -#include "cp_loader.h" -/** - *@author Juan Linietsky - */ - -/****************************** - loader_it.h - ---------- -Impulse Tracker Module CPLoader! -It lacks support for old -instrument files methinks... -and some other things like -midi. -********************************/ - -class AuxSampleData; //used for internal crap - -class CPLoader_IT : public CPLoader { - - - - CPFileAccessWrapper *file; - CPSong *song; - - struct IT_Header { - uint8_t blank01[2]; - uint16_t ordnum; - uint16_t insnum; - uint16_t smpnum; - uint16_t patnum; - uint16_t cwt; /* Created with tracker (y.xx = 0x0yxx) */ - uint16_t cmwt; /* Compatible with tracker ver > than val. */ - uint16_t flags; - uint16_t special; /* bit 0 set = song message attached */ - uint16_t msglength; - uint32_t msgoffset; - bool is_chibi; - }; - - /* Variables to store temp data */ - IT_Header header; - - /* CPSong Info Methods */ - Error load_header(bool p_dont_set); - Error load_orders(); - Error load_message(); - - /* CPPattern Methods */ - Error load_patterns(); - - /* CPSample Methods */ - - Error load_samples(); - Error load_sample(CPSample *p_sample); - CPSample_ID load_sample_data(AuxSampleData& p_sample_data); - - // CPSample decompression - - uint32_t read_n_bits_from_IT_compressed_block(uint8_t p_bits_to_read); - bool read_IT_compressed_block (bool p_16bits); - void free_IT_compressed_block (); - bool load_sample_8bits_IT_compressed(void *p_dest_buffer,int p_buffsize); - bool load_sample_16bits_IT_compressed(void *p_dest_buffer,int p_buffsize); - uint32_t *source_buffer; /* source buffer */ - uint32_t *source_position; /* actual reading position */ - uint8_t source_remaining_bits; /* bits remaining in read dword */ - uint8_t* pat_data; - - /* CPInstruments Methods */ - Error load_effects(); - Error load_instruments(); - Error load_instrument(CPInstrument *p_instrument,int *p_samples=0); - void load_envelope(CPEnvelope *p_envelope,bool*p_has_filter_flag=0); - - -public: - - - bool can_load_song(); - bool can_load_sample(); - bool can_load_instrument(); - - Error load_song(const char *p_file,CPSong *p_song, bool p_sampleset=false); - Error load_sample(const char *p_file,CPSample *p_sample); - Error load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx); - - CPLoader_IT(CPFileAccessWrapper *p_file); - -}; - - - -#endif diff --git a/modules/chibi/cp_loader_it_info.cpp b/modules/chibi/cp_loader_it_info.cpp deleted file mode 100644 index a474fcd2f9..0000000000 --- a/modules/chibi/cp_loader_it_info.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/*************************************************************************/ -/* cp_loader_it_info.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_loader_it.h" - - - -CPLoader::Error CPLoader_IT::load_header(bool p_dont_set) { - - - char aux_songname[26]; - - file->get_byte_array((uint8_t*)aux_songname,26); - if (!p_dont_set) - song->set_name( aux_songname ); - - uint8_t aux_hlmin=file->get_byte(); - uint8_t aux_hlmaj=file->get_byte(); - - if (aux_hlmin==0) aux_hlmin=4; - if (aux_hlmaj==0) aux_hlmaj=16; - - if (!p_dont_set) { - song->set_row_highlight_minor( aux_hlmin ); - song->set_row_highlight_major( aux_hlmaj ); - } - - header.ordnum=file->get_word(); - header.insnum=file->get_word(); - header.smpnum=file->get_word(); - header.patnum=file->get_word(); - - header.cwt=file->get_word(); /* Created with tracker (y.xx = 0x0yxx) */ - header.cmwt=file->get_word(); /* Compatible with tracker ver > than val. */ - header.flags=file->get_word(); - - if (!p_dont_set) { - song->set_stereo( header.flags & 1 ); - song->set_linear_slides( header.flags & 8 ); - song->set_old_effects( header.flags & 16 ); - song->set_compatible_gxx( header.flags & 32 ); - song->set_instruments( header.flags & 4 ); - } - - - header.special=file->get_word(); - if (!p_dont_set) { - - song->set_global_volume( file->get_byte() ); - song->set_mixing_volume( file->get_byte() ); - song->set_speed( file->get_byte() ); - song->set_tempo( file->get_byte() ); - song->set_stereo_separation( file->get_byte() ); - - } else { - - file->get_byte(); // skip - file->get_byte(); // skip - file->get_byte(); // skip - file->get_byte(); // skip - file->get_byte(); // skip - } - file->get_byte(); // ZERO Byte - header.msglength=file->get_word(); - header.msgoffset=file->get_dword(); - char chibi[4]; - file->get_byte_array((uint8_t*)chibi,4); - header.is_chibi=(chibi[0]=='C' && chibi[1]=='H' && chibi[2]=='B' && chibi[3]=='I'); - - for (int i=0;i<64;i++) { - - uint8_t panbyte=file->get_byte(); - - uint8_t pan_dst=(panbyte<65) ? panbyte : 32; - bool surround_dst=(panbyte==100); - bool mute_dst=(panbyte>=128); - - if (!p_dont_set) { - song->set_channel_pan( i, pan_dst ); - song->set_channel_surround( i, surround_dst ); - song->set_channel_mute( i, mute_dst ); - } - } - for (int i=0;i<64;i++) { - unsigned char cv = file->get_byte(); - if (!p_dont_set) - song->set_channel_volume( i, cv ); - } - - CP_ERR_COND_V( file->eof_reached(),FILE_CORRUPTED ); - CP_ERR_COND_V( file->get_error(),FILE_CORRUPTED ); - - return FILE_OK; -} - -CPLoader::Error CPLoader_IT::load_effects() { - - if (!header.is_chibi) - return FILE_OK; //no effects, regular IT file - - /* GOTO End of IT header */ - file->seek(0xC0+header.ordnum+header.insnum*4+header.smpnum*4+header.patnum*4); - - - if (file->get_byte()>0) //not made with this version, ignore extended info - return FILE_OK; - - /* Chibitracker Extended info */ - - switch(file->get_byte()) { - - case CPSong::REVERB_MODE_ROOM: { - - song->set_reverb_mode( CPSong::REVERB_MODE_ROOM ); - } break; - case CPSong::REVERB_MODE_STUDIO_SMALL: { - - song->set_reverb_mode( CPSong::REVERB_MODE_STUDIO_SMALL ); - - } break; - case CPSong::REVERB_MODE_STUDIO_MEDIUM: { - - song->set_reverb_mode( CPSong::REVERB_MODE_STUDIO_MEDIUM ); - - } break; - case CPSong::REVERB_MODE_STUDIO_LARGE: { - - song->set_reverb_mode( CPSong::REVERB_MODE_STUDIO_LARGE ); - - } break; - case CPSong::REVERB_MODE_HALL: { - - song->set_reverb_mode( CPSong::REVERB_MODE_HALL ); - - } break; - case CPSong::REVERB_MODE_SPACE_ECHO: { - - song->set_reverb_mode( CPSong::REVERB_MODE_SPACE_ECHO ); - - } break; - - case CPSong::REVERB_MODE_ECHO: { - - song->set_reverb_mode( CPSong::REVERB_MODE_ECHO ); - - } break; - case CPSong::REVERB_MODE_DELAY: { - - song->set_reverb_mode( CPSong::REVERB_MODE_DELAY ); - - } break; - case CPSong::REVERB_MODE_HALF_ECHO: { - - song->set_reverb_mode( CPSong::REVERB_MODE_HALF_ECHO ); - - } break; - - } - - //chorus - song->set_chorus_speed_hz10( file->get_byte() ); - song->set_chorus_delay_ms( file->get_byte() ); - song->set_chorus_depth_ms10( file->get_byte() ); - song->set_chorus_separation_ms( file->get_byte() ); - - for (int i=0;i<CPPattern::WIDTH;i++) { - song->set_channel_reverb(i,file->get_byte()); - } - for (int i=0;i<CPPattern::WIDTH;i++) { - song->set_channel_chorus(i,file->get_byte()); - } - - return FILE_OK; - -} - -CPLoader::Error CPLoader_IT::load_message() { - - - if (!(header.special & 1)) { - - return FILE_OK; - } - - - file->seek(header.msgoffset); - - //(void*)tmpmsg=malloc(header.msglength+1); - - char message[8000]; - - - char *tmpmsg = message; - - file->get_byte_array((uint8_t*)tmpmsg,header.msglength); - tmpmsg[header.msglength]=0; - - for (int i=0;i<header.msglength;i++) if (tmpmsg[i]=='\r') tmpmsg[i]='\n'; - - song->set_message(tmpmsg); - - return FILE_OK; -} - -CPLoader::Error CPLoader_IT::load_orders() { - - file->seek(0xC0); - - - for (int i=0;i<header.ordnum;i++) { - - uint8_t aux_order=file->get_byte(); - CPOrder order=CP_ORDER_NONE; - - - if (i>=CPSong::MAX_ORDERS) - continue; - if (aux_order==254) { - - order=CP_ORDER_BREAK; - - } else if (aux_order<200) { - - order=aux_order; - //nothing! - - } - song->set_order(i,order); - - } - - if (file->eof_reached() || file->get_error()) { - - - return FILE_CORRUPTED; - - } - - return FILE_OK; -} - - - diff --git a/modules/chibi/cp_loader_it_instruments.cpp b/modules/chibi/cp_loader_it_instruments.cpp deleted file mode 100644 index 446e841c5f..0000000000 --- a/modules/chibi/cp_loader_it_instruments.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/*************************************************************************/ -/* cp_loader_it_instruments.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_loader_it.h" - -enum EnvFlags { - ENV_ON=1, - ENV_LOOP=2, - ENV_SUSLOOP=4, - ENV_CARRY=8, - ENV_FILTER=128 -}; - -void CPLoader_IT::load_envelope(CPEnvelope *p_envelope,bool*p_has_filter_flag) { - - uint8_t flags=file->get_byte(); - uint8_t points=file->get_byte(); - uint8_t begin=file->get_byte(); - uint8_t end=file->get_byte(); - uint8_t susbegin=file->get_byte(); - uint8_t susend=file->get_byte(); - - p_envelope->reset(); - - for (int i=0;i<25;i++) { - - uint8_t height=file->get_byte(); - int8_t &signed_height=(int8_t&)height; - uint16_t tick=file->get_word(); - - if (i>=points) - continue; - p_envelope->add_position( tick, signed_height ); - - } - - p_envelope->set_enabled( flags & ENV_ON ); - p_envelope->set_carry_enabled( flags & ENV_CARRY); - - p_envelope->set_loop_enabled( flags & ENV_LOOP ); - p_envelope->set_loop_begin( begin ); - p_envelope->set_loop_end( end ); - - p_envelope->set_sustain_loop_enabled( flags & ENV_SUSLOOP ); - p_envelope->set_sustain_loop_begin( susbegin ); - p_envelope->set_sustain_loop_end( susend ); - - if (p_has_filter_flag) - *p_has_filter_flag=flags&ENV_FILTER; - - file->get_byte(); //zerobyte - - //fill with stuff if the envelope hass less than 2 points - while(p_envelope->get_node_count()<2) { - - p_envelope->add_position( 30*p_envelope->get_node_count(), p_envelope->get_min()==0 ? 64 : 0, false ); - } -} - - -CPLoader::Error CPLoader_IT::load_instrument(CPInstrument *p_instrument,int *p_samples) { - - - - char aux_header[4]; - - file->get_byte_array((uint8_t*)aux_header,4); - - - if ( aux_header[0]!='I' || - aux_header[1]!='M' || - aux_header[2]!='P' || - aux_header[3]!='I') { - CP_PRINTERR("IT CPLoader CPInstrument: Failed Identifier"); - - return FILE_UNRECOGNIZED; - } - - - - // Ignore deprecated 8.3 filename field - for (int i=0;i<12;i++) file->get_byte(); - - //Ignore zerobyte - file->get_byte(); /* (byte) CPInstrument type (always 0) */ - - switch( file->get_byte() ) { /* New CPNote Action [0,1,2,3] */ - case 0: p_instrument->set_NNA_type( CPInstrument::NNA_NOTE_CUT ) ; break; - case 1: p_instrument->set_NNA_type( CPInstrument::NNA_NOTE_CONTINUE ) ; break; - case 2: p_instrument->set_NNA_type( CPInstrument::NNA_NOTE_OFF ) ; break; - case 3: p_instrument->set_NNA_type( CPInstrument::NNA_NOTE_FADE ) ; break; - }; - switch( file->get_byte() ) { // Duplicate Check Type - case 0: p_instrument->set_DC_type( CPInstrument::DCT_DISABLED ); break ; - case 1: p_instrument->set_DC_type( CPInstrument::DCT_NOTE ); break ; - case 2: p_instrument->set_DC_type( CPInstrument::DCT_SAMPLE ); break ; - case 3: p_instrument->set_DC_type( CPInstrument::DCT_INSTRUMENT ); break ; - } - switch( file->get_byte() ) { //Duplicate Check Action - case 0: p_instrument->set_DC_action( CPInstrument::DCA_NOTE_CUT ); break ; - case 1: p_instrument->set_DC_action( CPInstrument::DCA_NOTE_OFF ); break ; - case 2: p_instrument->set_DC_action( CPInstrument::DCA_NOTE_FADE ); break ; - } - - int fade = file->get_word(); - //intf("AFADE: %i\n",fade); - if (fade>CPInstrument::MAX_FADEOUT) //needs to be clipped because of horrible modplug doings - fade=CPInstrument::MAX_FADEOUT; - - p_instrument->set_volume_fadeout( fade ); - p_instrument->set_pan_pitch_separation( file->get_byte() ); - p_instrument->set_pan_pitch_center( file->get_byte() ); - p_instrument->set_volume_global_amount( file->get_byte() ); - uint8_t pan=file->get_byte(); - p_instrument->set_pan_default_amount(pan&0x7F); - p_instrument->set_pan_default_enabled( !(pan&0x80) ); - p_instrument->set_volume_random_variation( file->get_byte() ); - p_instrument->set_pan_random_variation( file->get_byte() ); - - - - file->get_word(); //empty (version) - uint8_t samples=file->get_byte(); - if (p_samples) - *p_samples=samples; - file->get_byte(); //empty - char aux_name[26]; - file->get_byte_array((uint8_t*)aux_name,26); - p_instrument->set_name(aux_name); - - uint8_t cutoff=file->get_byte(); - - p_instrument->set_filter_default_cutoff(cutoff&0x7F); - p_instrument->set_filter_use_default_cutoff(cutoff&0x80); - - uint8_t resonance=file->get_byte(); - - p_instrument->set_filter_default_resonance(resonance&0x7F); - p_instrument->set_filter_use_default_resonance(resonance&0x80); - - file->get_dword(); //MIDI, IGNORED! - - /* CPNote -> CPSample table */ - for (uint8_t i=0;i<CPNote::NOTES;i++) { - - - uint8_t note=file->get_byte(); - if (note>=CPNote::NOTES) - note=0; - p_instrument->set_note_number(i,note); - - uint8_t samp=file->get_byte(); - if (samp==0 || samp>99) - samp=CPNote::EMPTY; - else - samp--; - - - p_instrument->set_sample_number(i,samp); - - - } - - - load_envelope( p_instrument->get_volume_envelope() ); - load_envelope( p_instrument->get_pan_envelope() ); - bool use_as_filter; - load_envelope( p_instrument->get_pitch_filter_envelope(), &use_as_filter ); - p_instrument->set_pitch_use_as_filter( use_as_filter ); - - return FILE_OK; - -} - - -CPLoader::Error CPLoader_IT::load_instruments() { - - - for (int i=0;i<header.insnum;i++) { - - - file->seek(0xC0+header.ordnum+i*4); - uint32_t final_location=file->get_dword(); - file->seek( final_location ); - - Error err=load_instrument( song->get_instrument( i ) ); - if (err) - return err; - - } - - return FILE_OK; - - if (file->eof_reached() || file->get_error()) - return FILE_CORRUPTED; -} - - diff --git a/modules/chibi/cp_loader_it_patterns.cpp b/modules/chibi/cp_loader_it_patterns.cpp deleted file mode 100644 index 528d99fff7..0000000000 --- a/modules/chibi/cp_loader_it_patterns.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/*************************************************************************/ -/* cp_loader_it_patterns.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_loader_it.h" - - -CPLoader::Error CPLoader_IT::load_patterns() { - - - for (int i=0;i<header.patnum;i++) { - - if (i>=CPSong::MAX_PATTERNS) - break; - - /* Position where pattern offsets are stored */ - file->seek(0xC0+header.ordnum+header.insnum*4+header.smpnum*4+i*4); - uint32_t pattern_offset=file->get_dword(); - - if (pattern_offset==0) { - - continue; - } - - uint16_t pat_size; - uint16_t pat_length; - - int row=0,flag,channel,j; - uint8_t aux_byte; - uint32_t reserved; - uint8_t chan_mask[64]; //mask cache for each - CPNote last_value[64]; //last value of each - - for (j=0;j<64;j++) { - - chan_mask[j]=0; - last_value[j].clear(); - } - - file->seek(pattern_offset); - - pat_size=file->get_word(); - pat_length=file->get_word(); - reserved=file->get_dword(); - - song->get_pattern(i)->set_length( pat_length ); - - do { - - aux_byte=file->get_byte(); - flag=aux_byte; - - if ( flag==0 ) { - - row++; - } else { - - channel=(flag-1) & 63; - - if ( flag & 128 ) { - - aux_byte=file->get_byte(); - chan_mask[channel]=aux_byte; - } - - CPNote note; //note used for reading - - if ( chan_mask[channel]&1 ) { // read note - - aux_byte=file->get_byte(); - - if ( aux_byte<120 ) - note.note=aux_byte; - else if ( aux_byte==255 ) - note.note=CPNote::OFF; - else if ( aux_byte==254 ) - note.note=CPNote::CUT; - - last_value[channel].note=note.note; - } - - - if ( chan_mask[channel]&2 ) { - - aux_byte=file->get_byte(); - if ( aux_byte<100 ) - note.instrument=aux_byte-1; - - last_value[channel].instrument=note.instrument; - } - if ( chan_mask[channel]&4 ) { - - aux_byte=file->get_byte(); - if ( aux_byte<213 ) - note.volume=aux_byte; - - last_value[channel].volume=note.volume; - } - if ( chan_mask[channel]&8 ) { - - aux_byte=file->get_byte(); - if ( aux_byte>0 ) - note.command=aux_byte-1; - - - last_value[channel].command=note.command; - - note.parameter=file->get_byte(); - - last_value[channel].parameter=note.parameter; - } - - if ( chan_mask[channel]&16 ) { - - note.note=last_value[channel].note; - } - - if ( chan_mask[channel]&32 ) { - - note.instrument=last_value[channel].instrument; - } - if ( chan_mask[channel]&64 ) { - - note.volume=last_value[channel].volume; - } - if ( chan_mask[channel]&128 ) { - - note.command=last_value[channel].command; - note.parameter=last_value[channel].parameter; - } - - song->get_pattern(i)->set_note(channel,row,note); - } - - - } while(row<pat_length); - - } - - return FILE_OK; -} - diff --git a/modules/chibi/cp_loader_it_samples.cpp b/modules/chibi/cp_loader_it_samples.cpp deleted file mode 100644 index c736c99c0f..0000000000 --- a/modules/chibi/cp_loader_it_samples.cpp +++ /dev/null @@ -1,620 +0,0 @@ -/*************************************************************************/ -/* cp_loader_it_samples.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_loader_it.h" -#include "cp_sample.h" - -struct AuxSampleData { - - - uint32_t fileofs; - uint32_t c5spd; - uint32_t length; - uint32_t loop_begin; - uint32_t loop_end; - bool loop_enabled; - bool pingpong_enabled; - bool is16bit; - bool stereo; - bool exists; - bool compressed; - -}; - - -enum IT_Sample_Flags { - - IT_SAMPLE_EXISTS=1, - IT_SAMPLE_16BITS=2, - IT_SAMPLE_STEREO=4, - IT_SAMPLE_COMPRESSED=8, - IT_SAMPLE_LOOPED=16, - IT_SAMPLE_SUSTAIN_LOOPED=32, - IT_SAMPLE_LOOP_IS_PINGPONG=64, - IT_SAMPLE_SUSTAIN_LOOP_IS_PINGPONG=128 -}; - - -CPLoader::Error CPLoader_IT::load_sample(CPSample *p_sample) { - - - AuxSampleData aux_sample_data; - - char aux_header[4]; - - file->get_byte_array((uint8_t*)aux_header,4); - - if ( aux_header[0]!='I' || - aux_header[1]!='M' || - aux_header[2]!='P' || - aux_header[3]!='S') { - - //CP_PRINTERR("IT CPLoader CPSample: Failed Identifier"); - return FILE_UNRECOGNIZED; - } - - - // Ignore deprecated 8.3 filename - for (int i=0;i<12;i++) file->get_byte(); - - file->get_byte(); //ignore zerobyte - - p_sample->set_global_volume( file->get_byte() ); - - /* SAMPLE FLAGS */ - uint8_t flags=file->get_byte(); - aux_sample_data.loop_enabled=flags&IT_SAMPLE_LOOPED; - aux_sample_data.pingpong_enabled=flags&IT_SAMPLE_LOOP_IS_PINGPONG; - aux_sample_data.is16bit=flags&IT_SAMPLE_16BITS; - aux_sample_data.exists=flags&IT_SAMPLE_EXISTS; - aux_sample_data.stereo=flags&IT_SAMPLE_STEREO; - aux_sample_data.compressed=flags&IT_SAMPLE_COMPRESSED; - - p_sample->set_default_volume(file->get_byte()); - /* SAMPLE NAME */ - char aux_name[26]; - file->get_byte_array((uint8_t*)aux_name,26); - p_sample->set_name(aux_name); - - // ?? - uint8_t convert_flag=file->get_byte(); - // PAN - uint8_t pan=file->get_byte(); - p_sample->set_pan( pan&0x7F ); - p_sample->set_pan_enabled( pan & 0x80 ); - - aux_sample_data.length=file->get_dword(); - - - aux_sample_data.loop_begin= file->get_dword(); - aux_sample_data.loop_end= file->get_dword(); - aux_sample_data.c5spd=file->get_dword(); - /*p_sample->data.set_sustain_loop_begin=*/file->get_dword(); - /*p_sample->data.sustain_loop_end=*/file->get_dword(); - aux_sample_data.fileofs=file->get_dword(); - p_sample->set_vibrato_speed( file->get_byte() ); - p_sample->set_vibrato_depth( file->get_byte() ); - p_sample->set_vibrato_rate( file->get_byte() ); - switch( file->get_byte() ) { - /* Vibrato Wave: 0=sine, 1=rampdown, 2=square, 3=random */ - case 0: p_sample->set_vibrato_type( CPSample::VIBRATO_SINE ); break; - case 1: p_sample->set_vibrato_type( CPSample::VIBRATO_SAW ); break; - case 2: p_sample->set_vibrato_type( CPSample::VIBRATO_SQUARE ); break; - case 3: p_sample->set_vibrato_type( CPSample::VIBRATO_RANDOM ); break; - default: p_sample->set_vibrato_type( CPSample::VIBRATO_SINE ); break; - } - - //printf("Name %s - Flags: fileofs :%i - c5spd %i - len %i 16b %i - data?: %i\n",p_sample->get_name(),aux_sample_data.fileofs,aux_sample_data.c5spd, aux_sample_data.length, aux_sample_data.is16bit,aux_sample_data.exists); - CPSample_ID samp_id; - - if (aux_sample_data.exists) { - samp_id=load_sample_data(aux_sample_data); - CPSampleManager::get_singleton()->set_c5_freq(samp_id,aux_sample_data.c5spd); - CPSampleManager::get_singleton()->set_loop_begin( samp_id,aux_sample_data.loop_begin ); - CPSampleManager::get_singleton()->set_loop_end( samp_id,aux_sample_data.loop_end ); - CPSample_Loop_Type loop_type=aux_sample_data.loop_enabled?( aux_sample_data.pingpong_enabled? CP_LOOP_BIDI: CP_LOOP_FORWARD):CP_LOOP_NONE; - CPSampleManager::get_singleton()->set_loop_end( samp_id,aux_sample_data.loop_end ); - CPSampleManager::get_singleton()->set_loop_type( samp_id, loop_type); - - } - - //printf("Loaded id is null?: %i\n",samp_id.is_null()); - p_sample->set_sample_data(samp_id); - if (!samp_id.is_null()) { - - //printf("Loaded ID: stereo: %i len %i 16bit %i\n",CPSampleManager::get_singleton()->is_stereo(samp_id), CPSampleManager::get_singleton()->get_size( samp_id), CPSampleManager::get_singleton()->is_16bits( samp_id) ); - } - - CP_ERR_COND_V( file->eof_reached(),FILE_CORRUPTED ); - CP_ERR_COND_V( file->get_error(),FILE_CORRUPTED ); - - return FILE_OK; - -} - -CPSample_ID CPLoader_IT::load_sample_data(AuxSampleData& p_sample_data) { - - - int aux_sample_properties = (p_sample_data.is16bit?IT_SAMPLE_16BITS:0)|(p_sample_data.compressed?IT_SAMPLE_COMPRESSED:0)|(p_sample_data.stereo?IT_SAMPLE_STEREO:0); - - file->seek(p_sample_data.fileofs); - - CPSampleManager *sm=CPSampleManager::get_singleton(); - - CPSample_ID id; - - switch (aux_sample_properties) { - - case (0): // 8 bits, mono - case (IT_SAMPLE_16BITS): // 16 bits mono - case (IT_SAMPLE_STEREO): // 8 bits stereo - case (IT_SAMPLE_16BITS|IT_SAMPLE_STEREO): { // 16 bits mono - - id=sm->create(p_sample_data.is16bit,p_sample_data.stereo,p_sample_data.length); - if (id.is_null()) - break; - - sm->lock_data(id); - - int16_t *ptr16 = (int16_t*)sm->get_data(id); - int8_t *ptr8=(int8_t*)ptr16; - - int chans=p_sample_data.stereo?2:1; - - if (p_sample_data.is16bit) { - - for (int c=0;c<chans;c++) { - - for (int i=0;i<p_sample_data.length;i++) { - - ptr16[i*chans+c]=file->get_word(); - } - } - } else { - - for (int c=0;c<chans;c++) { - - for (int i=0;i<p_sample_data.length;i++) { - - ptr8[i*chans+c]=file->get_byte(); - } - } - - } - - sm->unlock_data(id); - - } break; - case (IT_SAMPLE_COMPRESSED): { // 8 bits compressed - - - id=sm->create(false,false,p_sample_data.length); - if (id.is_null()) - break; - sm->lock_data(id); - - if ( load_sample_8bits_IT_compressed((void*)sm->get_data( id),p_sample_data.length) ) { - - sm->unlock_data(id); - sm->destroy(id); - - break; - } - - sm->unlock_data(id); - - - } break; - case (IT_SAMPLE_16BITS|IT_SAMPLE_COMPRESSED): { // 16 bits compressed - - - id=sm->create(true,false,p_sample_data.length); - if (id.is_null()) - break; - sm->lock_data(id); - - if ( load_sample_16bits_IT_compressed((void*)sm->get_data(id),p_sample_data.length) ) { - - sm->unlock_data(id); - sm->destroy(id); - break; - } - - sm->unlock_data(id); - - } break; - default: { - - // I dont know how to handle stereo compressed, does that exist? - } break; - - } - - - return id; -} - - -CPLoader::Error CPLoader_IT::load_samples() { - - for (int i=0;i<header.smpnum;i++) { - - //seek to sample - file->seek(0xC0+header.ordnum+header.insnum*4+i*4); - - uint32_t final_location=file->get_dword(); - file->seek( final_location ); - - - Error err=load_sample(song->get_sample(i)); - CP_ERR_COND_V(err,err); - - } - - if (file->eof_reached() || file->get_error()) - return FILE_CORRUPTED; - - return FILE_OK; -} -/* * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE - - -The following sample decompression code is based on xmp's code.(http://xmp.helllabs.org) which is based in openCP code. - -* NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE */ - -uint32_t CPLoader_IT::read_n_bits_from_IT_compressed_block (uint8_t p_bits_to_read) { - - uint32_t aux_return_value; - uint32_t val; - - uint8_t *buffer=(uint8_t*)source_position; - if ( p_bits_to_read <= source_remaining_bits ) { - - val=buffer[3]; - val<<=8; - val|=buffer[2]; - val<<=8; - val|=buffer[1]; - val<<=8; - val|=buffer[0]; - - aux_return_value = val & ((1 << p_bits_to_read) - 1); - val >>= p_bits_to_read; - source_remaining_bits -= p_bits_to_read; - - buffer[3]=val>>24; - buffer[2]=(val>>16)&0xFF; - buffer[1]=(val>>8)&0xFF; - buffer[0]=(val)&0xFF; - - } else { - aux_return_value=buffer[3]; - aux_return_value<<=8; - aux_return_value|=buffer[2]; - aux_return_value<<=8; - aux_return_value|=buffer[1]; - aux_return_value<<=8; - aux_return_value|=buffer[0]; - - uint32_t nbits = p_bits_to_read - source_remaining_bits; - source_position++; - - buffer+=4; - val=buffer[3]; - val<<=8; - val|=buffer[2]; - val<<=8; - val|=buffer[1]; - val<<=8; - val|=buffer[0]; - aux_return_value |= ((val & ((1 << nbits) - 1)) << source_remaining_bits); - val >>= nbits; - source_remaining_bits = 32 - nbits; - buffer[3]=val>>24; - buffer[2]=(val>>16)&0xFF; - buffer[1]=(val>>8)&0xFF; - buffer[0]=(val)&0xFF; - - } - - return aux_return_value; -} - -bool CPLoader_IT::read_IT_compressed_block (bool p_16bits) { - - uint16_t size; - - size=file->get_word(); - - if (file->eof_reached() || file->get_error()) return true; - - pat_data = (uint8_t*)CP_ALLOC( 4* ((size >> 2) + 2) ); - if (!pat_data) - return true; - - - source_buffer=(uint32_t*)pat_data; - file->get_byte_array((uint8_t*)source_buffer,size); - - if (file->eof_reached() || file->get_error()) { - - free_IT_compressed_block(); - return true; - } - - source_position = source_buffer; - source_remaining_bits = 32; - - return false; -} - -void CPLoader_IT::free_IT_compressed_block () { - - - if (pat_data) { - CP_FREE(pat_data); - pat_data=NULL; - } - -} - -bool CPLoader_IT::load_sample_8bits_IT_compressed(void *p_dest_buffer,int p_buffsize) { - - int8_t *dest_buffer; /* destination buffer which will be returned */ - uint16_t block_length; /* length of compressed data block in samples */ - uint16_t block_position; /* position in block */ - uint8_t bit_width; /* actual "bit width" */ - uint16_t aux_value; /* value read from file to be processed */ - int8_t d1, d2; /* integrator buffers (d2 for it2.15) */ - int8_t *dest_position; /* position in output buffer */ - int8_t v; /* sample value */ - bool it215; // is this an it215 module? - - dest_buffer = (int8_t *) p_dest_buffer; - - if (dest_buffer==NULL) - return true; - - for (int i=0;i<p_buffsize;i++) - dest_buffer[i]=0; - - - dest_position = dest_buffer; - - it215=(header.cmwt==0x215); - - /* now unpack data till the dest buffer is full */ - - while (p_buffsize) { - /* read a new block of compressed data and reset variables */ - if ( read_IT_compressed_block(false) ) { - CP_PRINTERR("Out of memory decompressing IT CPSample"); - return true; - } - - - block_length = (p_buffsize < 0x8000) ? p_buffsize : 0x8000; - - block_position = 0; - - bit_width = 9; /* start with width of 9 bits */ - - d1 = d2 = 0; /* reset integrator buffers */ - - /* now uncompress the data block */ - while ( block_position < block_length ) { - - aux_value = read_n_bits_from_IT_compressed_block(bit_width); /* read bits */ - - if ( bit_width < 7 ) { /* method 1 (1-6 bits) */ - - if ( aux_value == (1 << (bit_width - 1)) ) { /* check for "100..." */ - - aux_value = read_n_bits_from_IT_compressed_block(3) + 1; /* yes -> read new width; */ - bit_width = (aux_value < bit_width) ? aux_value : aux_value + 1; - /* and expand it */ - continue; /* ... next value */ - } - - } else if ( bit_width < 9 ) { /* method 2 (7-8 bits) */ - - uint8_t border = (0xFF >> (9 - bit_width)) - 4; - /* lower border for width chg */ - - if ( aux_value > border && aux_value <= (border + 8) ) { - - aux_value -= border; /* convert width to 1-8 */ - bit_width = (aux_value < bit_width) ? aux_value : aux_value + 1; - /* and expand it */ - continue; /* ... next value */ - } - - - } else if ( bit_width == 9 ) { /* method 3 (9 bits) */ - - if ( aux_value & 0x100 ) { /* bit 8 set? */ - - bit_width = (aux_value + 1) & 0xff; /* new width... */ - continue; /* ... and next value */ - } - - } else { /* illegal width, abort */ - - - free_IT_compressed_block(); - CP_PRINTERR("CPSample has illegal BitWidth "); - return true; - } - - /* now expand value to signed byte */ - if ( bit_width < 8 ) { - - uint8_t tmp_shift = 8 - bit_width; - - v=(aux_value << tmp_shift); - v>>=tmp_shift; - - } else v = (int8_t) aux_value; - - /* integrate upon the sample values */ - d1 += v; - d2 += d1; - - /* ... and store it into the buffer */ - *(dest_position++) = it215 ? d2 : d1; - block_position++; - - } - - /* now subtract block lenght from total length and go on */ - free_IT_compressed_block(); - p_buffsize -= block_length; - } - - - return false; -} - -bool CPLoader_IT::load_sample_16bits_IT_compressed(void *p_dest_buffer,int p_buffsize) { - - int16_t *dest_buffer; /* destination buffer which will be returned */ - uint16_t block_length; /* length of compressed data block in samples */ - uint16_t block_position; /* position in block */ - uint8_t bit_width; /* actual "bit width" */ - uint32_t aux_value; /* value read from file to be processed */ - int16_t d1, d2; /* integrator buffers (d2 for it2.15) */ - int16_t *dest_position; /* position in output buffer */ - int16_t v; /* sample value */ - - bool it215; // is this an it215 module? - - dest_buffer = (int16_t *) p_dest_buffer; - - if (dest_buffer==NULL) - return true; - - for (int i=0;i<p_buffsize;i++) - dest_buffer[i]=0; - - dest_position = dest_buffer; - - it215=(header.cmwt==0x215); - - - while (p_buffsize) { - /* read a new block of compressed data and reset variables */ - if ( read_IT_compressed_block(true) ) { - - return true; - } - - - block_length = (p_buffsize < 0x4000) ? p_buffsize : 0x4000; - - block_position = 0; - - bit_width = 17; /* start with width of 9 bits */ - - d1 = d2 = 0; /* reset integrator buffers */ - - while ( block_position < block_length ) { - - aux_value = read_n_bits_from_IT_compressed_block(bit_width); /* read bits */ - - if ( bit_width < 7 ) { /* method 1 (1-6 bits) */ - - if ( (signed)aux_value == (1 << (bit_width - 1)) ) { /* check for "100..." */ - - aux_value = read_n_bits_from_IT_compressed_block(4) + 1; /* yes -> read new width; */ - bit_width = (aux_value < bit_width) ? aux_value : aux_value + 1; - /* and expand it */ - continue; /* ... next value */ - } - - } else if ( bit_width < 17 ) { - - uint16_t border = (0xFFFF >> (17 - bit_width)) - 8; - - if ( (int)aux_value > (int)border && (int)aux_value <= ((int)border + 16) ) { - - aux_value -= border; /* convert width to 1-8 */ - bit_width = (aux_value < bit_width) ? aux_value : aux_value + 1; - /* and expand it */ - continue; /* ... next value */ - } - - - } else if ( bit_width == 17 ) { - - if ( aux_value & 0x10000 ) { /* bit 8 set? */ - - bit_width = (aux_value + 1) & 0xff; /* new width... */ - continue; /* ... and next value */ - } - - } else { /* illegal width, abort */ - - CP_PRINTERR("CPSample has illegal BitWidth "); - - free_IT_compressed_block(); - - return true; - } - - /* now expand value to signed byte */ - if ( bit_width < 16 ) { - - uint8_t tmp_shift = 16 - bit_width; - - v=(aux_value << tmp_shift); - v>>=tmp_shift; - - } else v = (int16_t) aux_value; - - /* integrate upon the sample values */ - d1 += v; - d2 += d1; - - /* ... and store it into the buffer */ - *(dest_position++) = it215 ? d2 : d1; - block_position++; - - } - - /* now subtract block lenght from total length and go on */ - free_IT_compressed_block(); - p_buffsize -= block_length; - } - - - return false; - -} - - - diff --git a/modules/chibi/cp_loader_mod.cpp b/modules/chibi/cp_loader_mod.cpp deleted file mode 100644 index cfa3e34736..0000000000 --- a/modules/chibi/cp_loader_mod.cpp +++ /dev/null @@ -1,482 +0,0 @@ -/*************************************************************************/ -/* cp_loader_mod.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_loader_mod.h" - - -static bool tag_equal_to(const char *p_tag, const char *p_string) { - - return( p_tag[0]==p_string[0] && - p_tag[1]==p_string[1] && - p_tag[2]==p_string[2] && - p_tag[3]==p_string[3]); -} -/* ProTracker period table */ -uint16_t period_table[6*12] = { - 1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,907, - 856,808,762,720,678,640,604,570,538,508,480,453, - 428,404,381,360,339,320,302,285,269,254,240,226, - 214,202,190,180,170,160,151,143,135,127,120,113, - 107,101,95,90,85,80,75,71,67,63,60,56, - 53,50,47,45,42,40,37,35,33,31,30,28 -}; - - -CPLoader::Error CPLoader_MOD::load_song(const char *p_file,CPSong *p_song,bool p_sampleset) { - - if (file->open(p_file,CPFileAccessWrapper::READ)) { - //printf("Can't open file! %s\n",p_file); - return FILE_CANNOT_OPEN; - }; - - /* FIRST OF ALL, one needs to read the .mod file format tag */ - file->seek( 1080 ); //located at 1080 - - char format_tag[4]; - - file->get_byte_array( (uint8_t*)format_tag, 4 ); - - int channels=-1; - - /** THE PAIN!! - COMPARE TAGS */ - - /* Classic 4-chan */ - if (tag_equal_to(format_tag,"M.K.") ) - channels=4; - if (tag_equal_to(format_tag,"FLT4") ) - channels=4; - if (tag_equal_to(format_tag,"M!K!") ) - channels=4; - - /* 8 Channel MODS */ - - if (tag_equal_to(format_tag,"FLT8") ) - channels=2; - - if (tag_equal_to(format_tag,"CD81") ) - channels=2; - - /* Custom channel MODS */ - - for (int i=1;i<=32;i++) { - - if (i<10) { // up to 9 channels mods - - /* Old Take Tracker */ - char old_take_tracker[4]={'T','D','Z',char('0'+i)}; - - if (tag_equal_to(format_tag,old_take_tracker)) { - - channels=i; - break; - } - - /* Contemplates many XCHN Formats */ - char xchn[4]={char('0'+i),'C','H','N'}; - - if (tag_equal_to(format_tag,xchn)) { - - channels=i; - break; - } - } - - /* Fast Tracker */ - char fast_tracker[4]={char('0'+(i/10)),char('0'+(i%10)),'C','H'}; - - if (tag_equal_to(format_tag,fast_tracker)) { - - channels=i; - break; - } - - } - - - if (channels==-1) { - - file->close(); - return FILE_UNRECOGNIZED; - } - - - - /** Load CPSong INFO */ - - file->seek( 0 ); //go to begining of file - - file->set_endian_conversion( true ); - p_song->reset(); - p_song->set_instruments( false ); - - char name[21]; - - file->get_byte_array( (uint8_t*)name,20); - name[20]=0; - - p_song->set_name(name); - p_song->set_old_effects( true ); - p_song->set_linear_slides( false ); - p_song->set_compatible_gxx( true ); - - - - CPSampleManager *sm=CPSampleManager::get_singleton(); - - int instruments=31; - - for (int i=0;i<instruments;i++) { - - char sample_name[23]; - file->get_byte_array( (uint8_t*)sample_name,22); - sample_name[22]=0; - - uint32_t sample_len=file->get_word(); - sample_len<<=1; - - uint8_t fine_nibble=file->get_byte()&0xF; - - - //(int8_t)(fine_nibble & 7) - (int8_t)(fine_nibble & 8); //yesso's genius trick - // boo, I can't use it :( but i leave it here because of how cool it is - uint8_t linear_volume=file->get_byte(); //0 .. ? - - uint32_t loop_begin=file->get_word(); //0 .. ? - loop_begin<<=1; - uint32_t loop_end=file->get_word(); //0 .. ? - loop_end<<=1; - - if (sample_len>0) { - - CPSample_ID sid=sm->create( false, false, sample_len ); - - if (sid.is_null()) { - - file->close(); - return FILE_OUT_OF_MEMORY; - } - - if (loop_end>2) { - sm->set_loop_begin( sid, loop_begin ); - sm->set_loop_end( sid, loop_end+loop_begin ); - sm->set_loop_type( sid,CP_LOOP_FORWARD ); - } - static const uint16_t fine_to_freq[16]={ - 8363,8413,8463,8529,8581,8651,8723,8757, - 7895,7941,7985,8046,8107,8169,8232,8280 - }; - - sm->set_c5_freq( sid, fine_to_freq[fine_nibble] ); - p_song->get_sample(i)->set_sample_data(sid); - } - - p_song->get_sample(i)->set_name(sample_name); - p_song->get_sample(i)->set_default_volume( linear_volume ); - - - - } - - /* pan for MODs */ - for (int i=0;i<channels;i++) - p_song->set_channel_pan( i, (((i&3)==1) || ((i&3)==2)) ? 0: 64); - - - uint8_t order_count=file->get_byte(); - //uint8_t loop_to=file->get_byte(); - - - int pattern_count=0; - - for (int i=0;i<128;i++) { - - uint8_t order=file->get_byte(); - - - if (i<order_count) { - p_song->set_order(i,order); - - /* Determine the amount of patterns */ - if ((order+1)>pattern_count) - pattern_count=order+1; - } else - p_song->set_order( i, CP_ORDER_NONE ); - } - - if (instruments==31) - file->get_dword(); // identiefier, now skip it - - for (int i=0;i<pattern_count;i++) { - - for(int line=0;line<64;line++) { - - for(int column=0;column<channels;column++) { - - uint32_t note_w=file->get_dword(); - - CPNote note; - - note.instrument=(note_w>>12)&0xF; - note.instrument|=(note_w>>24)&0xF0; - - if (note.instrument==0) - note.instrument=CPNote::EMPTY; - else - note.instrument--; - - note.parameter=note_w&0xFF; - - int cmd=(note_w>>8)&0xF; - - uint32_t period=(note_w>>16)&0xFFF; - - if (period>0 && period<0xFFF) { - - //period>>=2; - //period<<=1; - for (int n=0; n<6*12; n++) { - - if (period >= period_table[n]) { - - if ((period!=period_table[n]) && (n)) - { - uint32_t p1 = period_table[n-1]; - uint32_t p2 = period_table[n]; - if (p1 - period < (period - p2)) { - - note.note=n+36; - break; - } - } - note.note=n+1+36; - break; - } - } - if (note.note==CPNote::EMPTY) - note.note=6*12+36; - - note.note--; - } - - - switch(cmd) { - - case 0x0: { - - if (note.parameter>0) - note.command='J'-'A'; - } break; - case 0x1: { - note.command='F'-'A'; - } break; - case 0x2: { - - note.command='E'-'A'; - } break; - case 0x3: { - - note.command='G'-'A'; - } break; - case 0x4: { - - note.command='H'-'A'; - } break; - case 0x5: { - note.command='L'-'A'; - } break; - case 0x6: { - - note.command='K'-'A'; - } break; - case 0x7: { - note.command='R'-'A'; - } break; - case 0x8: { - - note.command='X'-'A'; - } break; - case 0x9: { - - note.command='O'-'A'; - - } break; - case 0xA: { - - note.command='D'-'A'; - - } break; - case 0xB: { - - note.command='B'-'A'; - - } break; - case 0xC: { - - note.volume=note.parameter; - if (note.volume>64) - note.volume=64; - note.parameter=0; - - } break; - case 0xD: { - - note.command='C'-'A'; - note.parameter=(note.parameter>>4)*10 + (note.parameter&0xF); - - } break; - case 0xE: { //SPECIAL EFFECT! - - note.command='S'-'A'; - - switch(note.parameter>>4) { - - case 0x1: { - - note.command='F'-'A'; - note.parameter=0xF0|(note.parameter&0xF); - } break; - case 0x2: { - - note.command='E'-'A'; - note.parameter=0xF0|(note.parameter&0xF); - } break; - case 0x4: { - - note.command='S'-'A'; - note.parameter=0x30|(note.parameter&0x3); - - } break; - case 0x6: { - - note.command='S'-'A'; - note.parameter=0xB0|(note.parameter&0xF); - - } break; - case 0x7: { - note.command='S'-'A'; - note.parameter=0x40|(note.parameter&0x3); - - } break; - case 0x8: { - - note.command='S'-'A'; // wow, it's the same! - - } break; - case 0x9: { - note.command='Q'-'A'; - note.parameter=(note.parameter&0xF); - - } break; - case 0xA: { - - note.command='D'-'A'; - note.parameter=0xF|((note.parameter&0xF)<<4); - - } break; - case 0xB: { - note.command='D'-'A'; - note.parameter=0xF0|(note.parameter&0xF); - - } break; - case 0xC: - case 0xD: { - - note.command='S'-'A'; //wow, they are the same! - - } break; - case 0xE: { - note.command='S'-'A'; - note.parameter=0x60|(note.parameter&0xF); - - } break; - - default: { - - note.command=CPNote::EMPTY; - note.parameter=0; - } break; - - } - } break; - case 0xF: { - - if (note.parameter<32) - note.command='A'-'A'; - else - note.command='T'-'A'; - - } break; - } - - p_song->get_pattern(i)->set_note( column,line, note ); - } - } - } - - - - for (int i=0;i<instruments;i++) { - - CPSample_ID sid=p_song->get_sample(i)->get_sample_data(); - if (sid.is_null()) { - continue; //empty sample, not stored? - } - sm->lock_data(sid); - uint8_t *dataptr = (uint8_t*)sm->get_data(sid); - - int len=sm->get_size(sid); - for (int s=0;s<len;s++) { - - uint8_t d=file->get_byte(); - //d-=128; //convert to signed - int8_t*ds=(int8_t*)&d; - dataptr[s]=*ds; - - } - sm->unlock_data(sid); - } - - file->close(); - - return FILE_OK; - - -} - - -CPLoader_MOD::CPLoader_MOD(CPFileAccessWrapper *p_file) { - - file=p_file; -} - - -CPLoader_MOD::~CPLoader_MOD() -{ -} - - diff --git a/modules/chibi/cp_loader_mod.h b/modules/chibi/cp_loader_mod.h deleted file mode 100644 index 57f7128bc0..0000000000 --- a/modules/chibi/cp_loader_mod.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************/ -/* cp_loader_mod.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_LOADER_MOD_H -#define CP_LOADER_MOD_H -#include "cp_loader.h" -/** - @author Juan Linietsky <reduz@gmail.com> -*/ -class CPLoader_MOD : public CPLoader { - - CPFileAccessWrapper *file; -public: - - bool can_load_song() { return true; } - bool can_load_sample() { return false; } - bool can_load_instrument() { return false; } - - Error load_song(const char *p_file,CPSong *p_song,bool p_sampleset); - Error load_sample(const char *p_file,CPSample *p_sample) { return FILE_UNRECOGNIZED; } - Error load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx) { return FILE_UNRECOGNIZED; } - - CPLoader_MOD(CPFileAccessWrapper *p_file); - ~CPLoader_MOD(); -}; - -#endif diff --git a/modules/chibi/cp_loader_s3m.cpp b/modules/chibi/cp_loader_s3m.cpp deleted file mode 100644 index 4943e6d86c..0000000000 --- a/modules/chibi/cp_loader_s3m.cpp +++ /dev/null @@ -1,413 +0,0 @@ -/*************************************************************************/ -/* cp_loader_s3m.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_loader_s3m.h" - -#define BITBOOL(m_exp) ((m_exp)?1:0) - - -CPLoader::Error CPLoader_S3M::load_header() { - - int i; - - - file->get_byte_array((uint8_t*)header.songname,28); - header.t1a=file->get_byte(); - header.type=file->get_byte(); - file->get_byte_array((uint8_t*)header.unused1,2); - header.ordnum=file->get_word(); - header.insnum=file->get_word(); - header.patnum=file->get_word(); - header.flags=file->get_word(); - header.tracker=file->get_word(); - header.fileformat=file->get_word(); - file->get_byte_array((uint8_t*)header.scrm,4); - header.scrm[4]=0; - - if (header.scrm[0]!='S' || header.scrm[1]!='C' || header.scrm[2]!='R' || header.scrm[3]!='M') - return FILE_UNRECOGNIZED; - - header.mastervol=file->get_byte(); - header.initspeed=file->get_byte(); - header.inittempo=file->get_byte(); - header.mastermult=file->get_byte(); - header.ultraclick=file->get_byte(); - header.pantable=file->get_byte(); - file->get_byte_array((uint8_t*)header.unused2,8); - header.special=file->get_word(); - file->get_byte_array((uint8_t*)header.channels,32); - - file->get_byte_array((uint8_t*)header.orderlist,header.ordnum); - - header.scrm[4]=0; - if (header.scrm[0]!='S' || header.scrm[1]!='C' || header.scrm[2]!='R' || header.scrm[3]!='M') //again? - return FILE_UNRECOGNIZED; - //sample parapointers - for (i=0;i<header.insnum;i++) { - - int parapointer; - parapointer=file->get_word(); - parapointer=(parapointer*16); - sample_parapointers[i]=parapointer; - } - //pattern - for (i=0;i<header.patnum;i++) { - - int parapointer; - parapointer=file->get_word(); - parapointer=(parapointer*16); - pattern_parapointers[i]=parapointer; - } - - if (header.pantable==252) { - - file->get_byte_array((uint8_t*)header.pannings,32); - } - - return FILE_OK; - - -} - - -void CPLoader_S3M::set_header() { - - - - - song->set_name( header.songname ); - //song->variables.filename= - - song->set_row_highlight_minor( 4 ); - song->set_row_highlight_major( 16 ); - song->set_mixing_volume( header.mastervol ); - song->set_linear_slides( false ); - song->set_old_effects( !(header.flags&64) ); - song->set_compatible_gxx( true ); - - song->set_global_volume( header.mastermult ); - song->set_speed( header.initspeed ); - song->set_tempo( header.inittempo ); - - //[TODO] Set Panning Positions.. ? - - for (int i=0;i<header.ordnum;i++) song->set_order(i,header.orderlist[i]); - -} - -CPLoader::Error CPLoader_S3M::load_sample(CPSample *p_sample) { - - - - int type=file->get_byte(); - - char filename[13]; - file->get_byte_array((uint8_t*)filename,12); - filename[12]=0; - - - uint32_t samplepos=(uint32_t)file->get_byte() << 16; - samplepos|=file->get_word(); - samplepos*=16; - //printf("sample at %i\n",samplepos); - /**/ - int sample_size=file->get_dword(); - - - int loop_begin=file->get_dword(); - int loop_end=file->get_dword(); - - int def_volume=file->get_byte();; - int dsk=file->get_byte(); - int pack=file->get_byte(); - - int flags=file->get_byte(); - int c2speed=file->get_dword(); - - file->get_dword(); //useless crap - file->get_dword(); - file->get_dword(); - - - char name[29]; - file->get_byte_array((uint8_t*)name,28); - name[28]=0; - - p_sample->set_default_volume(def_volume); - p_sample->set_name(name); - - char scrs[5]; - file->get_byte_array((uint8_t*)scrs,4); - scrs[4]=0; - - - - bool data_is_16bits=flags&4; - bool data_is_stereo=flags&2; - - if (type==0) { - //empty sample - return FILE_OK; - } - - - if ((type!=1) || scrs[0]!='S' || scrs[1]!='C' || scrs[2]!='R' || scrs[3]!='S' ) { - //printf("type: %i, %c%c%c%c\n",type,scrs[0],scrs[1],scrs[2],scrs[3]); - CP_PRINTERR("Not an S3M CPSample!"); - return FILE_CORRUPTED; - } - - //p_sample->data.set_c5_freq(p_sample->c2spd<<1); - - file->seek(samplepos); - - int real_sample_size=sample_size<<BITBOOL(data_is_16bits); - real_sample_size<<=BITBOOL(data_is_stereo); - - CPSampleManager *sm=CPSampleManager::get_singleton(); - - CPSample_ID id =sm->create( data_is_16bits, data_is_stereo, sample_size ); - - if (id.is_null()) - return FILE_OUT_OF_MEMORY; - - sm->lock_data(id); - void *dataptr = sm->get_data(id); - - int chans = (data_is_stereo?2:1); - for (int c=0;c<chans;c++) { - for (int i=0;i<sample_size;i++) { - - if (data_is_16bits) { - - uint16_t s=file->get_word(); - s-=32768; //toggle sign - - int16_t *v=(int16_t*)&s; - ((int16_t*)dataptr)[i*chans+c]=*v; - } else { - - - int8_t *v; - uint8_t s=file->get_byte(); - s-=128; //toggle sign - v=(int8_t*)&s; - ((int8_t*)dataptr)[i*chans+c]=*v; - - } - - } - - } - - sm->unlock_data(id); - - - sm->set_loop_begin( id, loop_begin ); - sm->set_loop_end( id, loop_end ); - sm->set_loop_type( id, (flags&1) ? CP_LOOP_FORWARD : CP_LOOP_NONE ); - sm->set_c5_freq( id, c2speed << 1 ); - p_sample->set_sample_data(id); - - /* Scream tracker previous to 3.10 seems to be buggy, as in, wont save what is after the sample loop, including the loop end point. Because of this I must fix it by habd */ - if (flags&1) { - - for (int c=0;c<(data_is_stereo?2:1);c++) { - sm->set_data( id, loop_end, sm->get_data( id, loop_begin,c ),c ); - - } - } - - - return FILE_OK; - -} - - -CPLoader::Error CPLoader_S3M::load_pattern(CPPattern *p_pattern) { - - int row=0,flag,ch; - CPNote n; - int length,accum=0; - - length=file->get_word(); - p_pattern->set_length(64); - - /* clear pattern data */ - while((row<64) && (accum<=length) ) { - flag=file->get_byte(); - accum++; - - n.clear(); - if(flag) { - // ch=remap[flag&31]; -// ch=remap[flag&31]; -// if(ch!=-1) -// n=s3mbuf[(64U*ch)+row]; -// else -// n=&dummy; - - ch=flag&31; - - if(flag&32) { - n.note=file->get_byte(); - if (n.note==255) { - - n.note=CPNote::EMPTY; - } else if (n.note==254) { - - n.note=CPNote::CUT; - } else { - - n.note=((n.note>>4)*12)+(n.note&0xF); - } - - n.instrument=file->get_byte()-1; - accum+=2; - - } - if(flag&64) { - n.volume=file->get_byte(); - if (n.volume>64) n.volume=64; - accum++; - - } - if(flag&128) { - n.command=file->get_byte()-1; - n.parameter=file->get_byte(); - accum+=2; - } - - p_pattern->set_note(ch,row,n); - } else row++; - } - return FILE_OK; - - -} - -CPLoader::Error CPLoader_S3M::load_sample(const char *p_file,CPSample *p_sample) { - - return FILE_UNRECOGNIZED; -} -CPLoader::Error CPLoader_S3M::load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx) { - - return FILE_UNRECOGNIZED; - -} - - -CPLoader::Error CPLoader_S3M::load_samples() { - - int i; - - for(i=0;i<header.insnum;i++) { - - file->seek(sample_parapointers[i]); - load_sample(song->get_sample(i)); - sample_count++; - } - - return FILE_OK; -} - -CPLoader::Error CPLoader_S3M::load_patterns() { - - int i; - - Error err; - for(i=0;i<header.patnum;i++) { - - file->seek(pattern_parapointers[i]); - - err=load_pattern(song->get_pattern(i) ); - CP_ERR_COND_V(err,err); - - - pattern_count++; - } - return FILE_OK; - -} - -CPLoader::Error CPLoader_S3M::load_song(const char *p_file,CPSong *p_song,bool p_sampleset) { - - song=p_song; - - if (file->open(p_file,CPFileAccessWrapper::READ)) { - //printf("Can't open file! %s\n",p_file); - return FILE_CANNOT_OPEN; - }; - - sample_count=0; - pattern_count=0; - - //printf("LOADING HEADER\n"); - CPLoader::Error err; - if ((err=load_header())) { - file->close(); - CP_ERR_COND_V(err,err); - - } - - song->reset(); //file type recognized, reset song! - - set_header(); - - //printf("LOADING SAMPLES\n"); - - if ((err=load_samples())) { - file->close(); - - CP_ERR_COND_V(err,err); - } - - //printf("LOADING PATTERNS\n"); - - if ((err=load_patterns())) { - - file->close(); - return err; - } - - file->close(); - - return FILE_OK; -} - - - -CPLoader_S3M::CPLoader_S3M(CPFileAccessWrapper *p_file){ - - file=p_file; - -} -CPLoader_S3M::~CPLoader_S3M(){ -} - diff --git a/modules/chibi/cp_loader_s3m.h b/modules/chibi/cp_loader_s3m.h deleted file mode 100644 index 04ee0b2917..0000000000 --- a/modules/chibi/cp_loader_s3m.h +++ /dev/null @@ -1,111 +0,0 @@ -/*************************************************************************/ -/* cp_loader_s3m.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_LOADER_S3M_H -#define CP_LOADER_S3M_H - -#include "cp_loader.h" - -/** - *@author Juan Linietsky - */ -/****************************** - loader_s3m.h - ---------- -Scream Tracker Module CPLoader! -It lacks support for -individual sample loading -and reorganizing the columns. -********************************/ - - - - -class CPLoader_S3M : public CPLoader { - - struct S3M_Header { - char songname[28]; - uint8_t t1a; - uint8_t type; - uint8_t unused1[2]; - uint16_t ordnum; - uint16_t insnum; - uint16_t patnum; - uint16_t flags; - uint16_t tracker; - uint16_t fileformat; - char scrm[5]; - uint8_t mastervol; - uint8_t initspeed; - uint8_t inittempo; - uint8_t mastermult; - uint8_t ultraclick; - uint8_t pantable; - uint8_t unused2[8]; - uint16_t special; - uint8_t channels[32]; - uint8_t pannings[32]; - uint8_t orderlist[300]; - }; - - - int sample_parapointers[CPSong::MAX_SAMPLES]; - int pattern_parapointers[CPSong::MAX_PATTERNS]; - - Error load_header(); - void set_header(); - Error load_sample(CPSample *p_sample); - Error load_pattern(CPPattern *p_pattern); - Error load_patterns(); - - Error load_samples(); - - S3M_Header header; - int sample_count; - int pattern_count; - - CPFileAccessWrapper *file; - CPSong *song; -public: - - bool can_load_song() { return true; } - bool can_load_sample() { return false; } - bool can_load_instrument() { return false; } - - Error load_song(const char *p_file,CPSong *p_song,bool p_sampleset); - Error load_sample(const char *p_file,CPSample *p_sample); - Error load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx); - - CPLoader_S3M(CPFileAccessWrapper *p_file); - ~CPLoader_S3M(); -}; - - - -#endif diff --git a/modules/chibi/cp_loader_xm.cpp b/modules/chibi/cp_loader_xm.cpp deleted file mode 100644 index cbd883642c..0000000000 --- a/modules/chibi/cp_loader_xm.cpp +++ /dev/null @@ -1,752 +0,0 @@ -/*************************************************************************/ -/* cp_loader_xm.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_loader_xm.h" -#include "cp_tables.h" - -#define ABORT_LOAD { file->close(); return FILE_CORRUPTED; } - - - - -CPLoader::Error CPLoader_XM::load_song(const char *p_file,CPSong *p_song,bool p_sampleset) { - - song=p_song; - - if (file->open(p_file,CPFileAccessWrapper::READ)) { - - return FILE_CANNOT_OPEN; - }; - - - /************************************** - LOAD HEADER - ***************************************/ - - file->get_byte_array(header.idtext,17); - header.idtext[17]=0; - - file->get_byte_array(header.songname,20); - - - - header.songname[20]=0; - header.hex1a=file->get_byte(); - if (header.hex1a!=0x1A) { //XM "magic" byte.. this sucks :) - - file->close(); - return FILE_UNRECOGNIZED; - - } - - - //magic byte sucks, but can't do much about it.. - - song->reset(); //must reset the song - - song->set_name( (const char*)header.songname ); - - file->get_byte_array(header.trackername,20); - header.trackername[20]=0; - - - header.version=file->get_word(); - - header.headersize=file->get_dword(); - - header.songlength=file->get_word(); - - header.restart_pos=file->get_word(); - - header.channels_used=file->get_word(); - - header.patterns_used=file->get_word(); - - header.instruments_used=file->get_word(); - - song->set_linear_slides( file->get_word() ); - - song->set_speed( file->get_word() ); - - song->set_tempo( file->get_word() ); - song->set_instruments( true ); - - file->get_byte_array(header.orderlist,256); - - for (int i=0;i<header.songlength;i++) { - - if (i>199) - break; - song->set_order(i,header.orderlist[i]); - } - - /************************************** - LOAD PATTERNS - ***************************************/ - - for (int i=0;i<header.patterns_used;i++) { - - uint32_t aux,rows; - - aux=file->get_dword(); //length - aux=file->get_byte(); //packing type - rows=aux=file->get_word(); //rows! - - song->get_pattern(i)->set_length( aux ); - - aux=file->get_word(); //packed size - if (aux==0) - continue; - //unpaaack! - for(int j=0;j<(int)rows;j++) - for(int k=0;k<header.channels_used;k++) { - - CPNote aux_note; - uint8_t aux_byte; - //uint8_t field; - aux_byte=file->get_byte(); //packing type - if (!(aux_byte&0x80)) { - - aux_note.note=aux_byte; - aux_byte=0xFE; //if bit 7 not set, read all of them except the note - } - - if (aux_byte&1) aux_note.note=file->get_byte(); - if (aux_byte&2) aux_note.instrument=file->get_byte(); - if (aux_byte&4) aux_note.volume=file->get_byte(); - if (aux_byte&8) aux_note.command=file->get_byte(); - if (aux_byte&16) aux_note.parameter=file->get_byte(); - - if (aux_note.note!=CPNote::EMPTY) { - - if (aux_note.note==97) aux_note.note=CPNote::OFF; - else { - aux_note.note+=11; //octave minus one (XM C-0 is 1, not zero ) - } - } - if (aux_note.instrument!=CPNote::EMPTY) { - - if ((aux_note.instrument>0) && (aux_note.instrument<100)) - aux_note.instrument--; - else - aux_note.instrument=CPNote::EMPTY; - } - if (aux_note.volume!=CPNote::EMPTY) { - - if (aux_note.volume<0x10) {} - else if (aux_note.volume<0x50) { - - aux_note.volume-=0x10; - - } else if (aux_note.volume<0x60) { - // - aux_note.volume=CPNote::EMPTY; - - } else if (aux_note.volume<0x70) { - //60 -- volume slide down - aux_note.volume-=0x60; - if (aux_note.volume>9) aux_note.volume=9; - aux_note.volume+=95; - - } else if (aux_note.volume<0x80) { - //70 -- volume slide up - aux_note.volume-=0x70; - if (aux_note.volume>9) aux_note.volume=9; - aux_note.volume+=85; - - - } else if (aux_note.volume<0x90) { - //80 -- fine volume slide down - aux_note.volume-=0x80; - if (aux_note.volume>9) aux_note.volume=9; - aux_note.volume+=75; - - - } else if (aux_note.volume<0xA0) { - //9 -- fine volume slide up - - aux_note.volume-=0x90; - if (aux_note.volume>9) aux_note.volume=9; - - aux_note.volume+=65; - - - - } else if (aux_note.volume<0xB0) { - //A -- set vibrato speed - aux_note.volume=CPNote::EMPTY; - - } else if (aux_note.volume<0xC0) { - //B -- vibrato - aux_note.volume-=0xB0; - if (aux_note.volume>9) aux_note.volume=9; - aux_note.volume+=203; - - - } else if (aux_note.volume<0xD0) { - //C -- set panning - int aux=aux_note.volume-=0xC0; - aux=aux*65/0xF; - aux_note.volume=128+aux; - - } else if (aux_note.volume<0xE0) { - aux_note.volume=CPNote::EMPTY; - - - } else if (aux_note.volume<0xF0) { - aux_note.volume=CPNote::EMPTY; - - - } else { - //F -- tone porta - aux_note.volume-=0xF0; - aux_note.volume*=9; - aux_note.volume/=0xF; - aux_note.volume+=193; - } - } - if (aux_note.command!=CPNote::EMPTY) { - - switch(aux_note.command) { - - case 0x0: - aux_note.command='J'-'A'; - break; - case 0x1: - aux_note.command='F'-'A'; - break; - case 0x2: - aux_note.command='E'-'A'; - break; - case 0x3: - aux_note.command='G'-'A'; - break; - case 0x4: - aux_note.command='H'-'A'; - break; - case 0x5: - aux_note.command='L'-'A'; - break; - case 0x6: - aux_note.command='K'-'A'; - break; - case 0x7: - aux_note.command='R'-'A'; - break; - case 0x8: - aux_note.command='X'-'A'; - break; - case 0x9: - aux_note.command='O'-'A'; - break; - case 0xa: - aux_note.command='D'-'A'; - break; - case 0xb: - aux_note.command='B'-'A'; - break; - case 0xc: - //printf("XM Import: Warning! effect C (set volume) not implemented!\n"); - break; - case 0xd: - aux_note.command='C'-'A'; - break; - - case 0xe: /* Extended effects */ - - aux_note.command='S'-'A'; - switch(aux_note.parameter>>4) { - case 0x1: /* XM fine porta up */ - if (!(aux_note.parameter&0xF)) { aux_note.command=CPNote::EMPTY; aux_note.parameter=0; break; } - aux_note.command='F'-'A'; - aux_note.parameter=0xF0|(aux_note.parameter&0xF); - break; - case 0x2: /* XM fine porta down */ - if (!(aux_note.parameter&0xF)) { aux_note.command=CPNote::EMPTY; aux_note.parameter=0; break; } - aux_note.command='E'-'A'; - aux_note.parameter=0xF0|(aux_note.parameter&0xF); - break; - case 0xa: /* XM fine volume up */ - if (!(aux_note.parameter&0xF)) { aux_note.command=CPNote::EMPTY; aux_note.parameter=0; break; } - aux_note.command='D'-'A'; - aux_note.parameter=0x0F|((aux_note.parameter&0xF)<<4); - - break; - case 0xb: /* XM fine volume down */ - if (!(aux_note.parameter&0xF)) { aux_note.command=CPNote::EMPTY; aux_note.parameter=0; break; } - aux_note.command='D'-'A'; - aux_note.parameter=0xF0|(aux_note.parameter&0xF); - - break; - case 0x9: /* XM fine volume down */ - if (!(aux_note.parameter&0xF)) { aux_note.command=CPNote::EMPTY; aux_note.parameter=0; break; } - aux_note.command='Q'-'A'; - aux_note.parameter=0x00|(aux_note.parameter&0xF); - break; - - case 0xc: //notecut - - aux_note.parameter=0xC0|(aux_note.parameter&0xF); - break; - - case 0xd: //notedelay - - aux_note.parameter=0xD0|(aux_note.parameter&0xF); - break; - - case 0xe: //patterndelay - - aux_note.parameter=0xE0|(aux_note.parameter&0xF); - break; - } - - break; - case 0xf: - if (aux_note.parameter<32) { - aux_note.command='A'-'A'; - } else { - aux_note.command='T'-'A'; - } - break; - case 'G'-55: - aux_note.command='V'-'A'; - break; - case 'H'-55: - aux_note.command='W'-'A'; - break; - case 'K'-55: - if (aux_note.note!=CPNote::EMPTY) break; - aux_note.note=CPNote::OFF; - break; - case 'P'-55: - aux_note.command='P'-'A'; - break; - case 'R'-55: - aux_note.command='Q'-'A'; - break; - case 'T'-55: - aux_note.command='I'-'A'; - break; - default: { - - aux_note.command=CPNote::EMPTY; - } - } - - - } - - song->get_pattern( i)->set_note( k,j,aux_note ); - } - } - - /************************************** - LOAD INSTRUMENTS! - ***************************************/ - - for (int i=0;i<header.instruments_used;i++) { - - - uint32_t aux; - int sampnum; - - CPInstrument &instrument=*song->get_instrument(i); - uint32_t cpos=file->get_pos(); - //printf("pos is %i\n",cpos); - - - -/* +4 */ uint32_t hsize=file->get_dword(); //header length - - char instrname[23]; - instrname[22]=0; - - file->get_byte_array((uint8_t*)instrname,22); -//XM_LOAD_DEBUG printf("name is %s\n",instrname); - -/* +27 */ aux=file->get_byte(); //byte that must be ignored -//XM_LOAD_DEBUG printf("header size is %i\n",hsize); - -/* +29 */ sampnum=file->get_word(); - -//XM_LOAD_DEBUG printf("samples %i\n",sampnum); - - - instrument.set_name( instrname ); - //printf("Header Len: %i, CPInstrument %i, %i samples , name: s,\n",hsize,i,sampnum,instrname); - - if (sampnum==0) { - //aux=file->get_dword(); //Why is this for? -- for nothing, skipped - if (hsize) { - - file->seek( cpos+hsize ); //skip header if size has been specified - } - continue; - } - -/* +33 */ file->get_dword(); - - if (Error result=load_instrument_internal(&instrument,false,cpos,hsize,sampnum)) { - - CP_PRINTERR("Error loading instrument"); - file->close(); - return result; - } - - } -// - file->close(); - return FILE_OK; -} - -CPLoader::Error CPLoader_XM::load_instrument_internal(CPInstrument *p_instr,bool p_xi,int p_cpos, int p_hsize, int p_sampnum) { - - int sampnum; - uint32_t aux; - uint8_t notenumb[96]; - uint16_t panenv[24],volenv[24]; - int volpoints,panpoints; - int vol_loop_begin,vol_loop_end,vol_sustain_loop; - int pan_loop_begin,pan_loop_end,pan_sustain_loop; - char instrname[23]; - int sample_index[16]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; //-1 means no index! - - instrname[22]=0; - - -/* +129 */ file->get_byte_array((uint8_t*)notenumb,96); - for (int j=0;j<24;j++) { - volenv[j]=file->get_word(); - } - for (int j=0;j<24;j++) { - panenv[j]=file->get_word(); - } - -/* +177 */ -/* +225 */ -/* +226 */ volpoints=file->get_byte(); -/* +227 */ panpoints=file->get_byte(); -/* +230 */ vol_sustain_loop=file->get_byte(); -/* +228 */ vol_loop_begin=file->get_byte(); -/* +229 */ vol_loop_end=file->get_byte(); - -//XM_LOAD_DEBUG printf("1- volpoints: %i, panpoints: %i, susloop: %i, loop begin: %i, loop end %i\n",volpoints,panpoints,vol_sustain_loop,vol_loop_begin,vol_loop_end); - pan_sustain_loop=file->get_byte(); -/* +231 */ pan_loop_begin=file->get_byte(); -/* +232 */ pan_loop_end=file->get_byte(); - - - -/* +234 */ aux=file->get_byte(); - p_instr->get_volume_envelope()->reset(); - p_instr->get_volume_envelope()->set_enabled(aux&1); - p_instr->get_volume_envelope()->set_sustain_loop_enabled((aux&2)?true:false); - p_instr->get_volume_envelope()->set_loop_enabled((aux&4)?true:false); -/* +235 */ aux=file->get_byte(); - p_instr->get_pan_envelope()->reset(); - p_instr->get_pan_envelope()->set_enabled(aux&1); - p_instr->get_pan_envelope()->set_sustain_loop_enabled((aux&2)?true:false); - p_instr->get_pan_envelope()->set_loop_enabled((aux&4)?true:false); - -/* +239 */ aux=file->get_dword(); // sadly, cant use those -/* +241 */ p_instr->set_volume_fadeout( file->get_word() >> 4 ); -/* +243 */ aux=file->get_word(); // reserved! - - - - for (int j=0;j<volpoints;j++) { - int ofs=volenv[j*2]; - int val=volenv[j*2+1]; - p_instr->get_volume_envelope()->add_position(ofs,val); - - } - - //make sure minimum is 2 - while (p_instr->get_volume_envelope()->get_node_count()<2) { - - p_instr->get_volume_envelope()->add_position( p_instr->get_volume_envelope()->get_node_count()*20,64 ); - } - - for (int j=0;j<panpoints;j++) { - int ofs=panenv[j*2]; - int val=panenv[j*2+1]; - p_instr->get_pan_envelope()->add_position(ofs,val-32); - } - - //make sure minimum is 2 - while (p_instr->get_pan_envelope()->get_node_count()<2) { - - p_instr->get_pan_envelope()->add_position( p_instr->get_pan_envelope()->get_node_count()*20,0 ); - } - - - p_instr->get_volume_envelope()->set_loop_begin(vol_loop_begin); - p_instr->get_volume_envelope()->set_loop_end(vol_loop_end); - p_instr->get_volume_envelope()->set_sustain_loop_end(vol_sustain_loop); - p_instr->get_volume_envelope()->set_sustain_loop_begin(vol_sustain_loop); - p_instr->get_pan_envelope()->set_loop_begin(pan_loop_begin); - p_instr->get_pan_envelope()->set_loop_end(pan_loop_end); - p_instr->get_pan_envelope()->set_sustain_loop_end(pan_sustain_loop); - p_instr->get_pan_envelope()->set_sustain_loop_begin(pan_sustain_loop); - - - if (!p_xi) { - - if ((file->get_pos()-p_cpos)<p_hsize) { - - uint8_t junkbuster[500]; - - //printf("extra junk XM instrument in header! hsize is %i, extra junk: %i\n",p_hsize,(file->get_pos()-p_cpos)); - //printf("extra: %i\n",p_hsize-(file->get_pos()-p_cpos)); - file->get_byte_array((uint8_t*)junkbuster,p_hsize-(file->get_pos()-p_cpos)); - } - - sampnum=p_sampnum; - } else { - - uint8_t junkbuster[500]; - file->get_byte_array((uint8_t*)junkbuster,20); //14 bytes? - - sampnum=file->get_word(); - - } - - - CPSampleManager *sm=CPSampleManager::get_singleton(); - - /*SAMPLE!!*/ - - for (int j=0;j<sampnum;j++) { - - if (j>16) ABORT_LOAD; - - - int s_idx=-1; - for (int s=0;s<CPSong::MAX_SAMPLES;s++) { - - if (song->get_sample(s)->get_sample_data().is_null()) { - //empty sample! - s_idx=s; - break; - } - } - - if (s_idx==-1) ABORT_LOAD; - //printf("free sample: %i\n",s_idx); - - - CPSample& sample=*song->get_sample(s_idx); - - int sample_size=file->get_dword(); - int tmp_loop_begin=file->get_dword(); - - int tmp_loop_end=file->get_dword(); - - sample.set_default_volume(file->get_byte()); - - uint8_t ftb=file->get_byte(); - int8_t *fts=(int8_t*)&ftb; - int finetune=*fts; - uint32_t flags=file->get_byte(); - - if (flags&16) { // is 16 bits.. at flag 16.. fun :) - - tmp_loop_end/=2; - tmp_loop_begin/=2; - sample_size/=2; - } - - - CPSample_ID sample_data=sm->create( flags&16, false, sample_size ); - - sample.set_sample_data(sample_data); - sm->set_loop_begin(sample_data,tmp_loop_begin); - sm->set_loop_end(sample_data,tmp_loop_end+tmp_loop_begin); - - sm->set_loop_type( sample_data, (flags&3)?( (flags&2) ? CP_LOOP_BIDI : CP_LOOP_FORWARD ):CP_LOOP_NONE ); - - - - sample.set_pan_enabled(true); - sample.set_pan(file->get_byte()*64/255); - uint8_t noteb=file->get_byte(); - int8_t *notes=(int8_t*)¬eb; - int note_offset=*notes; - note_offset+=48; - //note_offset+=60; - - - - //int linear_period=10*12*16*4 - (note_offset)*16*4 - finetune/2; - //int freq=(int)(8363*pow(2.0,(double)(6*12*16*4 - linear_period) / (double)(12*16*4))); - - //sm->set_c5_freq( sample_data, freq); - sm->set_c5_freq( sample_data, CPTables::get_linear_frequency(CPTables::get_linear_period(note_offset<<1,finetune)) ); - //printf("NOTE %i,fine %i\n",note_offset,finetune); - - char auxb; - auxb=file->get_byte(); //reserved? - file->get_byte_array((uint8_t*)instrname,22); - sample.set_name(instrname); - - sample_index[j]=s_idx; - } - - /*SAMPLE __DATA__!!*/ - - for (int j=0;j<sampnum;j++) { - - if (sample_index[j]==-1) continue; - - CPSample *sample=song->get_sample(sample_index[j]); - CPSample_ID sid=sample->get_sample_data(); - - sm->lock_data(sid); - - void*dataptr=sm->get_data(sid); - - if (sm->is_16bits( sid)) { - - int16_t old=0; - - - for (int k=0;k<sm->get_size(sid);k++) { - - int16_t newsample; - int16_t sampleval=file->get_word(); - newsample=sampleval+old; - old=newsample; - - ((int16_t*)dataptr)[k]=newsample; - //sm->set_data( sid, k, newsample ); - } - } else { - - int8_t old=0; - - - for (int k=0;k<sm->get_size(sid);k++) { - - int8_t newsample; - int8_t sampleval=file->get_byte(); - newsample=sampleval+old; - old=newsample; - - ((int8_t*)dataptr)[k]=newsample; - - //sm->set_data( sid, k, (int16_t)newsample << 8 ); - - } - } - - sm->unlock_data(sid); - - } - - for (int j=0;j<96;j++) { - - int val=notenumb[j]; - if ((val<0) || (val>15)) continue; - else val=sample_index[val]; - if (val==-1) continue; - p_instr->set_sample_number( 12+j,val ); - } - - - return FILE_OK; -} - - - -CPLoader::Error CPLoader_XM::load_sample(const char *p_file,CPSample *p_sample) { - - return FILE_UNRECOGNIZED; -} - - -/* Compute CPInstrument Info */ -CPLoader::Error CPLoader_XM::load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx) { - - if ( file->open(p_file,CPFileAccessWrapper::READ) ) return FILE_CANNOT_OPEN; - //int i; - song=p_song; - CPInstrument& instr=*p_song->get_instrument( p_instr_idx ); - int aux; - - - char buffer[500]; - file->get_byte_array((uint8_t*)buffer,0x15); - buffer[8]=0; - if ( buffer[0]!='E' || - buffer[1]!='x' || - buffer[2]!='t' || - buffer[3]!='e' || - buffer[4]!='n' || - buffer[5]!='d' || - buffer[6]!='e' || - buffer[7]!='d') { - file->close(); - return FILE_UNRECOGNIZED; - } - - file->get_byte_array((uint8_t*)buffer,0x16); - buffer[0x16]=0; - instr.set_name(buffer); - aux=file->get_byte(); //says ignore ti - /*if(aux!=0x1a) { I'm not sure. this is supposed to be ignored... - - file->close(); - return FILE_UNRECOGNIZED; - } */ - - file->get_byte_array((uint8_t*)buffer,0x14); //somethingaboutthename - aux=file->get_word(); //version or blahblah - - if (load_instrument_internal(&instr,true,0,0)) { - - file->close(); - return FILE_CORRUPTED; - } - - file->close(); //ook, we got it.. - - - return FILE_OK; - -} - - - -CPLoader_XM::CPLoader_XM(CPFileAccessWrapper *p_file){ - - file=p_file; -} -CPLoader_XM::~CPLoader_XM(){ -} - diff --git a/modules/chibi/cp_loader_xm.h b/modules/chibi/cp_loader_xm.h deleted file mode 100644 index 0889569b38..0000000000 --- a/modules/chibi/cp_loader_xm.h +++ /dev/null @@ -1,89 +0,0 @@ -/*************************************************************************/ -/* cp_loader_xm.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_LOADER_XM_H -#define CP_LOADER_XM_H - -#include "cp_loader.h" - - -/** - *@author red - */ - - - - -class CPLoader_XM : public CPLoader { - - - struct XM_Header { - - uint8_t idtext[18]; - uint8_t songname[21]; - uint8_t hex1a; // ? - uint8_t trackername[21]; - uint16_t version; - uint32_t headersize; //from here - - uint16_t songlength; //pattern ordertable - uint16_t restart_pos; - uint16_t channels_used; - uint16_t patterns_used; - uint16_t instruments_used; - uint16_t use_linear_freq; - uint16_t tempo; - uint16_t speed; - uint8_t orderlist[256]; - - } header; - - CPFileAccessWrapper *file; - - Error load_instrument_internal(CPInstrument *pint,bool p_xi,int p_cpos, int p_hsize, int p_sampnumb=-1); - CPSong *song; - -public: - - bool can_load_song() { return true; } - bool can_load_sample() { return false; } - bool can_load_instrument() { return true; } - - Error load_song(const char *p_file,CPSong *p_song,bool p_sampleset); - Error load_sample(const char *p_file,CPSample *p_sample); - Error load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx); - - - CPLoader_XM(CPFileAccessWrapper *p_file); - ~CPLoader_XM(); -}; - - - -#endif diff --git a/modules/chibi/cp_mixer.h b/modules/chibi/cp_mixer.h deleted file mode 100644 index d8564bae00..0000000000 --- a/modules/chibi/cp_mixer.h +++ /dev/null @@ -1,115 +0,0 @@ -/*************************************************************************/ -/* cp_mixer.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_MIXER_H -#define CP_MIXER_H - -#include "cp_sample_defs.h" - -/**Abstract base class representing a mixer - *@author Juan Linietsky - */ - - -/****************************** - mixer.h - ---------- - -Abstract base class for the mixer. -This is what the player uses to setup -voices and stuff.. this way -it can be abstracted to hardware -devices or other stuff.. -********************************/ - -class CPSample_ID; /* need this */ - -class CPMixer { -public: - - enum { - - FREQUENCY_BITS=8 - - }; - - enum ReverbMode { - REVERB_MODE_ROOM, - REVERB_MODE_STUDIO_SMALL, - REVERB_MODE_STUDIO_MEDIUM, - REVERB_MODE_STUDIO_LARGE, - REVERB_MODE_HALL, - REVERB_MODE_SPACE_ECHO, - REVERB_MODE_ECHO, - REVERB_MODE_DELAY, - REVERB_MODE_HALF_ECHO - }; - - /* Callback */ - - virtual void set_callback_interval(int p_interval_us)=0; //in usecs, for tracker it's 2500000/tempo - virtual void set_callback(void (*p_callback)(void*),void *p_userdata)=0; - - /* Voice Control */ - - virtual void setup_voice(int p_voice_index,CPSample_ID p_sample_id,int32_t p_start_index) =0; - virtual void stop_voice(int p_voice_index) =0; - virtual void set_voice_frequency(int p_voice_index,int32_t p_freq) =0; //in freq*FREQUENCY_BITS - virtual void set_voice_panning(int p_voice_index,int p_pan) =0; - virtual void set_voice_volume(int p_voice_index,int p_vol) =0; - virtual void set_voice_filter(int p_filter,bool p_enabled,uint8_t p_cutoff, uint8_t p_resonance )=0; - virtual void set_voice_reverb_send(int p_voice_index,int p_reverb)=0; - virtual void set_voice_chorus_send(int p_voice_index,int p_chorus)=0; /* 0 - 255 */ - - virtual void set_reverb_mode(ReverbMode p_mode)=0; - virtual void set_chorus_params(unsigned int p_delay_ms,unsigned int p_separation_ms,unsigned int p_depth_ms10,unsigned int p_speed_hz10)=0; - - - /* Info retrieving */ - - virtual int32_t get_voice_sample_pos_index(int p_voice_index) =0; - virtual int get_voice_panning(int p_voice_index) =0; - virtual int get_voice_volume(int p_voice_index) =0; - virtual CPSample_ID get_voice_sample_id(int p_voice_index) =0; - virtual bool is_voice_active(int p_voice_index) =0; - virtual int get_active_voice_count()=0; - virtual int get_total_voice_count()=0; - - - virtual uint32_t get_mix_frequency()=0; //if mixer is not software, return 0 - - /* Methods below only work with software mixers, meant for software-based sound drivers, hardware mixers ignore them */ - virtual int32_t process(int32_t p_frames)=0; /* Call this to process N frames, returns how much it was processed */ - virtual int32_t *get_mixdown_buffer_ptr()=0; /* retrieve what was mixed */ - virtual void set_mix_frequency(int32_t p_mix_frequency)=0; - - virtual ~CPMixer() {} -}; - -#endif diff --git a/modules/chibi/cp_note.h b/modules/chibi/cp_note.h deleted file mode 100644 index f9a3ef39fc..0000000000 --- a/modules/chibi/cp_note.h +++ /dev/null @@ -1,102 +0,0 @@ -/*************************************************************************/ -/* cp_note.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_NOTE_H -#define CP_NOTE_H - -#include "cp_config.h" - -struct CPNote { - - enum { - - NOTES=120, - OFF=254, - CUT=253, - EMPTY=255, - SCRIPT=252, - }; - - - uint8_t note; - uint8_t instrument; - uint8_t volume; - uint8_t command; - uint8_t parameter; - unsigned int script_source_sign; - bool cloned; - - void clear() { - - note=EMPTY; - instrument=EMPTY; - volume=EMPTY; - command=EMPTY; - parameter=0; - script_source_sign='\0'; - cloned=false; - } - - void raise() { - - if (note<(NOTES-1)) - note++; - else if (note==SCRIPT && parameter<0xFF) - parameter++; - } - - void lower() { - - if ((note>0) && (note<NOTES)) - note--; - else if (note==SCRIPT && parameter>0) - parameter--; - - } - - bool operator== (const CPNote &rvalue) { - - return ( - (note==rvalue.note) && - (instrument==rvalue.instrument) && - (volume==rvalue.volume) && - (command==rvalue.command) && - (parameter==rvalue.parameter) - ); - } - - bool is_empty() const { return (note==EMPTY && instrument==EMPTY && volume==EMPTY && command==EMPTY && parameter==0 && !cloned); } - CPNote() { - - clear(); - } -}; - - -#endif - diff --git a/modules/chibi/cp_order.h b/modules/chibi/cp_order.h deleted file mode 100644 index 8df67df40c..0000000000 --- a/modules/chibi/cp_order.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************/ -/* cp_order.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_ORDER_H -#define CP_ORDER_H - - -#include "cp_config.h" - -enum CPOrderType { - CP_ORDER_NONE=255, - CP_ORDER_BREAK=254 -}; - -typedef uint8_t CPOrder; - -#endif - diff --git a/modules/chibi/cp_pattern.cpp b/modules/chibi/cp_pattern.cpp deleted file mode 100644 index 8671b6247d..0000000000 --- a/modules/chibi/cp_pattern.cpp +++ /dev/null @@ -1,574 +0,0 @@ -/*************************************************************************/ -/* cp_pattern.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_pattern.h" - -void CPPattern::clear() { - - if (event_count>0) { - - - CP_FREE(events); - events=NULL; - event_count=0; - } - - length=DEFAULT_LEN; - -} - - -bool CPPattern::resize_event_list_to(uint32_t p_events) { - - - //Module is slow in some cpus, so this should be fast enough - uint32_t new_size=((p_events-1)&(~((1<<RESIZE_EVERY_BITS)-1)))+(1<<RESIZE_EVERY_BITS); - - CP_ERR_COND_V(new_size<p_events,true); //bugARM_INFO - - if (event_count==0 && new_size==0) - return false; //nothing to do - - if (event_count==0) { - - events=(Event*)CP_ALLOC( new_size*sizeof(Event) ); - - } else if (new_size==0) { - - CP_FREE(events); - events=NULL; - } else { - - CP_ERR_COND_V(events==NULL,true); - events=(Event*)CP_REALLOC(events, new_size*sizeof(Event)); - - } - - event_count=p_events; - - return false; -} - - -int32_t CPPattern::get_event_pos(uint16_t p_target_pos) { - - - if (event_count==0) - return -1; - - int low = 0; - int high = event_count -1; - int middle; - - while( low <= high ) - { - middle = ( low + high ) / 2; - - if( p_target_pos == events[middle].pos ) { //match - break; - } else if( p_target_pos < events[middle].pos ) - high = middle - 1; //search low end of array - else - low = middle + 1; //search high end of array - } - - /* adapt so we are behind 2 */ - - if (events[middle].pos<p_target_pos) - middle++; - return middle; - - /* Linear search for now */ - - /* - int32_t pos_idx=0; - - for (;pos_idx<event_count;pos_idx++) { - - if (event_list[pos_idx].pos>=p_target_pos) - break; - - } */ - - //return pos_idx; -} - -bool CPPattern::erase_event_at_pos(uint16_t p_pos) { - - if (event_count==0) - return false; - - - - Event *event_list=events; - - int32_t pos_idx = get_event_pos(p_pos); - if (pos_idx==-1) { - CP_ERR_COND_V(pos_idx==-1,true); - } - - if (pos_idx==event_count || event_list[pos_idx].pos!=p_pos) { - /* Nothing to Erase */ - return false; - } - - for (int32_t i=pos_idx;i<(event_count-1);i++) { - - event_list[i]=event_list[i+1]; - } - - - resize_event_list_to(event_count-1); - - return false; -} - -bool CPPattern::set_note(uint8_t p_column, uint16_t p_row,const CPNote& p_note) { - - CP_ERR_COND_V(p_column>=WIDTH,true); - CP_ERR_COND_V(p_row>=length,true); - - int32_t new_pos; - uint16_t target_pos=p_row*WIDTH+p_column; - - - - if (p_note.is_empty()) { - bool res=erase_event_at_pos(target_pos); - - return res;; - } - - Event *event_list=0; - - if (event_count==0) { - /* If no events, create the first */ - - if (resize_event_list_to(1)) { - - CP_PRINTERR("Can't resize event list to 1"); - return true; - } - - event_list=events; - if (event_list==0) { - - - CP_PRINTERR("Can't get event list"); - return true; - } - - new_pos=0; - - } else { - /* Prepare to add */ - - event_list=events; - if (event_list==0) { - - - CP_PRINTERR("Can't get event list"); - return true; - } - - int32_t pos_idx = get_event_pos(target_pos); - - if (pos_idx==-1) { - - - CP_PRINTERR("Can't find add position"); - return true; - } - - - if (pos_idx==event_count || event_list[pos_idx].pos!=target_pos) { - /* If the note being modified didnt exist, then we add it */ - - //resize, and return if out of mem - if (resize_event_list_to( event_count+1)) { - - - CP_PRINTERR("Can't resize event list"); - return true; - } - event_list=events; - if (event_list==0) { - - - CP_PRINTERR("Can't get event list"); - return true; - } - - //make room for new pos, this wont do a thing if pos_idx was ==event_count - for(int32_t i=(event_count-1);i>pos_idx;i--) { - event_list[i]=event_list[i-1]; - - } - - } /* Else it means that position is taken, so we just modify it! */ - - - new_pos=pos_idx; - } - - event_list[new_pos].pos=target_pos; - event_list[new_pos].note=p_note.note; - event_list[new_pos].instrument=p_note.instrument; - event_list[new_pos].volume=p_note.volume; - event_list[new_pos].command=p_note.command; - event_list[new_pos].parameter=p_note.parameter; - event_list[new_pos].script_source_sign=p_note.script_source_sign; - event_list[new_pos].cloned=p_note.cloned; - - - - - return false; - -} -CPNote CPPattern::get_note(uint8_t p_column,uint16_t p_row) { - - if (p_column==CPNote::EMPTY) return CPNote(); - - CP_ERR_COND_V(p_column>=WIDTH,CPNote()); - CP_ERR_COND_V(p_row>=length,CPNote()); - - if (event_count==0) - return CPNote(); - - - Event *event_list=events; - - CP_ERR_COND_V(event_list==0,CPNote()); - - uint16_t target_pos=p_row*WIDTH+p_column; - int32_t pos_idx = get_event_pos(target_pos); - if (pos_idx==-1) { - - CP_PRINTERR("Can't find event pos"); - return CPNote(); - } - - if (pos_idx>=event_count || event_list[pos_idx].pos!=target_pos) { - /* no note found */ - - return CPNote(); - } - - CPNote n; - n.note=event_list[pos_idx].note; - n.instrument=event_list[pos_idx].instrument; - n.volume=event_list[pos_idx].volume; - n.command=event_list[pos_idx].command; - n.parameter=event_list[pos_idx].parameter; - n.script_source_sign=event_list[pos_idx].script_source_sign; - n.cloned=event_list[pos_idx].cloned; - - - return n; - -} - -CPNote CPPattern::get_transformed_script_note(uint8_t p_column,uint16_t p_row ) { - - CPNote n = get_note( p_column, p_row ); - - // get source channel and note - - int channel = get_scripted_note_target_channel( p_column, p_row ); - CPNote src_n = get_note( channel, 0 ); - - if ( src_n.note == CPNote::SCRIPT ) return CPNote(); - - script_transform_note( src_n, n ); - - return src_n; - -} - -int CPPattern::get_scripted_note_target_channel(uint8_t p_column, uint16_t p_row) { - - CPNote n = get_note( p_column, p_row ); - - if ( n.note != CPNote::SCRIPT ) return CPNote::EMPTY; - - int channel = n.instrument; - - if ( n.script_source_sign == '\0' ) { - - if ( channel < 0 || channel >= CPPattern::WIDTH ) return CPNote::EMPTY; - - } else { - - channel = p_column + ( ( n.script_source_sign=='+') ? 1 : -1 ) * (channel+1); - if ( channel < 0 || channel >= CPPattern::WIDTH ) return CPNote::EMPTY; - - } - - return channel; -} - -void CPPattern::scripted_clone(uint8_t p_column, uint16_t p_row) { - - int channel = get_scripted_note_target_channel( p_column, p_row ); - int src_row = 1; - CPNote script_n = get_note( p_column, p_row ); - - for ( int row = p_row+1; row < length; ++row ) { - - CPNote src_n = get_note( channel, src_row ); - CPNote target_n = get_note( p_column, row ); - - if ( target_n.note != CPNote::SCRIPT ) { - if ( src_n.note == CPNote::SCRIPT ) { - src_n = CPNote(); - channel = CPNote::EMPTY; - } - - script_transform_note( src_n, script_n ); - - src_n.cloned = true; - set_note( p_column, row, src_n ); - - } else { - - return; - - } - - src_row++; - } - -} - -void CPPattern::scripted_clone_remove(uint8_t p_column, uint16_t p_row) { - - if ( get_note( p_column, p_row ).cloned ) - set_note( p_column, p_row, CPNote() ); - - for ( int row = p_row+1; row < length; ++row ) { - - CPNote target_n = get_note( p_column, row ); - - if ( target_n.note != CPNote::SCRIPT ) { - - set_note( p_column, row, CPNote() ); - - } else { - - return; - - } - - } - -} - -void CPPattern::script_transform_note(CPNote& n, const CPNote& p_note) { - - // set instrument - - if ( n.note < CPNote::NOTES && p_note.volume != CPNote::EMPTY ) { - - n.instrument = p_note.volume; - - } - - // transpose - - if ( n.note < CPNote::NOTES && p_note.command != CPNote::EMPTY ) { - - int transpose = ( p_note.parameter & 0xF ) + ( p_note.parameter / 0x10 ) * 12; - - if ( p_note.command == '^' ) { - - if ( n.note >= CPNote::NOTES-transpose ) - n.note = CPNote::NOTES-1; - else - n.note += transpose; - - } else if ( p_note.command == 'v' ) { - - if ( n.note <= transpose ) - n.note = 0; - else - n.note -= transpose; - - } - } - -} - -bool CPPattern::update_scripted_clones_sourcing_channel( int channel ) { - - bool updated = false; - - for ( int x = 0; x < WIDTH; ++x ) { - - for (int y = 0; y < length; ++y ) { - - if ( channel == get_scripted_note_target_channel( x, y ) ) { - - scripted_clone( x, y ); - updated = true; - } - - } - - } - - return updated; -} - -void CPPattern::set_length(uint16_t p_rows) { - - - - if (event_count==0) { - - if (p_rows>=MIN_ROWS) - length=p_rows; - - - return; - - } - - if (p_rows<MIN_ROWS) { - - return; - } - - if (p_rows<length) { - - Event* event_list=events; - if (event_list==0) { - - CP_PRINTERR("get_event_list() Failed"); - return; - } - - - uint16_t target_pos=p_rows*WIDTH; - int32_t pos_idx = get_event_pos(target_pos); - - - if (pos_idx==-1) { - - CP_ERR_COND(pos_idx==-1); - } - - if (resize_event_list_to(pos_idx)) { - - CP_PRINTERR("resize_event_list_to(pos_idx) Failed"); - return; - } - - } - - length=p_rows; - - -} -#if 0 -void CPPattern::copy_to(CPPattern *p_pattern) const { - - - - - p_pattern->clear(); - p_pattern->length=length; - - - if (!event_count) - return; - - - - int bufsiz=MemPool_Wrapper::get_singleton()->get_mem_size( mem_handle ); - MemPool_Handle aux_mem_handle=MemPool_Wrapper::get_singleton()->alloc_mem( bufsiz ); - - if (aux_mem_handle.is_null()) { - - CP_PRINTERR("own handle is null"); - - return; - } - - - if (MemPool_Wrapper::get_singleton()->lock_mem(aux_mem_handle)) { - CP_PRINTERR("Unable to lock aux new handle"); - - return; - - } - - if (MemPool_Wrapper::get_singleton()->lock_mem(mem_handle)) { - - CP_PRINTERR("Unable to lock own handle"); - - return; - } - - uint8_t* srcuint8_tt8_t*)MemPool_Wrapper::get_singleton()->get_mem(mem_handle); - uint8_t* dstuint8_tt8_t*)MemPool_Wrapper::get_singleton()->get_mem(aux_mem_handle); - - for (int i=0;i<bufsiz;i++) - dst[i]=src[i]; - - MemPool_Wrapper::get_singleton()->unlock_mem(mem_handle); - MemPool_Wrapper::get_singleton()->unlock_mem(aux_mem_handle); - - p_pattern->mem_handle=aux_mem_handle; - p_pattern->event_count=event_count; - - -} -#endif -uint16_t CPPattern::get_length() { - - - return length; -} -CPPattern::CPPattern() { - - - length=DEFAULT_LEN; - event_count=0; - clear(); - -} -bool CPPattern::is_empty() { - - return events==NULL; -} - -CPPattern::~CPPattern() { - - clear(); -} diff --git a/modules/chibi/cp_pattern.h b/modules/chibi/cp_pattern.h deleted file mode 100644 index fc3b032523..0000000000 --- a/modules/chibi/cp_pattern.h +++ /dev/null @@ -1,94 +0,0 @@ -/*************************************************************************/ -/* cp_pattern.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_PATTERN_H -#define CP_PATTERN_H - -#include "cp_note.h" - -class CPPattern { -public: - - - enum { - WIDTH=64, - DEFAULT_LEN=64, - RESIZE_EVERY_BITS=4, - MIN_ROWS=1, //otherwise clipboard wont work - MAX_LEN=256 - - }; - -private: - struct Event { - - uint16_t pos; //column*WIDTH+row - uint8_t note; - uint8_t instrument; - uint8_t volume; - uint8_t command; - uint8_t parameter; - unsigned int script_source_sign; - bool cloned; - }; - - uint16_t length; - uint32_t event_count; - Event* events; - - int32_t get_event_pos(uint16_t p_target_pos); - bool erase_event_at_pos(uint16_t p_pos); - - bool resize_event_list_to(uint32_t p_events); - - void operator=(const CPPattern& p_pattern); //no operator= -public: - - bool is_empty(); - void clear(); - - bool set_note(uint8_t p_column, uint16_t p_row,const CPNote& p_note); //true if no more memory - CPNote get_note(uint8_t p_column,uint16_t p_row); - - CPNote get_transformed_script_note(uint8_t p_column, uint16_t p_row); - int get_scripted_note_target_channel(uint8_t p_column, uint16_t p_row); - void scripted_clone(uint8_t p_column, uint16_t p_row); - void scripted_clone_remove(uint8_t p_column, uint16_t p_row); - void script_transform_note(CPNote& n, const CPNote& p_note); - bool update_scripted_clones_sourcing_channel(int channel); - - //void copy_to(CPPattern *p_pattern) const; - void set_length(uint16_t p_rows); - uint16_t get_length(); - CPPattern(); - ~CPPattern(); - - -}; - -#endif diff --git a/modules/chibi/cp_player_data.cpp b/modules/chibi/cp_player_data.cpp deleted file mode 100644 index c8cbfbd06e..0000000000 --- a/modules/chibi/cp_player_data.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/*************************************************************************/ -/* cp_player_data.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_player_data.h" -#include <stdio.h> - - -CPPlayer::CPPlayer(CPMixer *p_mixer,CPSong *p_song){ - - song=p_song; - mixer=p_mixer; - control.max_voices=p_mixer->get_total_voice_count()-1; //leave one for the sample - control.force_no_nna=false; - control.external_vibrato=false; - control.filters=true; - control.random_seed=128364; //anything - control.play_mode=0; - set_virtual_channels(p_mixer->get_total_voice_count()); - mixer->set_callback( &CPPlayer::callback_function, this ); - - reset(); -} -CPPlayer::~CPPlayer(){ -} - -void CPPlayer::set_virtual_channels(int p_amount) { - - if (p_amount<1) return; - if (p_amount>mixer->get_total_voice_count()) - return; - - control.max_voices=p_amount; - -} - - -void CPPlayer::callback_function(void *p_userdata) { - - CPPlayer*pd=(CPPlayer*)p_userdata; - pd->process_tick(); - -} - -void CPPlayer::process_tick() { - - handle_tick(); - mixer->set_callback_interval( 2500000/control.tempo ); - song_usecs+=2500000/control.tempo; -} - -void CPPlayer::reset() { - - if ( mixer==NULL ) return ; - if ( song==NULL ) return ; - - int i; - - for (i=0;i<control.max_voices;i++) { - - voice[i].reset(); - mixer->stop_voice(i); - } - - for (i=0;i<CPPattern::WIDTH;i++) { - - control.channel[i].reset(); - control.channel[i].channel_volume=song->get_channel_volume(i); - control.channel[i].channel_panning=((int)song->get_channel_pan( i)*PAN_RIGHT/64); - if (song->is_channel_surround(i)) - control.channel[i].channel_panning=PAN_SURROUND; - control.channel[i].mute=song->is_channel_mute( i ); - control.channel[i].chorus_send=song->get_channel_chorus(i)*0xFF/64; - control.channel[i].reverb_send=song->get_channel_reverb(i)*0xFF/64; - } - - - control.speed=song->get_speed(); - control.tempo=song->get_tempo(); - control.global_volume=song->get_global_volume(); - - control.position.current_pattern=0; - control.position.current_row=0; - control.position.current_order=0; - control.position.force_next_order=-1; - control.ticks_counter=control.speed; - control.position.forbid_jump=false; - - song_usecs=0; - -} - -int64_t CPPlayer::get_channel_last_note_time_usec(int p_channel) const { - - CP_FAIL_INDEX_V(p_channel,64,-1); - return control.channel[p_channel].last_event_usecs; - -} - -void CPPlayer::set_channel_global_volume(int p_channel,int p_volume) { - - CP_FAIL_INDEX(p_channel,64); - control.channel[p_channel].channel_global_volume=CLAMP(p_volume,0,255); - -} - -int CPPlayer::get_channel_global_volume(int p_channel) const{ - - CP_FAIL_INDEX_V(p_channel,64,-1); - return control.channel[p_channel].channel_global_volume; - -} - -bool CPPlayer::reached_end_of_song() { - - return control.reached_end; - -} -void CPPlayer::set_force_external_vibratos(bool p_force) { - - control.external_vibrato=p_force; -} -void CPPlayer::set_force_no_nna(bool p_force) { - - control.force_no_nna=p_force; -} diff --git a/modules/chibi/cp_player_data.h b/modules/chibi/cp_player_data.h deleted file mode 100644 index 2157319855..0000000000 --- a/modules/chibi/cp_player_data.h +++ /dev/null @@ -1,582 +0,0 @@ -/*************************************************************************/ -/* cp_player_data.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_PLAYER_DATA_H -#define CP_PLAYER_DATA_H - -#include "cp_config.h" -#include "cp_song.h" -#include "cp_mixer.h" -#include "cp_tables.h" - -/**CPPlayer Data - *@author Juan Linietsky - */ - -/****************************** - player_data.h - ------------------------ - -The player and its data. -I hope you dont get sick reading this -********************************/ - -//Default pan values - - -class CPPlayer { - - enum { - PAN_SURROUND=512, - PAN_RIGHT=255, - PAN_LEFT=0, - PAN_CENTER=128 - }; - - - CPSong *song; - - CPMixer *mixer; - - struct Filter_Control { - - int32_t it_reso; - int32_t it_cutoff; - int32_t envelope_cutoff; - int32_t final_cutoff; - - void process(); - void set_filter_parameters(int *p_cutoff,uint8_t *p_reso); - - }; - - //tells you if a channel is doing - //noteoff/notekill/notefade/etc - enum { - - END_NOTE_NOTHING=0, - END_NOTE_OFF=1, - END_NOTE_FADE=2, - END_NOTE_KILL=4 - }; - - //Tells you what should a channel restart - enum { - - KICK_NOTHING, - KICK_NOTE, - KICK_NOTEOFF, - KICK_ENVELOPE - }; - - enum { - - MAX_VOICES=256 - }; - - struct Channel_Control; - - struct Voice_Control { - - struct Envelope_Control { - - int pos_index; - int status; - int value; - bool sustain_looping; - bool looping; - bool terminated; - bool active; - bool kill; - - }; - - Filter_Control filter; - uint16_t reverb_send; - uint16_t chorus_send; - - CPInstrument* instrument_ptr; - CPSample* sample_ptr; - - //Sample_Data *sample_data; - - int32_t period; - - int32_t sample_start_index; /* The starting byte index in the sample */ - - bool has_master_channel; - int master_channel_index; - int instruement_index; - - int instrument_index; - int sample_index; - int8_t NNA_type; - - int note_end_flags; - - uint8_t sample; /* which instrument number */ - - int16_t output_volume; /* output volume (vol + sampcol + instvol) */ - int8_t channel_volume; /* channel's "global" volume */ - uint16_t fadeout_volume; /* fading volume rate */ - int32_t total_volume; /* total volume of channel (before global mixings) */ - uint8_t kick; /* if true = sample has to be restarted */ - - uint8_t note; /* the audible note (as heard, direct rep of period) */ - - int16_t panning; /* panning position */ - - uint8_t nna; /* New note action type + master/slave flags */ - uint8_t volflg; /* volume envelope settings */ - uint8_t panflg; /* panning envelope settings */ - uint8_t pitflg; /* pitch envelope settings */ - uint8_t keyoff; /* if true = fade out and stuff */ - int16_t handle; /* which sample-handle */ - int32_t start; /* The start byte index in the sample */ - - /* Below here is info NOT in MP_CONTROL!! */ - //ENVPR venv; - //ENVPR penv; - //ENVPR cenv; - - Envelope_Control volume_envelope_ctrl; - Envelope_Control panning_envelope_ctrl; - Envelope_Control pitch_envelope_ctrl; - - uint16_t auto_vibrato_pos; /* autovibrato pos */ - uint16_t auto_vibrato_sweep_pos; /* autovibrato sweep pos */ - - int16_t masterchn; - uint16_t masterperiod; - - Channel_Control* master_channel; /* index of "master" effects channel */ - - void start_envelope(CPEnvelope *p_envelope,Envelope_Control *p_envelope_ctrl,Envelope_Control *p_from_env); - bool process_envelope(CPEnvelope *p_envelope,Envelope_Control *p_envelope_ctrl); - - uint16_t display_volume; - - Voice_Control() { - - reset(); - } - - void reset(); - void update_info_from_master_channel(); - - - }; - - - struct Channel_Control { - - /* NOTE info */ - uint8_t note; /* the audible note as heard, direct rep of period */ - uint8_t real_note; /* the note that indexes the audible */ - int32_t sample_start_index; /* The starting byte index in the sample */ - uint8_t old_note; - - uint8_t kick; - - Filter_Control filter; - uint16_t reverb_send; - uint16_t chorus_send; - - - int note_end_flags; - - /* INSTRUMENT INFO */ - - CPInstrument* instrument_ptr; - CPSample* sample_ptr; - - uint8_t instrument_index; - uint8_t sample_index; - bool new_instrument; - - /* SAMPLE SPECIFIC INFO */ - int32_t base_speed; /* what finetune to use */ - - /* INSTRUMENT SPECIFIC INFO */ - - int8_t NNA_type; - int8_t duplicate_check_type; - int8_t duplicate_check_action; - - bool volume_envelope_on; - bool panning_envelope_on; - bool pitch_envelope_on; - - bool has_own_period; - - bool row_has_note; - - /* VOLUME COLUMN */ - - int16_t volume; /* amiga volume (0 t/m 64) to play the sample at */ - int16_t aux_volume; - bool has_own_volume; - bool mute; - int16_t random_volume_variation; /* 0-100 - 100 has no effect */ - - /* VOLUME/PAN/PITCH MODIFIERS */ - - int8_t default_volume; // CHANNEL default volume (0-64) - int16_t channel_volume; // CHANNEL current volume //chanvol - current! - int16_t output_volume; /* output volume (vol + sampcol + instvol) //volume */ - int16_t channel_global_volume; - - uint16_t fadeout_volume; /* fading volume rate */ - - int32_t period; /* period to play the sample at */ - - /* PAN */ - - int16_t panning; /* panning position */ - int16_t channel_panning; - int8_t sliding; - - uint16_t aux_period; /* temporary period */ - - - - /* TIMING */ - uint8_t note_delay; /* (used for note delay) */ - - /* Slave Voice Control */ - - Voice_Control *slave_voice; /* Audio Slave of current effects control channel */ - - struct Carry { - - Voice_Control::Envelope_Control vol; - Voice_Control::Envelope_Control pan; - Voice_Control::Envelope_Control pitch; - bool maybe; - - } carry; - - - - uint8_t slave_voice_index; /* Audio Slave of current effects control channel */ - - uint8_t* row; /* row currently playing on this channel */ - - /* effect memory variables */ - - uint8_t current_command; - uint8_t current_parameter; - uint8_t current_volume_command; - uint8_t current_volume_parameter; - uint8_t volcol_volume_slide; - - /* CPSample Offset */ - - int32_t lo_offset; - int32_t hi_offset; - - /* Panbrello waveform */ - uint8_t panbrello_type; /* current panbrello waveform */ - uint8_t panbrello_position; /* current panbrello position */ - int8_t panbrello_speed; /* "" speed */ - uint8_t panbrello_depth; /* "" depth */ - uint8_t panbrello_info; - /* Arpegio */ - - uint8_t arpegio_info; - /* CPPattern Loop */ - - int pattern_loop_position; - int8_t pattern_loop_count; - - /* Vibrato */ - bool doing_vibrato; - int8_t vibrato_position; /* current vibrato position */ - uint8_t vibrato_speed; /* "" speed */ - uint8_t vibrato_depth; /* "" depth */ - uint8_t vibrato_type; - /* Tremor */ - int8_t tremor_position; - uint8_t tremor_speed; /* s3m tremor ontime/offtime */ - uint8_t tremor_depth; - uint8_t tremor_info; - - /* Tremolo */ - int8_t tremolo_position; - uint8_t tremolo_speed; /* s3m tremor ontime/offtime */ - uint8_t tremolo_depth; - uint8_t tremolo_info; - uint8_t tremolo_type; - - /* Retrig */ - int8_t retrig_counter; /* retrig value (0 means don't retrig) */ - uint8_t retrig_speed; /* last used retrig speed */ - uint8_t retrig_volslide; /* last used retrig slide */ - - /* CPSample Offset */ - int32_t sample_offset_hi; /* last used high order of sample offset */ - uint16_t sample_offset; /* last used low order of sample-offset (effect 9) */ - uint16_t sample_offset_fine; /* fine sample offset memory */ - - /* Portamento */ - uint16_t slide_to_period; /* period to slide to (with effect 3 or 5) */ - uint8_t portamento_speed; - - /* Volume Slide */ - - uint8_t volume_slide_info; - - /* Channel Volume Slide */ - - uint8_t channel_volume_slide_info; - - /* Global Volume Slide */ - - uint8_t global_volume_slide_info; - - /* Channel Pan Slide */ - - uint8_t channel_pan_slide_info; - - /* Pitch Slide */ - - uint8_t pitch_slide_info; - /* Tempo Slide */ - - uint8_t tempo_slide_info; - - /* S effects memory */ - - uint8_t current_S_effect; - uint8_t current_S_data; - - /* Volume column memory */ - - uint8_t volume_column_effect_mem; - uint8_t volume_column_data_mem; - - int64_t last_event_usecs; - bool reserved; - - void reset(); - - Channel_Control() { channel_global_volume=255; last_event_usecs=-1; } - }; - - struct Control_Variables { // control variables (dynamic version) of initial variables - - bool reached_end; - - char play_mode; - bool filters; - int global_volume; - int speed; - int tempo; - - int ticks_counter; - - int pattern_delay_1; - int pattern_delay_2; - - Channel_Control channel[CPPattern::WIDTH]; - - int max_voices; - - int voices_used; /* reference value */ - - bool force_no_nna; - bool external_vibrato; - - struct Position { - - int current_order; - int current_pattern; - int current_row; - int force_next_order; - bool forbid_jump; - }; - - int32_t random_seed; - - Position position; - Position previous_position; - - }; - - - Voice_Control voice[MAX_VOICES]; - - Control_Variables control; - - /* VOICE SETUP */ - - void setup_voices(); - - /* MIXER SETUP */ - void handle_tick(); - void update_mixer(); - - /* NOTE / INSTRUMENT PROCESSING */ - - void process_new_note(int p_track,uint8_t p_note); - bool process_new_instrument(int p_track,uint8_t p_instrument); - bool process_note_and_instrument(int p_track,int p_note,int p_instrument); - - /* EFFECT PROCESSING */ - void do_effect_S(int p_track); - void do_panbrello(int p_track); - void do_global_volume_slide(int p_track); - void do_tremolo(int p_track); - void do_retrig(int p_track); - void do_pan_slide(int p_track); - void do_channel_volume_slide(int p_track); - void do_volume_slide(int p_track,int inf); - void do_pitch_slide_down(int p_track,uint8_t inf); - void do_pitch_slide_up(int p_track,uint8_t inf); - void do_tremor(int p_track); - void do_vibrato(int p_track,bool fine); - void do_pitch_slide_to_note(int p_track); - void run_effects(int p_track); - void run_volume_column_effects(int p_track); - void pre_process_effects(); - void do_arpegio(int p_track); - uint64_t song_usecs; - /* NNA */ - - void process_NNAs(); - - - /* MISC UTILS */ - - - int find_empty_voice(); - void process_volume_column(int p_track,uint8_t p_volume); - void process_note(int p_track,CPNote p_note); - - /* CPTables */ - static uint8_t auto_vibrato_table[128]; - static uint8_t vibrato_table[32]; - static int8_t panbrello_table[256]; - - static void callback_function(void *p_userdata); - -public: - //Play modes - - enum { - - PLAY_NOTHING =0, - PLAY_PATTERN =1, - PLAY_SONG =2 - }; - - - int32_t get_frequency(int32_t period); - int32_t get_period(uint16_t note,int32_t p_c5freq); - - - int get_current_tempo() { return control.tempo; }; - int get_current_speed() { return control.speed; }; - - int get_voices_used() { return control.voices_used;}; - int get_voice_envelope_pos(int p_voice,CPEnvelope *p_envelope); - int get_voice_amount_limit() { return control.max_voices; }; - void set_voice_amount_limit(int p_limit); - void set_reserved_voices(int p_amount); - int get_reserved_voices_amount(); - - bool is_voice_active(int p_voice); - int get_channel_voice(int p_channel); - const char* get_voice_sample_name(int p_voice); - const char* get_voice_instrument_name(int p_voice); - CPEnvelope* get_voice_envelope(int p_voice,CPInstrument::EnvelopeType p_env_type); - int get_voice_envelope_pos(int p_voice,CPInstrument::EnvelopeType p_env_type); - int get_voice_volume(int p_voice); - - int get_voice_sample_index(int p_voice); - - void set_virtual_channels(int p_amount); - int get_virtual_channels() { return control.max_voices; }; - - - /* Play Info/Position */ - bool is_playing() { return (control.play_mode>0); }; - int get_play_mode() {return (control.play_mode);}; - int get_current_order() { return control.position.current_order; }; - int get_current_row() { return control.position.current_row; }; - int get_current_pattern() { return control.position.current_pattern; }; - - void goto_next_order(); - void goto_previous_order(); - - void process_tick(); - - - CPMixer* get_mixer_ptr() { - - return mixer; - } - - - void reset(); - - - - /* External player control - editor - */ - - void play_start_pattern(int p_pattern); - void play_start_song(); - void play_start_song_from_order(int p_order); - void play_start_song_from_order_and_row(int p_order,int p_row); - void play_start(int p_pattern, int p_order, int p_row,bool p_lock=true); - - void play_stop(); - void play_note(int p_channel,CPNote note,bool p_reserve=false); - - bool reached_end_of_song(); - - void set_force_no_nna(bool p_force); - void set_force_external_vibratos(bool p_force); - - void set_filters_enabled(bool p_enable); - bool are_filters_enabled() { return control.filters; } - - void set_channel_global_volume(int p_channel,int p_volume); //0-255 - int get_channel_global_volume(int p_channel) const; - - int64_t get_channel_last_note_time_usec(int p_channel) const; - - CPSong *get_song() { return song; }; - - - CPPlayer(CPMixer *p_mixer,CPSong *p_song); - ~CPPlayer(); -}; - -#endif diff --git a/modules/chibi/cp_player_data_control.cpp b/modules/chibi/cp_player_data_control.cpp deleted file mode 100644 index 2ef1c1de8c..0000000000 --- a/modules/chibi/cp_player_data_control.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/*************************************************************************/ -/* cp_player_data_control.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_player_data.h" - -void CPPlayer::play_start_pattern(int p_pattern) { - - play_start(p_pattern,-1,-1); -} - -void CPPlayer::play_start_song() { - - play_start(-1,-1,-1); -} - -void CPPlayer::play_start_song_from_order(int p_order) { - - play_start(-1,p_order,-1); -} - -void CPPlayer::play_start_song_from_order_and_row(int p_order,int p_row) { - - play_start(-1,p_order,p_row); -} - -void CPPlayer::play_start(int p_pattern, int p_order, int p_row,bool p_lock) { - - - if (control.play_mode!=PLAY_NOTHING) play_stop(); - - - reset(); - - if (p_pattern!=-1) { - - control.play_mode=PLAY_PATTERN; - control.position.current_pattern=p_pattern; - control.position.current_row=(p_row!=-1)?p_row:0; - - } else { - - control.position.current_order=get_song_next_order_idx(song,(p_order==-1)?p_order:p_order-1); - if (control.position.current_order!=-1) { - - control.play_mode=PLAY_SONG; - control.position.current_pattern=song->get_order(control.position.current_order); - control.position.current_row=(p_row!=-1)?p_row:0; - } - } - - - control.reached_end=(control.play_mode==PLAY_NOTHING); - - -} - -void CPPlayer::play_stop() { - - int i; - - - control.play_mode=PLAY_NOTHING; - - for (i=0;i<control.max_voices;i++) { - - voice[i].reset(); - mixer->stop_voice(i); - } - - for (i=0;i<CPPattern::WIDTH;i++) { - - control.channel[i].reset(); - } - - reset(); - -} - -void CPPlayer::play_note(int p_channel,CPNote note,bool p_reserve) { - - - - if (control.play_mode==PLAY_NOTHING) { - - control.ticks_counter=0; - } - - /*control.channel[p_channel].reset(); - control.channel[p_channel].channel_volume=song->get_channel_volume(p_channel); - control.channel[p_channel].channel_panning=((int)song->get_channel_pan( p_channel)*255/64);*/ - if (p_reserve) { - control.channel[p_channel].mute=false; - control.channel[p_channel].reserved=true; - } else { - - control.channel[p_channel].reserved=false; - - } - process_note(p_channel,note); - - - -} - - -int CPPlayer::get_voice_volume(int p_voice) { - - return voice[p_voice].display_volume; -} - - -int CPPlayer::get_voice_envelope_pos(int p_voice,CPEnvelope *p_envelope) { - - int i,tmp_index=-1; - - i=p_voice; - - - - - if ((song->has_instruments()) && (voice[i].instrument_ptr!=NULL) && (voice[i].fadeout_volume>0)) { - - if ((p_envelope==voice[i].instrument_ptr->get_volume_envelope()) && (voice[i].instrument_ptr->get_volume_envelope()->is_enabled())) { - - tmp_index=voice[i].volume_envelope_ctrl.pos_index; - } - - if ((p_envelope==voice[i].instrument_ptr->get_pan_envelope()) && (voice[i].instrument_ptr->get_pan_envelope()->is_enabled())) { - - tmp_index=voice[i].panning_envelope_ctrl.pos_index; - } - - if ((p_envelope==voice[i].instrument_ptr->get_pitch_filter_envelope()) && (voice[i].instrument_ptr->get_pitch_filter_envelope()->is_enabled())) { - - - tmp_index=voice[i].pitch_envelope_ctrl.pos_index; - } - - } - - - - return tmp_index; -} - -void CPPlayer::goto_next_order() { - - - if (control.play_mode!=PLAY_SONG) return; - - - - control.position.current_row=0; - - - control.position.current_order=get_song_next_order_idx(song, control.position.current_order); - - - - if (control.position.current_order==-1) { - - reset(); - } - - control.position.current_pattern=song->get_order(control.position.current_order); - - -} -void CPPlayer::goto_previous_order() { - - if (control.play_mode!=PLAY_SONG) return; - - - int next_order,current_order; - - control.position.current_row=0; - - current_order=control.position.current_order; - - next_order=get_song_next_order_idx(song, current_order); - - while ((next_order!=control.position.current_order) && (next_order!=-1)) { - - current_order=next_order; - next_order=get_song_next_order_idx(song, current_order); - } - - if (next_order==-1) { - - reset(); - } else { - - control.position.current_order=current_order; - control.position.current_pattern=song->get_order(control.position.current_order); - - } - - - -} - -int CPPlayer::get_channel_voice(int p_channel) { - - if (control.channel[p_channel].slave_voice==NULL) return -1; - else return control.channel[p_channel].slave_voice_index; -} - -const char* CPPlayer::get_voice_sample_name(int p_voice) { - - const char *name = NULL; - - - - if (!voice[p_voice].sample_ptr) name=voice[p_voice].sample_ptr->get_name(); - - - - return name; - -} - - -bool CPPlayer::is_voice_active(int p_voice) { - - return !( ((voice[p_voice].kick==KICK_NOTHING)||(voice[p_voice].kick==KICK_ENVELOPE))&&!mixer->is_voice_active(p_voice) ); - -} - - - -int CPPlayer::get_voice_envelope_pos(int p_voice,CPInstrument::EnvelopeType p_env_type) { - - if (!is_voice_active(p_voice)) - return -1; - - Voice_Control::Envelope_Control *env=0; - - switch (p_env_type) { - - case CPInstrument::VOLUME_ENVELOPE: env=&voice[p_voice].volume_envelope_ctrl; break; - case CPInstrument::PAN_ENVELOPE: env=&voice[p_voice].panning_envelope_ctrl; break; - case CPInstrument::PITCH_ENVELOPE: env=&voice[p_voice].pitch_envelope_ctrl; break; - - } - - if (!env) - return -1; - - if (!env->active || env->terminated) - return -1; - - return env->pos_index; -} - - -CPEnvelope* CPPlayer::get_voice_envelope(int p_voice,CPInstrument::EnvelopeType p_env_type) { - - CPInstrument *ins=voice[p_voice].instrument_ptr; - - if (!ins) - return 0; - - switch( p_env_type ) { - - - case CPInstrument::VOLUME_ENVELOPE: return ins->get_volume_envelope(); - case CPInstrument::PAN_ENVELOPE: return ins->get_pan_envelope(); - case CPInstrument::PITCH_ENVELOPE: return ins->get_pitch_filter_envelope(); - }; - - return 0; - -} - -const char * CPPlayer::get_voice_instrument_name(int p_voice) { - - - - const char *name = NULL; - - - - if (voice[p_voice].instrument_ptr!=NULL) name=voice[p_voice].instrument_ptr->get_name(); - - - - return name; - -} -void CPPlayer::set_filters_enabled(bool p_enable){ - - control.filters=p_enable; -} - -int CPPlayer::get_voice_sample_index(int p_voice) { - - return voice[p_voice].sample_index; -} diff --git a/modules/chibi/cp_player_data_effects.cpp b/modules/chibi/cp_player_data_effects.cpp deleted file mode 100644 index 56fb7a2905..0000000000 --- a/modules/chibi/cp_player_data_effects.cpp +++ /dev/null @@ -1,1232 +0,0 @@ -/*************************************************************************/ -/* cp_player_data_effects.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_player_data.h" - - - -/********************** - complex effects -***********************/ -#define RANDOM_MAX 2147483647 - -static inline int32_t cp_random_generate(int32_t *seed) { - int32_t k; - int32_t s = (int32_t)(*seed); - if (s == 0) - s = 0x12345987; - k = s / 127773; - s = 16807 * (s - k * 127773) - 2836 * k; - if (s < 0) - s += 2147483647; - (*seed) = (int32_t)s; - return (int32_t)(s & RANDOM_MAX); -} - - - -void CPPlayer::do_vibrato(int p_track,bool fine) { - - uint8_t q; - uint16_t temp=0; - - if ((control.ticks_counter==0) && control.channel[p_track].row_has_note) control.channel[p_track].vibrato_position=0; - - q=(control.channel[p_track].vibrato_position>>2)&0x1f; - - switch (control.channel[p_track].vibrato_type) { - case 0: /* sine */ - temp=vibrato_table[q]; - break; - case 1: /* square wave */ - temp=255; - break; - case 2: /* ramp down */ - q<<=3; - if (control.channel[p_track].vibrato_position<0) q=255-q; - temp=q; - break; - case 3: /* random */ - temp=cp_random_generate(&control.random_seed) %256;//getrandom(256); - break; - } - - temp*=control.channel[p_track].vibrato_depth; - - if (song->has_old_effects()) { - - temp>>=7; - } else { - - temp>>=8; - } - - if (!fine) temp<<=2; - - if (control.channel[p_track].vibrato_position>=0) { - - control.channel[p_track].period=control.channel[p_track].aux_period+temp; - } else { - - control.channel[p_track].period=control.channel[p_track].aux_period-temp; - } - - if (!song->has_old_effects() || control.ticks_counter) control.channel[p_track].vibrato_position+=control.channel[p_track].vibrato_speed; -} - - -void CPPlayer::do_pitch_slide_down(int p_track,uint8_t inf) { - - uint8_t hi,lo; - - if (inf) control.channel[p_track].pitch_slide_info=inf; - else inf=control.channel[p_track].pitch_slide_info; - - hi=inf>>4; - lo=inf&0xf; - - if (hi==0xf) { - - if (!control.ticks_counter) control.channel[p_track].aux_period+=(uint16_t)lo<<2; - } else if (hi==0xe) { - - if (!control.ticks_counter) control.channel[p_track].aux_period+=lo; - } else { - - if (control.ticks_counter) control.channel[p_track].aux_period+=(uint16_t)inf<<2; - } -} - -void CPPlayer::do_pitch_slide_up(int p_track,uint8_t inf) { - - uint8_t hi,lo; - - if (inf) control.channel[p_track].pitch_slide_info=inf; - else inf=control.channel[p_track].pitch_slide_info; - - hi=inf>>4; - lo=inf&0xf; - - if (hi==0xf) { - - if (!control.ticks_counter) control.channel[p_track].aux_period-=(uint16_t)lo<<2; - } else if (hi==0xe) { - - if (!control.ticks_counter) control.channel[p_track].aux_period-=lo; - } else { - - if (control.ticks_counter) control.channel[p_track].aux_period-=(uint16_t)inf<<2; - } -} - -void CPPlayer::do_pitch_slide_to_note(int p_track) { - - if (control.ticks_counter) { - int dist; - - /* We have to slide a->period towards a->wantedperiod, compute the - difference between those two values */ - dist=control.channel[p_track].period-control.channel[p_track].slide_to_period; - - /* if they are equal or if portamentospeed is too big... */ - if ((!dist)||((control.channel[p_track].portamento_speed<<2)>cp_intabs(dist))) { - /* ... make tmpperiod equal tperiod */ - control.channel[p_track].aux_period=control.channel[p_track].period=control.channel[p_track].slide_to_period; - } else { - - if (dist>0) { - - control.channel[p_track].aux_period-=control.channel[p_track].portamento_speed<<2; - control.channel[p_track].period-=control.channel[p_track].portamento_speed<<2; /* dist>0 slide up */ - } else { - control.channel[p_track].aux_period+=control.channel[p_track].portamento_speed<<2; - control.channel[p_track].period+=control.channel[p_track].portamento_speed<<2; /* dist<0 slide down */ - } - } - - } else { - - control.channel[p_track].aux_period=control.channel[p_track].period; - } -} - -void CPPlayer::do_tremor(int p_track) { - - uint8_t on,off,inf; - - inf=control.channel[p_track].current_parameter; - - if (inf) { - control.channel[p_track].tremor_info=inf; - } else { - inf= control.channel[p_track].tremor_info; - if (!inf) return; - } - - //if (!control.ticks_counter) return; - - on=(inf>>4); - off=(inf&0xf); - - control.channel[p_track].tremor_position%=(on+off); - control.channel[p_track].volume=(control.channel[p_track].tremor_position<on)?control.channel[p_track].aux_volume:0; - control.channel[p_track].tremor_position++; -} - -void CPPlayer::do_pan_slide(int p_track) { - - uint8_t lo,hi,inf; - int16_t pan; - - inf=control.channel[p_track].current_parameter; - - if (inf) control.channel[p_track].channel_pan_slide_info=inf; - else inf=control.channel[p_track].channel_pan_slide_info; - - lo=inf&0xf; - hi=inf>>4; - - pan=(control.channel[p_track].panning==PAN_SURROUND)?PAN_CENTER:control.channel[p_track].panning; - - if (!hi) - pan+=lo<<2; - else - if (!lo) { - pan-=hi<<2; - } else - if (hi==0xf) { - if (!control.ticks_counter) pan+=lo<<2; - } else - if (lo==0xf) { - if (!control.ticks_counter) pan-=hi<<2; - } - //this sets both chan & voice paning - control.channel[p_track].panning=(pan<PAN_LEFT)?PAN_LEFT:(pan>PAN_RIGHT?PAN_RIGHT:pan); - control.channel[p_track].channel_panning=control.channel[p_track].panning; -} - -void CPPlayer::do_volume_slide(int p_track,int inf) { - - uint8_t hi,lo; - - lo=inf&0xf; - hi=inf>>4; - - if (!lo) { - - if ((control.ticks_counter)) control.channel[p_track].aux_volume+=hi; - - } else if (!hi) { - - if ((control.ticks_counter)) control.channel[p_track].aux_volume-=lo; - - } else if (lo==0xf) { - - if (!control.ticks_counter) control.channel[p_track].aux_volume+=(hi?hi:0xf); - } else if (hi==0xf) { - - if (!control.ticks_counter) control.channel[p_track].aux_volume-=(lo?lo:0xf); - } else return; - - if (control.channel[p_track].aux_volume<0) { - - control.channel[p_track].aux_volume=0; - } else if (control.channel[p_track].aux_volume>64) { - - control.channel[p_track].aux_volume=64; - } -} - -void CPPlayer::do_channel_volume_slide(int p_track) { - - uint8_t lo, hi,inf; - - inf=control.channel[p_track].current_parameter; - - if (inf) control.channel[p_track].channel_volume_slide_info=inf; - inf=control.channel[p_track].channel_volume_slide_info; - - lo=inf&0xf; - hi=inf>>4; - - if (!hi) - control.channel[p_track].channel_volume-=lo; - else - if (!lo) { - control.channel[p_track].channel_volume+=hi; - } else - if (hi==0xf) { - if (!control.ticks_counter) control.channel[p_track].channel_volume-=lo; - } else - if (lo==0xf) { - if (!control.ticks_counter) control.channel[p_track].channel_volume+=hi; - } - - if (control.channel[p_track].channel_volume<0) control.channel[p_track].channel_volume=0; - if (control.channel[p_track].channel_volume>64) control.channel[p_track].channel_volume=64; -} - -void CPPlayer::do_tremolo(int p_track) { - - uint8_t q; - int16_t temp=0; - - if ((control.ticks_counter==0) && control.channel[p_track].row_has_note) control.channel[p_track].tremolo_position=0; - - q=(control.channel[p_track].tremolo_position>>2)&0x1f; - - switch (control.channel[p_track].tremolo_type) { - case 0: /* sine */ - temp=vibrato_table[q]; - break; - case 1: /* ramp down */ - q<<=3; - if (control.channel[p_track].tremolo_position<0) q=255-q; - temp=q; - break; - case 2: /* square wave */ - temp=255; - break; - case 3: /* random */ - temp=cp_random_generate(&control.random_seed) % 256;//getrandom(256); - break; - } - - temp*=control.channel[p_track].tremolo_depth; - temp>>=7; - - - - if (control.channel[p_track].tremolo_position>=0) { - - - control.channel[p_track].volume=control.channel[p_track].aux_volume+temp; - if (control.channel[p_track].volume>64) control.channel[p_track].volume=64; - } else { - - control.channel[p_track].volume=control.channel[p_track].aux_volume-temp; - if (control.channel[p_track].volume<0) control.channel[p_track].volume=0; - } - - /*if (control.ticks_counter)*/ control.channel[p_track].tremolo_position+=control.channel[p_track].tremolo_speed; - -} - -void CPPlayer::do_arpegio(int p_track) { - - uint8_t note,dat; - //note=control.channel[p_track].note; - note=0; - - if (control.channel[p_track].current_parameter) { - - control.channel[p_track].arpegio_info=control.channel[p_track].current_parameter; - } - - dat=control.channel[p_track].arpegio_info; - - if (dat) { - - switch (control.ticks_counter%3) { - - case 1: { - - note+=(dat>>4); - - } break; - case 2: { - - note+=(dat&0xf); - } break; - } - - if (song->has_linear_slides()) { - - control.channel[p_track].period=control.channel[p_track].aux_period-cp_intabs(get_period((uint16_t)46,0)-get_period((uint16_t)44,0))*note; - } else if (control.channel[p_track].sample_ptr) { - - control.channel[p_track].period=get_period( (((uint16_t)control.channel[p_track].note)+note)<<1,CPSampleManager::get_singleton()->get_c5_freq( (control.channel[p_track].sample_ptr->get_sample_data()))); - } - - control.channel[p_track].has_own_period=true; - } - - -} - - -void CPPlayer::do_retrig(int p_track) { - - uint8_t inf; - - inf=control.channel[p_track].current_parameter; - - if (inf) { - - control.channel[p_track].retrig_volslide=inf>>4; - control.channel[p_track].retrig_speed=inf&0xf; - } - - /* only retrigger if low nibble > 0 */ - if ( control.channel[p_track].retrig_speed>0) { - - if ( !control.channel[p_track].retrig_counter ) { - /* when retrig counter reaches 0, reset counter and restart the - sample */ - if (control.channel[p_track].kick!=KICK_NOTE) control.channel[p_track].kick=KICK_NOTEOFF; - control.channel[p_track].retrig_counter=control.channel[p_track].retrig_speed; - - - if ((control.ticks_counter)/*||(pf->flags&UF_S3MSLIDES)*/) { - switch (control.channel[p_track].retrig_volslide) { - case 1: - case 2: - case 3: - case 4: - case 5: - control.channel[p_track].aux_volume-=(1<<(control.channel[p_track].retrig_volslide-1)); - break; - case 6: - control.channel[p_track].aux_volume=(2*control.channel[p_track].aux_volume)/3; - break; - case 7: - control.channel[p_track].aux_volume>>=1; - break; - case 9: - case 0xa: - case 0xb: - case 0xc: - case 0xd: - control.channel[p_track].aux_volume+=(1<<(control.channel[p_track].retrig_volslide-9)); - break; - case 0xe: - control.channel[p_track].aux_volume=(3*control.channel[p_track].aux_volume)>>1; - break; - case 0xf: - control.channel[p_track].aux_volume=control.channel[p_track].aux_volume<<1; - break; - } - if (control.channel[p_track].aux_volume<0) control.channel[p_track].aux_volume=0; - else if (control.channel[p_track].aux_volume>64) control.channel[p_track].aux_volume=64; - } - } - control.channel[p_track].retrig_counter--; /* countdown */ - } -} - -void CPPlayer::do_global_volume_slide(int p_track) { - - uint8_t lo,hi,inf; - - inf=control.channel[p_track].current_parameter; - - if (inf) control.channel[p_track].global_volume_slide_info=inf; - inf=control.channel[p_track].global_volume_slide_info; - - lo=inf&0xf; - hi=inf>>4; - - if (!lo) { - if (control.ticks_counter) control.global_volume+=hi; - } else - if (!hi) { - if (control.ticks_counter) control.global_volume-=lo; - } else - if (lo==0xf) { - if (!control.ticks_counter) control.global_volume+=hi; - } else - if (hi==0xf) { - if (!control.ticks_counter) control.global_volume-=lo; - } - - if (control.global_volume<0) control.global_volume=0; - if (control.global_volume>128) control.global_volume=128; -} - -void CPPlayer::do_panbrello(int p_track) { - - uint8_t q; - int32_t temp=0; - - q=control.channel[p_track].panbrello_position; - - switch (control.channel[p_track].panbrello_type) { - case 0: {/* sine */ - temp=panbrello_table[q]; - } break; - case 1: {/* square wave */ - temp=(q<0x80)?64:0; - } break; - case 2: {/* ramp down */ - q<<=3; - temp=q; - } break; - case 3: {/* random */ - if (control.channel[p_track].panbrello_position>=control.channel[p_track].panbrello_speed) { - control.channel[p_track].panbrello_position=0; - temp=cp_random_generate(&control.random_seed)%256;//getrandom(256); - } - } break; - } - - - - temp=temp*(int)control.channel[p_track].panbrello_depth/0xF; - temp<<=1; - if (control.channel[p_track].channel_panning!=PAN_SURROUND) - temp+=control.channel[p_track].channel_panning; - - control.channel[p_track].panning=(temp<PAN_LEFT)?PAN_LEFT:(temp>PAN_RIGHT?PAN_RIGHT:temp); - control.channel[p_track].panbrello_position+=control.channel[p_track].panbrello_speed; -} - -/****************** - S effect -*******************/ - - -void CPPlayer::do_effect_S(int p_track) { - - uint8_t inf,c,dat; - - dat=control.channel[p_track].current_parameter; - - inf=dat&0xf; - c=dat>>4; - - if (!dat) { - c=control.channel[p_track].current_S_effect; - inf=control.channel[p_track].current_S_data; - } else { - control.channel[p_track].current_S_effect=c; - control.channel[p_track].current_S_data=inf; - } - - switch (c) { - case 1: {/* S1x set glissando voice */ - // this is unsupported in IT! - - control.channel[p_track].chorus_send=inf*0xFF/0xF; - - }break; - case 2: /* S2x set finetune */ - //Also not supported! - break; - case 3: /* S3x set vibrato waveform */ - if (inf<4) control.channel[p_track].vibrato_type=inf; - break; - case 4: /* S4x set tremolo waveform */ - if (inf<4) control.channel[p_track].tremolo_type=inf; - break; - case 5: /* S5x panbrello */ - if (inf<4) control.channel[p_track].panbrello_type=inf; - break; - case 6: {/* S6x delay x number of frames (patdly) */ - - if (control.ticks_counter) break; - if (!control.pattern_delay_2) control.pattern_delay_1=inf+1; /* only once, when vbtick=0 */ - - } break; - case 7: /* S7x instrument / NNA commands */ - - if (!song->has_instruments()) - break; - switch(inf) { - - case 0x3: { - - control.channel[p_track].NNA_type=CPInstrument::NNA_NOTE_CUT; - } break; - case 0x4: { - - control.channel[p_track].NNA_type=CPInstrument::NNA_NOTE_CONTINUE; - } break; - case 0x5: { - - control.channel[p_track].NNA_type=CPInstrument::NNA_NOTE_OFF; - } break; - case 0x6: { - - control.channel[p_track].NNA_type=CPInstrument::NNA_NOTE_FADE; - } break; - case 0x7: { - - if (control.channel[p_track].slave_voice) - control.channel[p_track].slave_voice->volume_envelope_ctrl.active=false; - } break; - case 0x8: { - - if (control.channel[p_track].slave_voice) - control.channel[p_track].slave_voice->volume_envelope_ctrl.active=true; - - } break; - case 0x9: { - - if (control.channel[p_track].slave_voice) - control.channel[p_track].slave_voice->panning_envelope_ctrl.active=false; - - } break; - case 0xA: { - - if (control.channel[p_track].slave_voice) - control.channel[p_track].slave_voice->panning_envelope_ctrl.active=true; - - } break; - case 0xB: { - if (control.channel[p_track].slave_voice) - control.channel[p_track].slave_voice->pitch_envelope_ctrl.active=false; - - } break; - case 0xC: { - - if (control.channel[p_track].slave_voice) - control.channel[p_track].slave_voice->pitch_envelope_ctrl.active=true; - - } break; - - } break; - - break; - case 8: {/* S8x set panning position */ - - //if (pf->panflag) { - if (inf<=8) inf<<=4; - else inf*=17; - control.channel[p_track].panning=control.channel[p_track].channel_panning=inf; -// } - } break; - - case 9: { /* S9x set surround sound */ - //if (pf->panflag) - control.channel[p_track].panning=control.channel[p_track].channel_panning=PAN_SURROUND; - } break; - case 0xA:{ /* SAy set high order sample offset yxx00h */ - - if (control.channel[p_track].current_parameter) control.channel[p_track].hi_offset=(int32_t)inf<<16; - control.channel[p_track].sample_start_index=control.channel[p_track].hi_offset|control.channel[p_track].lo_offset; - } break; - case 0xB: { /* SBx pattern loop */ - if (control.ticks_counter) break; - - if (inf) { /* set reppos or repcnt ? */ - /* set repcnt, so check if repcnt already is set, which means we - are already looping */ - if (control.channel[p_track].pattern_loop_count>0) - control.channel[p_track].pattern_loop_count--; /* already looping, decrease counter */ - else { - control.channel[p_track].pattern_loop_count=inf; /* not yet looping, so set repcnt */ - } - - if (control.channel[p_track].pattern_loop_count>0) { /* jump to reppos if repcnt>0 */ - - control.position=control.previous_position; // This will also anulate any Cxx or break.. - - control.position.current_row=control.channel[p_track].pattern_loop_position; - control.position.forbid_jump=true; - } - - } else { - - - control.channel[p_track].pattern_loop_position=control.position.current_row-1; - } - - } break; - case 0xC: { /* SCx notecut */ - - if (control.ticks_counter>=inf) { - - control.channel[p_track].aux_volume=0; - control.channel[p_track].note_end_flags|=END_NOTE_OFF; - control.channel[p_track].note_end_flags|=END_NOTE_KILL; - } - } break; - case 0xD: {/* SDx notedelay */ - - if (!control.ticks_counter) { - - control.channel[p_track].note_delay=inf; - - } else if (control.channel[p_track].note_delay) { - - control.channel[p_track].note_delay--; - } - - } break; - case 0xF: {/* SEx patterndelay */ - - if (control.ticks_counter) break; - if (!control.pattern_delay_2) control.pattern_delay_1=inf+1; /* only once, when vbtick=0 */ - - } break; - } -} - - - - - - - - -/********************* - volume effects -**********************/ - -void CPPlayer::run_volume_column_effects(int p_track) { - - uint8_t param=control.channel[p_track].current_volume_parameter; - - - switch ('A'+control.channel[p_track].current_volume_command) { - - case 'A': { - - if (param>0) control.channel[p_track].volcol_volume_slide=param; - else param=control.channel[p_track].volcol_volume_slide; - - do_volume_slide(p_track,param*0x10+0xF); - - } break; - case 'B': { - - if (param>0) control.channel[p_track].volcol_volume_slide=param; - else param=control.channel[p_track].volcol_volume_slide; - - do_volume_slide(p_track,0xF0+param); - - } break; - case 'C': { - - if (param>0) control.channel[p_track].volcol_volume_slide=param; - else param=control.channel[p_track].volcol_volume_slide; - - do_volume_slide(p_track,param*0x10); - } break; - case 'D': { - - if (param>0) control.channel[p_track].volcol_volume_slide=param; - else param=control.channel[p_track].volcol_volume_slide; - do_volume_slide(p_track,param); - - } break; - case 'E': { - - do_pitch_slide_down(p_track,param<<2); - } break; - case 'F': { - - do_pitch_slide_up(p_track,param<<2); - } break; - case 'G': { - - const uint8_t slide_table[]={0,1,4,8,16,32,64,96,128,255}; - if (param) { - - control.channel[p_track].portamento_speed=slide_table[param]; - } - - if (control.channel[p_track].period && (control.channel[p_track].old_note<=120)) { - - if ( (!control.ticks_counter) && (control.channel[p_track].new_instrument) ){ - - //control.channel[p_track].kick=KICK_NOTE; - //control.channel[p_track].sample_start_index=0; // < am i stupid? - } else { - - control.channel[p_track].kick=(control.channel[p_track].kick==KICK_NOTE)?KICK_ENVELOPE:KICK_NOTHING; - do_pitch_slide_to_note(p_track); - control.channel[p_track].has_own_period=true; - } - - } - } break; - case 'H': { - - - if (!control.ticks_counter) { - if (param&0x0f) control.channel[p_track].vibrato_depth=param; - } - control.channel[p_track].doing_vibrato=true; - if (control.external_vibrato) break; - if (control.channel[p_track].period) { - - do_vibrato(p_track,false); - control.channel[p_track].has_own_period=true; - } - - } break; - } -} -/********************* - table -**********************/ - - -void CPPlayer::run_effects(int p_track) { - - switch ('A'+control.channel[p_track].current_command) { - - case 'A': { - - if ((control.ticks_counter>0) || (control.pattern_delay_2>0)) break; - - int new_speed; - - new_speed=control.channel[p_track].current_parameter % 128; - - if (new_speed>0) { - control.speed=new_speed; - control.ticks_counter=0; - } - } break; - case 'B': { - - int next_order; - - if (control.ticks_counter || control.position.forbid_jump) break; - - control.position.current_row=0; - - if (control.play_mode==PLAY_PATTERN) break; - - next_order=get_song_next_order_idx(song, (int)control.channel[p_track].current_parameter-1); - - if (next_order!=-1) { - // Do we have a "next order?" - control.position.current_pattern=song->get_order(next_order); - control.position.force_next_order=next_order; - - } else { - // no, probably the user deleted the orderlist. - control.play_mode=PLAY_NOTHING; - reset(); - } - } break; - case 'C': { - - int next_order; - - if (control.ticks_counter || control.position.forbid_jump) break; - - control.position.current_row=control.channel[p_track].current_parameter; - - if (control.play_mode==PLAY_PATTERN) { - - if (control.position.current_row>=song->get_pattern(control.position.current_pattern)->get_length()) { - - control.position.current_row=0; - } - - break; - } - - next_order=get_song_next_order_idx(song, (int)control.position.current_order); - - if (next_order!=-1) { - // Do we have a "next order?" - control.position.current_pattern=song->get_order(next_order); - - if (control.position.current_row>=song->get_pattern(song->get_order(next_order))->get_length()) { - - control.position.current_row=0; - } - - control.position.force_next_order=next_order; - - } else { - // no, probably the user deleted the orderlist. - control.play_mode=PLAY_NOTHING; - reset(); - } - - } break; - case 'D': { - - uint8_t inf ; - //explicitslides=1; - inf=control.channel[p_track].current_parameter; - - if (inf) control.channel[p_track].volume_slide_info=inf; - else inf=control.channel[p_track].volume_slide_info; - - do_volume_slide(p_track,inf); - - } break; - case 'E': { - - uint8_t inf; - - inf=control.channel[p_track].current_parameter; - do_pitch_slide_down(p_track,inf); - - } break; - case 'F': { - - uint8_t inf; - - inf=control.channel[p_track].current_parameter; - do_pitch_slide_up(p_track,inf); - - } break; - case 'G': { - - if (control.channel[p_track].current_parameter) { - - control.channel[p_track].portamento_speed=control.channel[p_track].current_parameter; - } - - if (control.channel[p_track].period && (control.channel[p_track].old_note<=120)) { - - if ( (!control.ticks_counter) && (control.channel[p_track].new_instrument) ){ - - - control.channel[p_track].kick=KICK_NOTE; - control.channel[p_track].sample_start_index=0; - - } else { - - control.channel[p_track].kick=(control.channel[p_track].kick==KICK_NOTE)?KICK_ENVELOPE:KICK_NOTHING; - } - - do_pitch_slide_to_note(p_track); - control.channel[p_track].has_own_period=true; - } - - } break; - case 'H': { - - uint8_t dat; - - control.channel[p_track].doing_vibrato=true; - - dat=control.channel[p_track].current_parameter; - - if (!control.ticks_counter) { - if (dat&0x0f) control.channel[p_track].vibrato_depth=dat&0xf; - if (dat&0xf0) control.channel[p_track].vibrato_speed=(dat&0xf0)>>2; - } - - if (control.external_vibrato) break; - - if (control.channel[p_track].period) { - - do_vibrato(p_track,false); - control.channel[p_track].has_own_period=true; - } - - } break; - case 'I': { - - do_tremor(p_track); - control.channel[p_track].has_own_volume=true; - } break; - case 'J': { - - do_arpegio(p_track); - } break; - case 'K': { - - uint8_t inf ; - //explicitslides=1; - inf=control.channel[p_track].current_parameter; - - control.channel[p_track].doing_vibrato=true; - - - if (inf) control.channel[p_track].volume_slide_info=inf; - else inf=control.channel[p_track].volume_slide_info; - - do_volume_slide(p_track,inf); - - if (control.external_vibrato) break; - - if (control.channel[p_track].period) { - - do_vibrato(p_track,false); - control.channel[p_track].has_own_period=true; - } - - } break; - case 'L': { - uint8_t inf ; - //explicitslides=1; - inf=control.channel[p_track].current_parameter; - - if (inf) control.channel[p_track].volume_slide_info=inf; - else inf=control.channel[p_track].volume_slide_info; - - do_volume_slide(p_track,inf); - - if (control.channel[p_track].period && (control.channel[p_track].old_note<=120)) { - if ( (!control.ticks_counter) && (control.channel[p_track].new_instrument) ){ - - control.channel[p_track].kick=KICK_NOTE; - control.channel[p_track].sample_start_index=0; - - } else { - - control.channel[p_track].kick=(control.channel[p_track].kick==KICK_NOTE)?KICK_ENVELOPE:KICK_NOTHING; - } - - do_pitch_slide_to_note(p_track); - control.channel[p_track].has_own_period=true; - } - } break; - case 'M': { - control.channel[p_track].channel_volume=control.channel[p_track].current_parameter; - if (control.channel[p_track].channel_volume>64) control.channel[p_track].channel_volume=64; - else if (control.channel[p_track].channel_volume<0) control.channel[p_track].channel_volume=0; - } break; - case 'N': { - - do_channel_volume_slide(p_track); - } - case 'O': { - - if (!control.ticks_counter) { - - if (control.channel[p_track].current_parameter) control.channel[p_track].lo_offset=(uint16_t)control.channel[p_track].current_parameter<<8; - control.channel[p_track].sample_start_index=control.channel[p_track].hi_offset|control.channel[p_track].lo_offset; - - //if ((control.channel[p_track].sample_ptr!=NULL)&&(control.channel[p_track].sample_start_index>control.channel[p_track].sample_ptr->data.size)) { - //TODO, O effect - //a->start=a->s->flags&(SF_LOOP|SF_BIDI)?a->s->loopstart:a->s->length; - //} - } - } break; - case 'P': { - - do_pan_slide(p_track); - } break; - case 'Q': { - do_retrig(p_track); - - } break; - case 'R': { - - - uint8_t dat; - - if (control.channel[p_track].current_parameter) { - - control.channel[p_track].tremolo_info=control.channel[p_track].current_parameter; - } - - dat=control.channel[p_track].tremolo_info; - - if (!control.ticks_counter && dat) { - - if (dat&0x0f) control.channel[p_track].tremolo_depth=dat&0xf; - if (dat&0xf0) control.channel[p_track].tremolo_speed=(dat&0xf0)>>2; - } - - do_tremolo(p_track); - control.channel[p_track].has_own_volume=true; - - } break; - case 'S': { - - do_effect_S(p_track); - } break; - case 'T': { - uint8_t dat; - int16_t temp=control.tempo; - - if (control.pattern_delay_2) return; - - if (control.channel[p_track].current_parameter) { - - control.channel[p_track].tempo_slide_info=control.channel[p_track].current_parameter; - } - - dat=control.channel[p_track].tempo_slide_info; - - if (dat>=0x20) { - - if (control.ticks_counter) break; - control.tempo=dat; - } else { - - if (!control.ticks_counter) break; - - if (dat&0x10) { - - temp+=(dat&0x0f); - } else { - - temp-=dat; - } - control.tempo=(temp>255)?255:(temp<0x20?0x20:temp); - } - - } break; - case 'U': { - - uint8_t dat; - - dat=control.channel[p_track].current_parameter; - control.channel[p_track].doing_vibrato=true; - if (!control.ticks_counter) { - if (dat&0x0f) control.channel[p_track].vibrato_depth=dat&0xf; - if (dat&0xf0) control.channel[p_track].vibrato_speed=(dat&0xf0)>>2; - } - - if (control.external_vibrato) break; - - if (control.channel[p_track].period) { - - do_vibrato(p_track,true); - control.channel[p_track].has_own_period=true; - } - } break; - case 'V': { - - control.global_volume=control.channel[p_track].current_parameter; - if (control.global_volume>128) control.global_volume=128; - } break; - case 'W': { - do_global_volume_slide(p_track); - } break; - case 'X': { - //sets both channel and current - control.channel[p_track].channel_panning=control.channel[p_track].current_parameter; - control.channel[p_track].panning=control.channel[p_track].current_parameter; - } break; - case 'Y': { - - uint8_t dat; - - if (control.channel[p_track].current_parameter) { - - control.channel[p_track].panbrello_info=control.channel[p_track].current_parameter; - } - - dat=control.channel[p_track].panbrello_info; - - if (!control.ticks_counter) { - - if (dat&0x0f) control.channel[p_track].panbrello_depth=(dat&0xf); - if (dat&0xf0) control.channel[p_track].panbrello_speed=(dat&0xf0)>>4; - } - - //if (pf->panflag) - if (control.channel[p_track].panning!=PAN_SURROUND)do_panbrello(p_track); - - } break; - case 'Z': { - //I DO! cuttoff! - uint16_t dat=control.channel[p_track].current_parameter; - - if (dat<0x80) { - - control.channel[p_track].filter.it_cutoff=dat*2; - if (control.channel[p_track].filter.it_cutoff>0x80) - control.channel[p_track].filter.it_cutoff++; - } else if (dat<0x90) { - - control.channel[p_track].filter.it_reso=(dat-0x80)*0x10; - } else { - - control.channel[p_track].reverb_send=(dat-0x90)*255/0x6F; - } - - } break; - - } - -} - -void CPPlayer::pre_process_effects() { - -// MP_VOICE *aout; - int i; - - for (i=0;i<CPPattern::WIDTH;i++) { - - //a=&pf->control[mp_channel]; - - // if ((aout=a->slave)) { - // a->fadevol=aout->fadevol; - // a->period=aout->period; - // if (a->kick==KICK_KEYOFF) a->keyoff=aout->keyoff; - //} - - //if (!a->row) continue; - //UniSetRow(a->row); - control.channel[i].has_own_period=false; - control.channel[i].has_own_volume=false; - control.channel[i].doing_vibrato=false; - //explicitslides=0; - //pt_playeffects(); - if (control.ticks_counter<control.speed) { - - run_effects(i); - run_volume_column_effects(i); - } - - /* continue volume slide if necessary for XM and IT */ - //if (pf->flags&UF_BGSLIDES) { - // if (!explicitslides && a->sliding) - // DoS3MVolSlide(0); - // else if (a->tmpvolume) a->sliding=explicitslides; - //} - - if (!control.channel[i].has_own_period) control.channel[i].period=control.channel[i].aux_period; - if (!control.channel[i].has_own_volume) control.channel[i].volume=control.channel[i].aux_volume; - - if ((control.channel[i].sample_ptr!=NULL) && !(song->has_instruments() && (control.channel[i].instrument_ptr==NULL))) { - - if (song->has_instruments()) { - - control.channel[i].output_volume= - (control.channel[i].volume*control.channel[i].sample_ptr->get_global_volume()*control.channel[i].instrument_ptr->get_volume_global_amount())/2048; - control.channel[i].output_volume=control.channel[i].output_volume*control.channel[i].random_volume_variation/100; - - } else { - - control.channel[i].output_volume= - (control.channel[i].volume*control.channel[i].sample_ptr->get_global_volume())>>4; - - } - - if (control.channel[i].output_volume>256) { - - control.channel[i].output_volume=256; - - } else if (control.channel[i].output_volume<0) { - - control.channel[i].output_volume=0; - } - - - } - } - -} diff --git a/modules/chibi/cp_player_data_envelopes.cpp b/modules/chibi/cp_player_data_envelopes.cpp deleted file mode 100644 index a720eaf734..0000000000 --- a/modules/chibi/cp_player_data_envelopes.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/*************************************************************************/ -/* cp_player_data_envelopes.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_player_data.h" - - -void CPPlayer::Voice_Control::start_envelope(CPEnvelope *p_envelope,Envelope_Control *p_envelope_ctrl,Envelope_Control *p_from_env) { - - - if (p_from_env && p_envelope->is_carry_enabled() && !p_from_env->terminated) { - - - *p_envelope_ctrl=*p_from_env; - } else { - p_envelope_ctrl->pos_index=0; - p_envelope_ctrl->status=1; - p_envelope_ctrl->sustain_looping=p_envelope->is_sustain_loop_enabled(); - p_envelope_ctrl->looping=p_envelope->is_loop_enabled(); - p_envelope_ctrl->terminated=false; - p_envelope_ctrl->kill=false; - p_envelope_ctrl->value=p_envelope->get_height_at_pos(p_envelope_ctrl->pos_index); - } -} - -bool CPPlayer::Voice_Control::process_envelope(CPEnvelope *p_envelope,Envelope_Control *p_envelope_ctrl) { - - if (!p_envelope_ctrl->active) - return false; - - if (note_end_flags&END_NOTE_OFF) p_envelope_ctrl->sustain_looping=false; - - p_envelope_ctrl->value=p_envelope->get_height_at_pos(p_envelope_ctrl->pos_index); - if (p_envelope_ctrl->value==CPEnvelope::NO_POINT) - return false; - - - p_envelope_ctrl->pos_index++; - - if (p_envelope_ctrl->sustain_looping) { - - if (p_envelope_ctrl->pos_index>p_envelope->get_node(p_envelope->get_sustain_loop_end()).tick_offset) { - - p_envelope_ctrl->pos_index=p_envelope->get_node(p_envelope->get_sustain_loop_begin()).tick_offset; - } - - } else if (p_envelope_ctrl->looping) { - - if (p_envelope_ctrl->pos_index>p_envelope->get_node(p_envelope->get_loop_end()).tick_offset) { - - p_envelope_ctrl->pos_index=p_envelope->get_node(p_envelope->get_loop_begin()).tick_offset; - } - - } - - if (p_envelope_ctrl->pos_index>p_envelope->get_node(p_envelope->get_node_count()-1).tick_offset) { - - p_envelope_ctrl->terminated=true; - p_envelope_ctrl->pos_index=p_envelope->get_node(p_envelope->get_node_count()-1).tick_offset; - if (p_envelope->get_node(p_envelope->get_node_count()-1).value==0) p_envelope_ctrl->kill=true; - } - - return true; -} diff --git a/modules/chibi/cp_player_data_events.cpp b/modules/chibi/cp_player_data_events.cpp deleted file mode 100644 index 94a048ab2f..0000000000 --- a/modules/chibi/cp_player_data_events.cpp +++ /dev/null @@ -1,681 +0,0 @@ -/*************************************************************************/ -/* cp_player_data_events.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_player_data.h" -#include "cp_sample_manager.h" -#include "stdio.h" -/* - setup_voices(): - -This will go throught all the REAL channels, if it finds a channel -that needs to be restarted or assigned a new VIRTUAL channel, then it -will just find one and do it. - -*/ - - -#define C5FREQ 261.6255653006 -static const int32_t C5FREQ_MIXER = ((int32_t)(C5FREQ*(float)(1<<CPMixer::FREQUENCY_BITS))); - - -void CPPlayer::setup_voices() { - - int i,voice_index; - - - - - for (i=0;i<CPPattern::WIDTH;i++) { - - voice_index=-1; - - if (control.channel[i].note_delay) continue; - - - // check if we need a new empty voice - if (control.channel[i].kick==KICK_NOTE) { - - /* if no channel was cut above, find an empty or quiet channel - here */ - if ( song->has_instruments() && !control.force_no_nna) { - - if (control.channel[i].slave_voice==NULL) { // no slave?? - - int newchn; - if ((newchn=find_empty_voice())!=-1) { - - control.channel[i].slave_voice_index=newchn; - control.channel[i].slave_voice=&voice[newchn]; - } - } - - } else { - if (i<control.max_voices) { - - control.channel[i].slave_voice_index=i; - control.channel[i].slave_voice=&voice[i]; - } else { - //This is a _DIRTY_ hack, but i cant think a better way. - control.channel[i].slave_voice_index=control.max_voices-1; - control.channel[i].slave_voice=&voice[control.max_voices-1]; - } - - } - - - /* assign parts of MP_VOICE only done for a KICK_NOTE */ - if ( ( control.channel[i].slave_voice!=NULL ) ) { - - voice_index=control.channel[i].slave_voice_index; - Voice_Control &v=voice[voice_index]; - - if (v.has_master_channel && (v.master_channel!=NULL) ) { - // If this voice already has a master channel, make sure to remove the reference to it. - v.master_channel->slave_voice=NULL; - - } - //notify the voice that the current channel is the master - v.master_channel=&control.channel[i]; - //set the voice as slave of the current channel - control.channel[i].slave_voice=&v; - //master channel index of the voice - v.master_channel_index=i; - v.has_master_channel=true; - } - - } else { - // nope.. - // so if we DO have a slave voice then use it. - if ( control.channel[i].slave_voice!=NULL ) { - - voice_index=control.channel[i].slave_voice_index; - } - } - //assuming this channel has a slave voice.. - if (voice_index>=0) { - - // IMPROVE: Code a method for this: - voice[voice_index].update_info_from_master_channel(); - } - - control.channel[i].kick=KICK_NOTHING; - } -} -void CPPlayer::Voice_Control::reset() { - - cp_memzero(this,sizeof(*this)); - - instrument_ptr=NULL; - sample_ptr=NULL; - has_master_channel=false; - instrument_index=-1; - reverb_send=0; - chorus_send=0; - filter.it_cutoff=255; - filter.it_reso=0; - display_volume=0; - - -} - -void CPPlayer::Channel_Control::reset() { - - int prev_gv =channel_global_volume; - cp_memzero(this,sizeof(*this)); - - slave_voice=NULL; - slave_voice_index=255; - - mute=false; - old_note=255; - real_note=255; - instrument_index=255; - filter.it_cutoff=255; - filter.it_reso=0; - reverb_send=0; - chorus_send=0; - reserved=false; - carry.maybe=false; - last_event_usecs=-1; - channel_global_volume=prev_gv; -} - -void CPPlayer::Voice_Control::update_info_from_master_channel() { - - instrument_ptr=master_channel->instrument_ptr; - sample_ptr=master_channel->sample_ptr; - - instrument_index=master_channel->instrument_index; - sample_index=master_channel->sample_index; - - note=master_channel->note; - output_volume=master_channel->output_volume; - - channel_volume=master_channel->channel_volume; - - panning=master_channel->panning; - - kick=master_channel->kick; - note_end_flags=master_channel->note_end_flags; - period=master_channel->period; - - volume_envelope_ctrl.active=master_channel->volume_envelope_on; - panning_envelope_ctrl.active=master_channel->panning_envelope_on; - pitch_envelope_ctrl.active=master_channel->pitch_envelope_on; - - - NNA_type=master_channel->NNA_type; - reverb_send=master_channel->reverb_send; - chorus_send=master_channel->chorus_send; - - //last_note_type=master_channel->last_note_type; - - sample_start_index=master_channel->sample_start_index; - filter=master_channel->filter; - -} - - -void CPPlayer::update_mixer() { - - int tmp_mixer_period; - int32_t tmp_vibrato_value,tmp_vibrato_depth,tmp_volenv_value; - uint64_t tmpvol; // 64bits should be the only way to avoid getting notes raped out - int i; - - - control.voices_used=0; - - for (i=0;i<control.max_voices;i++) { - - - int filter_env=-1; - Voice_Control &v=voice[i]; - - if ( !((v.kick==KICK_NOTE)||(v.kick==KICK_NOTEOFF)) && !is_voice_active(i)) - continue; - - //if voice doesnt have a sample set or size is 0.. forget it - if ( v.sample_ptr==NULL) continue; - - - //TODO set limits somewhere else - - if (v.period<40) { - - v.period=40; - - } else if (v.period>50000) { - - v.period=50000; - } - - - if ((v.kick==KICK_NOTE)||(v.kick==KICK_NOTEOFF)) { - - int real_start_index; - - if (v.sample_start_index==-1) { - - real_start_index=0; - - } else { - - real_start_index=v.sample_start_index; - } - - mixer->setup_voice(i,v.sample_ptr->get_sample_data(),real_start_index); - v.fadeout_volume=1024; //IT Docs it is 1024 internally - v.auto_vibrato_sweep_pos=0; - - - - } - - - /* Start Envelopes */ - if ( song->has_instruments() && ((v.kick==KICK_NOTE)||(v.kick==KICK_ENVELOPE))) { - - //Voice_Control *carry=0; - - - if (v.has_master_channel && v.master_channel->carry.maybe) { - - v.start_envelope(v.instrument_ptr->get_volume_envelope(),&v.volume_envelope_ctrl,&v.master_channel->carry.vol); - v.start_envelope(v.instrument_ptr->get_pan_envelope(),&v.panning_envelope_ctrl,&v.master_channel->carry.pan); - v.start_envelope(v.instrument_ptr->get_pitch_filter_envelope(),&v.pitch_envelope_ctrl,&v.master_channel->carry.pitch); - - } else { - - v.start_envelope(v.instrument_ptr->get_volume_envelope(),&v.volume_envelope_ctrl,NULL); - v.start_envelope(v.instrument_ptr->get_pan_envelope(),&v.panning_envelope_ctrl,NULL); - v.start_envelope(v.instrument_ptr->get_pitch_filter_envelope(),&v.pitch_envelope_ctrl,NULL); - - } - - - } - - v.kick=KICK_NOTHING; - - if (song->has_instruments()) { - - if (!v.process_envelope(v.instrument_ptr->get_volume_envelope(),&v.volume_envelope_ctrl)) - v.volume_envelope_ctrl.value=64; - - if (!v.process_envelope(v.instrument_ptr->get_pan_envelope(),&v.panning_envelope_ctrl)) - v.panning_envelope_ctrl.value=0; - - if (!v.process_envelope(v.instrument_ptr->get_pitch_filter_envelope(),&v.pitch_envelope_ctrl)) - v.pitch_envelope_ctrl.value=0; - - - if (v.volume_envelope_ctrl.terminated) { - - if (v.volume_envelope_ctrl.kill) { - - v.fadeout_volume=0; - } else { - - v.note_end_flags|=END_NOTE_FADE; - } - } - - } - - if (song->has_instruments()) { - - tmp_volenv_value=v.volume_envelope_ctrl.value; - } else { - - tmp_volenv_value=64; - - } - - /*printf("fadeout %i\n",(int)v.fadeout_volume); - printf("channel %i\n",(int)v.channel_volume); - printf("output %i\n",(int)v.output_volume); - printf("env %i\n",(int)tmp_volenv_value); - printf("cgb %i\n",(int)v.master_channel->channel_global_volume); -*/ - - - tmpvol=(uint64_t)v.fadeout_volume; /* max 1024 - 10 bits */ - tmpvol*=(uint64_t)v.channel_volume; /* * max 64 - 6 bits */ - tmpvol*=(uint64_t)v.output_volume; /* * max 256 - 8 bits */ - tmpvol*=(uint64_t)tmp_volenv_value; /* max 64 - 6 bits*/ - tmpvol*=(uint64_t)v.master_channel->channel_global_volume; - v.display_volume=tmpvol>>22; //volume used for display purposes , 0 -- 256 - - tmpvol*=(uint64_t)song->get_mixing_volume(); /* max 128 - 7 bits */ - tmpvol*=(uint64_t)control.global_volume; /* max 128 - 7 bits*/ - /* total 10+6+8+6+7+7=44 bits */ - - tmpvol>>=43; /* Move back to 8 bits range , 44-19+8=43*/ - - if (tmpvol>CP_VOL_MAX) - tmpvol=CP_VOL_MAX; - - //printf("volume check - fade %i, channel %i, output %i, env %i, mix %i, global %i -- final %i\n",v.fadeout_volume, v.channel_volume,v.output_volume,tmp_volenv_value, song->get_mixing_volume(),control.global_volume,tmpvol); - - v.total_volume=tmpvol; - - - if ((v.master_channel!=NULL) && song->is_channel_mute( v.master_channel_index ) && !v.master_channel->reserved) { - - mixer->set_voice_volume(i,0); - } else { - mixer->set_voice_volume(i,tmpvol); - if (v.fadeout_volume>0) control.voices_used++; - } - - - if (!song->is_stereo()) { - - mixer->set_voice_panning(i,PAN_CENTER); - - } else if (v.panning==PAN_SURROUND) { - - mixer->set_voice_panning(i,PAN_SURROUND); - } else if (song->has_instruments()) { - - int newpan,real_modifier; - - - real_modifier=(v.panning_envelope_ctrl.value*(PAN_CENTER-cp_intabs(v.panning-PAN_CENTER)))/32; - - newpan=v.panning+real_modifier; - - newpan=(newpan<PAN_LEFT)?PAN_LEFT:(newpan>PAN_RIGHT)?PAN_RIGHT:newpan; - //printf("panenv val: %i, finalpan val %i\n",v.panning_envelope_ctrl.value,newpan); - - mixer->set_voice_panning(i,newpan); - } else { - mixer->set_voice_panning(i,v.panning); - } - - - - /* VIBRATO */ - - if ( (v.period>0) && (v.sample_ptr->get_vibrato_depth()>0) ) { - - switch (v.sample_ptr->get_vibrato_type()) { - case CPSample::VIBRATO_SINE: - tmp_vibrato_value=auto_vibrato_table[v.auto_vibrato_pos&127]; - if (v.auto_vibrato_pos & 0x80) tmp_vibrato_value=-tmp_vibrato_value; - break; - case CPSample::VIBRATO_SQUARE: - tmp_vibrato_value=64; - if (v.auto_vibrato_pos & 0x80) tmp_vibrato_value=-tmp_vibrato_value; - break; - case CPSample::VIBRATO_SAW: - tmp_vibrato_value=63-(((v.auto_vibrato_pos+128)&255)>>1); - break; - default: - tmp_vibrato_value=(((v.auto_vibrato_pos+128)&255)>>1)-64; - break; - } - } else { - - tmp_vibrato_value=0; - } - - if ((v.auto_vibrato_sweep_pos>>8)<v.sample_ptr->get_vibrato_depth()) { - - v.auto_vibrato_sweep_pos+=v.sample_ptr->get_vibrato_speed(); //FIXME - speed? i think so - tmp_vibrato_depth=v.auto_vibrato_sweep_pos; - - } else { - - tmp_vibrato_depth=v.sample_ptr->get_vibrato_depth()<<8; - } - - tmp_vibrato_value=(tmp_vibrato_value*tmp_vibrato_depth)>>16; - if (song->has_linear_slides()) - tmp_vibrato_value>>=1; - v.period-=tmp_vibrato_value; - - - /* update vibrato position */ - v.auto_vibrato_pos=(v.auto_vibrato_pos+v.sample_ptr->get_vibrato_rate())&0xff; - - - /* process pitch envelope */ - tmp_mixer_period=v.period; - - if (v.pitch_envelope_ctrl.active) { - - long aux_pitch_diff; - int pe_value=v.pitch_envelope_ctrl.value; - - if (!v.instrument_ptr->is_pitch_use_as_filter()) { - - - if (((uint16_t)v.note<<1)+pe_value<=0) - pe_value=-(v.note<<1); - - int smp_c5=CPSampleManager::get_singleton()->get_c5_freq( v.sample_ptr->get_sample_data()); - - int base=get_period(((uint16_t)v.note<<1),smp_c5); - int env=get_period(((uint16_t)v.note<<1)+pe_value,smp_c5); - /* - int env_next=(pe_value<0)?get_period(((uint16_t)(v.note-1)<<1)+pe_value,smp_c5):get_period(((uint16_t)(v.note+1)<<1)+pe_value,smp_c5); - - env=env+(abs(v.pitch_envelope_ctrl.value)&((1<<CPEnvelope::FX_HEIGHT_BITS)-1))*(env_next-env)/(1<<CPEnvelope::FX_HEIGHT_BITS); - - printf("env %i\n",env); - */ - aux_pitch_diff=env-base; - - - if ( ((int)tmp_mixer_period-aux_pitch_diff)<0 ) aux_pitch_diff=0; - - tmp_mixer_period+=aux_pitch_diff; - - } else { - - filter_env=pe_value+32; //max 64 - //printf("pitch envelope at %i",filter_env); - - } - } - - if (v.fadeout_volume==0 || (v.note_end_flags & END_NOTE_KILL)) { /* check for a dead note (fadevol=0) */ - - mixer->stop_voice(i); - - } else { - - - int32_t freq=get_frequency(tmp_mixer_period); - int32_t tracker_c5=get_frequency(get_period(60<<1,CPSampleManager::get_singleton()->get_c5_freq( v.sample_ptr->get_sample_data()))); - - freq=(int32_t)((uint64_t)freq*(uint64_t)C5FREQ_MIXER/(uint64_t)tracker_c5); //numbers may become very high - mixer->set_voice_frequency(i,freq); - - /* if keyfade, start substracting fadeoutspeed from fadevol: */ - if ((song->has_instruments())&&(v.note_end_flags & END_NOTE_FADE)) { - - if (v.fadeout_volume>=(v.instrument_ptr->get_volume_fadeout())) { - - v.fadeout_volume-=(v.instrument_ptr->get_volume_fadeout()); - } else { - - v.fadeout_volume=0; - } - } - - /*FILTARSSSSSSSS*/ - - - - v.filter.envelope_cutoff=filter_env; - v.filter.process(); - - if ((v.filter.final_cutoff<0xFF) && (control.filters)) { - - //int final_cutoff; - //uint8_t final_reso; - - //v.filter.set_filter_parameters( &final_cutoff, &final_reso ); - - mixer->set_voice_filter(i,true,v.filter.final_cutoff,v.filter.it_reso); - } else { - - - mixer->set_voice_filter(i,false,0,0); - } - - /* RAIVERV */ - - mixer->set_voice_reverb_send(i,v.reverb_send); - - /* CHAURUZ */ - - mixer->set_voice_chorus_send(i,v.chorus_send); - - } - } - - - switch(song->get_reverb_mode()) { - - case CPSong::REVERB_MODE_ROOM: { - - mixer->set_reverb_mode( CPMixer::REVERB_MODE_ROOM ); - } break; - case CPSong::REVERB_MODE_STUDIO_SMALL: { - - mixer->set_reverb_mode( CPMixer::REVERB_MODE_STUDIO_SMALL ); - - } break; - case CPSong::REVERB_MODE_STUDIO_MEDIUM: { - - mixer->set_reverb_mode( CPMixer::REVERB_MODE_STUDIO_MEDIUM ); - - } break; - case CPSong::REVERB_MODE_STUDIO_LARGE: { - - mixer->set_reverb_mode( CPMixer::REVERB_MODE_STUDIO_LARGE ); - - } break; - case CPSong::REVERB_MODE_HALL: { - - mixer->set_reverb_mode( CPMixer::REVERB_MODE_HALL ); - - } break; - case CPSong::REVERB_MODE_SPACE_ECHO: { - - mixer->set_reverb_mode( CPMixer::REVERB_MODE_SPACE_ECHO ); - - } break; - case CPSong::REVERB_MODE_ECHO: { - - mixer->set_reverb_mode( CPMixer::REVERB_MODE_ECHO ); - - } break; - case CPSong::REVERB_MODE_DELAY: { - - mixer->set_reverb_mode( CPMixer::REVERB_MODE_DELAY ); - - } break; - case CPSong::REVERB_MODE_HALF_ECHO: { - - mixer->set_reverb_mode( CPMixer::REVERB_MODE_HALF_ECHO ); - - } break; - - } - - mixer->set_chorus_params(song->get_chorus_delay_ms(),song->get_chorus_separation_ms(),song->get_chorus_depth_ms10(),song->get_chorus_speed_hz10() ); - - -} - - - - - - - - -void CPPlayer::handle_tick() { - - int i; - - - if ( mixer==NULL ) return; - if ( song==NULL ) return; - - - /* update time counter (sngtime is in milliseconds (in fact 2^-10)) */ - - if (control.ticks_counter>=control.speed) { // time to process... ***THE ROW***! - - /* process pattern-delay. pf->patdly2 is the counter and pf->patdly is - the command memory. */ - - /* - if (control.pattern_delay_1) { - - control.pattern_delay_2=control.pattern_delay_1; - control.pattern_delay_1=0; - } - if (control.pattern_delay_2) { - patterndelay active - if (--control.pattern_delay_2) - // so turn back pf->patpos by 1 - if (pf->patpos) pf->patpos--; - } - */ - - if (control.play_mode!=PLAY_NOTHING) { - - control.ticks_counter=0; - - - if (control.position.force_next_order>=0) { - - control.position.current_order=control.position.force_next_order; - } - - control.position.force_next_order=-1; - - control.previous_position=control.position; // for those special cases... - control.position.forbid_jump=false; - - for (i=0;i<CPPattern::WIDTH;i++) { - - process_note(i,song->get_pattern(control.position.current_pattern)->get_note(i,control.position.current_row)); - } - - control.position.current_row++; - - if ( control.position.current_row>=song->get_pattern(control.position.current_pattern)->get_length() ) { - - if (control.play_mode==PLAY_SONG) { - - int next_order; - - next_order=get_song_next_order_idx(song,control.position.current_order); - - if (next_order!=-1) { - // Do we have a "next order?" - control.position.current_pattern=song->get_order(next_order); - if (next_order<=control.position.current_order) - control.reached_end=true; - control.position.current_order=next_order; - - } else { - // no, probably the user deleted the orderlist. - control.play_mode=PLAY_NOTHING; - reset(); - control.reached_end=true; - } - } - control.position.current_row=0; - } - - } - - - } - - - - pre_process_effects(); - process_NNAs(); - setup_voices(); - - /* now set up the actual hardware channel playback information */ - update_mixer(); - - control.ticks_counter++; -} diff --git a/modules/chibi/cp_player_data_filter.cpp b/modules/chibi/cp_player_data_filter.cpp deleted file mode 100644 index e04ae126fd..0000000000 --- a/modules/chibi/cp_player_data_filter.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/*************************************************************************/ -/* cp_player_data_filter.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_player_data.h" - -static float filter_cutoff[256] = { - 130, 132, 134, 136, 138, 140, 142, 144, - 146, 148, 151, 153, 155, 157, 160, 162, - 164, 167, 169, 172, 174, 177, 179, 182, - 184, 187, 190, 193, 195, 198, 201, 204, - 207, 210, 213, 216, 220, 223, 226, 229, - 233, 236, 239, 243, 246, 250, 254, 257, - 261, 265, 269, 273, 277, 281, 285, 289, - 293, 297, 302, 306, 311, 315, 320, 324, - 329, 334, 339, 344, 349, 354, 359, 364, - 369, 375, 380, 386, 391, 397, 403, 409, - 415, 421, 427, 433, 440, 446, 452, 459, - 466, 472, 479, 486, 493, 501, 508, 515, - 523, 530, 538, 546, 554, 562, 570, 578, - 587, 595, 604, 613, 622, 631, 640, 649, - 659, 668, 678, 688, 698, 708, 718, 729, - 739, 750, 761, 772, 783, 795, 806, 818, - 830, 842, 854, 867, 880, 892, 905, 918, - 932, 945, 959, 973, 987, 1002, 1016, 1031, - 1046, 1061, 1077, 1092, 1108, 1124, 1141, 1157, - 1174, 1191, 1209, 1226, 1244, 1262, 1280, 1299, - 1318, 1337, 1357, 1376, 1396, 1417, 1437, 1458, - 1479, 1501, 1523, 1545, 1567, 1590, 1613, 1637, - 1661, 1685, 1709, 1734, 1760, 1785, 1811, 1837, - 1864, 1891, 1919, 1947, 1975, 2004, 2033, 2062, - 2093, 2123, 2154, 2185, 2217, 2249, 2282, 2315, - 2349, 2383, 2418, 2453, 2489, 2525, 2561, 2599, - 2637, 2675, 2714, 2753, 2793, 2834, 2875, 2917, - 2959, 3003, 3046, 3091, 3135, 3181, 3227, 3274, - 3322, 3370, 3419, 3469, 3520, 3571, 3623, 3675, - 3729, 3783, 3838, 3894, 3951, 4008, 4066, 4125, - 4186, 4246, 4308, 4371, 4434, 4499, 4564, 4631, - 4698, 4766, 4836, 4906, 4978, 5050, 5123, 5198 -}; - - -void CPPlayer::Filter_Control::process() { - - - final_cutoff=it_cutoff; - if (envelope_cutoff>=0) { - - envelope_cutoff=envelope_cutoff*255/64; - final_cutoff=final_cutoff*envelope_cutoff/255; - if (final_cutoff>=0xFF) final_cutoff=0xFE; - - } - -} - -void CPPlayer::Filter_Control::set_filter_parameters(int *p_cutoff,uint8_t *p_reso) { - - - - *p_cutoff=filter_cutoff[final_cutoff]; - *p_reso=it_reso; -} diff --git a/modules/chibi/cp_player_data_nna.cpp b/modules/chibi/cp_player_data_nna.cpp deleted file mode 100644 index 3c50bfb01f..0000000000 --- a/modules/chibi/cp_player_data_nna.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/*************************************************************************/ -/* cp_player_data_nna.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_player_data.h" - -void CPPlayer::process_NNAs() { - - int i; - - if (!song->has_instruments()) return; - - for (i=0;i<CPPattern::WIDTH;i++) { - - Channel_Control *aux_chn_ctrl = &control.channel[i]; - - if (aux_chn_ctrl->kick==KICK_NOTE) { - - bool k=false; - - if (aux_chn_ctrl->slave_voice!=NULL) { - - Voice_Control *aux_voc_ctrl; - - aux_voc_ctrl=aux_chn_ctrl->slave_voice; - - if (aux_chn_ctrl->instrument_index==aux_chn_ctrl->slave_voice->instrument_index) { //maybe carry - - aux_chn_ctrl->carry.pan=aux_chn_ctrl->slave_voice->panning_envelope_ctrl; - aux_chn_ctrl->carry.vol=aux_chn_ctrl->slave_voice->volume_envelope_ctrl; - aux_chn_ctrl->carry.pitch=aux_chn_ctrl->slave_voice->pitch_envelope_ctrl; - aux_chn_ctrl->carry.maybe=true; - } else - aux_chn_ctrl->carry.maybe=false; - - if (aux_voc_ctrl->NNA_type != CPInstrument::NNA_NOTE_CUT) { - /* Make sure the old MP_VOICE channel knows it has no - master now ! */ - - - - aux_chn_ctrl->slave_voice=NULL; - /* assume the channel is taken by NNA */ - aux_voc_ctrl->has_master_channel=false; - - switch (aux_voc_ctrl->NNA_type) { - case CPInstrument::NNA_NOTE_CONTINUE: { - - } break; - case CPInstrument::NNA_NOTE_OFF: { - - - aux_voc_ctrl->note_end_flags|=END_NOTE_OFF; - - if (!aux_voc_ctrl->volume_envelope_ctrl.active || aux_voc_ctrl->instrument_ptr->get_volume_envelope()->is_loop_enabled()) { - aux_voc_ctrl->note_end_flags|=END_NOTE_FADE; - } - } break; - case CPInstrument::NNA_NOTE_FADE: { - - aux_voc_ctrl->note_end_flags|=END_NOTE_FADE; - } break; - } - } - } - - if (aux_chn_ctrl->duplicate_check_type!=CPInstrument::DCT_DISABLED) { - int i; - - for (i=0;i<control.max_voices;i++) { - if (!mixer->is_voice_active(i)|| - (voice[i].master_channel!=aux_chn_ctrl) || - (aux_chn_ctrl->instrument_index!=voice[i].instrument_index)) - continue; - - Voice_Control *aux_voc_ctrl; - - aux_voc_ctrl=&voice[i]; - - k=false; - switch (aux_chn_ctrl->duplicate_check_type) { - case CPInstrument::DCT_NOTE: - if (aux_chn_ctrl->note==aux_voc_ctrl->note) - k=true; - break; - case CPInstrument::DCT_SAMPLE: - if (aux_chn_ctrl->sample_ptr==aux_voc_ctrl->sample_ptr) - k=true; - break; - case CPInstrument::DCT_INSTRUMENT: - k=true; - break; - } - if (k) { - switch (aux_chn_ctrl->duplicate_check_action) { - case CPInstrument::DCA_NOTE_CUT: { - aux_voc_ctrl->fadeout_volume=0; - } break; - case CPInstrument::DCA_NOTE_OFF: { - - aux_voc_ctrl->note_end_flags|=END_NOTE_OFF; - - if (!aux_voc_ctrl->volume_envelope_ctrl.active || aux_chn_ctrl->instrument_ptr->get_volume_envelope()->is_loop_enabled()) { - - aux_voc_ctrl->note_end_flags|=END_NOTE_FADE; - } - - } break; - case CPInstrument::DCA_NOTE_FADE: { - aux_voc_ctrl->note_end_flags|=END_NOTE_FADE; - } break; - } - } - } - - } - } /* if (aux_chn_ctrl->kick==KICK_NOTE) */ - } -} diff --git a/modules/chibi/cp_player_data_notes.cpp b/modules/chibi/cp_player_data_notes.cpp deleted file mode 100644 index 189403343c..0000000000 --- a/modules/chibi/cp_player_data_notes.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/*************************************************************************/ -/* cp_player_data_notes.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_player_data.h" -#include "cp_sample_manager.h" - -#define RANDOM_MAX 2147483647 - -static inline int32_t cp_random_generate(int32_t *seed) { - int32_t k; - int32_t s = (int32_t)(*seed); - if (s == 0) - s = 0x12345987; - k = s / 127773; - s = 16807 * (s - k * 127773) - 2836 * k; - if (s < 0) - s += 2147483647; - (*seed) = (int32_t)s; - return (int32_t)(s & RANDOM_MAX); -} - - -void CPPlayer::process_new_note(int p_track,uint8_t p_note) { // if there's really a new note.... - - if (control.channel[p_track].real_note!=255) { - control.channel[p_track].old_note=control.channel[p_track].real_note; - - } - - control.channel[p_track].real_note=p_note; - - control.channel[p_track].kick=KICK_NOTE; - - control.channel[p_track].sample_start_index=-1; - control.channel[p_track].sliding=0; - control.channel[p_track].row_has_note=true; - control.channel[p_track].last_event_usecs=song_usecs; - - if (control.channel[p_track].panbrello_type) control.channel[p_track].panbrello_position=0; -} - -bool CPPlayer::process_new_instrument(int p_track,uint8_t p_instrument) { - - //bool different_instrument=false; - ERR_FAIL_INDEX_V(p_instrument,CPSong::MAX_INSTRUMENTS,false); - - if ( song->has_instruments() ) { - - - control.channel[p_track].instrument_ptr=song->get_instrument(p_instrument); - } else { - - control.channel[p_track].instrument_ptr=NULL; - } - - control.channel[p_track].retrig_counter=0; - control.channel[p_track].tremor_position=0; - control.channel[p_track].sample_offset_fine=0; - int old_instr_index=control.channel[p_track].instrument_index; - control.channel[p_track].instrument_index=p_instrument; - - return (old_instr_index!=p_instrument); - - -} - - - // returns if it was able to process -bool CPPlayer::process_note_and_instrument(int p_track,int p_note,int p_instrument) { - - bool aux_result; - aux_result=false; - CPSample *aux_sample=0; // current sample - int dest_sample_index; - bool new_instrument=false; - - control.channel[p_track].row_has_note=false; // wise man says.. "we dont have a note... until we really know we have a note". - control.channel[p_track].new_instrument=false; - - if ( (p_note<0) && (p_instrument<0) ) return aux_result; // nothing to do here - if ( (p_note==255) && (p_instrument==255) ) return aux_result; - - if ( (p_note>=0) && (p_note<120) ) { - - process_new_note(p_track,p_note); - - } else if (p_note==CPNote::CUT) { - - control.channel[p_track].aux_volume=0; - control.channel[p_track].note_end_flags|=END_NOTE_OFF; - control.channel[p_track].note_end_flags|=END_NOTE_KILL; - return aux_result; - - } else if ((p_note==CPNote::OFF) && (song->has_instruments())) { - - if (control.channel[p_track].instrument_ptr!=NULL) { - - control.channel[p_track].note_end_flags|=END_NOTE_OFF; - - if (!control.channel[p_track].instrument_ptr->get_volume_envelope()->is_enabled() || control.channel[p_track].instrument_ptr->get_volume_envelope()->is_loop_enabled()) { - - control.channel[p_track].note_end_flags|=END_NOTE_FADE; - } - } - - return aux_result; - } else return aux_result; // invalid note! - - - if ( (p_instrument>=0) && (p_instrument<CPSong::MAX_INSTRUMENTS)) { - new_instrument=process_new_instrument(p_track,p_instrument); - - if ( song->has_instruments() ) { - // If we're in instrument mode... - if ( control.channel[p_track].instrument_ptr->get_sample_number(control.channel[p_track].real_note) >= CPSong::MAX_SAMPLES) { - - control.channel[p_track].kick=KICK_NOTHING; - return aux_result; - - } else { - dest_sample_index=control.channel[p_track].instrument_ptr->get_sample_number(control.channel[p_track].real_note); - control.channel[p_track].note=control.channel[p_track].instrument_ptr->get_note_number(control.channel[p_track].real_note); - } - - } else { - // If we're in sample mode... - dest_sample_index=control.channel[p_track].instrument_index; - control.channel[p_track].note=control.channel[p_track].real_note; - } - - control.channel[p_track].sample_index=dest_sample_index; - aux_sample=song->get_sample(dest_sample_index); - - if (!CPSampleManager::get_singleton()->check( aux_sample->get_sample_data() )) { - /* INVALID SAMPLE */ - control.channel[p_track].kick=KICK_NOTHING; - return aux_result; - - } - - aux_sample=song->get_sample(dest_sample_index); - } else { - - - if (!control.channel[p_track].sample_ptr) - return aux_result; - - if (song->has_instruments()) { - - if (!control.channel[p_track].instrument_ptr) - return aux_result; - - control.channel[p_track].note=control.channel[p_track].instrument_ptr->get_note_number(control.channel[p_track].real_note); - - } else { - - control.channel[p_track].note=control.channel[p_track].real_note; - - } - - aux_sample=control.channel[p_track].sample_ptr; - - } - - - - if (p_instrument>=CPSong::MAX_INSTRUMENTS && control.channel[p_track].sample_ptr!=aux_sample) { - - control.channel[p_track].new_instrument=(control.channel[p_track].period>0); - } - - control.channel[p_track].sample_ptr=aux_sample; - - /* channel or instrument determined panning ? */ - - control.channel[p_track].panning=control.channel[p_track].channel_panning; - - /* set filter,if any ? */ - - - if (aux_sample->is_pan_enabled()) { - - control.channel[p_track].panning=(int)aux_sample->get_pan()*255/64; - - } else if ( song->has_instruments() && (control.channel[p_track].instrument_ptr->is_pan_default_enabled()) ) { - - control.channel[p_track].panning=(int)control.channel[p_track].instrument_ptr->get_pan_default_amount()*255/64; - } - - - if (song->has_instruments()) { - - - /* Pitch-Pan Separation */ - if ((control.channel[p_track].instrument_ptr->get_pan_pitch_separation()!=0) && (control.channel[p_track].channel_panning!=PAN_SURROUND)){ - - control.channel[p_track].panning+=((control.channel[p_track].real_note-control.channel[p_track].instrument_ptr->get_pan_pitch_center())*control.channel[p_track].instrument_ptr->get_pan_pitch_separation())/8; - - if (control.channel[p_track].panning<PAN_LEFT) control.channel[p_track].panning=PAN_LEFT; - if (control.channel[p_track].panning>PAN_RIGHT) control.channel[p_track].panning=PAN_RIGHT; - } - - /* Random Volume Variation */ - if (control.channel[p_track].instrument_ptr->get_volume_random_variation()>0) { - - control.channel[p_track].random_volume_variation=100-(cp_random_generate(&control.random_seed) % control.channel[p_track].instrument_ptr->get_volume_random_variation()); - - } else { - - control.channel[p_track].random_volume_variation=100; - } - - - /* Random Pan Variation */ - if ((control.channel[p_track].instrument_ptr->get_pan_random_variation()>0) && (control.channel[p_track].panning!=PAN_SURROUND)){ - - int aux_pan_modifier; - - aux_pan_modifier=(cp_random_generate(&control.random_seed) % (control.channel[p_track].instrument_ptr->get_pan_random_variation() << 2)); - if ((cp_random_generate(&control.random_seed) % 2)==1) aux_pan_modifier=0-aux_pan_modifier; /* it's 5am, let me sleep :) */ - - control.channel[p_track].panning+=aux_pan_modifier; - - if (control.channel[p_track].panning<PAN_LEFT) control.channel[p_track].panning=PAN_LEFT; - if (control.channel[p_track].panning>PAN_RIGHT) control.channel[p_track].panning=PAN_RIGHT; - - - } - - /*filter*/ - - if (control.channel[p_track].instrument_ptr->filter_use_default_cutoff()) { - - control.channel[p_track].filter.it_cutoff=control.channel[p_track].instrument_ptr->get_filter_default_cutoff()*2; - - } - - if (control.channel[p_track].instrument_ptr->filter_use_default_resonance()) { - - control.channel[p_track].filter.it_reso=control.channel[p_track].instrument_ptr->get_filter_default_resonance()*2; - - } - - /*envelopes*/ - - - control.channel[p_track].volume_envelope_on=control.channel[p_track].instrument_ptr->get_volume_envelope()->is_enabled(); - control.channel[p_track].panning_envelope_on=control.channel[p_track].instrument_ptr->get_pan_envelope()->is_enabled(); - control.channel[p_track].pitch_envelope_on=control.channel[p_track].instrument_ptr->get_pitch_filter_envelope()->is_enabled(); - control.channel[p_track].NNA_type=control.channel[p_track].instrument_ptr->get_NNA_type(); - control.channel[p_track].duplicate_check_type=control.channel[p_track].instrument_ptr->get_DC_type(); - control.channel[p_track].duplicate_check_action=control.channel[p_track].instrument_ptr->get_DC_action(); - - - } else { - - control.channel[p_track].NNA_type=CPInstrument::NNA_NOTE_CUT; - control.channel[p_track].duplicate_check_type=CPInstrument::DCT_DISABLED; - control.channel[p_track].duplicate_check_action=CPInstrument::DCA_NOTE_CUT; - } - - - if (p_instrument<CPSong::MAX_INSTRUMENTS) { // instrument change - - control.channel[p_track].volume=control.channel[p_track].aux_volume=aux_sample->get_default_volume(); - - } - - - control.channel[p_track].slide_to_period=control.channel[p_track].aux_period=get_period((uint16_t)(control.channel[p_track].note)<<1,CPSampleManager::get_singleton()->get_c5_freq( (aux_sample->get_sample_data()))); - - control.channel[p_track].note_end_flags=END_NOTE_NOTHING; /* clears flags */ - - return true; -} - -void CPPlayer::process_volume_column(int p_track,uint8_t p_volume) { - - control.channel[p_track].current_volume_command=CPNote::EMPTY; - control.channel[p_track].current_volume_parameter=CPNote::EMPTY; - - if (p_volume<65) { // VOLUME - - control.channel[p_track].aux_volume=p_volume; - } else if (p_volume<125) { // Volume Command - - - control.channel[p_track].current_volume_command=(p_volume-65) / 10; - control.channel[p_track].current_volume_parameter=(p_volume-65) % 10; - } else if (p_volume<193) { // PAN - - control.channel[p_track].channel_panning=(p_volume-128)*PAN_RIGHT/64; - control.channel[p_track].panning=control.channel[p_track].channel_panning; - - } else if (p_volume<213) { //More volume Commands - - control.channel[p_track].current_volume_command=((p_volume-193) / 10)+6; - control.channel[p_track].current_volume_parameter=(p_volume-193) % 10; - } -} - - -void CPPlayer::process_note(int p_track,CPNote p_note) { - - if ( p_note.note!=CPNote::SCRIPT ) { - - process_note_and_instrument(p_track,p_note.note,p_note.instrument); - process_volume_column(p_track,p_note.volume); - control.channel[p_track].current_command=p_note.command; - control.channel[p_track].current_parameter=p_note.parameter; - - } else { - - CPNote n = song->get_pattern( control.position.current_pattern )->get_transformed_script_note( p_track, control.position.current_row ); - process_note( p_track, n ); - - song->get_pattern( control.position.current_pattern )->scripted_clone( p_track, control.position.current_row ); - } -} diff --git a/modules/chibi/cp_player_data_utils.cpp b/modules/chibi/cp_player_data_utils.cpp deleted file mode 100644 index b99dbfcb99..0000000000 --- a/modules/chibi/cp_player_data_utils.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/*************************************************************************/ -/* cp_player_data_utils.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_player_data.h" -uint8_t CPPlayer::vibrato_table[32]={ - 0, 24, 49, 74, 97,120,141,161,180,197,212,224,235,244,250,253, - 255,253,250,244,235,224,212,197,180,161,141,120, 97, 74, 49, 24 -}; - -uint8_t CPPlayer::auto_vibrato_table[128]={ - 0, 1, 3, 4, 6, 7, 9,10,12,14,15,17,18,20,21,23, - 24,25,27,28,30,31,32,34,35,36,38,39,40,41,42,44, - 45,46,47,48,49,50,51,52,53,54,54,55,56,57,57,58, - 59,59,60,60,61,61,62,62,62,63,63,63,63,63,63,63, - 64,63,63,63,63,63,63,63,62,62,62,61,61,60,60,59, - 59,58,57,57,56,55,54,54,53,52,51,50,49,48,47,46, - 45,44,42,41,40,39,38,36,35,34,32,31,30,28,27,25, - 24,23,21,20,18,17,15,14,12,10, 9, 7, 6, 4, 3, 1 -}; - - -int8_t CPPlayer::panbrello_table[256]={ - 0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 16, 17, 19, 20, 22, 23, - 24, 26, 27, 29, 30, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, - 59, 60, 60, 61, 61, 62, 62, 62, 63, 63, 63, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 63, 63, 63, 62, 62, 62, 61, 61, 60, 60, - 59, 59, 58, 57, 56, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, - 45, 44, 43, 42, 41, 39, 38, 37, 36, 34, 33, 32, 30, 29, 27, 26, - 24, 23, 22, 20, 19, 17, 16, 14, 12, 11, 9, 8, 6, 5, 3, 2, - 0,- 2,- 3,- 5,- 6,- 8,- 9,-11,-12,-14,-16,-17,-19,-20,-22,-23, - -24,-26,-27,-29,-30,-32,-33,-34,-36,-37,-38,-39,-41,-42,-43,-44, - -45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-56,-57,-58,-59, - -59,-60,-60,-61,-61,-62,-62,-62,-63,-63,-63,-64,-64,-64,-64,-64, - -64,-64,-64,-64,-64,-64,-63,-63,-63,-62,-62,-62,-61,-61,-60,-60, - -59,-59,-58,-57,-56,-56,-55,-54,-53,-52,-51,-50,-49,-48,-47,-46, - -45,-44,-43,-42,-41,-39,-38,-37,-36,-34,-33,-32,-30,-29,-27,-26, - -24,-23,-22,-20,-19,-17,-16,-14,-12,-11,- 9,- 8,- 6,- 5,- 3,- 2 -}; - - - - - - -int32_t CPPlayer::get_period(uint16_t p_note,int32_t p_c5speed) { - - if (song->has_linear_slides()) { - - return CPTables::get_linear_period(p_note,0); - } else { - - - return CPTables::get_log_period(p_note>>1,p_c5speed >>1); - } -} - - -int32_t CPPlayer::get_frequency(int32_t period) { - - if (song->has_linear_slides()) { - - return CPTables::get_linear_frequency(period); - } else { - - return CPTables::get_old_frequency(period); - } -} - -int CPPlayer::find_empty_voice() { - - int i; - int min_priority,min_priority_chan=0,priority; - - for (i=0;i<control.max_voices;i++) { - - if ( ((voice[i].kick==KICK_NOTHING)||(voice[i].kick==KICK_ENVELOPE))&&!mixer->is_voice_active(i) ) { - - return i; - - } - } - - // todo more - - for (i=0;i<control.max_voices;i++) { - /* allow us to take over a nonexisting sample */ - /* - if ((voice[i].s==NULL) - return k; - */ - - if ((voice[i].kick==KICK_NOTHING)||(voice[i].kick==KICK_ENVELOPE)) { - - priority=voice[i].total_volume<<((CPSampleManager::get_singleton()->get_loop_type( voice[i].sample_ptr->get_sample_data())!=CP_LOOP_NONE)?1:0); - - if ((voice[i].has_master_channel)&&(&voice[i]==voice[i].master_channel->slave_voice)) { - - priority<<=2; - - } - - if ((i==0) || (priority<min_priority)) { - min_priority=priority; - min_priority_chan=i; - } - } - } - - if (min_priority>8000*7) return -1; /* what the fuck is this? */ - - return min_priority_chan; -} - diff --git a/modules/chibi/cp_sample.cpp b/modules/chibi/cp_sample.cpp deleted file mode 100644 index bea8835548..0000000000 --- a/modules/chibi/cp_sample.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/*************************************************************************/ -/* cp_sample.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_sample.h" - -const char * CPSample::get_name() const { - - return name; -} -void CPSample::set_name(const char *p_name) { - - if (p_name==NULL) { - name[0]=0; - return; - } - - - bool done=false; - for (int i=0;i<NAME_MAX_LEN;i++) { - - - name[i]=done?0:p_name[i]; - if (!done && p_name[i]==0) - done=true; - } - - name[NAME_MAX_LEN-1]=0; /* just in case */ - -} - -void CPSample::set_default_volume(uint8_t p_vol) { - - default_volume=p_vol; -} -uint8_t CPSample::get_default_volume() const{ - - return default_volume; -} - -void CPSample::set_global_volume(uint8_t p_vol) { - - global_volume=p_vol; -} -uint8_t CPSample::get_global_volume() const{ - - return global_volume; -} - -void CPSample::set_pan_enabled(bool p_vol) { - - pan_enabled=p_vol; -} -bool CPSample::is_pan_enabled() const{ - - return pan_enabled; -} - -void CPSample::set_pan(uint8_t p_pan) { - - pan=p_pan; - -} -uint8_t CPSample::get_pan() const{ - - return pan; -} - - -void CPSample::set_vibrato_type(VibratoType p_vibrato_type) { - - vibrato_type=p_vibrato_type; -} -CPSample::VibratoType CPSample::get_vibrato_type() const{ - - return vibrato_type; -} - -void CPSample::set_vibrato_speed(uint8_t p_vibrato_speed) { - - vibrato_speed=p_vibrato_speed; -} -uint8_t CPSample::get_vibrato_speed() const { - - return vibrato_speed; -} - -void CPSample::set_vibrato_depth(uint8_t p_vibrato_depth) { - - vibrato_depth=p_vibrato_depth; -} -uint8_t CPSample::get_vibrato_depth() const{ - - return vibrato_depth; -} - -void CPSample::set_vibrato_rate(uint8_t p_vibrato_rate) { - - vibrato_rate=p_vibrato_rate; -} -uint8_t CPSample::get_vibrato_rate() const{ - - return vibrato_rate; -} - -void CPSample::set_sample_data(CPSample_ID p_ID) { - - id=p_ID; -} -CPSample_ID CPSample::get_sample_data() const{ - - return id; -} - -void CPSample::operator=(const CPSample &p_sample) { - - copy_from(p_sample); -} -void CPSample::copy_from(const CPSample &p_sample) { - - reset(); - set_name(p_sample.get_name()); - - default_volume=p_sample.default_volume; - global_volume=p_sample.global_volume; - - pan_enabled=p_sample.pan_enabled; - pan=p_sample.pan; - - vibrato_type=p_sample.vibrato_type; - vibrato_speed=p_sample.vibrato_speed; - vibrato_depth=p_sample.vibrato_depth; - vibrato_rate=p_sample.vibrato_rate; - - if (CPSampleManager::get_singleton() && !p_sample.id.is_null()) - CPSampleManager::get_singleton()->copy_to( p_sample.id, id ); -} - - - - - -void CPSample::reset() { - - - name[0]=0; - - default_volume=64; - global_volume=64; - - pan_enabled=false; - pan=32; - - vibrato_type=VIBRATO_SINE; - vibrato_speed=0; - vibrato_depth=0; - vibrato_rate=0; - - if (!id.is_null() && CPSampleManager::get_singleton()) - CPSampleManager::get_singleton()->destroy( id ); - - id=CPSample_ID(); - -} - -CPSample::CPSample(const CPSample&p_from) { - - reset(); - copy_from(p_from); -} -CPSample::CPSample() { - - reset(); -} - -CPSample::~CPSample() { - - reset(); -} diff --git a/modules/chibi/cp_sample.h b/modules/chibi/cp_sample.h deleted file mode 100644 index c02b220c84..0000000000 --- a/modules/chibi/cp_sample.h +++ /dev/null @@ -1,112 +0,0 @@ -/*************************************************************************/ -/* cp_sample.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CPSAMPLE_H -#define CPSAMPLE_H - - -#include "cp_config.h" -#include "cp_sample_manager.h" -class CPSample { - -public: - enum VibratoType { - VIBRATO_SINE, - VIBRATO_SAW, - VIBRATO_SQUARE, - VIBRATO_RANDOM - - }; - -private: - - enum { NAME_MAX_LEN=26 }; - - char name[NAME_MAX_LEN]; - - uint8_t default_volume; /* 0.. 64 */ - uint8_t global_volume; /* 0.. 64 */ - - bool pan_enabled; - uint8_t pan; /* 0.. 64 */ - - VibratoType vibrato_type; - uint8_t vibrato_speed; /* 0.. 64 */ - uint8_t vibrato_depth; /* 0.. 64 */ - uint8_t vibrato_rate; /* 0.. 64 */ - - CPSample_ID id; - - void copy_from(const CPSample &p_sample); -public: - - - void operator=(const CPSample &p_sample); - - const char * get_name() const; - void set_name(const char *p_name); - - void set_default_volume(uint8_t p_vol); - uint8_t get_default_volume() const; - - void set_global_volume(uint8_t p_vol); - uint8_t get_global_volume() const; - - void set_pan_enabled(bool p_vol); - bool is_pan_enabled() const; - - void set_pan(uint8_t p_pan); - uint8_t get_pan() const; - - void set_vibrato_type(VibratoType p_vibrato_type); - VibratoType get_vibrato_type() const; - - void set_vibrato_speed(uint8_t p_vibrato_speed) ; - uint8_t get_vibrato_speed() const; - - void set_vibrato_depth(uint8_t p_vibrato_depth); - uint8_t get_vibrato_depth() const; - - void set_vibrato_rate(uint8_t p_vibrato_rate); - uint8_t get_vibrato_rate() const; - - void set_sample_data(CPSample_ID); - CPSample_ID get_sample_data() const; - - void reset(); - - CPSample(const CPSample&p_from); - CPSample(); - ~CPSample(); - -}; - - - - -#endif diff --git a/modules/chibi/cp_sample_defs.h b/modules/chibi/cp_sample_defs.h deleted file mode 100644 index 5ae57aed82..0000000000 --- a/modules/chibi/cp_sample_defs.h +++ /dev/null @@ -1,97 +0,0 @@ -/*************************************************************************/ -/* cp_sample_defs.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_SAMPLE_DEFS_H -#define CP_SAMPLE_DEFS_H - -#include "cp_config.h" - -enum CPSample_Loop_Type { - - CP_LOOP_NONE, - CP_LOOP_FORWARD, - CP_LOOP_BIDI -}; - -//#define INVALID_SAMPLE_ID -1 - -#define CP_MIXING_FRAC_BITS_MACRO 13 -#define CP_MIXING_FRAC_BITS_TEXT "13" -// 1<<9 - 1 -#define CP_MIXING_FRAC_BITS_MASK_TEXT "8191" - -enum CPMixConstants { - CP_MIXING_FRAC_BITS=CP_MIXING_FRAC_BITS_MACRO, - CP_MIXING_FRAC_LENGTH=(1<<CP_MIXING_FRAC_BITS), - CP_MIXING_FRAC_MASK=CP_MIXING_FRAC_LENGTH-1, - CP_MIXING_VOL_FRAC_BITS=8, - CP_MIXING_FREQ_FRAC_BITS=8 -}; - -enum CPFilterConstants { - CP_FILTER_SHIFT=16, - CP_FILTER_LENGTH=(1<<CP_FILTER_SHIFT) -}; - - -enum CPInterpolationType { - CP_INTERPOLATION_RAW, - CP_INTERPOLATION_LINEAR, - CP_INTERPOLATION_CUBIC -}; - -enum CPPanConstants { - - CP_PAN_BITS=8, // 0 .. 256 - CP_PAN_LEFT=0, - CP_PAN_RIGHT=((1<<CP_PAN_BITS)-1), // 255 - CP_PAN_CENTER=CP_PAN_RIGHT/2, // 128 - CP_PAN_SURROUND=512 -}; - -enum CPMixerVolConstants { - CP_VOL_MAX=512, - CP_VOL_RAMP_BITS=9, - CP_VOL_SHIFT=2 - - -}; - -enum CPStereoCannels { - CP_CHAN_LEFT, - CP_CHAN_RIGHT -}; - -#define CP_FIRST_SAMPLE_DECLICK_THRESHOLD 1000 -#define CP_FIRST_SAMPLE_RAMP_LEN 32 - -typedef signed char CPFrame8; -typedef signed short CPFrame16; - - -#endif diff --git a/modules/chibi/cp_sample_manager.cpp b/modules/chibi/cp_sample_manager.cpp deleted file mode 100644 index 2ad0a720b4..0000000000 --- a/modules/chibi/cp_sample_manager.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************/ -/* cp_sample_manager.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_sample_manager.h" - - -CPSampleManager * CPSampleManager::singleton=NULL; - - -void CPSampleManager::copy_to(CPSample_ID p_from,CPSample_ID &p_to) { - - ERR_FAIL_COND(!check( p_from )); - - - if (p_to.is_null()) { - - p_to=create( is_16bits( p_from), is_stereo( p_from), get_size(p_from)); - } else { - - recreate( p_to, is_16bits( p_from), is_stereo( p_from), get_size(p_from)); - - } - - int len=get_size( p_from ); - int ch=is_stereo( p_from ) ? 2 : 1; - - for (int c=0;c<ch;c++) { - - for (int i=0;i<len;i++) { - - int16_t s=get_data( p_from, i, c ); - set_data( p_to, i, s, c ); - } - } - - set_loop_type( p_to, get_loop_type( p_from ) ); - set_loop_begin( p_to, get_loop_begin( p_from ) ); - set_loop_end( p_to, get_loop_end( p_from ) ); - set_c5_freq( p_to, get_c5_freq( p_from ) ); - - - -} - -CPSampleManager::CPSampleManager() { - - singleton=this; -} - -CPSampleManager *CPSampleManager::get_singleton() { - - return singleton; -} diff --git a/modules/chibi/cp_sample_manager.h b/modules/chibi/cp_sample_manager.h deleted file mode 100644 index b6d47a3013..0000000000 --- a/modules/chibi/cp_sample_manager.h +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************/ -/* cp_sample_manager.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CP_SAMPLE_MANAGER_H -#define CP_SAMPLE_MANAGER_H - -#include "cp_config.h" -#include "cp_sample_defs.h" - - - -/** -@author Juan Linietsky -*/ - - -/* abstract base CPSample_ID class */ - -struct CPSample_ID { - - void *_private; - - bool operator==(const CPSample_ID&p_other) const { return _private==p_other._private; } - bool operator!=(const CPSample_ID&p_other) const { return _private!=p_other._private; } - bool is_null() const { return _private==0; } - CPSample_ID(void *p_private=0) { _private=p_private; }; -}; - - -class CPSampleManager { - - static CPSampleManager * singleton; - -public: - - /* get the singleton instance */ - static CPSampleManager *get_singleton(); - - virtual void copy_to(CPSample_ID p_from,CPSample_ID &p_to); ///< if p_to is null, it gets created - - virtual CPSample_ID create(bool p_16bits,bool p_stereo,int32_t p_len)=0; - virtual void recreate(CPSample_ID p_id,bool p_16bits,bool p_stereo,int32_t p_len)=0; - virtual void destroy(CPSample_ID p_id)=0; - virtual bool check(CPSample_ID p_id)=0; // return false if invalid - - virtual void set_c5_freq(CPSample_ID p_id,int32_t p_freq)=0; - virtual void set_loop_begin(CPSample_ID p_id,int32_t p_begin)=0; - virtual void set_loop_end(CPSample_ID p_id,int32_t p_end)=0; - virtual void set_loop_type(CPSample_ID p_id,CPSample_Loop_Type p_type)=0; - virtual void set_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len)=0; - - - virtual int32_t get_loop_begin(CPSample_ID p_id)=0; - virtual int32_t get_loop_end(CPSample_ID p_id)=0; - virtual CPSample_Loop_Type get_loop_type(CPSample_ID p_id)=0; - virtual int32_t get_c5_freq(CPSample_ID p_id)=0; - virtual int32_t get_size(CPSample_ID p_id)=0; - virtual bool is_16bits(CPSample_ID p_id)=0; - virtual bool is_stereo(CPSample_ID p_id)=0; - virtual bool lock_data(CPSample_ID p_id)=0; - virtual void *get_data(CPSample_ID p_id)=0; /* WARNING: Not all sample managers -may be able to implement this, it depends on the mixer in use! */ - virtual int16_t get_data(CPSample_ID p_id, int p_sample, int p_channel=0)=0; /// Does not need locking - virtual void set_data(CPSample_ID p_id, int p_sample, int16_t p_data,int p_channel=0)=0; /// Does not need locking - virtual void unlock_data(CPSample_ID p_id)=0; - - virtual void get_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len)=0; - - CPSampleManager(); - virtual ~CPSampleManager(){} - -}; - -#endif diff --git a/modules/chibi/cp_song.cpp b/modules/chibi/cp_song.cpp deleted file mode 100644 index 197e44f69d..0000000000 --- a/modules/chibi/cp_song.cpp +++ /dev/null @@ -1,957 +0,0 @@ -/*************************************************************************/ -/* cp_song.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_song.h" - -void CPSong::set_name(const char *p_name) { - - if (p_name==NULL) { - variables.name[0]=0; - return; - } - - - bool done=false; - for (int i=0;i<MAX_SONG_NAME;i++) { - - - variables.name[i]=done?0:p_name[i]; - if (!done && p_name[i]==0) - done=true; - } - - variables.name[MAX_SONG_NAME-1]=0; /* just in case */ -} - -const char * CPSong::get_name() { - - return variables.name; - -} - -void CPSong::set_message(const char *p_message) { - - if (p_message==NULL) { - variables.message[0]=0; - return; - } - - bool done=false; - for (int i=0;i<MAX_MESSAGE_LEN;i++) { - - - variables.message[i]=done?0:p_message[i]; - if (!done && p_message[i]==0) - done=true; - } - - variables.message[MAX_MESSAGE_LEN-1]=0; /* just in case */ -} - -const char * CPSong::get_message() { - - return variables.message; - -} - -void CPSong::set_row_highlight_minor(int p_hl_minor) { - - variables.row_highlight_minor=p_hl_minor; -} -int CPSong::get_row_highlight_minor() { - - return variables.row_highlight_minor; -} - -void CPSong::set_row_highlight_major(int p_hl_major) { - - variables.row_highlight_major=p_hl_major; - - -} /* 0 .. 256 */ -int CPSong::get_row_highlight_major() { - - return variables.row_highlight_major; - - -} /* 0 .. 256 */ - -void CPSong::set_mixing_volume(int p_mix_volume) { - - - variables.mixing_volume=p_mix_volume; -} /* 0 .. 128 */ -int CPSong::get_mixing_volume() { - - return variables.mixing_volume; - -} /* 0 .. 128 */ - -void CPSong::set_global_volume(int p_global_volume) { - - - initial_variables.global_volume=p_global_volume; - -} /* 0 .. 128 */ -int CPSong::get_global_volume() { - - return initial_variables.global_volume; - -} /* 0 .. 128 */ - -void CPSong::set_stereo_separation(int p_separation) { - - variables.stereo_separation=p_separation; - -} /* 0 .. 128 */ -int CPSong::get_stereo_separation() { - - return variables.stereo_separation; -} /* 0 .. 128 */ - -void CPSong::set_stereo(bool p_stereo) { - - variables.use_stereo=p_stereo; - -} -bool CPSong::is_stereo() { - - return variables.use_stereo; -} - -void CPSong::set_instruments(bool p_instruments) { - - variables.use_instruments=p_instruments; - - -} -bool CPSong::has_instruments() { - - - return variables.use_instruments; - -} - -void CPSong::set_linear_slides(bool p_linear_slides) { - - variables.use_linear_slides=p_linear_slides; - - -} -bool CPSong::has_linear_slides() { - - return variables.use_linear_slides; - - -} - -void CPSong::set_old_effects(bool p_old_effects) { - - variables.old_effects=p_old_effects; - - -} -bool CPSong::has_old_effects() { - - return variables.old_effects; -} - -void CPSong::set_compatible_gxx(bool p_compatible_gxx) { - - - variables.compatible_gxx=p_compatible_gxx; -} -bool CPSong::has_compatible_gxx() { - - return variables.compatible_gxx; - -} - -void CPSong::set_speed(int p_speed) { - - CP_ERR_COND(p_speed<MIN_SPEED); - CP_ERR_COND(p_speed>MAX_SPEED); - - initial_variables.speed=p_speed; - -} /* 1 .. 255 */ -int CPSong::get_speed() { - - return initial_variables.speed; - -} /* 1 .. 255 */ - -void CPSong::set_tempo(int p_tempo) { - - CP_ERR_COND( p_tempo<MIN_TEMPO ); - CP_ERR_COND( p_tempo>MAX_TEMPO ); - - initial_variables.tempo=p_tempo; - -} /* MIN_TEMPO .. MAX_TEMPO */ -int CPSong::get_tempo() { - - return initial_variables.tempo; - - -} /* MIN_TEMPO .. MAX_TEMPO */ - -void CPSong::set_channel_pan(int p_channel,int p_pan) { - - CP_FAIL_INDEX(p_channel,CPPattern::WIDTH); - CP_FAIL_INDEX(p_pan,CHANNEL_MAX_PAN+1); - - initial_variables.channel[p_channel].pan=p_pan; - -} /* 0 .. CHANNEL_MAX_PAN */ -int CPSong::get_channel_pan(int p_channel) { - - CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,-1); - - return initial_variables.channel[p_channel].pan; -} - -void CPSong::set_channel_volume(int p_channel,int p_volume) { - - CP_FAIL_INDEX(p_channel,CPPattern::WIDTH); - CP_FAIL_INDEX(p_volume,CHANNEL_MAX_VOLUME+1); - - - initial_variables.channel[p_channel].volume=p_volume; - - -} /* 0 .. CHANNEL_MAX_VOLUME */ - - -int CPSong::get_channel_volume(int p_channel) { - - CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,-1); - - return initial_variables.channel[p_channel].volume; - -} - -void CPSong::set_channel_chorus(int p_channel,int p_chorus) { - - CP_FAIL_INDEX(p_channel,CPPattern::WIDTH); - CP_FAIL_INDEX(p_chorus,CHANNEL_MAX_CHORUS+1); - - - initial_variables.channel[p_channel].chorus=p_chorus; - - -} /* 0 .. CHANNEL_MAX_CHORUS */ - - -int CPSong::get_channel_chorus(int p_channel) { - - CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,-1); - - return initial_variables.channel[p_channel].chorus; - -} - -void CPSong::set_channel_reverb(int p_channel,int p_reverb) { - - CP_FAIL_INDEX(p_channel,CPPattern::WIDTH); - CP_FAIL_INDEX(p_reverb,CHANNEL_MAX_REVERB+1); - - - initial_variables.channel[p_channel].reverb=p_reverb; - - -} /* 0 .. CHANNEL_MAX_CHORUS */ - - -int CPSong::get_channel_reverb(int p_channel) { - - CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,-1); - - return initial_variables.channel[p_channel].reverb; - -} - -void CPSong::set_channel_surround(int p_channel,bool p_surround) { - - CP_FAIL_INDEX(p_channel,CPPattern::WIDTH); - initial_variables.channel[p_channel].surround=p_surround; - -} -bool CPSong::is_channel_surround(int p_channel) { - - CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,false); - - return initial_variables.channel[p_channel].surround; - - -} - -void CPSong::set_channel_mute(int p_channel,bool p_mute) { - - CP_FAIL_INDEX(p_channel,CPPattern::WIDTH); - - initial_variables.channel[p_channel].mute=p_mute; - -} -bool CPSong::is_channel_mute(int p_channel) { - - CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,false); - - return initial_variables.channel[p_channel].mute; - -} - -/* arrays of stuff */ - -CPPattern* CPSong::get_pattern(int p_pattern) { - - CP_FAIL_INDEX_V(p_pattern,MAX_PATTERNS, NULL); - - return &pattern[p_pattern]; - -} -CPSample* CPSong::get_sample(int p_sample) { - - CP_FAIL_INDEX_V(p_sample,MAX_SAMPLES,NULL); - - return &sample[p_sample]; - - -} -CPInstrument* CPSong::get_instrument(int p_instrument) { - - - CP_FAIL_INDEX_V(p_instrument,MAX_INSTRUMENTS,NULL); - - return &instrument[p_instrument]; - -} - -int CPSong::get_order(int p_order) { - - CP_FAIL_INDEX_V(p_order,MAX_ORDERS,CP_ORDER_NONE); - - - return order[p_order]; - -} -void CPSong::set_order(int p_order,int p_pattern) { - - CP_FAIL_INDEX(p_order,MAX_ORDERS); - - order[p_order]=p_pattern; - -} - - -void CPSong::clear_instrument_with_samples(int p_instrument) { - - CPInstrument *ins = get_instrument( p_instrument ); - if (!ins) - return; - - for (int i=0;i<CPNote::NOTES;i++) { - - CPSample *s=get_sample( ins->get_sample_number( i ) ); - - if (!s) - continue; - - if (s->get_sample_data().is_null()) - continue; - - s->reset(); - } - ins->reset(); -} - -void CPSong::make_instrument_from_sample(int p_sample) { - - if (!has_instruments()) - return; - CP_ERR_COND(!get_sample( p_sample )); - - for (int i=0;i<MAX_INSTRUMENTS;i++) { - - - CPInstrument *ins=get_instrument(i); - - bool empty_slot=true; - for (int n=0;n<CPNote::NOTES;n++) { - - if (ins->get_sample_number(n)<MAX_SAMPLES) { - - empty_slot=false; - break; - } - } - - if (!empty_slot) - continue; - - for (int n=0;n<CPNote::NOTES;n++) { - - ins->set_sample_number(n,p_sample); - ins->set_note_number(n,n); - } - - ins->set_name( get_sample( p_sample )->get_name() ); - break; - } - -} - -void CPSong::make_instruments_from_samples() { - - for (int i=0;i<MAX_SAMPLES;i++) { - - CPInstrument *ins=get_instrument( i ); - - if (!ins) - continue; - - ins->reset(); - - CPSample *s=get_sample( i ); - - if (!s) - continue; - - ins->set_name( s->get_name() ); - - if (s->get_sample_data().is_null()) - continue; - - - - - for(int j=0;j<CPNote::NOTES;j++) - ins->set_sample_number( j, i ); - - - - } -} - -void CPSong::reset(bool p_clear_patterns,bool p_clear_samples,bool p_clear_instruments,bool p_clear_variables) { - - if (p_clear_variables) { - variables.name[0]=0; - variables.message[0]=0; - variables.row_highlight_major=16; - variables.row_highlight_minor=4; - variables.mixing_volume=48; - variables.old_effects=false; - if (p_clear_instruments) //should not be cleared, if not clearing instruments!! - variables.use_instruments=false; - variables.stereo_separation=128; - variables.use_linear_slides=true; - variables.use_stereo=true; - - initial_variables.global_volume=128; - initial_variables.speed=6; - initial_variables.tempo=125; - - for (int i=0;i<CPPattern::WIDTH;i++) { - - initial_variables.channel[i].pan=32; - initial_variables.channel[i].volume=CHANNEL_MAX_VOLUME; - initial_variables.channel[i].mute=false; - initial_variables.channel[i].surround=false; - initial_variables.channel[i].chorus=0; - initial_variables.channel[i].reverb=0; - - } - - effects.chorus.delay_ms=6; - effects.chorus.separation_ms=3; - effects.chorus.depth_ms10=6, - effects.chorus.speed_hz10=5; - effects.reverb_mode=REVERB_MODE_ROOM; - } - - if (p_clear_samples) { - for (int i=0;i<MAX_SAMPLES;i++) - get_sample(i)->reset(); - } - - if (p_clear_instruments) { - for (int i=0;i<MAX_INSTRUMENTS;i++) - get_instrument(i)->reset(); - } - - if (p_clear_patterns) { - for (int i=0;i<MAX_PATTERNS;i++) - get_pattern(i)->clear(); - - for (int i=0;i<MAX_ORDERS;i++) - set_order( i, CP_ORDER_NONE ); - } - - -} - - -CPSong::ReverbMode CPSong::get_reverb_mode() { - - return effects.reverb_mode; -} -void CPSong::set_reverb_mode(ReverbMode p_mode) { - - effects.reverb_mode=p_mode; -} - -void CPSong::set_chorus_delay_ms(int p_amount) { - - effects.chorus.delay_ms=p_amount; -} -void CPSong::set_chorus_separation_ms(int p_amount) { - - effects.chorus.separation_ms=p_amount; - -} -void CPSong::set_chorus_depth_ms10(int p_amount) { - - effects.chorus.depth_ms10=p_amount; - -} -void CPSong::set_chorus_speed_hz10(int p_amount) { - - effects.chorus.speed_hz10=p_amount; - -} - -int CPSong::get_chorus_delay_ms() { - - return effects.chorus.delay_ms; - -} -int CPSong::get_chorus_separation_ms() { - - return effects.chorus.separation_ms; -} -int CPSong::get_chorus_depth_ms10() { - - return effects.chorus.depth_ms10; - -} -int CPSong::get_chorus_speed_hz10() { - - return effects.chorus.speed_hz10; - -} - -void CPSong::cleanup_unused_patterns() { - - for (int i=0;i<MAX_PATTERNS;i++) { - - bool used=false; - if (get_pattern(i)->is_empty()) - continue; - - for (int j=0;j<MAX_ORDERS;j++) { - - if (get_order(j)==i) { - used=true; - - } - } - - if (!used) - get_pattern(i)->clear(); - } - -} -void CPSong::cleanup_unused_instruments(){ - - if (!has_instruments()) - return; - - bool instr_found[MAX_INSTRUMENTS]; - for (int i=0;i<MAX_INSTRUMENTS;i++) - instr_found[i]=false; - - for (int i=0;i<MAX_PATTERNS;i++) { - - if (get_pattern(i)->is_empty()) - continue; - - for (int row=0;row<get_pattern(i)->get_length();row++) { - - - for (int col=0;col<CPPattern::WIDTH;col++) { - - CPNote n; - n=get_pattern(i)->get_note( col,row ); - - if (n.instrument<MAX_INSTRUMENTS) - instr_found[n.instrument]=true; - - } - - } - - } - - for (int i=0;i<MAX_INSTRUMENTS;i++) - if (!instr_found[i]) - get_instrument(i)->reset(); - - -} -void CPSong::cleanup_unused_samples(){ - - if (!has_instruments()) - return; - - bool sample_found[MAX_SAMPLES]; - for (int i=0;i<MAX_INSTRUMENTS;i++) - sample_found[i]=false; - - for (int i=0;i<MAX_PATTERNS;i++) { - - if (get_pattern(i)->is_empty()) - continue; - - - for (int row=0;row<get_pattern(i)->get_length();row++) { - - - for (int col=0;col<CPPattern::WIDTH;col++) { - - CPNote n; - n=get_pattern(i)->get_note( col,row ); - - if (n.instrument>=MAX_SAMPLES) - continue; - - if (has_instruments()) { - - for (int nt=0;nt<CPNote::NOTES;nt++) { - - int smp=get_instrument(n.instrument)->get_sample_number(nt); - if (smp<MAX_SAMPLES) - sample_found[smp]=true; - } - - } else { - if (n.instrument<MAX_SAMPLES) - sample_found[n.instrument]=true; - } - - } - - } - - } - - for (int i=0;i<MAX_SAMPLES;i++) - if (!sample_found[i]) - get_sample(i)->reset(); - -} -void CPSong::cleanup_unused_orders(){ - - bool finito=false; - for (int j=0;j<MAX_ORDERS;j++) { - - - if (get_order(j)==CP_ORDER_NONE) - finito=true; - if (finito) - set_order(j,CP_ORDER_NONE); - - } - -} - -void CPSong::clear_all_default_pan() { - - for (int i=0;i<MAX_INSTRUMENTS;i++) - get_instrument(i)->set_pan_default_enabled( false ); //die! - - for (int i=0;i<MAX_SAMPLES;i++) - get_sample(i)->set_pan_enabled( false ); //die! - -} - - -void CPSong::clear_all_default_vol(){ - - for (int i=0;i<MAX_SAMPLES;i++) - get_sample(i)->set_default_volume( 64 ); //die! - for (int i=0;i<MAX_INSTRUMENTS;i++) - get_instrument(i)->set_volume_global_amount( CPInstrument::MAX_VOLUME ); - -} - - -int CPSong::get_order_in_use_count() { - - - int order_count = 0; - - for (int i=(MAX_ORDERS-1);i>=0;i--) { - - - if (get_order(i)!=CP_ORDER_NONE) { - order_count=i+1; - break; - } - } - - return order_count; -} -int CPSong::get_pattern_in_use_count() { - - - int pattern_count=0; - - for (int i=(CPSong::MAX_PATTERNS-1);i>=0;i--) { - - - if (!get_pattern(i)->is_empty()) { - pattern_count=i+1; - break; - } - } - - return pattern_count; -} - -int CPSong::get_instrument_in_use_count() { - - int instrument_count=0; - - for (int i=(CPSong::MAX_INSTRUMENTS-1);i>=0;i--) { - - CPInstrument *ins = get_instrument(i); - bool in_use=false; - - for (int s = 0 ; s < CPNote::NOTES ; s++ ) { - - int smp_idx = ins->get_sample_number(s); - if (smp_idx<0 || smp_idx>=CPSong::MAX_SAMPLES) - continue; - - if (!get_sample(smp_idx)->get_sample_data().is_null()) { - in_use=true; - break; - } - - } - - if (in_use) { - instrument_count=i+1; - break; - } - } - - return instrument_count; -} -#include <stdio.h> -int CPSong::get_channels_in_use() { - - int max=0; - - for (int p=0;p<CPSong::MAX_PATTERNS;p++) { - - CPPattern *pat = get_pattern(p); - if (pat->is_empty()) - continue; - - - for (int c=(CPPattern::WIDTH-1);c>=0;c--) { - - if (c<max) - break; - - bool has_note=false; - for (int r=0;r<pat->get_length();r++) { - - CPNote n = pat->get_note( c, r ); - if (!n.is_empty()) { - has_note=true; - break; - } - } - - if (has_note) { - - max=c+1; - } - } - } - - return max; -} - - -void CPSong::separate_in_one_sample_instruments(int p_instrument) { - - CP_ERR_COND( !variables.use_instruments ); - CP_FAIL_INDEX( p_instrument, MAX_INSTRUMENTS ); - - int remapped_count=0; - - signed char remap[MAX_SAMPLES]; - - for (int i=0;i<MAX_SAMPLES;i++) { - - remap[i]=-1; - } - - /* Find remaps */ - CPInstrument *ins=get_instrument(p_instrument); - for (int i=0;i<CPNote::NOTES;i++) { - - int sn = ins->get_sample_number(i); - - // check for unusable sample - if (sn<0 || sn>=MAX_SAMPLES || get_sample(sn)->get_sample_data().is_null()) - continue; - printf("sample %i\n",sn); - if ( remap[sn] !=-1 ) { - printf("already mapped to %i\n",remap[sn]); - continue; - } - - printf("isn't remapped\n"); - - // find remap - - for (int j=0;j<MAX_INSTRUMENTS;j++) { - - if (!get_instrument(j)->is_empty()) - continue; - - printf("map to %i\n",j); - - //copy - *get_instrument(j)=*ins; - - // assign samples - for (int k=0;k<CPNote::NOTES;k++) { - - get_instrument(j)->set_note_number(k,k); - get_instrument(j)->set_sample_number(k,sn); - } - remap[sn]=j; - remapped_count++; - break; - } - - CP_ERR_COND(remap[sn]==-1); // no more free instruments - } - - printf("remapped %i\n",remapped_count); - - if (remapped_count<2) { - //undo if only one is remapped - for (int i=0;i<MAX_SAMPLES;i++) { - - if (remap[i]!=-1) { - - get_instrument(remap[i])->reset(); - } - } - return; - } - - /* remap all song */ - - for (int p=0;p<CPSong::MAX_PATTERNS;p++) { - - CPPattern *pat = get_pattern(p); - if (pat->is_empty()) - continue; - - - for (int c=0;c<CPPattern::WIDTH;c++) { - - for (int r=0;r<pat->get_length();r++) { - - CPNote n = pat->get_note(c,r); - if (n.note<CPNote::NOTES && n.instrument==p_instrument) { - - int sn = ins->get_sample_number(n.note); - if (remap[sn]==-1) - pat->set_note(c,r,CPNote()); - else { - - n.instrument=remap[sn]; - pat->set_note(c,r,n); - } - } - } - } - } - - ins->reset(); - -} - - -CPSong::CPSong() { - - reset(); -} -CPSong::~CPSong() { - -} - - - - -int get_song_next_order_idx(CPSong *p_song, int p_order_idx) { - - int baseorder,order_counter; - - order_counter=-1; - - baseorder=p_order_idx; - - do { - - baseorder++; - if ( baseorder>(CPSong::MAX_ORDERS-1) ) baseorder=0; - order_counter++; - - } while ( (p_song->get_order(baseorder)>=(CPSong::MAX_PATTERNS) ) && (order_counter<CPSong::MAX_ORDERS) ); - - - if (order_counter==CPSong::MAX_ORDERS) { - - return -1; - - } else { - - return baseorder; - } - -} diff --git a/modules/chibi/cp_song.h b/modules/chibi/cp_song.h deleted file mode 100644 index ba0fa3e80a..0000000000 --- a/modules/chibi/cp_song.h +++ /dev/null @@ -1,261 +0,0 @@ -/*************************************************************************/ -/* cp_song.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CPSONG_H -#define CPSONG_H - - -/**CPSong Class - *@author Juan Linietsky - */ - -#include "cp_order.h" -#include "cp_pattern.h" -#include "cp_sample.h" -#include "cp_instrument.h" - -class CPSong { -public: - enum { - MAX_SONG_NAME=26, - MAX_ORDERS=200, - MAX_PATTERNS=200, - MAX_SAMPLES=99, - MAX_INSTRUMENTS=99, - - CHANNEL_MAX_PAN=64, - CHANNEL_MAX_VOLUME=64, - CHANNEL_MAX_CHORUS=64, - CHANNEL_MAX_REVERB=64, - - MIN_TEMPO=31, - MAX_TEMPO=255, - MIN_SPEED=1, - MAX_SPEED=255, - MAX_MESSAGE_LEN=8000, - - - - }; - - enum ReverbMode { - REVERB_MODE_ROOM, - REVERB_MODE_STUDIO_SMALL, - REVERB_MODE_STUDIO_MEDIUM, - REVERB_MODE_STUDIO_LARGE, - REVERB_MODE_HALL, - REVERB_MODE_SPACE_ECHO, - REVERB_MODE_ECHO, - REVERB_MODE_DELAY, - REVERB_MODE_HALF_ECHO - }; - -private: - CPOrder order[MAX_ORDERS]; - CPPattern pattern[MAX_PATTERNS]; - CPSample sample[MAX_SAMPLES]; - CPInstrument instrument[MAX_INSTRUMENTS]; - - - - struct Song_Variables { // variables that wont change in playback - - char name[MAX_SONG_NAME]; - char message[MAX_MESSAGE_LEN]; - /* string message; */ - - int row_highlight_minor; - int row_highlight_major; - - int mixing_volume; - int stereo_separation; - - bool use_stereo; - bool use_instruments; - bool use_linear_slides; - - bool old_effects; - bool compatible_gxx; - - } variables; - - struct Initial_Variables { // Initial values used for playback - - struct Channel_State { - - int pan,volume; // 0-- CHANNEL_MAX_PAN, CHANNEL_MAX_VOLUME - bool surround; - bool mute; - int chorus; //0 - 64 - int reverb; //0 - 64 - }; - - int global_volume; - int speed; - int tempo; - - Channel_State channel[CPPattern::WIDTH]; - } initial_variables; - - struct Effects { - - ReverbMode reverb_mode; - - struct Chorus { - - int delay_ms; - int separation_ms; - int depth_ms10; - int speed_hz10; - } chorus; - - } effects; - -public: - - /* Properties */ - - const char *get_name(); - void set_name(const char *p_name); - - const char *get_message(); - void set_message(const char *p_message); - - void set_row_highlight_minor(int p_hl_minor); /* 0 .. 256 */ - int get_row_highlight_minor(); /* 0 .. 256 */ - - void set_row_highlight_major(int p_hl_major); /* 0 .. 256 */ - int get_row_highlight_major(); /* 0 .. 256 */ - - void set_mixing_volume(int p_mix_volume); /* 0 .. 128 */ - int get_mixing_volume(); /* 0 .. 128 */ - - void set_global_volume(int p_global_volume); /* 0 .. 128 */ - int get_global_volume(); /* 0 .. 128 */ - - void set_stereo_separation(int p_separation); /* 0 .. 128 */ - int get_stereo_separation(); /* 0 .. 128 */ - - void set_stereo(bool p_stereo); - bool is_stereo(); - - void set_instruments(bool p_instruments); - bool has_instruments(); - - void set_linear_slides(bool p_linear_slides); - bool has_linear_slides(); - - void set_old_effects(bool p_old_effects); - bool has_old_effects(); - - void set_compatible_gxx(bool p_compatible_gxx); - bool has_compatible_gxx(); - - void set_speed(int p_speed); /* 1 .. 255 */ - int get_speed(); /* 1 .. 255 */ - - void set_tempo(int p_tempo); /* 31 .. 255 */ - int get_tempo(); /* 31 .. 255 */ - - void set_channel_pan(int p_channel,int p_pan); /* 0 .. 64 */ - int get_channel_pan(int p_channel); - - void set_channel_volume(int p_channel,int p_volume); /* 0 .. 64 */ - int get_channel_volume(int p_channel); - - void set_channel_surround(int p_channel,bool p_surround); - bool is_channel_surround(int p_channel); - - void set_channel_mute(int p_channel,bool p_mute); - bool is_channel_mute(int p_channel); - - void set_channel_chorus(int p_channel,int p_chorus); /* 0 .. 64 */ - int get_channel_chorus(int p_channel); - - void set_channel_reverb(int p_channel,int p_reverb); /* 0 .. 64 */ - int get_channel_reverb(int p_channel); - - /* arrays of stuff */ - - CPPattern* get_pattern(int p_pattern); - CPSample* get_sample(int p_sample); - CPInstrument* get_instrument(int p_instrument); - - int get_order(int p_position); - void set_order(int p_position,int p_order); - - - /* Effects */ - - ReverbMode get_reverb_mode(); - void set_reverb_mode(ReverbMode p_mode); - - void set_chorus_delay_ms(int p_amount); - void set_chorus_separation_ms(int p_amount); - void set_chorus_depth_ms10(int p_amount); - void set_chorus_speed_hz10(int p_amount); - - int get_chorus_delay_ms(); - int get_chorus_separation_ms(); - int get_chorus_depth_ms10(); - int get_chorus_speed_hz10(); - - /* utils */ - - void reset(bool p_clear_patterns=true,bool p_clear_samples=true,bool p_clear_instruments=true,bool p_clear_variables=true); - - void cleanup_unused_patterns(); - void cleanup_unused_instruments(); - void cleanup_unused_samples(); - void cleanup_unused_orders(); - void clear_all_default_pan(); - void clear_all_default_vol(); - - void clear_instrument_with_samples(int p_instrument); - - void make_instruments_from_samples(); - void make_instrument_from_sample(int p_sample); - - void separate_in_one_sample_instruments(int p_instrument); - - int get_order_in_use_count(); - int get_pattern_in_use_count(); - int get_instrument_in_use_count(); - int get_channels_in_use(); - - CPSong(); - ~CPSong(); - -}; - - -/* Some helper for something used a lot */ - -int get_song_next_order_idx(CPSong *p_song, int p_order_idx); - -#endif diff --git a/modules/chibi/cp_tables.cpp b/modules/chibi/cp_tables.cpp deleted file mode 100644 index a7ed34ff31..0000000000 --- a/modules/chibi/cp_tables.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/*************************************************************************/ -/* cp_tables.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "cp_tables.h" - -int32_t CPTables::linear_period_to_freq_tab[768]={ - - 535232,534749,534266,533784,533303,532822,532341,531861, - 531381,530902,530423,529944,529466,528988,528511,528034, - 527558,527082,526607,526131,525657,525183,524709,524236, - 523763,523290,522818,522346,521875,521404,520934,520464, - 519994,519525,519057,518588,518121,517653,517186,516720, - 516253,515788,515322,514858,514393,513929,513465,513002, - 512539,512077,511615,511154,510692,510232,509771,509312, - 508852,508393,507934,507476,507018,506561,506104,505647, - 505191,504735,504280,503825,503371,502917,502463,502010, - 501557,501104,500652,500201,499749,499298,498848,498398, - 497948,497499,497050,496602,496154,495706,495259,494812, - 494366,493920,493474,493029,492585,492140,491696,491253, - 490809,490367,489924,489482,489041,488600,488159,487718, - 487278,486839,486400,485961,485522,485084,484647,484210, - 483773,483336,482900,482465,482029,481595,481160,480726, - 480292,479859,479426,478994,478562,478130,477699,477268, - 476837,476407,475977,475548,475119,474690,474262,473834, - 473407,472979,472553,472126,471701,471275,470850,470425, - 470001,469577,469153,468730,468307,467884,467462,467041, - 466619,466198,465778,465358,464938,464518,464099,463681, - 463262,462844,462427,462010,461593,461177,460760,460345, - 459930,459515,459100,458686,458272,457859,457446,457033, - 456621,456209,455797,455386,454975,454565,454155,453745, - 453336,452927,452518,452110,451702,451294,450887,450481, - 450074,449668,449262,448857,448452,448048,447644,447240, - 446836,446433,446030,445628,445226,444824,444423,444022, - 443622,443221,442821,442422,442023,441624,441226,440828, - 440430,440033,439636,439239,438843,438447,438051,437656, - 437261,436867,436473,436079,435686,435293,434900,434508, - 434116,433724,433333,432942,432551,432161,431771,431382, - 430992,430604,430215,429827,429439,429052,428665,428278, - 427892,427506,427120,426735,426350,425965,425581,425197, - 424813,424430,424047,423665,423283,422901,422519,422138, - 421757,421377,420997,420617,420237,419858,419479,419101, - 418723,418345,417968,417591,417214,416838,416462,416086, - 415711,415336,414961,414586,414212,413839,413465,413092, - 412720,412347,411975,411604,411232,410862,410491,410121, - 409751,409381,409012,408643,408274,407906,407538,407170, - 406803,406436,406069,405703,405337,404971,404606,404241, - 403876,403512,403148,402784,402421,402058,401695,401333, - 400970,400609,400247,399886,399525,399165,398805,398445, - 398086,397727,397368,397009,396651,396293,395936,395579, - 395222,394865,394509,394153,393798,393442,393087,392733, - 392378,392024,391671,391317,390964,390612,390259,389907, - 389556,389204,388853,388502,388152,387802,387452,387102, - 386753,386404,386056,385707,385359,385012,384664,384317, - 383971,383624,383278,382932,382587,382242,381897,381552, - 381208,380864,380521,380177,379834,379492,379149,378807, - 378466,378124,377783,377442,377102,376762,376422,376082, - 375743,375404,375065,374727,374389,374051,373714,373377, - 373040,372703,372367,372031,371695,371360,371025,370690, - 370356,370022,369688,369355,369021,368688,368356,368023, - 367691,367360,367028,366697,366366,366036,365706,365376, - 365046,364717,364388,364059,363731,363403,363075,362747, - 362420,362093,361766,361440,361114,360788,360463,360137, - 359813,359488,359164,358840,358516,358193,357869,357547, - 357224,356902,356580,356258,355937,355616,355295,354974, - 354654,354334,354014,353695,353376,353057,352739,352420, - 352103,351785,351468,351150,350834,350517,350201,349885, - 349569,349254,348939,348624,348310,347995,347682,347368, - 347055,346741,346429,346116,345804,345492,345180,344869, - 344558,344247,343936,343626,343316,343006,342697,342388, - 342079,341770,341462,341154,340846,340539,340231,339924, - 339618,339311,339005,338700,338394,338089,337784,337479, - 337175,336870,336566,336263,335959,335656,335354,335051, - 334749,334447,334145,333844,333542,333242,332941,332641, - 332341,332041,331741,331442,331143,330844,330546,330247, - 329950,329652,329355,329057,328761,328464,328168,327872, - 327576,327280,326985,326690,326395,326101,325807,325513, - 325219,324926,324633,324340,324047,323755,323463,323171, - 322879,322588,322297,322006,321716,321426,321136,320846, - 320557,320267,319978,319690,319401,319113,318825,318538, - 318250,317963,317676,317390,317103,316817,316532,316246, - 315961,315676,315391,315106,314822,314538,314254,313971, - 313688,313405,313122,312839,312557,312275,311994,311712, - 311431,311150,310869,310589,310309,310029,309749,309470, - 309190,308911,308633,308354,308076,307798,307521,307243, - 306966,306689,306412,306136,305860,305584,305308,305033, - 304758,304483,304208,303934,303659,303385,303112,302838, - 302565,302292,302019,301747,301475,301203,300931,300660, - 300388,300117,299847,299576,299306,299036,298766,298497, - 298227,297958,297689,297421,297153,296884,296617,296349, - 296082,295815,295548,295281,295015,294749,294483,294217, - 293952,293686,293421,293157,292892,292628,292364,292100, - 291837,291574,291311,291048,290785,290523,290261,289999, - 289737,289476,289215,288954,288693,288433,288173,287913, - 287653,287393,287134,286875,286616,286358,286099,285841, - 285583,285326,285068,284811,284554,284298,284041,283785, - 283529,283273,283017,282762,282507,282252,281998,281743, - 281489,281235,280981,280728,280475,280222,279969,279716, - 279464,279212,278960,278708,278457,278206,277955,277704, - 277453,277203,276953,276703,276453,276204,275955,275706, - 275457,275209,274960,274712,274465,274217,273970,273722, - 273476,273229,272982,272736,272490,272244,271999,271753, - 271508,271263,271018,270774,270530,270286,270042,269798, - 269555,269312,269069,268826,268583,268341,268099,267857 -}; - -uint16_t CPTables::old_period_table[OCTAVE*2]={ - - 0x6b00, 0x6800, 0x6500, 0x6220, 0x5f50, 0x5c80, - 0x5a00, 0x5740, 0x54d0, 0x5260, 0x5010, 0x4dc0, - 0x4b90, 0x4960, 0x4750, 0x4540, 0x4350, 0x4160, - 0x3f90, 0x3dc0, 0x3c10, 0x3a40, 0x38b0, 0x3700 -}; - -#define LOGFAC 2*16 - -uint16_t CPTables::log_table[104]= { - LOGFAC*907,LOGFAC*900,LOGFAC*894,LOGFAC*887, - LOGFAC*881,LOGFAC*875,LOGFAC*868,LOGFAC*862, - LOGFAC*856,LOGFAC*850,LOGFAC*844,LOGFAC*838, - LOGFAC*832,LOGFAC*826,LOGFAC*820,LOGFAC*814, - LOGFAC*808,LOGFAC*802,LOGFAC*796,LOGFAC*791, - LOGFAC*785,LOGFAC*779,LOGFAC*774,LOGFAC*768, - LOGFAC*762,LOGFAC*757,LOGFAC*752,LOGFAC*746, - LOGFAC*741,LOGFAC*736,LOGFAC*730,LOGFAC*725, - LOGFAC*720,LOGFAC*715,LOGFAC*709,LOGFAC*704, - LOGFAC*699,LOGFAC*694,LOGFAC*689,LOGFAC*684, - LOGFAC*678,LOGFAC*675,LOGFAC*670,LOGFAC*665, - LOGFAC*660,LOGFAC*655,LOGFAC*651,LOGFAC*646, - LOGFAC*640,LOGFAC*636,LOGFAC*632,LOGFAC*628, - LOGFAC*623,LOGFAC*619,LOGFAC*614,LOGFAC*610, - LOGFAC*604,LOGFAC*601,LOGFAC*597,LOGFAC*592, - LOGFAC*588,LOGFAC*584,LOGFAC*580,LOGFAC*575, - LOGFAC*570,LOGFAC*567,LOGFAC*563,LOGFAC*559, - LOGFAC*555,LOGFAC*551,LOGFAC*547,LOGFAC*543, - LOGFAC*538,LOGFAC*535,LOGFAC*532,LOGFAC*528, - LOGFAC*524,LOGFAC*520,LOGFAC*516,LOGFAC*513, - LOGFAC*508,LOGFAC*505,LOGFAC*502,LOGFAC*498, - LOGFAC*494,LOGFAC*491,LOGFAC*487,LOGFAC*484, - LOGFAC*480,LOGFAC*477,LOGFAC*474,LOGFAC*470, - LOGFAC*467,LOGFAC*463,LOGFAC*460,LOGFAC*457, - LOGFAC*453,LOGFAC*450,LOGFAC*447,LOGFAC*443, - LOGFAC*440,LOGFAC*437,LOGFAC*434,LOGFAC*431 -}; - - - -int32_t CPTables::get_linear_period(uint16_t note,int32_t fine) { - - int32_t t; - - t=(24L*OCTAVE-(int32_t)note)*32L-(fine>>1); - return t; -} - -static int s3m_period_table[12]={1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,907}; - - -int32_t CPTables::get_log_period(uint16_t note,int32_t p_c5freq) { - - return (8363L * 16 * s3m_period_table[note%12] >> (note/12)) / p_c5freq; - -} - -/* -int32_t CPTables::get_log_period(uint16_t note,int32_t p_c5freq) -{ - uint16_t n,o; - uint16_t p1,p2; - int32_t i; - - n=note%(2*OCTAVE); - o=note/(2*OCTAVE); - i=(n<<2); // n*8 + fine/16 - - if (i<0) - i=0; - - if (i>102) - i=102; - - - p1=log_table[i]; - p2=log_table[i+1]; - - - return (Interpolate(fine>>4,0,15,p1,p2)>>o); - -} */ - -int32_t CPTables::get_old_period(uint16_t note,int32_t speed) { - - uint16_t n,o,res; - -// if (!speed) { - - // return 4242; /* <- prevent divide overflow */ - // } - - n=note%(2*OCTAVE); - o=note/(2*OCTAVE); - - res=((8363L*(int32_t)old_period_table[n])>>o)/((old_period_table[17]>>1)+(speed<<2)); /*/(128-speed)*/; - - return res; -} - -int32_t CPTables::get_linear_frequency(int32_t period) { - - int32_t shift_value=(((int32_t)period/768)-2); - if (shift_value>0) { - - return linear_period_to_freq_tab[period%768]>>shift_value; - } else { - shift_value=0-shift_value; - return linear_period_to_freq_tab[period%768]<<shift_value; - } -} - -int32_t CPTables::get_old_frequency(int32_t period) { - - return (8363L*1712L)/(period?period:1); - -} - -CPTables::CPTables(){ -} -CPTables::~CPTables(){ -} diff --git a/modules/chibi/cp_tables.h b/modules/chibi/cp_tables.h deleted file mode 100644 index 4baa1c6488..0000000000 --- a/modules/chibi/cp_tables.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************/ -/* cp_tables.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 CPTABLES_H -#define CPTABLES_H - -#include "cp_config.h" - -/**conversion CPTables/functions - *@author Juan Linietsky - */ - -/****************************** - CPTables.h - -------- - -CPTables methods for miscelaneous -conversion utilities -********************************/ - -class CPTables { -public: - - enum { OCTAVE=12 }; - - static uint16_t old_period_table[OCTAVE*2]; - static uint16_t log_table[104]; - static int32_t linear_period_to_freq_tab[768]; - - static int32_t get_old_period(uint16_t note,int32_t speed); - static int32_t get_amiga_period(uint16_t note,int32_t fine); - static int32_t get_linear_period(uint16_t note,int32_t fine); - static int32_t get_linear_frequency(int32_t period); - static int32_t get_old_frequency(int32_t period); - static int32_t get_log_period(uint16_t note,int32_t p_c5freq); - - CPTables(); - ~CPTables(); -}; - -#endif diff --git a/modules/chibi/event_stream_chibi.cpp b/modules/chibi/event_stream_chibi.cpp deleted file mode 100644 index ab34080525..0000000000 --- a/modules/chibi/event_stream_chibi.cpp +++ /dev/null @@ -1,872 +0,0 @@ -/*************************************************************************/ -/* event_stream_chibi.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "event_stream_chibi.h" -#include "cp_loader_it.h" -#include "cp_loader_xm.h" -#include "cp_loader_s3m.h" -#include "cp_loader_mod.h" - -static CPSampleManagerImpl *sample_manager; -static ResourceFormatLoaderChibi *resource_loader; - -CPSample_ID CPSampleManagerImpl::create(bool p_16bits,bool p_stereo,int32_t p_len) { - - AudioServer::SampleFormat sf=p_16bits?AudioServer::SAMPLE_FORMAT_PCM16:AudioServer::SAMPLE_FORMAT_PCM8; - - SampleData *sd = memnew( SampleData ); - sd->rid = AudioServer::get_singleton()->sample_create(sf,p_stereo,p_len); - sd->stereo=p_stereo; - sd->len=p_len; - sd->is16=p_16bits; - sd->mixfreq=44100; - sd->loop_begin=0; - sd->loop_end=0; - sd->loop_type=CP_LOOP_NONE; - sd->locks=0; -#ifdef DEBUG_ENABLED - valid.insert(sd); -#endif - CPSample_ID sid; - sid._private=sd; - return sid; -} - -void CPSampleManagerImpl::recreate(CPSample_ID p_id,bool p_16bits,bool p_stereo,int32_t p_len){ - - AudioServer::SampleFormat sf=p_16bits?AudioServer::SAMPLE_FORMAT_PCM16:AudioServer::SAMPLE_FORMAT_PCM8; - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND(!valid.has(sd)); -#endif - AudioServer::get_singleton()->free(sd->rid); - sd->rid = AudioServer::get_singleton()->sample_create(sf,p_stereo,p_len); - sd->stereo=p_stereo; - sd->len=p_len; - sd->is16=p_16bits; - sd->mixfreq=44100; - sd->loop_begin=0; - sd->loop_end=0; - sd->loop_type=CP_LOOP_NONE; -} -void CPSampleManagerImpl::destroy(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND(!valid.has(sd)); - valid.erase(sd); -#endif - AudioServer::get_singleton()->free(sd->rid); - - memdelete(sd); -} -bool CPSampleManagerImpl::check(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - return valid.has(sd); -#else - return _getsd(p_id)!=NULL; -#endif -} - -void CPSampleManagerImpl::set_c5_freq(CPSample_ID p_id,int32_t p_freq){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND(!valid.has(sd)); -#endif - sd->mixfreq=p_freq; - AudioServer::get_singleton()->sample_set_mix_rate(sd->rid,p_freq); - -} -void CPSampleManagerImpl::set_loop_begin(CPSample_ID p_id,int32_t p_begin){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND(!valid.has(sd)); -#endif - sd->loop_begin=p_begin; - AudioServer::get_singleton()->sample_set_loop_begin(sd->rid,p_begin); - -} -void CPSampleManagerImpl::set_loop_end(CPSample_ID p_id,int32_t p_end){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND(!valid.has(sd)); -#endif - sd->loop_end=p_end; - AudioServer::get_singleton()->sample_set_loop_end(sd->rid,p_end); - -} -void CPSampleManagerImpl::set_loop_type(CPSample_ID p_id,CPSample_Loop_Type p_type){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND(!valid.has(sd)); -#endif - - sd->loop_type=p_type; - AudioServer::get_singleton()->sample_set_loop_format(sd->rid,AudioServer::SampleLoopFormat(p_type)); - - -} -void CPSampleManagerImpl::set_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND(!valid.has(sd)); -#endif - - ERR_FAIL(); -} - - -int32_t CPSampleManagerImpl::get_loop_begin(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!valid.has(sd),0); -#endif - - return sd->loop_begin; - -} -int32_t CPSampleManagerImpl::get_loop_end(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!valid.has(sd),0); -#endif - - return sd->loop_end; -} -CPSample_Loop_Type CPSampleManagerImpl::get_loop_type(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!valid.has(sd),CP_LOOP_NONE); -#endif - - return sd->loop_type; -} -int32_t CPSampleManagerImpl::get_c5_freq(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!valid.has(sd),0); -#endif - - return sd->mixfreq; -} -int32_t CPSampleManagerImpl::get_size(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!valid.has(sd),0); -#endif - - return sd->len; - -} -bool CPSampleManagerImpl::is_16bits(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!valid.has(sd),false); -#endif - - return sd->is16; - -} -bool CPSampleManagerImpl::is_stereo(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!valid.has(sd),false); -#endif - return sd->stereo; - - -} -bool CPSampleManagerImpl::lock_data(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!valid.has(sd),0); -#endif - - sd->locks++; - if (sd->locks==1) { - sd->lock=AudioServer::get_singleton()->sample_get_data(sd->rid); - sd->w=sd->lock.write(); - } - - return true; -} -void *CPSampleManagerImpl::get_data(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!valid.has(sd),0); -#endif - - ERR_FAIL_COND_V(sd->locks==0,0); - return sd->w.ptr(); -} - -int16_t CPSampleManagerImpl::get_data(CPSample_ID p_id, int p_sample, int p_channel){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!valid.has(sd),0); -#endif - - ERR_FAIL_V(0); - lock_data(p_id); - - int sofs = sd->stereo ? 2:1; - uint16_t v=0; - if (sd->is16) { - int16_t *p=(int16_t*)sd->w.ptr(); - v=p[p_sample*sofs+p_channel]; - } else { - int8_t *p=(int8_t*)sd->w.ptr(); - v=p[p_sample*sofs+p_channel]; - } - - unlock_data(p_id); - - return v; -} -void CPSampleManagerImpl::set_data(CPSample_ID p_id, int p_sample, int16_t p_data,int p_channel){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND(!valid.has(sd)); -#endif - - ERR_FAIL(); - lock_data(p_id); - - int sofs = sd->stereo ? 2:1; - if (sd->is16) { - int16_t *p=(int16_t*)sd->w.ptr(); - p[p_sample*sofs+p_channel]=p_data; - } else { - int8_t *p=(int8_t*)sd->w.ptr(); - p[p_sample*sofs+p_channel]=p_data; - } - - unlock_data(p_id); - -} -void CPSampleManagerImpl::unlock_data(CPSample_ID p_id){ - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND(!valid.has(sd)); -#endif - - ERR_FAIL_COND(sd->locks==0); - - sd->locks--; - if (sd->locks==0) { - sd->w=PoolVector<uint8_t>::Write(); - AudioServer::get_singleton()->sample_set_data(sd->rid,sd->lock); - sd->lock=PoolVector<uint8_t>(); - } -} - -void CPSampleManagerImpl::get_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len) { - - SampleData *sd=_getsd(p_id); -#ifdef DEBUG_ENABLED - ERR_FAIL_COND(!valid.has(sd)); -#endif - - ERR_FAIL(); -} - - -/** MIXER **/ - -void CPMixerImpl::set_callback_interval(int p_interval_us) { - - callback_interval=p_interval_us; -} - -void CPMixerImpl::set_callback(void (*p_callback)(void*),void *p_userdata) { - - callback=p_callback; - userdata=p_userdata; -} - -void CPMixerImpl::setup_voice(int p_voice_index,CPSample_ID p_sample_id,int32_t p_start_index) { - - Voice &v=voices[p_voice_index]; - if (v.channel!=AudioMixer::INVALID_CHANNEL) { - mixer->channel_free(v.channel); - } - v.channel=mixer->channel_alloc(sample_manager->get_rid(p_sample_id)); - v.freq_mult = sample_manager->get_c5_freq(p_sample_id)/261.6255653006; - v.sample = p_sample_id; -} - -void CPMixerImpl::stop_voice(int p_voice_index) { - - Voice &v=voices[p_voice_index]; - if (v.channel==AudioMixer::INVALID_CHANNEL) - return; - - mixer->channel_free(v.channel); - v.channel=AudioMixer::INVALID_CHANNEL; - -} - -void CPMixerImpl::set_voice_frequency(int p_voice_index,int32_t p_freq) { - - Voice &v=voices[p_voice_index]; - ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL); - float f = p_freq / 256.0; - f*=pitch_scale; - mixer->channel_set_mix_rate(v.channel,f * v.freq_mult ); -} - -void CPMixerImpl::set_voice_panning(int p_voice_index,int p_pan) { - - Voice &v=voices[p_voice_index]; - ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL); - if (p_pan==CP_PAN_SURROUND) - p_pan=CP_PAN_CENTER; - float p = p_pan / 256.0; - mixer->channel_set_pan(v.channel,p); - -} - -void CPMixerImpl::set_voice_volume(int p_voice_index,int p_vol) { - - - Voice &v=voices[p_voice_index]; - ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL); - float vol = p_vol/512.0; - vol*=voice_scale; - mixer->channel_set_volume(v.channel,vol); - mixer->channel_set_reverb(v.channel,reverb_type,vol*v.reverb); -} - -void CPMixerImpl::set_voice_filter(int p_voice_index,bool p_enabled,uint8_t p_cutoff, uint8_t p_resonance ){ - - Voice &v=voices[p_voice_index]; - ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL); - -} - -void CPMixerImpl::set_voice_reverb_send(int p_voice_index,int p_reverb){ - - Voice &v=voices[p_voice_index]; - ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL); - v.reverb=p_reverb/255.0; - //mixer->channel_set_reverb(v.channel,reverb_type,p_reverb/255.0); - -} - -void CPMixerImpl::set_voice_chorus_send(int p_voice_index,int p_chorus){ - - Voice &v=voices[p_voice_index]; - ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL); - mixer->channel_set_chorus(v.channel,p_chorus/255.0); - -} - - -void CPMixerImpl::set_reverb_mode(ReverbMode p_mode){ - - //Voice &v=voices[p_voice_index]; - //ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL); - switch(p_mode) { - case CPMixer::REVERB_MODE_STUDIO_SMALL: reverb_type=AudioMixer::REVERB_SMALL; break; - case CPMixer::REVERB_MODE_STUDIO_MEDIUM: reverb_type=AudioMixer::REVERB_MEDIUM; break; - case CPMixer::REVERB_MODE_STUDIO_LARGE: reverb_type=AudioMixer::REVERB_LARGE; break; - case CPMixer::REVERB_MODE_HALL: reverb_type=AudioMixer::REVERB_HALL; break; - default: reverb_type=AudioMixer::REVERB_SMALL; break; - } - -} - -void CPMixerImpl::set_chorus_params(unsigned int p_delay_ms,unsigned int p_separation_ms,unsigned int p_depth_ms10,unsigned int p_speed_hz10){ - - //Voice &v=voices[p_voice_index]; - //ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL); - -} - - - -/* Info retrieving */ - -int32_t CPMixerImpl::get_voice_sample_pos_index(int p_voice_index) { - - Voice &v=voices[p_voice_index]; - ERR_FAIL_COND_V(v.channel==AudioMixer::INVALID_CHANNEL,0); - return 0; - -} - -int CPMixerImpl::get_voice_panning(int p_voice_index) { - - Voice &v=voices[p_voice_index]; - ERR_FAIL_COND_V(!is_voice_active(p_voice_index),0); - return mixer->channel_get_pan(v.channel)*CP_PAN_RIGHT; - -} - -int CPMixerImpl::get_voice_volume(int p_voice_index) { - - Voice &v=voices[p_voice_index]; - ERR_FAIL_COND_V(!is_voice_active(p_voice_index),0); - return mixer->channel_get_volume(v.channel); - - -} - -CPSample_ID CPMixerImpl::get_voice_sample_id(int p_voice_index) { - - Voice &v=voices[p_voice_index]; - ERR_FAIL_COND_V(v.channel==AudioMixer::INVALID_CHANNEL,CPSample_ID()); - return v.sample; - - -} - -bool CPMixerImpl::is_voice_active(int p_voice_index){ - - Voice &v=voices[p_voice_index]; - if (v.channel==AudioMixer::INVALID_CHANNEL) - return false; - if (!mixer->channel_is_valid(v.channel)) - v.channel=AudioMixer::INVALID_CHANNEL; - - return v.channel!=AudioMixer::INVALID_CHANNEL; -} - -void CPMixerImpl::process_usecs(int p_usec,float p_volume,float p_pitch_scale,float p_tempo_scale) { - - ERR_FAIL_COND(callback_interval==0); - //update this somewhere - pitch_scale=p_pitch_scale; - tempo_scale=p_tempo_scale; - voice_scale = AudioServer::get_singleton()->get_event_voice_global_volume_scale()*p_volume; - while(p_usec) { - - if (p_usec>=callback_timeout) { - - p_usec-=callback_timeout; - callback_timeout=0; - if (callback) { - callback(userdata); - } - callback_timeout=callback_interval*(1.0/p_tempo_scale); - - } else { - - callback_timeout-=p_usec; - p_usec=0; - } - } -} - - -CPMixerImpl::CPMixerImpl(AudioMixer *p_mixer) { - - callback_interval=1; - callback_timeout=0; - userdata=0; - callback=0; - tempo_scale=1.0; - pitch_scale=1.0; - mixer=p_mixer; - voice_scale = AudioServer::get_singleton()->get_event_voice_global_volume_scale(); - reverb_type = AudioMixer::REVERB_SMALL; - -} - -/** FILE ACCESS WRAPPER **/ - - -CPFileAccessWrapperImpl::Error CPFileAccessWrapperImpl::open(const char *p_filename, int p_mode_flags) { - - ERR_FAIL_COND_V(p_mode_flags&WRITE,ERROR_WRITING_FILE); - close(); - f = FileAccess::open(String::utf8(p_filename),p_mode_flags); - if (!f) - return ERROR_FILE_NOT_FOUND; - return OK; -} - -void CPFileAccessWrapperImpl::close(){ - - if (f) - memdelete(f); - f=NULL; - - -} - -void CPFileAccessWrapperImpl::seek(uint32_t p_position){ - - f->seek(p_position); -} -void CPFileAccessWrapperImpl::seek_end(){ - - f->seek_end(); -} -uint32_t CPFileAccessWrapperImpl::get_pos(){ - - return f->get_pos(); -} - -bool CPFileAccessWrapperImpl::eof_reached(){ - - return f->eof_reached(); -} - -uint8_t CPFileAccessWrapperImpl::get_byte(){ - - return f->get_8(); -} -void CPFileAccessWrapperImpl::get_byte_array(uint8_t *p_dest,int p_elements){ - - f->get_buffer(p_dest,p_elements); -} -void CPFileAccessWrapperImpl::get_word_array(uint16_t *p_dest,int p_elements){ - - for(int i=0;i<p_elements;i++) { - p_dest[i]=f->get_16(); - } - -} - -uint16_t CPFileAccessWrapperImpl::get_word(){ - - return f->get_16(); -} -uint32_t CPFileAccessWrapperImpl::get_dword(){ - - return f->get_32(); -} - -void CPFileAccessWrapperImpl::set_endian_conversion(bool p_swap){ - - f->set_endian_swap(p_swap); -} -bool CPFileAccessWrapperImpl::is_open(){ - - return f!=NULL; -} - -CPFileAccessWrapperImpl::Error CPFileAccessWrapperImpl::get_error(){ - - return (f->get_error()!=::OK)?ERROR_READING_FILE:OK; -} - -void CPFileAccessWrapperImpl::store_byte(uint8_t p_dest){ - -} -void CPFileAccessWrapperImpl::store_byte_array(const uint8_t *p_dest,int p_elements){ - -} - -void CPFileAccessWrapperImpl::store_word(uint16_t p_dest){ - -} -void CPFileAccessWrapperImpl::store_dword(uint32_t p_dest){ - -} - -//////////////////////////////////////////////// - - -Error EventStreamPlaybackChibi::_play() { - - last_order=0; - loops=0; - player->play_start_song(); - total_usec=0; - - return OK; -} - -bool EventStreamPlaybackChibi::_update(AudioMixer* p_mixer, uint64_t p_usec){ - - total_usec+=p_usec; - mixer.process_usecs(p_usec,volume,pitch_scale,tempo_scale); - int order=player->get_current_order(); - if (order<last_order) { - if (!loop) { - stop(); - } else { - loops++; - } - } - last_order=order; - return false; -} -void EventStreamPlaybackChibi::_stop(){ - - player->play_stop(); -} - -void EventStreamPlaybackChibi::set_paused(bool p_paused){ - -} -bool EventStreamPlaybackChibi::is_paused() const{ - - return false; -} -void EventStreamPlaybackChibi::set_loop(bool p_loop){ - - loop=p_loop; - -} -bool EventStreamPlaybackChibi::is_loop_enabled() const{ - - return loop; -} - -int EventStreamPlaybackChibi::get_loop_count() const{ - - //return player->is - return loops; -} - -float EventStreamPlaybackChibi::get_pos() const{ - - return double(total_usec)/1000000.0; -} -void EventStreamPlaybackChibi::seek_pos(float p_time){ - - WARN_PRINT("seek_pos unimplemented."); -} - -void EventStreamPlaybackChibi::set_volume(float p_volume) { - - volume=p_volume; -} - -float EventStreamPlaybackChibi::get_volume() const{ - - return volume; -} - -void EventStreamPlaybackChibi::set_pitch_scale(float p_pitch_scale) { - - pitch_scale=p_pitch_scale; -} - -float EventStreamPlaybackChibi::get_pitch_scale() const{ - - return pitch_scale; -} - -void EventStreamPlaybackChibi::set_tempo_scale(float p_tempo_scale) { - - tempo_scale=p_tempo_scale; -} - -float EventStreamPlaybackChibi::get_tempo_scale() const{ - - return tempo_scale; -} - - -void EventStreamPlaybackChibi::set_channel_volume(int p_channel,float p_volume) { - - - if (p_channel>=64) - return; - player->set_channel_global_volume(p_channel,p_volume*256); -} - - - -float EventStreamPlaybackChibi::get_channel_volume(int p_channel) const{ - - return player->get_channel_global_volume(p_channel)/256.0; - -} - -float EventStreamPlaybackChibi::get_last_note_time(int p_channel) const { - - - double v = (player->get_channel_last_note_time_usec(p_channel))/1000000.0; - if (v<0) - v=-1; - return v; -} - -EventStreamPlaybackChibi::EventStreamPlaybackChibi(Ref<EventStreamChibi> p_stream) : mixer(_get_mixer()) { - - stream=p_stream; - player = memnew( CPPlayer(&mixer,&p_stream->song) ); - loop=false; - last_order=0; - loops=0; - volume=1.0; - pitch_scale=1.0; - tempo_scale=1.0; -} -EventStreamPlaybackChibi::~EventStreamPlaybackChibi(){ - - player->play_stop(); - memdelete(player); -} - -//////////////////////////////////////////////////// - -Ref<EventStreamPlayback> EventStreamChibi::instance_playback() { - - return Ref<EventStreamPlayback>( memnew(EventStreamPlaybackChibi(Ref<EventStreamChibi>(this))) ); -} - -String EventStreamChibi::get_stream_name() const{ - - return song.get_name(); - -} - - - -float EventStreamChibi::get_length() const{ - - return 1; -} - - -EventStreamChibi::EventStreamChibi() { - - -} - - - -////////////////////////////////////////////////////////////////// - - - - -RES ResourceFormatLoaderChibi::load(const String &p_path, const String& p_original_path, Error *r_error) { - - if (r_error) - *r_error=ERR_FILE_CANT_OPEN; - String el = p_path.get_extension().to_lower(); - - CPFileAccessWrapperImpl f; - - if (el=="it") { - - Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) ); - CPLoader_IT loader(&f); - CPLoader::Error err = loader.load_song(p_path.utf8().get_data(),&esc->song,false); - ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES()); - if (r_error) - *r_error=OK; - - return esc; - - } else if (el=="xm") { - - Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) ); - CPLoader_XM loader(&f); - CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false); - ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES()); - if (r_error) - *r_error=OK; - return esc; - - } else if (el=="s3m") { - - Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) ); - CPLoader_S3M loader(&f); - CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false); - ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES()); - if (r_error) - *r_error=OK; - - return esc; - - } else if (el=="mod") { - - Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) ); - CPLoader_MOD loader(&f); - CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false); - ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES()); - if (r_error) - *r_error=OK; - return esc; - } - - return RES(); - -} - -void ResourceFormatLoaderChibi::get_recognized_extensions(List<String> *p_extensions) const { - - p_extensions->push_back("it"); - p_extensions->push_back("xm"); - p_extensions->push_back("s3m"); - p_extensions->push_back("mod"); -} -bool ResourceFormatLoaderChibi::handles_type(const String& p_type) const { - - return (p_type=="EventStreamChibi" || p_type=="EventStream"); -} - -String ResourceFormatLoaderChibi::get_resource_type(const String &p_path) const { - String el = p_path.get_extension().to_lower(); - if (el=="it" || el=="s3m" || el=="xm" || el=="mod") - return "EventStreamChibi"; - return ""; -} - -///////////////////////////////////////////////////////////////// -void initialize_chibi() { - - sample_manager = memnew( CPSampleManagerImpl ); - resource_loader = memnew( ResourceFormatLoaderChibi ); - ClassDB::register_class<EventStreamChibi>(); - ResourceLoader::add_resource_format_loader( resource_loader ); -} - -void finalize_chibi() { - - memdelete( sample_manager ); - memdelete( resource_loader ); -} - diff --git a/modules/chibi/event_stream_chibi.h b/modules/chibi/event_stream_chibi.h deleted file mode 100644 index 0244ee0a95..0000000000 --- a/modules/chibi/event_stream_chibi.h +++ /dev/null @@ -1,314 +0,0 @@ -/*************************************************************************/ -/* event_stream_chibi.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 EVENT_STREAM_CHIBI_H -#define EVENT_STREAM_CHIBI_H - -#include "scene/resources/event_stream.h" -#include "cp_sample_manager.h" -#include "cp_mixer.h" -#include "cp_song.h" -#include "cp_file_access_wrapper.h" -#include "cp_player_data.h" -#include "resource.h" -#include "servers/audio_server.h" -#include "os/file_access.h" -#include "io/resource_loader.h" - -/** SAMPLE MANAGER **/ - -class CPSampleManagerImpl : public CPSampleManager { - - struct SampleData { - - RID rid; - bool stereo; - bool is16; - int len; - int mixfreq; - int loop_begin; - int loop_end; - int locks; - PoolVector<uint8_t> lock; - PoolVector<uint8_t>::Write w; - CPSample_Loop_Type loop_type; - }; - - - _FORCE_INLINE_ SampleData* _getsd(CPSample_ID p_id) { - - return ((SampleData*)p_id._private); - } - Set<SampleData*> valid; - -public: - - _FORCE_INLINE_ RID get_rid(CPSample_ID p_id) { return _getsd(p_id)->rid; } - virtual CPSample_ID create(bool p_16bits,bool p_stereo,int32_t p_len); - virtual void recreate(CPSample_ID p_id,bool p_16bits,bool p_stereo,int32_t p_len); - virtual void destroy(CPSample_ID p_id); - virtual bool check(CPSample_ID p_id); // return false if invalid - - virtual void set_c5_freq(CPSample_ID p_id,int32_t p_freq); - virtual void set_loop_begin(CPSample_ID p_id,int32_t p_begin); - virtual void set_loop_end(CPSample_ID p_id,int32_t p_end); - virtual void set_loop_type(CPSample_ID p_id,CPSample_Loop_Type p_type); - virtual void set_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len); - - - virtual int32_t get_loop_begin(CPSample_ID p_id); - virtual int32_t get_loop_end(CPSample_ID p_id); - virtual CPSample_Loop_Type get_loop_type(CPSample_ID p_id); - virtual int32_t get_c5_freq(CPSample_ID p_id); - virtual int32_t get_size(CPSample_ID p_id); - virtual bool is_16bits(CPSample_ID p_id); - virtual bool is_stereo(CPSample_ID p_id); - virtual bool lock_data(CPSample_ID p_id); - virtual void *get_data(CPSample_ID p_id); /* WARNING: Not all sample managers -may be able to implement this, it depends on the mixer in use! */ - virtual int16_t get_data(CPSample_ID p_id, int p_sample, int p_channel=0); /// Does not need locking - virtual void set_data(CPSample_ID p_id, int p_sample, int16_t p_data,int p_channel=0); /// Does not need locking - virtual void unlock_data(CPSample_ID p_id); - - virtual void get_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len); - -}; - - -/** MIXER **/ - -class CPMixerImpl : public CPMixer { - - enum { - MAX_VOICES=64 - }; - - struct Voice { - - AudioMixer::ChannelID channel; - CPSample_ID sample; - float freq_mult; - float reverb; - Voice() { reverb=0.0; } - }; - - Voice voices[MAX_VOICES]; - - - int callback_interval; - int callback_timeout; - void (*callback)(void*); - void *userdata; - float voice_scale; - float tempo_scale; - float pitch_scale; - AudioMixer::ReverbRoomType reverb_type; - AudioMixer *mixer; -public: - - void process_usecs(int p_usec,float p_volume,float p_pitch_scale,float p_tempo_scale); - - /* Callback */ - - virtual void set_callback_interval(int p_interval_us); //in usecs, for tracker it's 2500000/tempo - virtual void set_callback(void (*p_callback)(void*),void *p_userdata); - - /* Voice Control */ - - virtual void setup_voice(int p_voice_index,CPSample_ID p_sample_id,int32_t p_start_index) ; - virtual void stop_voice(int p_voice_index) ; - virtual void set_voice_frequency(int p_voice_index,int32_t p_freq) ; //in freq*FREQUENCY_BITS - virtual void set_voice_panning(int p_voice_index,int p_pan) ; - virtual void set_voice_volume(int p_voice_index,int p_vol) ; - virtual void set_voice_filter(int p_filter,bool p_enabled,uint8_t p_cutoff, uint8_t p_resonance ); - virtual void set_voice_reverb_send(int p_voice_index,int p_reverb); - virtual void set_voice_chorus_send(int p_voice_index,int p_chorus); /* 0 - 255 */ - - virtual void set_reverb_mode(ReverbMode p_mode); - virtual void set_chorus_params(unsigned int p_delay_ms,unsigned int p_separation_ms,unsigned int p_depth_ms10,unsigned int p_speed_hz10); - - - /* Info retrieving */ - - virtual int32_t get_voice_sample_pos_index(int p_voice_index) ; - virtual int get_voice_panning(int p_voice_index) ; - virtual int get_voice_volume(int p_voice_index) ; - virtual CPSample_ID get_voice_sample_id(int p_voice_index) ; - virtual bool is_voice_active(int p_voice_index); - virtual int get_active_voice_count() { return 0; } - virtual int get_total_voice_count() { return MAX_VOICES; } - - - virtual uint32_t get_mix_frequency() { return 0; } - - /* Methods below only work with software mixers, meant for software-based sound drivers, hardware mixers ignore them */ - virtual int32_t process(int32_t p_frames) { return 0; } - virtual int32_t *get_mixdown_buffer_ptr() { return NULL; } - virtual void set_mix_frequency(int32_t p_mix_frequency) {}; - - CPMixerImpl(AudioMixer *p_mixer=NULL); - virtual ~CPMixerImpl() {} -}; - -/** FILE ACCESS **/ - -class CPFileAccessWrapperImpl : public CPFileAccessWrapper { - - FileAccess *f; -public: - - - virtual Error open(const char *p_filename, int p_mode_flags); - virtual void close(); - - virtual void seek(uint32_t p_position); - virtual void seek_end(); - virtual uint32_t get_pos(); - - virtual bool eof_reached(); - - virtual uint8_t get_byte(); - virtual void get_byte_array(uint8_t *p_dest,int p_elements); - virtual void get_word_array(uint16_t *p_dest,int p_elements); - - virtual uint16_t get_word(); - virtual uint32_t get_dword(); - - virtual void set_endian_conversion(bool p_swap); - virtual bool is_open(); - - virtual Error get_error(); - - virtual void store_byte(uint8_t p_dest); - virtual void store_byte_array(const uint8_t *p_dest,int p_elements); - - virtual void store_word(uint16_t p_dest); - virtual void store_dword(uint32_t p_dest); - - CPFileAccessWrapperImpl() { f=NULL; } - virtual ~CPFileAccessWrapperImpl(){ if (f) memdelete(f); } - -}; - - - -///////////////////// - -class EventStreamChibi; - -class EventStreamPlaybackChibi : public EventStreamPlayback { - - GDCLASS(EventStreamPlaybackChibi,EventStreamPlayback); - - CPMixerImpl mixer; - uint64_t total_usec; - Ref<EventStreamChibi> stream; - mutable CPPlayer *player; - bool loop; - int last_order; - int loops; - virtual Error _play(); - virtual bool _update(AudioMixer* p_mixer, uint64_t p_usec); - virtual void _stop(); - float volume; - float tempo_scale; - float pitch_scale; - - -public: - - - virtual void set_paused(bool p_paused); - virtual bool is_paused() const; - - virtual void set_loop(bool p_loop); - virtual bool is_loop_enabled() const; - - virtual int get_loop_count() const; - - virtual float get_pos() const; - virtual void seek_pos(float p_time); - - virtual void set_volume(float p_vol); - virtual float get_volume() const; - - virtual void set_pitch_scale(float p_pitch_scale); - virtual float get_pitch_scale() const; - - virtual void set_tempo_scale(float p_tempo_scale); - virtual float get_tempo_scale() const; - - virtual void set_channel_volume(int p_channel,float p_volume); - virtual float get_channel_volume(int p_channel) const; - - virtual float get_last_note_time(int p_channel) const; - - EventStreamPlaybackChibi(Ref<EventStreamChibi> p_stream=Ref<EventStreamChibi>()); - ~EventStreamPlaybackChibi(); -}; - - -class EventStreamChibi : public EventStream { - - GDCLASS(EventStreamChibi,EventStream); - -friend class ResourceFormatLoaderChibi; -friend class EventStreamPlaybackChibi; - //I think i didn't know what const was when i wrote this more than a decade ago - //so it goes mutable :( - mutable CPSong song; - - -public: - - virtual Ref<EventStreamPlayback> instance_playback(); - - virtual String get_stream_name() const; - - virtual float get_length() const; - - virtual int get_channel_count() const { return 64; } //tracker limit - - EventStreamChibi(); -}; - - -class ResourceFormatLoaderChibi : public ResourceFormatLoader { - -public: - virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL); - virtual void get_recognized_extensions(List<String> *p_extensions) const; - virtual bool handles_type(const String& p_type) const; - virtual String get_resource_type(const String &p_path) const; - -}; - -void initialize_chibi(); -void finalize_chibi(); - -#endif // EVENT_STREAM_CHIBI_H diff --git a/modules/chibi/register_types.cpp b/modules/chibi/register_types.cpp deleted file mode 100644 index 1a0c808819..0000000000 --- a/modules/chibi/register_types.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************/ -/* register_types.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "register_types.h" - -#include "event_stream_chibi.h" - -void register_chibi_types() { - - initialize_chibi(); -} - -void unregister_chibi_types() { - - finalize_chibi(); -} diff --git a/modules/chibi/register_types.h b/modules/chibi/register_types.h deleted file mode 100644 index 08856c0744..0000000000 --- a/modules/chibi/register_types.h +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************/ -/* register_types.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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. */ -/*************************************************************************/ -void register_chibi_types(); -void unregister_chibi_types(); diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp index a5351a584b..398c2cf82a 100644 --- a/modules/gdscript/gd_compiler.cpp +++ b/modules/gdscript/gd_compiler.cpp @@ -1576,7 +1576,7 @@ Error GDCompiler::_parse_function(GDScript *p_script,const GDParser::ClassNode * //funciton and class if (p_class->name) { - signature+="::"+String(p_class->name)+"."+String(func_name);; + signature+="::"+String(p_class->name)+"."+String(func_name); } else { signature+="::"+String(func_name); } diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 19472d3d46..114a25feeb 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -2914,7 +2914,7 @@ Error GDScriptLanguage::lookup_code(const String& p_code, const String& p_symbol Ref<GDNativeClass> gdn = t.value; if (gdn.is_valid()) { r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; - r_result.class_name=gdn->get_name();; + r_result.class_name=gdn->get_name(); r_result.class_member=p_symbol; return OK; diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index 6659988602..51e2c1e2be 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -331,8 +331,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a #endif ip+=5; - - } continue; + continue; + } case OPCODE_EXTENDS_TEST: { CHECK_SPACE(4); @@ -404,8 +404,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst=extends_ok; ip+=4; - - } continue; + continue; + } case OPCODE_SET: { CHECK_SPACE(3); @@ -429,7 +429,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } ip+=4; - } continue; + continue; + } case OPCODE_GET: { CHECK_SPACE(3); @@ -460,7 +461,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst=ret; #endif ip+=4; - } continue; + continue; + } case OPCODE_SET_NAMED: { CHECK_SPACE(3); @@ -483,7 +485,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } ip+=4; - } continue; + continue; + } case OPCODE_GET_NAMED: { @@ -518,7 +521,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst=ret; #endif ip+=4; - } continue; + continue; + } case OPCODE_SET_MEMBER: { CHECK_SPACE(3); @@ -540,7 +544,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } #endif ip+=3; - } continue; + continue; + } case OPCODE_GET_MEMBER: { CHECK_SPACE(3); @@ -557,8 +562,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } #endif ip+=3; - - } continue; + continue; + } case OPCODE_ASSIGN: { CHECK_SPACE(3); @@ -568,8 +573,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = *src; ip+=3; - - } continue; + continue; + } case OPCODE_ASSIGN_TRUE: { CHECK_SPACE(2); @@ -578,7 +583,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = true; ip+=2; - } continue; + continue; + } case OPCODE_ASSIGN_FALSE: { CHECK_SPACE(2); @@ -587,7 +593,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = false; ip+=2; - } continue; + continue; + } case OPCODE_CONSTRUCT: { CHECK_SPACE(2); @@ -612,7 +619,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a ip+=4+argc; //construct a basic type - } continue; + continue; + } case OPCODE_CONSTRUCT_ARRAY: { CHECK_SPACE(1); @@ -632,8 +640,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst=array; ip+=3+argc; - - } continue; + continue; + } case OPCODE_CONSTRUCT_DICTIONARY: { CHECK_SPACE(1); @@ -655,8 +663,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst=dict; ip+=3+argc*2; - - } continue; + continue; + } case OPCODE_CALL_RETURN: case OPCODE_CALL: { @@ -737,8 +745,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a //_call_func(NULL,base,*methodname,ip,argc,p_instance,stack); ip+=argc+1; - - } continue; + continue; + } case OPCODE_CALL_BUILT_IN: { CHECK_SPACE(4); @@ -775,12 +783,12 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a break; } ip+=argc+1; - - } continue; + continue; + } case OPCODE_CALL_SELF: { - - } break; + break; + } case OPCODE_CALL_SELF_BASE: { CHECK_SPACE(2); @@ -857,8 +865,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } ip+=4+argc; - - } continue; + continue; + } case OPCODE_YIELD: case OPCODE_YIELD_SIGNAL: { @@ -938,8 +946,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } exit_ok=true; - - } break; + break; + } case OPCODE_YIELD_RESUME: { CHECK_SPACE(2); @@ -950,8 +958,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a GET_VARIANT_PTR(result,1); *result=p_state->result; ip+=2; - - } continue; + continue; + } case OPCODE_JUMP: { CHECK_SPACE(2); @@ -959,8 +967,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a ERR_BREAK(to<0 || to>_code_size); ip=to; - - } continue; + continue; + } case OPCODE_JUMP_IF: { CHECK_SPACE(3); @@ -983,7 +991,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a continue; } ip+=3; - } continue; + continue; + } case OPCODE_JUMP_IF_NOT: { CHECK_SPACE(3); @@ -1006,21 +1015,22 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a continue; } ip+=3; - } continue; + continue; + } case OPCODE_JUMP_TO_DEF_ARGUMENT: { CHECK_SPACE(2); ip=_default_arg_ptr[defarg]; - - } continue; + continue; + } case OPCODE_RETURN: { CHECK_SPACE(2); GET_VARIANT_PTR(r,1); retvalue=*r; exit_ok=true; - - } break; + break; + } case OPCODE_ITERATE_BEGIN: { CHECK_SPACE(8); //space for this an regular iterate @@ -1050,8 +1060,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a ip+=5; //skip regular iterate which is always next - - } continue; + continue; + } case OPCODE_ITERATE: { CHECK_SPACE(4); @@ -1079,7 +1089,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } ip+=5; //loop again - } continue; + continue; + } case OPCODE_ASSERT: { CHECK_SPACE(2); GET_VARIANT_PTR(test,1); @@ -1105,7 +1116,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a #endif ip+=2; - } continue; + continue; + } case OPCODE_BREAKPOINT: { #ifdef DEBUG_ENABLED if (ScriptDebugger::get_singleton()) { @@ -1113,7 +1125,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } #endif ip+=1; - } continue; + continue; + } case OPCODE_LINE: { CHECK_SPACE(2); @@ -1142,17 +1155,19 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a ScriptDebugger::get_singleton()->line_poll(); } - } continue; + continue; + } case OPCODE_END: { exit_ok=true; break; - } break; + } default: { err_text="Illegal opcode "+itos(_code_ptr[ip])+" at address "+itos(ip); - } break; + break; + } } diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index f0da1ea8cc..4f3516c097 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "gd_functions.h" #include "math_funcs.h" -#include "object_type_db.h" +#include "class_db.h" #include "reference.h" #include "gd_script.h" #include "func_ref.h" @@ -555,7 +555,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va String str; for(int i=0;i<p_arg_count;i++) { - String os = p_args[i]->operator String();; + String os = p_args[i]->operator String(); if (i==0) str=os; diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 4a36fbb4f1..70659326e5 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -643,7 +643,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ case GDTokenizer::TK_OP_ADD: e.op=OperatorNode::OP_POS; break; case GDTokenizer::TK_OP_SUB: e.op=OperatorNode::OP_NEG; break; case GDTokenizer::TK_OP_NOT: e.op=OperatorNode::OP_NOT; break; - case GDTokenizer::TK_OP_BIT_INVERT: e.op=OperatorNode::OP_BIT_INVERT;; break; + case GDTokenizer::TK_OP_BIT_INVERT: e.op=OperatorNode::OP_BIT_INVERT; break; default: {} } @@ -1043,8 +1043,8 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ case GDTokenizer::TK_OP_ASSIGN_MUL: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_MUL ; break; case GDTokenizer::TK_OP_ASSIGN_DIV: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_DIV ; break; case GDTokenizer::TK_OP_ASSIGN_MOD: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_MOD ; break; - case GDTokenizer::TK_OP_ASSIGN_SHIFT_LEFT: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_SHIFT_LEFT; ; break; - case GDTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_SHIFT_RIGHT; ; break; + case GDTokenizer::TK_OP_ASSIGN_SHIFT_LEFT: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_SHIFT_LEFT; break; + case GDTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_SHIFT_RIGHT; break; case GDTokenizer::TK_OP_ASSIGN_BIT_AND: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_BIT_AND ; break; case GDTokenizer::TK_OP_ASSIGN_BIT_OR: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_BIT_OR ; break; case GDTokenizer::TK_OP_ASSIGN_BIT_XOR: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_BIT_XOR ; break; diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index d9a3dd13f0..89df7e962a 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -541,7 +541,7 @@ bool GDScript::_update_exports() { } } - members_cache.clear();; + members_cache.clear(); member_default_values_cache.clear(); for(int i=0;i<c->variables.size();i++) { diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 271db4babc..2dd7e951ab 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -65,7 +65,7 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) { int amount=cells.size(); PoolVector<int>::Read r = cells.read(); ERR_FAIL_COND_V(amount&1,false); // not even - cell_map.clear();; + cell_map.clear(); for(int i=0;i<amount/3;i++) { @@ -90,7 +90,7 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) { int amount=cells.size(); PoolVector<int>::Read r = cells.read(); ERR_FAIL_COND_V(amount%3,false); // not even - cell_map.clear();; + cell_map.clear(); for(int i=0;i<amount/3;i++) { IndexKey ik; @@ -123,7 +123,7 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) { Octant &g = *octant_map[ok]; g.baked=b; - g.bake_instance=VS::get_singleton()->instance_create();; + g.bake_instance=VS::get_singleton()->instance_create(); VS::get_singleton()->instance_set_base(g.bake_instance,g.baked->get_rid()); VS::get_singleton()->instance_geometry_set_baked_light(g.bake_instance,baked_light_instance?baked_light_instance->get_baked_light_instance():RID()); } @@ -908,7 +908,7 @@ void GridMap::_octant_bake(const OctantKey &p_key, const Ref<TriangleMesh>& p_tm if (V) V=V->next(); else - V=st->get_vertex_array().front();; + V=st->get_vertex_array().front(); int lc = p_lights.size(); const BakeLight* bl = p_lights.ptr(); float ofs = cell_size*0.02; diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 109f6338db..0d57ffa394 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -903,7 +903,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) { Vector3 axis; axis[i]=1; Vector3 axis_n1; - axis_n1[(i+1)%3]=cell_size[(i+1)%3];; + axis_n1[(i+1)%3]=cell_size[(i+1)%3]; Vector3 axis_n2; axis_n2[(i+2)%3]=cell_size[(i+2)%3]; @@ -1274,8 +1274,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { edit_mode = memnew(OptionButton); edit_mode->set_area_as_parent_rect(); - edit_mode->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_BEGIN,24);; - edit_mode->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,14);; + edit_mode->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_BEGIN,24); + edit_mode->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,14); edit_mode->add_item("Tiles"); edit_mode->add_item("Areas"); hb->add_child(edit_mode); diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp index b4a0d3b0b7..9cd70a0f9b 100644 --- a/modules/gridmap/register_types.cpp +++ b/modules/gridmap/register_types.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "register_types.h" #ifndef _3D_DISABLED -#include "object_type_db.h" +#include "class_db.h" #include "grid_map.h" #include "grid_map_editor_plugin.h" #endif diff --git a/modules/ogg/config.py b/modules/ogg/config.py index fb920482f5..ef5daca05c 100644 --- a/modules/ogg/config.py +++ b/modules/ogg/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True +# return True + return False def configure(env): diff --git a/modules/opus/config.py b/modules/opus/config.py index fb920482f5..ef5daca05c 100644 --- a/modules/opus/config.py +++ b/modules/opus/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True +# return True + return False def configure(env): diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 0d8cabb331..9805675f2c 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -464,16 +464,19 @@ static void get_modulation_value(int x, int y, const int p_2bit, const int p_mod if(((x^y)&1)==0) mod_val = rep_vals0[p_modulation[y][x]]; else if(p_modulation_modes[y][x] == 1) { - mod_val = (rep_vals0[p_modulation[y-1][x]] + - rep_vals0[p_modulation[y+1][x]] + - rep_vals0[p_modulation[y][x-1]] + - rep_vals0[p_modulation[y][x+1]] + 2) / 4; + mod_val = ( + rep_vals0[p_modulation[y-1][x]] + + rep_vals0[p_modulation[y+1][x]] + + rep_vals0[p_modulation[y][x-1]] + + rep_vals0[p_modulation[y][x+1]] + 2) / 4; } else if(p_modulation_modes[y][x] == 2) { - mod_val = (rep_vals0[p_modulation[y][x-1]] + - rep_vals0[p_modulation[y][x+1]] + 1) / 2; + mod_val = ( + rep_vals0[p_modulation[y][x-1]] + + rep_vals0[p_modulation[y][x+1]] + 1) / 2; } else { - mod_val = (rep_vals0[p_modulation[y-1][x]] + - rep_vals0[p_modulation[y+1][x]] + 1) / 2; + mod_val = ( + rep_vals0[p_modulation[y-1][x]] + + rep_vals0[p_modulation[y+1][x]] + 1) / 2; } } else { mod_val = rep_vals1[p_modulation[y][x]]; @@ -615,11 +618,12 @@ static void decompress_pvrtc(PVRTCBlock *p_comp_img, const int p_2bit, const int for(j = 0; j < 2; j++) { unpack_5554(p_blocks[i][j], colors5554[i][j].Reps); - unpack_modulations(p_blocks[i][j], - p_2bit, - p_modulation, - p_modulation_modes, - p_x, p_y); + unpack_modulations( + p_blocks[i][j], + p_2bit, + p_modulation, + p_modulation_modes, + p_x, p_y); p_x += x_block_size; } @@ -632,19 +636,21 @@ static void decompress_pvrtc(PVRTCBlock *p_comp_img, const int p_2bit, const int } - interpolate_colors(colors5554[0][0].Reps[0], - colors5554[0][1].Reps[0], - colors5554[1][0].Reps[0], - colors5554[1][1].Reps[0], - p_2bit, x, y, - ASig); - - interpolate_colors(colors5554[0][0].Reps[1], - colors5554[0][1].Reps[1], - colors5554[1][0].Reps[1], - colors5554[1][1].Reps[1], - p_2bit, x, y, - BSig); + interpolate_colors( + colors5554[0][0].Reps[0], + colors5554[0][1].Reps[0], + colors5554[1][0].Reps[0], + colors5554[1][1].Reps[0], + p_2bit, x, y, + ASig); + + interpolate_colors( + colors5554[0][0].Reps[1], + colors5554[0][1].Reps[1], + colors5554[1][0].Reps[1], + colors5554[1][1].Reps[1], + p_2bit, x, y, + BSig); get_modulation_value(x,y, p_2bit, (const int (*)[16])p_modulation, (const int (*)[16])p_modulation_modes, &Mod, &DoPT); diff --git a/modules/regex/register_types.cpp b/modules/regex/register_types.cpp index d44c7e563c..c62a04d80f 100644 --- a/modules/regex/register_types.cpp +++ b/modules/regex/register_types.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "register_types.h" -#include "object_type_db.h" +#include "class_db.h" #include "regex.h" void register_regex_types() { diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp index 7410658603..a48c1f3485 100644 --- a/modules/squish/image_compress_squish.cpp +++ b/modules/squish/image_compress_squish.cpp @@ -54,12 +54,12 @@ void image_compress_squish(Image *p_image) { if (p_image->get_format()==Image::FORMAT_LA8) { //compressed normalmap - target_format = Image::FORMAT_DXT5; squish_comp|=squish::kDxt5;; + target_format = Image::FORMAT_DXT5; squish_comp|=squish::kDxt5; } else if (p_image->detect_alpha()!=Image::ALPHA_NONE) { - target_format = Image::FORMAT_DXT3; squish_comp|=squish::kDxt3;; + target_format = Image::FORMAT_DXT3; squish_comp|=squish::kDxt3; } else { - target_format = Image::FORMAT_DXT1; shift=1; squish_comp|=squish::kDxt1;; + target_format = Image::FORMAT_DXT1; shift=1; squish_comp|=squish::kDxt1; } p_image->convert(Image::FORMAT_RGBA8); //always expects rgba diff --git a/modules/theora/config.py b/modules/theora/config.py index fb920482f5..8eefe81288 100644 --- a/modules/theora/config.py +++ b/modules/theora/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True +# return True + return False def configure(env): diff --git a/modules/theora/yuv2rgb.h b/modules/theora/yuv2rgb.h index 431b47e651..3b81607a65 100644 --- a/modules/theora/yuv2rgb.h +++ b/modules/theora/yuv2rgb.h @@ -3,8 +3,7 @@ #include "typedefs.h" -static const uint32_t tables[256*3] = -{ +static const uint32_t tables[256*3] = { /* y_table */ 0x7FFFFFEDU, 0x7FFFFFEFU, diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 2a14e62a52..169af6fbec 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -1,6 +1,6 @@ #include "visual_script_builtin_funcs.h" #include "math_funcs.h" -#include "object_type_db.h" +#include "class_db.h" #include "reference.h" #include "func_ref.h" #include "os/os.h" diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 37ee225aeb..eadc9a8892 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -1918,7 +1918,7 @@ void VisualScriptEditor::drop_data_fw(const Point2& p_point,const Variant& p_dat Ref<VisualScriptFunctionCall> call; call.instance(); call->set_call_mode(VisualScriptFunctionCall::CALL_MODE_NODE_PATH); - call->set_base_path(sn->get_path_to(node));; + call->set_base_path(sn->get_path_to(node)); call->set_base_type(node->get_class()); n=call; diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index c9e24fc9dc..ce33b2e5ae 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -3615,7 +3615,7 @@ void VisualScriptInputAction::_validate_property(PropertyInfo& property) const { al.push_back(name); } - al.sort();; + al.sort(); for(int i=0;i<al.size();i++) { if (actions!=String()) @@ -3705,7 +3705,7 @@ String VisualScriptDeconstruct::get_category() const { void VisualScriptDeconstruct::_update_elements() { - elements.clear();; + elements.clear(); Variant v; if (type==Variant::INPUT_EVENT) { InputEvent ie; diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp index 2b05daca16..98920954a4 100644 --- a/modules/vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp @@ -141,7 +141,7 @@ int AudioStreamPlaybackOGGVorbis::mix(int16_t* p_bufer,int p_frames) { int errv = ov_open_callbacks(f,&vf,NULL,0,_ov_callbacks); if (errv!=0) { playing=false; - break;; // :( + break; // :( } if (loop_restart_time) { diff --git a/modules/vorbis/config.py b/modules/vorbis/config.py index fb920482f5..ef5daca05c 100644 --- a/modules/vorbis/config.py +++ b/modules/vorbis/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True +# return True + return False def configure(env): diff --git a/modules/webm/config.py b/modules/webm/config.py index fb920482f5..ef5daca05c 100644 --- a/modules/webm/config.py +++ b/modules/webm/config.py @@ -1,6 +1,7 @@ def can_build(platform): - return True +# return True + return False def configure(env): diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index d9e40a5913..e0e89e6344 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -27,9 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "audio_driver_jandroid.h" + #include "globals.h" #include "os/os.h" #include "thread_jandroid.h" + #ifndef ANDROID_NATIVE_ACTIVITY AudioDriverAndroid* AudioDriverAndroid::s_ad=NULL; @@ -199,9 +201,9 @@ int AudioDriverAndroid::get_mix_rate() const { return mix_rate; } -AudioDriverSW::OutputFormat AudioDriverAndroid::get_output_format() const{ +AudioDriver::SpeakerMode AudioDriverAndroid::get_speaker_mode() const{ - return OUTPUT_STEREO; + return SPEAKER_MODE_STEREO; } void AudioDriverAndroid::lock(){ diff --git a/platform/android/audio_driver_jandroid.h b/platform/android/audio_driver_jandroid.h index 01ce31be8f..f485df2001 100644 --- a/platform/android/audio_driver_jandroid.h +++ b/platform/android/audio_driver_jandroid.h @@ -29,12 +29,13 @@ #ifndef AUDIO_DRIVER_ANDROID_H #define AUDIO_DRIVER_ANDROID_H -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" + #ifndef ANDROID_NATIVE_ACTIVITY #include "java_glue.h" -class AudioDriverAndroid : public AudioDriverSW { +class AudioDriverAndroid : public AudioDriver { static Mutex *mutex; @@ -65,7 +66,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const ; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index 7aec2b174e..2ec80f23c3 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -27,11 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "audio_driver_opensl.h" -#include <string.h> - - - +#include <string.h> #define MAX_NUMBER_INTERFACES 3 #define MAX_NUMBER_OUTPUT_DEVICES 6 @@ -373,9 +370,9 @@ int AudioDriverOpenSL::get_mix_rate() const { return 44100; } -AudioDriverSW::OutputFormat AudioDriverOpenSL::get_output_format() const{ +AudioDriver::SpeakerMode AudioDriverOpenSL::get_speaker_mode() const{ - return OUTPUT_STEREO; + return SPEAKER_MODE_STEREO; } void AudioDriverOpenSL::lock(){ diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h index 8839d20bab..1baaa95052 100644 --- a/platform/android/audio_driver_opensl.h +++ b/platform/android/audio_driver_opensl.h @@ -29,15 +29,13 @@ #ifndef AUDIO_DRIVER_OPENSL_H #define AUDIO_DRIVER_OPENSL_H - - -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include "os/mutex.h" -#include <SLES/OpenSLES.h> -#include "SLES/OpenSLES_Android.h" +#include <SLES/OpenSLES.h> +#include <SLES/OpenSLES_Android.h> -class AudioDriverOpenSL : public AudioDriverSW { +class AudioDriverOpenSL : public AudioDriver { bool active; Mutex *mutex; @@ -94,7 +92,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const ; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/android/dir_access_android.cpp b/platform/android/dir_access_android.cpp index 42ac34a589..82b2761bb0 100644 --- a/platform/android/dir_access_android.cpp +++ b/platform/android/dir_access_android.cpp @@ -192,6 +192,6 @@ DirAccessAndroid::DirAccessAndroid() { DirAccessAndroid::~DirAccessAndroid() { - list_dir_end();; + list_dir_end(); } #endif diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 204bf684b7..33283eccea 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1748,6 +1748,7 @@ Error EditorExportPlatformAndroid::run(int p_device, int p_flags) { args.push_back("shell"); args.push_back("am"); args.push_back("start"); + args.push_back("--user 0"); args.push_back("-a"); args.push_back("android.intent.action.MAIN"); args.push_back("-n"); @@ -1914,4 +1915,3 @@ void register_android_exporter() { EditorImportExport::get_singleton()->add_export_platform(exporter); } - diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 562666b679..1095689a5b 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -27,18 +27,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "os_android.h" -#include "drivers/gles2/rasterizer_gles2.h" +#include "drivers/gles2/rasterizer_gles2.h" #include "core/io/file_access_buffered_fa.h" #include "drivers/unix/file_access_unix.h" #include "drivers/unix/dir_access_unix.h" - #include "servers/visual/visual_server_raster.h" #include "servers/visual/visual_server_wrap_mt.h" #include "main/main.h" - #include "file_access_android.h" - #include "core/globals.h" #ifdef ANDROID_NATIVE_ACTIVITY @@ -129,7 +126,7 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_ if (gfx_init_func) gfx_init_func(gfx_init_ud,use_gl2); - AudioDriverManagerSW::add_driver(&audio_driver_android); + AudioDriverManager::add_driver(&audio_driver_android); RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,use_reload_hooks,false,use_reload_hooks ) ); @@ -147,26 +144,13 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_ visual_server->init(); visual_server->cursor_set_visible(false, 0); - AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); + AudioDriverManager::get_driver(p_audio_driver)->set_singleton(); - if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) { + if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) { ERR_PRINT("Initializing audio failed."); } - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - - audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,true); - audio_server->init(); - - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - - // physics_server = memnew( PhysicsServerSW ); physics_server->init(); //physics_2d_server = memnew( Physics2DServerSW ); diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 9ed7ba5fac..bf1db57ba5 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -33,31 +33,20 @@ #include "drivers/unix/os_unix.h" #include "os/main_loop.h" #include "servers/physics/physics_server_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/physics_2d/physics_2d_server_wrap_mt.h" #include "servers/visual/rasterizer.h" #include "main/input_default.h" - -//#ifdef USE_JAVA_FILE_ACCESS - +#include "audio_driver_jandroid.h" +#include "audio_driver_opensl.h" #ifdef ANDROID_NATIVE_ACTIVITY - #include <android/sensor.h> #include <android/log.h> #include <android_native_app_glue.h> - -#else - - #endif -#include "audio_driver_jandroid.h" -#include "audio_driver_opensl.h" - typedef void (*GFXInitFunc)(void *ud,bool gl2); typedef int (*OpenURIFunc)(const String&); typedef String (*GetDataDirFunc)(); @@ -118,10 +107,6 @@ private: Rasterizer *rasterizer; VisualServer *visual_server; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; diff --git a/platform/bb10/audio_driver_bb10.cpp b/platform/bb10/audio_driver_bb10.cpp index 7b5c0800a8..b6ea0bc267 100644 --- a/platform/bb10/audio_driver_bb10.cpp +++ b/platform/bb10/audio_driver_bb10.cpp @@ -44,7 +44,7 @@ Error AudioDriverBB10::init(const char* p_name) { samples_out = NULL; mix_rate = 44100; - output_format = OUTPUT_STEREO; + speaker_mode = SPEAKER_MODE_STEREO; char* dev_name; if (p_name == NULL) { @@ -70,7 +70,7 @@ Error AudioDriverBB10::init(const char* p_name) { ERR_FAIL_COND_V(!(cinfo.formats & SND_PCM_FMT_S16_LE), FAILED); printf("voices %i\n", cinfo.max_voices); - output_format = cinfo.max_voices >= 2 ? OUTPUT_STEREO : OUTPUT_MONO; + speaker_mode = SPEAKER_MODE_STEREO; snd_pcm_channel_params_t cp; zeromem(&cp, sizeof(cp)); @@ -84,7 +84,7 @@ Error AudioDriverBB10::init(const char* p_name) { cp.buf.block.frags_min = 1; cp.format.interleave = 1; cp.format.rate = mix_rate; - cp.format.voices = output_format == OUTPUT_MONO ? 1 : 2; + cp.format.voices = speaker_mode; cp.format.format = SND_PCM_SFMT_S16_LE; ret = snd_pcm_plugin_params(pcm_handle, &cp); @@ -121,7 +121,7 @@ void AudioDriverBB10::thread_func(void* p_udata) { AudioDriverBB10* ad = (AudioDriverBB10*)p_udata; - int channels = (ad->output_format == OUTPUT_MONO ? 1 : 2); + int channels = speaker_mode; int frame_count = ad->sample_buf_count / channels; int bytes_out = frame_count * channels * 2; @@ -204,16 +204,18 @@ int AudioDriverBB10::get_mix_rate() const { return mix_rate; }; -AudioDriverSW::OutputFormat AudioDriverBB10::get_output_format() const { +AudioDriver::SpeakerMode AudioDriverBB10::get_speaker_mode() const { - return output_format; + return speaker_mode; }; + void AudioDriverBB10::lock() { if (!thread) return; mutex->lock(); }; + void AudioDriverBB10::unlock() { if (!thread) diff --git a/platform/bb10/audio_driver_bb10.h b/platform/bb10/audio_driver_bb10.h index 738bcf2619..efb98b1b91 100644 --- a/platform/bb10/audio_driver_bb10.h +++ b/platform/bb10/audio_driver_bb10.h @@ -26,14 +26,14 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include "core/os/thread.h" #include "core/os/mutex.h" #include <sys/asoundlib.h> -class AudioDriverBB10 : public AudioDriverSW { +class AudioDriverBB10 : public AudioDriver { Thread* thread; Mutex* mutex; @@ -47,7 +47,7 @@ class AudioDriverBB10 : public AudioDriverSW { static void thread_func(void* p_udata); int mix_rate; - OutputFormat output_format; + SpeakerMode speaker_mode; int pcm_frag_size; int pcm_max_frags; @@ -67,7 +67,7 @@ public: virtual Error init(const char* p_name); virtual void start(); virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/bb10/bbutil.c b/platform/bb10/bbutil.c index fce52c5b81..ab3dcf69b2 100644 --- a/platform/bb10/bbutil.c +++ b/platform/bb10/bbutil.c @@ -426,7 +426,7 @@ get_window_group_id() int bbutil_rotate_screen_surface(int angle) { - int rc, rotation, skip = 1, temp;; + int rc, rotation, skip = 1, temp; EGLint interval = 1; int size[2]; diff --git a/platform/bb10/bbutil.h b/platform/bb10/bbutil.h index c2a4c5a7f5..77f4402fbd 100644 --- a/platform/bb10/bbutil.h +++ b/platform/bb10/bbutil.h @@ -13,7 +13,11 @@ extern "C" { extern EGLDisplay egl_disp; extern EGLSurface egl_surf; -enum RENDERING_API {GL_ES_1 = EGL_OPENGL_ES_BIT, GL_ES_2 = EGL_OPENGL_ES2_BIT, VG = EGL_OPENVG_BIT}; +enum RENDERING_API { + GL_ES_1 = EGL_OPENGL_ES_BIT, + GL_ES_2 = EGL_OPENGL_ES2_BIT, + VG = EGL_OPENVG_BIT +}; /** * Initializes EGL, GL and loads a default font diff --git a/platform/bb10/os_bb10.cpp b/platform/bb10/os_bb10.cpp index ea2e326b05..c51f1c6092 100644 --- a/platform/bb10/os_bb10.cpp +++ b/platform/bb10/os_bb10.cpp @@ -31,22 +31,21 @@ #include "drivers/gles2/rasterizer_gles2.h" #include "servers/visual/visual_server_raster.h" #include "core/os/dir_access.h" - #include "core/globals.h" #include "main/main.h" #include "bbutil.h" +#include "core/os/keyboard.h" + #include <stdlib.h> #include <stdbool.h> #include <assert.h> -#include "core/os/keyboard.h" - -#include "bps/bps.h" -#include "bps/screen.h" -#include "bps/navigator.h" -#include "bps/accelerometer.h" -#include "bps/orientation.h" -#include "bps/virtualkeyboard.h" -#include "bps/audiodevice.h" +#include <bps/bps.h> +#include <bps/screen.h> +#include <bps/navigator.h> +#include <bps/accelerometer.h> +#include <bps/orientation.h> +#include <bps/virtualkeyboard.h> +#include <bps/audiodevice.h> #ifdef BB10_SCORELOOP_ENABLED #include "modules/scoreloop/scoreloop_bb10.h" @@ -141,18 +140,6 @@ void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi audio_driver->set_singleton(); audio_driver->init(NULL); - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,false); - audio_server->init(); - - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - - // physics_server = memnew( PhysicsServerSW ); physics_server->init(); physics_2d_server = memnew( Physics2DServerSW ); @@ -185,22 +172,12 @@ void OSBB10::finalize() { memdelete(main_loop); main_loop=NULL; - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); - /* if (debugger_connection_console) { memdelete(debugger_connection_console); } */ - memdelete(sample_manager); - - audio_server->finish(); - memdelete(audio_server); - visual_server->finish(); memdelete(visual_server); memdelete(rasterizer); diff --git a/platform/bb10/os_bb10.h b/platform/bb10/os_bb10.h index 5c484cd120..9cf2091d49 100644 --- a/platform/bb10/os_bb10.h +++ b/platform/bb10/os_bb10.h @@ -34,9 +34,7 @@ #include "os/main_loop.h" #include "main/input_default.h" #include "servers/physics/physics_server_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/visual/rasterizer.h" #include "audio_driver_bb10.h" @@ -44,8 +42,7 @@ #include <screen/screen.h> #include <sys/platform.h> -#include "bps/event.h" - +#include <bps/event.h> #include <stdint.h> class OSBB10 : public OS_Unix { @@ -58,11 +55,6 @@ class OSBB10 : public OS_Unix { Rasterizer *rasterizer; VisualServer *visual_server; - //AudioDriverPSP audio_driver_psp; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; AudioDriverBB10* audio_driver; diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp index 2af93061f8..c6afe7a261 100644 --- a/platform/haiku/audio_driver_media_kit.cpp +++ b/platform/haiku/audio_driver_media_kit.cpp @@ -38,7 +38,7 @@ Error AudioDriverMediaKit::init() { active = false; mix_rate = 44100; - output_format = OUTPUT_STEREO; + speaker_mode = SPEAKER_MODE_STEREO; channels = 2; int latency = GLOBAL_DEF("audio/output_latency", 25); @@ -99,8 +99,8 @@ int AudioDriverMediaKit::get_mix_rate() const { return mix_rate; } -AudioDriverSW::OutputFormat AudioDriverMediaKit::get_output_format() const { - return output_format; +AudioDriverSW::SpeakerMode AudioDriverMediaKit::get_speaker_mode() const { + return speaker_mode; } void AudioDriverMediaKit::lock() { diff --git a/platform/haiku/audio_driver_media_kit.h b/platform/haiku/audio_driver_media_kit.h index fbf6bc20de..ce760f8dd7 100644 --- a/platform/haiku/audio_driver_media_kit.h +++ b/platform/haiku/audio_driver_media_kit.h @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #ifdef MEDIA_KIT_ENABLED @@ -36,7 +36,7 @@ #include <kernel/image.h> // needed for image_id #include <SoundPlayer.h> -class AudioDriverMediaKit : public AudioDriverSW { +class AudioDriverMediaKit : public AudioDriver { Mutex* mutex; BSoundPlayer* player; @@ -45,7 +45,7 @@ class AudioDriverMediaKit : public AudioDriverSW { static void PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format); unsigned int mix_rate; - OutputFormat output_format; + SpeakerMode speaker_mode; unsigned int buffer_size; int channels; @@ -60,7 +60,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 176e1b0fbc..9f218aeff4 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -40,7 +40,7 @@ OS_Haiku::OS_Haiku() { #ifdef MEDIA_KIT_ENABLED - AudioDriverManagerSW::add_driver(&driver_media_kit); + AudioDriverManager::add_driver(&driver_media_kit); #endif }; @@ -138,20 +138,11 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ //physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>(); physics_2d_server->init(); - AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); + AudioDriverManager::get_driver(p_audio_driver)->set_singleton(); - if (AudioDriverManagerSW::get_driver(p_audio_driver)->init() != OK) { + if (AudioDriverManager::get_driver(p_audio_driver)->init() != OK) { ERR_PRINT("Initializing audio failed."); } - - sample_manager = memnew(SampleManagerMallocSW); - audio_server = memnew(AudioServerSW(sample_manager)); - audio_server->init(); - - spatial_sound_server = memnew(SpatialSoundServerSW); - spatial_sound_server->init(); - spatial_sound_2d_server = memnew(SpatialSound2DServerSW); - spatial_sound_2d_server->init(); } void OS_Haiku::finalize() { @@ -161,17 +152,6 @@ void OS_Haiku::finalize() { main_loop = NULL; - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); - - memdelete(sample_manager); - - audio_server->finish(); - memdelete(audio_server); - visual_server->finish(); memdelete(visual_server); memdelete(rasterizer); diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index fc873f49ad..531c7a56c3 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -34,12 +34,8 @@ #include "servers/visual/rasterizer.h" #include "servers/physics_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" -#include "servers/audio/audio_server_sw.h" -#include "servers/audio/sample_manager_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" +#include "servers/audio_server.h" #include "main/input_default.h" - #include "audio_driver_media_kit.h" #include "context_gl_haiku.h" #include "haiku_application.h" @@ -57,10 +53,6 @@ private: VideoMode current_video_mode; PhysicsServer* physics_server; Physics2DServer* physics_2d_server; - AudioServerSW* audio_server; - SampleManagerMallocSW* sample_manager; - SpatialSoundServerSW* spatial_sound_server; - SpatialSound2DServerSW* spatial_sound_2d_server; #ifdef MEDIA_KIT_ENABLED AudioDriverMediaKit driver_media_kit; diff --git a/platform/iphone/app_delegate.h b/platform/iphone/app_delegate.h index 6883692b15..1b2ca42ab6 100644 --- a/platform/iphone/app_delegate.h +++ b/platform/iphone/app_delegate.h @@ -30,8 +30,6 @@ #import "gl_view.h" #import "view_controller.h" -// Old accelerometer approach deprecated since IOS 7.0 -// Include coremotion for accelerometer, gyroscope and magnetometer access, available since IOS 4.0 but some functionality won't work for anything before IOS 5.0 #import <CoreMotion/CoreMotion.h> @interface AppDelegate : NSObject <UIApplicationDelegate, GLViewDelegate> { diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 664683ad64..740f1d7edc 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -284,12 +284,12 @@ static int frame_count = 0; //glView.autoresizesSubviews = YES; //[glView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth]; - int backingWidth; - int backingHeight; - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); + int backingWidth; + int backingHeight; + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); - iphone_main(backingWidth, backingHeight, gargc, gargv); + iphone_main(backingWidth, backingHeight, gargc, gargv); view_controller = [[ViewController alloc] init]; view_controller.view = glView; @@ -305,16 +305,6 @@ static int frame_count = 0; [window makeKeyAndVisible]; //Configure and start accelerometer -/* - Old accelerometer approach deprecated since IOS 7.0 - - last_accel[0] = 0; - last_accel[1] = 0; - last_accel[2] = 0; - [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)]; - [[UIAccelerometer sharedAccelerometer] setDelegate:self]; -*/ - if (!motionInitialised) { motionManager = [[CMMotionManager alloc] init]; if (motionManager.deviceMotionAvailable) { @@ -365,10 +355,10 @@ static int frame_count = 0; if (motionInitialised) { ///@TODO is this the right place to clean this up? - [motionManager stopDeviceMotionUpdates]; - [motionManager release]; - motionManager = nil; - motionInitialised = NO; + [motionManager stopDeviceMotionUpdates]; + [motionManager release]; + motionManager = nil; + motionInitialised = NO; }; iphone_finish(); @@ -416,16 +406,6 @@ static int frame_count = 0; }; } -/* - Depricated since IOS 7.0 -- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration { - //Use a basic low-pass filter to only keep the gravity in the accelerometer values - accel[0] = acceleration.x; // * kFilteringFactor + accel[0] * (1.0 - kFilteringFactor); - accel[1] = acceleration.y; // * kFilteringFactor + accel[1] * (1.0 - kFilteringFactor); - accel[2] = acceleration.z; // * kFilteringFactor + accel[2] * (1.0 - kFilteringFactor); -} -*/ - - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { #ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED return [[[FacebookScorer sharedInstance] facebook] handleOpenURL:url]; diff --git a/platform/iphone/audio_driver_iphone.cpp b/platform/iphone/audio_driver_iphone.cpp index 556576cdc3..eda3897841 100644 --- a/platform/iphone/audio_driver_iphone.cpp +++ b/platform/iphone/audio_driver_iphone.cpp @@ -155,8 +155,8 @@ int AudioDriverIphone::get_mix_rate() const { return 44100; }; -AudioDriverSW::OutputFormat AudioDriverIphone::get_output_format() const { - return OUTPUT_STEREO; +AudioDriver::SpeakerMode AudioDriverIphone::get_speaker_mode() const { + return SPEAKER_MODE_STEREO; }; void AudioDriverIphone::lock() { diff --git a/platform/iphone/audio_driver_iphone.h b/platform/iphone/audio_driver_iphone.h index cbcb0cffce..4c0cbfcb22 100644 --- a/platform/iphone/audio_driver_iphone.h +++ b/platform/iphone/audio_driver_iphone.h @@ -26,11 +26,12 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "servers/audio/audio_server_sw.h" + +#include "servers/audio_server.h" #include <AudioUnit/AudioUnit.h> -class AudioDriverIphone : public AudioDriverSW { +class AudioDriverIphone : public AudioDriver { AudioComponentInstance audio_unit; bool active; @@ -56,7 +57,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 88ec83ef7a..20fa45d708 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -62,13 +62,13 @@ def configure(env): env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') elif (env["arch"] == "arm64"): # arm64 env["bits"] = "64" - env['CCFLAGS'] = string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=5.1.1 -isysroot $IPHONESDK') + env['CCFLAGS'] = string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=7.0 -isysroot $IPHONESDK') env.Append(CPPFLAGS=['-DNEED_LONG_INT']) env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) else: # armv7 env["arch"] = "arm" env["bits"] = "32" - env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=5.1.1 -MMD -MT dependencies -isysroot $IPHONESDK') + env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot $IPHONESDK -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=7.0 -MMD -MT dependencies -isysroot $IPHONESDK') if (env["arch"] == "x86"): env['IPHONEPLATFORM'] = 'iPhoneSimulator' @@ -94,7 +94,7 @@ def configure(env): '-F$IPHONESDK', ]) elif (env["arch"] == "arm64"): - env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', + env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=7.0', '-isysroot', '$IPHONESDK', #'-stdlib=libc++', '-framework', 'Foundation', @@ -113,7 +113,7 @@ def configure(env): '-framework', 'CoreMotion', ]) else: - env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', + env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=7.0', '-isysroot', '$IPHONESDK', '-framework', 'Foundation', '-framework', 'UIKit', diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm index 03ee327d65..de6ea73c20 100644 --- a/platform/iphone/game_center.mm +++ b/platform/iphone/game_center.mm @@ -182,11 +182,11 @@ void GameCenter::request_achievement_descriptions() { ret["type"] = "achievement_descriptions"; if (error == nil) { ret["result"] = "ok"; - StringArray names; - StringArray titles; - StringArray unachieved_descriptions; - StringArray achieved_descriptions; - IntArray maximum_points; + PoolStringArray names; + PoolStringArray titles; + PoolStringArray unachieved_descriptions; + PoolStringArray achieved_descriptions; + PoolIntArray maximum_points; Array hidden; Array replayable; @@ -239,8 +239,8 @@ void GameCenter::request_achievements() { ret["type"] = "achievements"; if (error == nil) { ret["result"] = "ok"; - StringArray names; - RealArray percentages; + PoolStringArray names; + PoolRealArray percentages; for (int i=0; i<[achievements count]; i++) { diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index 3df29c5178..a3af8f4aa8 100755 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -274,7 +274,7 @@ static void clear_touches() { nil]; // Create our EAGLContext, and if successful make it current and create our framebuffer. - context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; if(!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) { diff --git a/platform/iphone/icloud.mm b/platform/iphone/icloud.mm index de70bb7e14..0d1825dd6b 100644 --- a/platform/iphone/icloud.mm +++ b/platform/iphone/icloud.mm @@ -78,12 +78,12 @@ Variant nsobject_to_variant(NSObject* object) { return String::utf8(str != NULL ? str : ""); } else if ([object isKindOfClass:[NSData class]]) { - ByteArray ret; + PoolByteArray ret; NSData* data = (NSData*)object; if ([data length] > 0) { ret.resize([data length]); { - ByteArray::Write w = ret.write(); + PoolByteArray::Write w = ret.write(); copymem(w.ptr(), [data bytes], [data length]); } } @@ -199,9 +199,9 @@ NSObject* variant_to_nsobject(Variant v) { } return result; } - else if (v.get_type() == Variant::RAW_ARRAY) { - ByteArray arr = v; - ByteArray::Read r = arr.read(); + else if (v.get_type() == Variant::POOL_BYTE_ARRAY) { + PoolByteArray arr = v; + PoolByteArray::Read r = arr.read(); NSData* result = [NSData dataWithBytes:r.ptr() length:arr.size()]; return result; } @@ -333,7 +333,7 @@ ICloud::ICloud() { Dictionary ret; ret["type"] = "key_value_changed"; - //StringArray result_keys; + //PoolStringArray result_keys; //Array result_values; Dictionary keyValues; String reason = ""; diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm index 49026ceb0a..050498c125 100644 --- a/platform/iphone/in_app_store.mm +++ b/platform/iphone/in_app_store.mm @@ -89,11 +89,11 @@ void InAppStore::_bind_methods() { Dictionary ret; ret["type"] = "product_info"; ret["result"] = "ok"; - StringArray titles; - StringArray descriptions; - RealArray prices; - StringArray ids; - StringArray localized_prices; + PoolStringArray titles; + PoolStringArray descriptions; + PoolRealArray prices; + PoolStringArray ids; + PoolStringArray localized_prices; for (int i=0; i<[products count]; i++) { @@ -114,7 +114,7 @@ void InAppStore::_bind_methods() { ret["ids"] = ids; ret["localized_prices"] = localized_prices; - StringArray invalid_ids; + PoolStringArray invalid_ids; for (NSString* ipid in response.invalidProductIdentifiers) { @@ -134,7 +134,7 @@ Error InAppStore::request_product_info(Variant p_params) { Dictionary params = p_params; ERR_FAIL_COND_V(!params.has("product_ids"), ERR_INVALID_PARAMETER); - StringArray pids = params["product_ids"]; + PoolStringArray pids = params["product_ids"]; printf("************ request product info! %i\n", pids.size()); NSMutableArray* array = [[[NSMutableArray alloc] initWithCapacity:pids.size()] autorelease]; diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 051c562b6a..e34dbae017 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -30,11 +30,9 @@ #include "os_iphone.h" -#include "drivers/gles2/rasterizer_gles2.h" - - +#include "drivers/gles3/rasterizer_gles3.h" #include "servers/visual/visual_server_raster.h" -#include "servers/visual/visual_server_wrap_mt.h" +//#include "servers/visual/visual_server_wrap_mt.h" #include "main/main.h" #include "audio_driver_iphone.h" @@ -109,16 +107,17 @@ void OSIPhone::initialize(const VideoMode& p_desired,int p_video_driver,int p_au supported_orientations |= ((GLOBAL_DEF("video_mode/allow_vertical", false)?1:0) << PortraitDown); supported_orientations |= ((GLOBAL_DEF("video_mode/allow_vertical_flipped", false)?1:0) << PortraitUp); - rasterizer_gles22 = memnew( RasterizerGLES2(false, false, false) ); - rasterizer = rasterizer_gles22; - rasterizer_gles22->set_base_framebuffer(gl_view_base_fb); + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); + RasterizerStorageGLES3::system_fbo = gl_view_base_fb; - visual_server = memnew( VisualServerRaster(rasterizer) ); + visual_server = memnew( VisualServerRaster() ); + /* + FIXME: Reimplement threaded rendering? Or remove? if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { - visual_server = memnew(VisualServerWrapMT(visual_server, false)); }; - visual_server->init(); + */ visual_server->init(); visual_server->cursor_set_visible(false, 0); @@ -127,16 +126,7 @@ void OSIPhone::initialize(const VideoMode& p_desired,int p_video_driver,int p_au audio_driver->set_singleton(); audio_driver->init(); - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - audio_server->init(); - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - - // + // init physics servers physics_server = memnew( PhysicsServerSW ); physics_server->init(); //physics_2d_server = memnew( Physics2DServerSW ); @@ -148,28 +138,28 @@ void OSIPhone::initialize(const VideoMode& p_desired,int p_video_driver,int p_au /* #ifdef IOS_SCORELOOP_ENABLED scoreloop = memnew(ScoreloopIOS); - Globals::get_singleton()->add_singleton(Globals::Singleton("Scoreloop", scoreloop)); + GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Scoreloop", scoreloop)); scoreloop->connect(); #endif */ #ifdef GAME_CENTER_ENABLED game_center = memnew(GameCenter); - Globals::get_singleton()->add_singleton(Globals::Singleton("GameCenter", game_center)); + GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("GameCenter", game_center)); game_center->connect(); #endif #ifdef STOREKIT_ENABLED store_kit = memnew(InAppStore); - Globals::get_singleton()->add_singleton(Globals::Singleton("InAppStore", store_kit)); + GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("InAppStore", store_kit)); #endif #ifdef ICLOUD_ENABLED icloud = memnew(ICloud); - Globals::get_singleton()->add_singleton(Globals::Singleton("ICloud", icloud)); + GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("ICloud", icloud)); //icloud->connect(); #endif - Globals::get_singleton()->add_singleton(Globals::Singleton("iOS", memnew(iOS))); + GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("iOS", memnew(iOS))); }; MainLoop *OSIPhone::get_main_loop() const { @@ -294,8 +284,8 @@ void OSIPhone::mouse_move(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_ }; input->set_mouse_pos(Point2(ev.mouse_motion.x,ev.mouse_motion.y)); - ev.mouse_motion.speed_x=input->get_mouse_speed().x; - ev.mouse_motion.speed_y=input->get_mouse_speed().y; + ev.mouse_motion.speed_x=input->get_last_mouse_speed().x; + ev.mouse_motion.speed_y=input->get_last_mouse_speed().y; ev.mouse_motion.button_mask = 1; // pressed queue_event(ev); @@ -394,7 +384,7 @@ void OSIPhone::finalize() { visual_server->finish(); memdelete(visual_server); - memdelete(rasterizer); +// memdelete(rasterizer); physics_server->finish(); memdelete(physics_server); @@ -402,14 +392,8 @@ void OSIPhone::finalize() { physics_2d_server->finish(); memdelete(physics_2d_server); - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - memdelete(input); - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); - }; void OSIPhone::set_mouse_show(bool p_show) { }; @@ -456,9 +440,8 @@ bool OSIPhone::can_draw() const { int OSIPhone::set_base_framebuffer(int p_fb) { - if (rasterizer_gles22) { - rasterizer_gles22->set_base_framebuffer(p_fb); - }; + RasterizerStorageGLES3::system_fbo = gl_view_base_fb; + return 0; }; @@ -542,7 +525,7 @@ Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_ print("Unable to play %S using the native player as it resides in a .pck file\n", p_path.c_str()); return ERR_INVALID_PARAMETER; } else { - p_path = p_path.replace("res:/", Globals::get_singleton()->get_resource_path()); + p_path = p_path.replace("res:/", GlobalConfig::get_singleton()->get_resource_path()); } } else if (p_path.begins_with("user://")) p_path = p_path.replace("user:/", get_data_dir()); @@ -579,10 +562,8 @@ void OSIPhone::native_video_stop() { OSIPhone::OSIPhone(int width, int height) { - rasterizer_gles22 = NULL; main_loop = NULL; visual_server = NULL; - rasterizer = NULL; VideoMode vm; vm.fullscreen = true; diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index ab976edcba..65dcc884bb 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -39,10 +39,7 @@ #include "servers/physics/physics_server_sw.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/physics_2d/physics_2d_server_wrap_mt.h" -#include "servers/audio/audio_server_sw.h" -#include "servers/audio/sample_manager_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" +#include "servers/audio_server.h" #include "main/input_default.h" #include "game_center.h" #include "in_app_store.h" @@ -50,7 +47,7 @@ class AudioDriverIphone; -class RasterizerGLES2; +// class RasterizerGLES2; class OSIPhone : public OS_Unix { @@ -71,18 +68,13 @@ private: uint8_t supported_orientations; - Rasterizer *rasterizer; - - RasterizerGLES2* rasterizer_gles22; +// Rasterizer *rasterizer; +// RasterizerGLES2* rasterizer_gles22; VisualServer *visual_server; PhysicsServer* physics_server; Physics2DServer *physics_2d_server; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; AudioDriverIphone* audio_driver; #ifdef GAME_CENTER_ENABLED diff --git a/platform/iphone/platform_config.h b/platform/iphone/platform_config.h index c8468f0152..64e9388910 100644 --- a/platform/iphone/platform_config.h +++ b/platform/iphone/platform_config.h @@ -27,8 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include <alloca.h> -#define GLES2_INCLUDE_H <ES2/gl.h> - +// #define GLES2_INCLUDE_H <ES2/gl.h> +#define GLES3_INCLUDE_H <ES3/gl.h> #define PLATFORM_REFCOUNT diff --git a/platform/iphone/rasterizer_iphone.h b/platform/iphone/rasterizer_iphone.h index cec367e2fa..299a11e895 100644 --- a/platform/iphone/rasterizer_iphone.h +++ b/platform/iphone/rasterizer_iphone.h @@ -688,7 +688,7 @@ public: virtual void multimesh_instance_set_color(RID p_multimesh,int p_index,const Color& p_color); virtual RID multimesh_get_mesh(RID p_multimesh) const; - virtual AABB multimesh_get_aabb(RID p_multimesh) const;; + virtual AABB multimesh_get_aabb(RID p_multimesh) const; virtual Transform multimesh_instance_get_transform(RID p_multimesh,int p_index) const; virtual Color multimesh_instance_get_color(RID p_multimesh,int p_index) const; @@ -846,7 +846,7 @@ public: virtual void canvas_begin(); virtual void canvas_set_transparency(float p_transparency); - virtual void canvas_set_rect(const Rect2& p_rect, bool p_clip);; + virtual void canvas_set_rect(const Rect2& p_rect, bool p_clip); virtual void canvas_draw_line(const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width); virtual void canvas_draw_rect(const Rect2& p_rect, bool p_region, const Rect2& p_source,bool p_tile,RID p_texture,const Color& p_modulate); virtual void canvas_draw_style_box(const Rect2& p_rect, RID p_texture,const float *p_margins, bool p_draw_center=true); diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp index af9f28169b..bff01d7c37 100644 --- a/platform/javascript/audio_driver_javascript.cpp +++ b/platform/javascript/audio_driver_javascript.cpp @@ -27,20 +27,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "audio_driver_javascript.h" -#include <string.h> - - - - +#include <string.h> #define MAX_NUMBER_INTERFACES 3 #define MAX_NUMBER_OUTPUT_DEVICES 6 /* Structure for passing information to callback function */ - - //AudioDriverJavaScript* AudioDriverJavaScript::s_ad=NULL; const char* AudioDriverJavaScript::get_name() const { @@ -53,19 +47,23 @@ Error AudioDriverJavaScript::init(){ return OK; } + void AudioDriverJavaScript::start(){ } + int AudioDriverJavaScript::get_mix_rate() const { return 44100; } -AudioDriverSW::OutputFormat AudioDriverJavaScript::get_output_format() const{ - return OUTPUT_STEREO; +AudioDriver::SpeakerMode AudioDriverJavaScript::get_speaker_mode() const{ + + return SPEAKER_MODE_STEREO; } + void AudioDriverJavaScript::lock(){ /* @@ -74,6 +72,7 @@ void AudioDriverJavaScript::lock(){ */ } + void AudioDriverJavaScript::unlock() { /* @@ -82,11 +81,11 @@ void AudioDriverJavaScript::unlock() { */ } + void AudioDriverJavaScript::finish(){ } - AudioDriverJavaScript::AudioDriverJavaScript() { } diff --git a/platform/javascript/audio_driver_javascript.h b/platform/javascript/audio_driver_javascript.h index 528b45569d..da146fcdd0 100644 --- a/platform/javascript/audio_driver_javascript.h +++ b/platform/javascript/audio_driver_javascript.h @@ -29,11 +29,11 @@ #ifndef AUDIO_DRIVER_JAVASCRIPT_H #define AUDIO_DRIVER_JAVASCRIPT_H +#include "servers/audio_server.h" -#include "servers/audio/audio_server_sw.h" #include "os/mutex.h" -class AudioDriverJavaScript : public AudioDriverSW { +class AudioDriverJavaScript : public AudioDriver { public: void set_singleton(); @@ -43,7 +43,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const ; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/javascript/audio_server_javascript.cpp b/platform/javascript/audio_server_javascript.cpp index 5489f179eb..d5940fb102 100644 --- a/platform/javascript/audio_server_javascript.cpp +++ b/platform/javascript/audio_server_javascript.cpp @@ -198,14 +198,15 @@ RID AudioServerJavascript::voice_create(){ voice->positional=false; voice->active=false; + /* clang-format off */ EM_ASM_( { - _as_voices[$0]=null; - _as_voice_gain[$0]=_as_audioctx.createGain(); - _as_voice_pan[$0]=_as_audioctx.createStereoPanner(); - _as_voice_gain[$0].connect(_as_voice_pan[$0]); - _as_voice_pan[$0].connect(_as_audioctx.destination); - - },voice_base); + _as_voices[$0] = null; + _as_voice_gain[$0] = _as_audioctx.createGain(); + _as_voice_pan[$0] = _as_audioctx.createStereoPanner(); + _as_voice_gain[$0].connect(_as_voice_pan[$0]); + _as_voice_pan[$0].connect(_as_audioctx.destination); + }, voice_base); + /* clang-format on */ voice_base++; @@ -227,27 +228,29 @@ void AudioServerJavascript::voice_play(RID p_voice, RID p_sample){ //create sample if not created ERR_FAIL_COND(sample->tmp_data.size()==0); sample->index=sample_base; - EM_ASM_( { - _as_samples[$0]=_as_audioctx.createBuffer($1,$2,$3); - },sample_base,sample->stereo?2:1,sample->length,sample->mix_rate); + /* clang-format off */ + EM_ASM_({ + _as_samples[$0] = _as_audioctx.createBuffer($1, $2, $3); + }, sample_base, sample->stereo ? 2 : 1, sample->length, sample->mix_rate); + /* clang-format on */ sample_base++; int chans = sample->stereo?2:1; for(int i=0;i<chans;i++) { - - + /* clang-format off */ EM_ASM_({ - _as_edited_buffer=_as_samples[$0].getChannelData($1); - },sample->index,i); - + _as_edited_buffer = _as_samples[$0].getChannelData($1); + }, sample->index, i); + /* clang-format on */ for(int j=0;j<sample->length;j++) { - + /* clang-format off */ EM_ASM_({ - _as_edited_buffer[$0]=$1; - },j,sample->tmp_data[j*chans+i]); + _as_edited_buffer[$0] = $1; + }, j, sample->tmp_data[j * chans + i]); + /* clang-format on */ } } @@ -263,26 +266,27 @@ void AudioServerJavascript::voice_play(RID p_voice, RID p_sample){ float freq_diff = Math::log(float(voice->mix_rate)/float(voice->sample_mix_rate))/Math::log(2.0); int detune = int(freq_diff*1200.0); - EM_ASM_( { - if (_as_voices[$0]!==null) { - _as_voices[$0].stop(); //stop and byebye - } - _as_voices[$0]=_as_audioctx.createBufferSource(); - _as_voices[$0].connect(_as_voice_gain[$0]); - _as_voices[$0].buffer=_as_samples[$1]; - _as_voices[$0].loopStart.value=$1; - _as_voices[$0].loopEnd.value=$2; - _as_voices[$0].loop.value=$3; - _as_voices[$0].detune.value=$6; - _as_voice_pan[$0].pan.value=$4; - _as_voice_gain[$0].gain.value=$5; - _as_voices[$0].start(); - _as_voices[$0].onended=function() { - _as_voices[$0].disconnect(_as_voice_gain[$0]); - _as_voices[$0]=null; - } - - },voice->index,sample->index,sample->mix_rate*sample->loop_begin,sample->mix_rate*sample->loop_end,sample->loop_format!=SAMPLE_LOOP_NONE,voice->pan,voice->volume*fx_volume_scale,detune); + /* clang-format off */ + EM_ASM_({ + if (_as_voices[$0] !== null) { + _as_voices[$0].stop(); //stop and byebye + } + _as_voices[$0] = _as_audioctx.createBufferSource(); + _as_voices[$0].connect(_as_voice_gain[$0]); + _as_voices[$0].buffer = _as_samples[$1]; + _as_voices[$0].loopStart.value = $1; + _as_voices[$0].loopEnd.value = $2; + _as_voices[$0].loop.value = $3; + _as_voices[$0].detune.value = $6; + _as_voice_pan[$0].pan.value = $4; + _as_voice_gain[$0].gain.value = $5; + _as_voices[$0].start(); + _as_voices[$0].onended = function() { + _as_voices[$0].disconnect(_as_voice_gain[$0]); + _as_voices[$0] = null; + } + }, voice->index, sample->index, sample->mix_rate * sample->loop_begin, sample->mix_rate * sample->loop_end, sample->loop_format != SAMPLE_LOOP_NONE, voice->pan, voice->volume * fx_volume_scale, detune); + /* clang-format on */ voice->active=true; } @@ -295,11 +299,11 @@ void AudioServerJavascript::voice_set_volume(RID p_voice, float p_volume){ voice->volume=p_volume; if (voice->active) { - EM_ASM_( { - - _as_voice_gain[$0].gain.value=$1; - - },voice->index,voice->volume*fx_volume_scale); + /* clang-format off */ + EM_ASM_({ + _as_voice_gain[$0].gain.value = $1; + }, voice->index, voice->volume * fx_volume_scale); + /* clang-format on */ } } @@ -313,11 +317,11 @@ void AudioServerJavascript::voice_set_pan(RID p_voice, float p_pan, float p_dept voice->pan_height=height; if (voice->active) { - EM_ASM_( { - - _as_voice_pan[$0].pan.value=$1; - - },voice->index,voice->pan); + /* clang-format off */ + EM_ASM_({ + _as_voice_pan[$0].pan.value = $1; + }, voice->index, voice->pan); + /* clang-format on */ } } void AudioServerJavascript::voice_set_filter(RID p_voice, FilterType p_type, float p_cutoff, float p_resonance, float p_gain){ @@ -340,11 +344,11 @@ void AudioServerJavascript::voice_set_mix_rate(RID p_voice, int p_mix_rate){ float freq_diff = Math::log(float(voice->mix_rate)/float(voice->sample_mix_rate))/Math::log(2.0); int detune = int(freq_diff*1200.0); - EM_ASM_( { - - _as_voices[$0].detune.value=$1; - - },voice->index,detune); + /* clang-format off */ + EM_ASM_({ + _as_voices[$0].detune.value = $1; + }, voice->index, detune); + /* clang-format on */ } } void AudioServerJavascript::voice_set_positional(RID p_voice, bool p_positional){ @@ -419,14 +423,15 @@ void AudioServerJavascript::voice_stop(RID p_voice){ ERR_FAIL_COND(!voice); if (voice->active) { - - EM_ASM_( { - if (_as_voices[$0]!==null) { - _as_voices[$0].stop(); - _as_voices[$0].disconnect(_as_voice_gain[$0]); - _as_voices[$0]=null; - } - },voice->index); + /* clang-format off */ + EM_ASM_({ + if (_as_voices[$0] !== null) { + _as_voices[$0].stop(); + _as_voices[$0].disconnect(_as_voice_gain[$0]); + _as_voices[$0] = null; + } + }, voice->index); + /* clang-format on */ voice->active=false; } @@ -524,22 +529,25 @@ void AudioServerJavascript::free(RID p_id){ ERR_FAIL_COND(!voice); if (voice->active) { - EM_ASM_( { - if (_as_voices[$0]!==null) { + /* clang-format off */ + EM_ASM_({ + if (_as_voices[$0] !== null) { _as_voices[$0].stop(); - _as_voices[$0].disconnect(_as_voice_gain[$0]); + _as_voices[$0].disconnect(_as_voice_gain[$0]); } - },voice->index); + }, voice->index); + /* clang-format on */ } - EM_ASM_( { + /* clang-format off */ + EM_ASM_({ delete _as_voices[$0]; _as_voice_gain[$0].disconnect(_as_voice_pan[$0]); delete _as_voice_gain[$0]; _as_voice_pan[$0].disconnect(_as_audioctx.destination); delete _as_voice_pan[$0]; - - },voice->index); + }, voice->index); + /* clang-format on */ voice_owner.free(p_id); memdelete(voice); @@ -549,10 +557,11 @@ void AudioServerJavascript::free(RID p_id){ Sample *sample = sample_owner.get(p_id); ERR_FAIL_COND(!sample); - EM_ASM_( { + /* clang-format off */ + EM_ASM_({ delete _as_samples[$0]; - - },sample->index); + }, sample->index); + /* clang-format on */ sample_owner.free(p_id); memdelete(sample); @@ -594,21 +603,20 @@ void AudioServerJavascript::mix_to_js(int p_frames) { int tomix=MIN(todo,INTERNAL_BUFFER_SIZE); driver_process_chunk(tomix); - + /* clang-format off */ EM_ASM_({ - - var data = HEAPF32.subarray($0/4, $0/4 + $2*2); + var data = HEAPF32.subarray($0 / 4, $0 / 4 + $2 * 2); for (var channel = 0; channel < _as_output_buffer.numberOfChannels; channel++) { var outputData = _as_output_buffer.getChannelData(channel); // Loop through samples for (var sample = 0; sample < $2; sample++) { // make output equal to the same as the input - outputData[sample+$1] = data[sample*2+channel]; + outputData[sample + $1] = data[sample * 2 + channel]; } } - - },internal_buffer,offset,tomix); + }, internal_buffer, offset, tomix); + /* clang-format on */ todo-=tomix; offset+=tomix; @@ -618,9 +626,11 @@ void AudioServerJavascript::mix_to_js(int p_frames) { void AudioServerJavascript::init(){ /* + // clang-format off EM_ASM( - console.log('server is '+audio_server); + console.log('server is ' + audio_server); ); + // clang-format on */ @@ -634,19 +644,19 @@ void AudioServerJavascript::init(){ int buffer_latency=16384; + /* clang-format off */ EM_ASM_( { - _as_script_node = _as_audioctx.createScriptProcessor($0, 0, 2); _as_script_node.connect(_as_audioctx.destination); console.log(_as_script_node.bufferSize); - _as_script_node.onaudioprocess = function(audioProcessingEvent) { // The output buffer contains the samples that will be modified and played _as_output_buffer = audioProcessingEvent.outputBuffer; audio_server_mix_function(_as_output_buffer.getChannelData(0).length); } - },buffer_latency); + }, buffer_latency); + /* clang-format on */ } @@ -813,20 +823,24 @@ AudioServerJavascript::AudioServerJavascript() { singleton=this; sample_base=1; voice_base=1; + /* clang-format off */ EM_ASM( - _as_samples={}; - _as_voices={}; - _as_voice_pan={}; - _as_voice_gain={}; + _as_samples = {}; + _as_voices = {}; + _as_voice_pan = {}; + _as_voice_gain = {}; _as_audioctx = new (window.AudioContext || window.webkitAudioContext)(); audio_server_mix_function = Module.cwrap('audio_server_mix_function', 'void', ['number']); ); + /* clang-format on */ + /* clang-format off */ webaudio_mix_rate = EM_ASM_INT_V( - return _as_audioctx.sampleRate; - ); + return _as_audioctx.sampleRate; + ); + /* clang-format on */ print_line("WEBAUDIO MIX RATE: "+itos(webaudio_mix_rate)); event_voice_scale=1.0; fx_volume_scale=1.0; diff --git a/platform/javascript/audio_server_javascript.h b/platform/javascript/audio_server_javascript.h index 8e61e94dfc..f8c8774e4c 100644 --- a/platform/javascript/audio_server_javascript.h +++ b/platform/javascript/audio_server_javascript.h @@ -29,7 +29,6 @@ #ifndef AUDIO_SERVER_JAVASCRIPT_H #define AUDIO_SERVER_JAVASCRIPT_H - #include "servers/audio_server.h" class AudioServerJavascript : public AudioServer { diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp index 7bbe0ae99b..a79e5473c2 100644 --- a/platform/javascript/javascript_eval.cpp +++ b/platform/javascript/javascript_eval.cpp @@ -41,6 +41,7 @@ JavaScript *JavaScript::get_singleton() { Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) { union { int i; double d; char* s; } js_data[4]; + /* clang-format off */ Variant::Type return_type = static_cast<Variant::Type>(EM_ASM_INT({ var eval_ret; @@ -49,8 +50,7 @@ Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) { // indirect eval call grants global execution context var global_eval = eval; eval_ret = global_eval(UTF8ToString($2)); - } - else { + } else { eval_ret = eval(UTF8ToString($2)); } } catch (e) { @@ -125,6 +125,7 @@ Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) { return 0; // NIL }, js_data, sizeof *js_data, p_code.utf8().get_data(), p_use_global_exec_context)); + /* clang-format on */ switch(return_type) { case Variant::BOOL: @@ -136,7 +137,9 @@ Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) { case Variant::STRING: { String str = String::utf8(js_data->s); + /* clang-format off */ EM_ASM_({ _free($0); }, js_data->s); + /* clang-format on */ return str; } case Variant::VECTOR2: diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index dc4d80df7b..94320d53c1 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -178,6 +178,7 @@ int main(int argc, char *argv[]) { //glutSpecialFunc(gears_special); //mount persistent file system + /* clang-format off */ EM_ASM( FS.mkdir('/userfs'); FS.mount(IDBFS, {}, '/userfs'); @@ -196,6 +197,7 @@ int main(int argc, char *argv[]) { } }); ); + /* clang-format on */ glutMainLoop(); diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index fed9598096..317a6676a4 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -27,24 +27,24 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "os_javascript.h" + #include "drivers/gles2/rasterizer_gles2.h" #include "core/io/file_access_buffered_fa.h" #include "drivers/unix/file_access_unix.h" #include "drivers/unix/dir_access_unix.h" - #include "servers/visual/visual_server_raster.h" - #include "main/main.h" - #include "core/globals.h" -#include "stdlib.h" -#include "emscripten.h" #include "dom_keys.h" +#include <stdlib.h> +#include <emscripten.h> + int OS_JavaScript::get_video_driver_count() const { return 1; } + const char * OS_JavaScript::get_video_driver_name(int p_driver) const { return "GLES2"; @@ -215,6 +215,7 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int // find locale, emscripten only sets "C" char locale_ptr[16]; + /* clang-format off */ EM_ASM_({ var locale = ""; if (Module.locale) { @@ -230,14 +231,15 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int locale = locale.split('.')[0]; stringToUTF8(locale, $0, 16); }, locale_ptr); + /* clang-format on */ setenv("LANG", locale_ptr, true); print_line("Init Audio"); - AudioDriverManagerSW::add_driver(&audio_driver_javascript); + AudioDriverManager::add_driver(&audio_driver_javascript); if (true) { - RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,false,false,false) );; + RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,false,false,false) ); rasterizer_gles22->set_use_framebuffers(false); //not supported by emscripten if (gl_extensions) rasterizer_gles22->set_extensions(gl_extensions); @@ -259,27 +261,6 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int ERR_PRINT("Initializing audio failed."); }*/ - print_line("Init SM"); - - //sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerJavascript ); - - print_line("Init Mixer"); - - //audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,false); - audio_server->init(); - - print_line("Init SoundServer"); - - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - - print_line("Init SpatialSoundServer"); - - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - - // print_line("Init Physicsserver"); physics_server = memnew( PhysicsServerSW ); @@ -332,9 +313,11 @@ void OS_JavaScript::finalize() { void OS_JavaScript::alert(const String& p_alert,const String& p_title) { + /* clang-format off */ EM_ASM_({ window.alert(UTF8ToString($0)); }, p_alert.utf8().get_data()); + /* clang-format on */ } @@ -366,9 +349,11 @@ int OS_JavaScript::get_mouse_button_state() const { void OS_JavaScript::set_window_title(const String& p_title) { + /* clang-format off */ EM_ASM_({ document.title = UTF8ToString($0); }, p_title.utf8().get_data()); + /* clang-format on */ } //interesting byt not yet @@ -424,8 +409,10 @@ void OS_JavaScript::set_window_maximized(bool p_enabled) { set_window_fullscreen(false); } else { + /* clang-format off */ video_mode.width = EM_ASM_INT_V(return window.innerWidth); video_mode.height = EM_ASM_INT_V(return window.innerHeight); + /* clang-format on */ emscripten_set_canvas_size(video_mode.width, video_mode.height); } } @@ -444,7 +431,9 @@ void OS_JavaScript::set_window_fullscreen(bool p_enable) { // _browser_resize_callback or _fullscreen_change_callback EMSCRIPTEN_RESULT result; if (p_enable) { + /* clang-format off */ EM_ASM(Module.requestFullscreen(false, false);); + /* clang-format on */ } else { result = emscripten_exit_fullscreen(); @@ -504,11 +493,13 @@ bool OS_JavaScript::main_loop_iterate() { if (time_to_save_sync<0) { //time to sync, for real + /* clang-format off */ EM_ASM( FS.syncfs(function(err) { if (err) { Module.printErr('Failed to save IDB file system: ' + err.message); } }); ); + /* clang-format on */ } @@ -785,9 +776,11 @@ void OS_JavaScript::reload_gfx() { } Error OS_JavaScript::shell_open(String p_uri) { + /* clang-format off */ EM_ASM_({ window.open(UTF8ToString($0), '_blank'); }, p_uri.utf8().get_data()); + /* clang-format on */ return OK; } diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 370322e93d..d11494a8aa 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -35,15 +35,16 @@ #include "servers/physics/physics_server_sw.h" #include "servers/spatial_sound/spatial_sound_server_sw.h" #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/visual/rasterizer.h" #include "audio_server_javascript.h" #include "audio_driver_javascript.h" #include "main/input_default.h" -#include "emscripten/html5.h" #include "javascript_eval.h" +#include <emscripten/html5.h> + typedef void (*GFXInitFunc)(void *ud,bool gl2,int w, int h, bool fs); typedef String (*GetDataDirFunc)(); @@ -71,10 +72,6 @@ private: Rasterizer *rasterizer; VisualServer *visual_server; - AudioServerJavascript *audio_server; - //SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; AudioDriverJavaScript audio_driver_javascript; diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp index 87901f6ec4..4ad3a5b8fc 100644 --- a/platform/osx/audio_driver_osx.cpp +++ b/platform/osx/audio_driver_osx.cpp @@ -157,8 +157,8 @@ int AudioDriverOSX::get_mix_rate() const { return 44100; }; -AudioDriverSW::OutputFormat AudioDriverOSX::get_output_format() const { - return OUTPUT_STEREO; +AudioDriver::SpeakerMode AudioDriverOSX::get_speaker_mode() const { + return SPEAKER_MODE_STEREO; }; void AudioDriverOSX::lock() { diff --git a/platform/osx/audio_driver_osx.h b/platform/osx/audio_driver_osx.h index 19b396de57..9e9bb63726 100644 --- a/platform/osx/audio_driver_osx.h +++ b/platform/osx/audio_driver_osx.h @@ -31,11 +31,11 @@ #ifndef AUDIO_DRIVER_OSX_H #define AUDIO_DRIVER_OSX_H -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include <AudioUnit/AudioUnit.h> -class AudioDriverOSX : public AudioDriverSW { +class AudioDriverOSX : public AudioDriver { AudioComponentInstance audio_unit; bool active; @@ -61,7 +61,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index f6559f1f7a..d8c35472f2 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -38,10 +38,7 @@ // #include "servers/visual/visual_server_wrap_mt.h" #include "servers/visual/rasterizer.h" #include "servers/physics_server.h" -#include "servers/audio/audio_server_sw.h" -#include "servers/audio/sample_manager_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" +#include "servers/audio_server.h" #include "drivers/rtaudio/audio_driver_rtaudio.h" #include "drivers/alsa/audio_driver_alsa.h" #include "servers/physics_2d/physics_2d_server_sw.h" @@ -72,10 +69,6 @@ public: IP_Unix *ip_unix; AudioDriverOSX audio_driver_osx; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; InputDefault *input; JoypadOSX *joypad_osx; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 5750e19c87..854ccacbf1 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1083,7 +1083,7 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi - AudioDriverManagerSW::add_driver(&audio_driver_osx); + AudioDriverManager::add_driver(&audio_driver_osx); // only opengl support here... RasterizerGLES3::register_config(); @@ -1102,25 +1102,13 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi visual_server->init(); visual_server->cursor_set_visible(false, 0); - AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); + AudioDriverManager::get_driver(p_audio_driver)->set_singleton(); - if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) { + if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) { ERR_PRINT("Initializing audio failed."); } - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - - audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,false); - audio_server->init(); - - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - // physics_server = memnew( PhysicsServerSW ); physics_server->init(); @@ -1167,19 +1155,9 @@ void OS_OSX::finalize() { CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL); delete_main_loop(); - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); - memdelete(joypad_osx); memdelete(input); - memdelete(sample_manager); - - audio_server->finish(); - memdelete(audio_server); - visual_server->finish(); memdelete(visual_server); //memdelete(rasterizer); diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp index 6b91a5ce77..d691ae35bd 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -61,9 +61,9 @@ void OS_Server::initialize(const VideoMode& p_desired,int p_video_driver,int p_a //visual_server = memnew( VisualServerRaster(rasterizer) ); - AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); + AudioDriverManager::get_driver(p_audio_driver)->set_singleton(); - if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) { + if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) { ERR_PRINT("Initializing audio failed."); } @@ -237,7 +237,7 @@ void OS_Server::run() { OS_Server::OS_Server() { - AudioDriverManagerSW::add_driver(&driver_dummy); + AudioDriverManager::add_driver(&driver_dummy); //adriver here grab=false; diff --git a/platform/server/os_server.h b/platform/server/os_server.h index f7fe586b1b..2b6225c48d 100644 --- a/platform/server/os_server.h +++ b/platform/server/os_server.h @@ -29,17 +29,13 @@ #ifndef OS_SERVER_H #define OS_SERVER_H - #include "main/input_default.h" #include "drivers/unix/os_unix.h" #include "servers/visual_server.h" #include "servers/visual/rasterizer.h" #include "servers/audio/audio_driver_dummy.h" #include "servers/physics_server.h" -#include "servers/audio/audio_server_sw.h" -#include "servers/audio/sample_manager_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" +#include "servers/audio_server.h" #include "drivers/rtaudio/audio_driver_rtaudio.h" #include "servers/physics_2d/physics_2d_server_sw.h" @@ -66,11 +62,6 @@ class OS_Server : public OS_Unix { virtual void delete_main_loop(); IP_Unix *ip_unix; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; - bool force_quit; InputDefault *input; diff --git a/platform/uwp/app.h b/platform/uwp/app.h index 6df9c5699e..fd6fc950a7 100644 --- a/platform/uwp/app.h +++ b/platform/uwp/app.h @@ -32,38 +32,41 @@ #include <wrl.h> -#include "os_uwp.h" #include "GLES2/gl2.h" +#include "os_uwp.h" + +/** clang-format does not play nice with this C++/CX hybrid, needs investigation. */ +/* clang-format off */ namespace GodotUWP { - ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView - { - public: - App(); - - // IFrameworkView Methods. - virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView); - virtual void SetWindow(Windows::UI::Core::CoreWindow^ window); - virtual void Load(Platform::String^ entryPoint); - virtual void Run(); - virtual void Uninitialize(); + ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView + { + public: + App(); + + // IFrameworkView Methods. + virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView); + virtual void SetWindow(Windows::UI::Core::CoreWindow^ window); + virtual void Load(Platform::String^ entryPoint); + virtual void Run(); + virtual void Uninitialize(); property Windows::Foundation::EventRegistrationToken MouseMovedToken { - Windows::Foundation::EventRegistrationToken get() { return this->mouseMovedToken; } - void set(Windows::Foundation::EventRegistrationToken p_token) { this->mouseMovedToken = p_token; } - }; + Windows::Foundation::EventRegistrationToken get() { return this->mouseMovedToken; } + void set(Windows::Foundation::EventRegistrationToken p_token) { this->mouseMovedToken = p_token; } + } - private: + private: void RecreateRenderer(); - // Application lifecycle event handlers. - void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args); + // Application lifecycle event handlers. + void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args); - // Window event handlers. - void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args); - void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args); - void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args); + // Window event handlers. + void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args); + void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args); + void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args); void pointer_event(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args, bool p_pressed, bool p_is_wheel = false); void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); @@ -81,20 +84,20 @@ namespace GodotUWP void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args); void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args); - void UpdateWindowSize(Windows::Foundation::Size size); - void InitializeEGL(Windows::UI::Core::CoreWindow^ window); - void CleanupEGL(); + void UpdateWindowSize(Windows::Foundation::Size size); + void InitializeEGL(Windows::UI::Core::CoreWindow^ window); + void CleanupEGL(); char** get_command_line(unsigned int* out_argc); - bool mWindowClosed; - bool mWindowVisible; - GLsizei mWindowWidth; - GLsizei mWindowHeight; + bool mWindowClosed; + bool mWindowVisible; + GLsizei mWindowWidth; + GLsizei mWindowHeight; - EGLDisplay mEglDisplay; - EGLContext mEglContext; - EGLSurface mEglSurface; + EGLDisplay mEglDisplay; + EGLContext mEglContext; + EGLSurface mEglSurface; CoreWindow^ window; OSUWP* os; @@ -103,6 +106,7 @@ namespace GodotUWP int last_touch_y[32]; int number_of_contacts; Windows::Foundation::Point last_mouse_pos; - }; - + } } + +/* clang-format on */ diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 4648384480..f31c91ef6d 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -618,9 +618,7 @@ void AppxPackager::make_content_types() { types[ext] = content_type(ext); - tmp_file->store_string("<Default Extension=\"" + ext + - "\" ContentType=\"" - + types[ext] + "\" />"); + tmp_file->store_string("<Default Extension=\"" + ext + "\" ContentType=\"" + types[ext] + "\" />"); } // Appx signature file @@ -1174,9 +1172,9 @@ Error AppxPackager::MakeIndirectDataContent(asn1::SPCIndirectDataContent &idc) { MakeSPCInfoValue(*infoValue); ASN1_TYPE* value = - EncodedASN1::FromItem<asn1::SPCInfoValue, - asn1::i2d_SPCInfoValue>(infoValue) - .ToSequenceType(); + EncodedASN1::FromItem<asn1::SPCInfoValue, + asn1::i2d_SPCInfoValue>(infoValue) + .ToSequenceType(); { Vector<uint8_t> digest; @@ -1202,8 +1200,10 @@ Error AppxPackager::add_attributes(PKCS7_SIGNER_INFO * p_signer_info) { asn1::SPCSpOpusInfo* opus = asn1::SPCSpOpusInfo_new(); if (!opus) return openssl_error(ERR_peek_last_error()); - ASN1_STRING* opus_value = EncodedASN1::FromItem<asn1::SPCSpOpusInfo, asn1::i2d_SPCSpOpusInfo>(opus) - .ToSequenceString(); + ASN1_STRING* opus_value = + EncodedASN1::FromItem<asn1::SPCSpOpusInfo, + asn1::i2d_SPCSpOpusInfo>(opus) + .ToSequenceString(); if (!PKCS7_add_signed_attribute( p_signer_info, @@ -1237,8 +1237,9 @@ Error AppxPackager::add_attributes(PKCS7_SIGNER_INFO * p_signer_info) { statement_type->type = OBJ_nid2obj(NID_ms_code_ind); ASN1_STRING* statement_type_value = - EncodedASN1::FromItem<asn1::SPCStatementType, asn1::i2d_SPCStatementType>(statement_type) - .ToSequenceString(); + EncodedASN1::FromItem<asn1::SPCStatementType, + asn1::i2d_SPCStatementType>(statement_type) + .ToSequenceString(); if (!PKCS7_add_signed_attribute( p_signer_info, diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h index 90505b409a..5d81ac44c0 100644 --- a/platform/uwp/joypad_uwp.h +++ b/platform/uwp/joypad_uwp.h @@ -33,10 +33,12 @@ ref class JoypadUWP sealed { + /** clang-format breaks this, it does not understand this token. */ + /* clang-format off */ internal: - void register_events(); uint32_t process_controllers(uint32_t p_last_id); + /* clang-format on */ JoypadUWP(); JoypadUWP(InputDefault* p_input); diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 9dd745716e..90c21e11a1 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -36,16 +36,12 @@ #include "main/main.h" #include "drivers/windows/file_access_windows.h" #include "drivers/windows/dir_access_windows.h" - - #include "servers/visual/visual_server_raster.h" -#include "servers/audio/audio_server_sw.h" -#include "servers/visual/visual_server_wrap_mt.h" - +#include "servers/audio_server.h" +//#include "servers/visual/visual_server_wrap_mt.h" #include "os/memory_pool_dynamic_prealloc.h" #include "globals.h" #include "io/marshalls.h" - #include "platform/windows/packet_peer_udp_winsock.h" #include "platform/windows/stream_peer_winsock.h" #include "platform/windows/tcp_server_winsock.h" @@ -145,13 +141,14 @@ void OSUWP::set_keep_screen_on(bool p_enabled) { int OSUWP::get_audio_driver_count() const { - return AudioDriverManagerSW::get_driver_count(); + return AudioDriverManager::get_driver_count(); } + const char * OSUWP::get_audio_driver_name(int p_driver) const { - AudioDriverSW* driver = AudioDriverManagerSW::get_driver(p_driver); + AudioDriver* driver = AudioDriverManager::get_driver(p_driver); ERR_FAIL_COND_V( !driver, "" ); - return AudioDriverManagerSW::get_driver(p_driver)->get_name(); + return AudioDriverManager::get_driver(p_driver)->get_name(); } static MemoryPoolStatic *mempool_static=NULL; @@ -288,23 +285,13 @@ void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio joypad = ref new JoypadUWP(input); joypad->register_events(); - AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); + AudioDriverManager::get_driver(p_audio_driver)->set_singleton(); - if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) { + if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) { ERR_PRINT("Initializing audio failed."); } - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - - audio_server->init(); - - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - managed_object->update_clipboard(); Clipboard::ContentChanged += ref new EventHandler<Platform::Object^>(managed_object, &ManagedType::on_clipboard_changed); @@ -407,22 +394,12 @@ void OSUWP::finalize() { if (rasterizer) memdelete(rasterizer); - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); - /* if (debugger_connection_console) { memdelete(debugger_connection_console); } */ - memdelete(sample_manager); - - audio_server->finish(); - memdelete(audio_server); - memdelete(input); physics_server->finish(); @@ -971,7 +948,7 @@ OSUWP::OSUWP() { mouse_mode_changed = CreateEvent(NULL, TRUE, FALSE, L"os_mouse_mode_changed"); - AudioDriverManagerSW::add_driver(&audio_driver); + AudioDriverManager::add_driver(&audio_driver); } diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index 82376dd2f6..f65aa2d8d9 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -34,28 +34,19 @@ #include "servers/visual_server.h" #include "servers/visual/rasterizer.h" #include "servers/physics/physics_server_sw.h" - -#include "servers/audio/audio_server_sw.h" -#include "servers/audio/sample_manager_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" +#include "servers/audio_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "drivers/xaudio2/audio_driver_xaudio2.h" - #include "gl_context_egl.h" - #include "core/math/math_2d.h" #include "core/ustring.h" +#include "main/input_default.h" +#include "joypad_uwp.h" #include <windows.h> - #include <io.h> - #include <fcntl.h> #include <stdio.h> -#include "main/input_default.h" - -#include "joypad_uwp.h" /** @author Juan Linietsky <reduzio@gmail.com> @@ -119,10 +110,6 @@ private: MainLoop *main_loop; AudioDriverXAudio2 audio_driver; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; MouseMode mouse_mode; bool alt_mem; @@ -157,9 +144,12 @@ private: void on_magnetometer_reading_changed(Windows::Devices::Sensors::Magnetometer^ sender, Windows::Devices::Sensors::MagnetometerReadingChangedEventArgs^ args); void on_gyroscope_reading_changed(Windows::Devices::Sensors::Gyrometer^ sender, Windows::Devices::Sensors::GyrometerReadingChangedEventArgs^ args); + /** clang-format breaks this, it does not understand this token. */ + /* clang-format off */ internal: ManagedType() { alert_close_handle = false; } property OSUWP* os; + /* clang-format on */ }; ManagedType^ managed_object; Windows::Devices::Sensors::Accelerometer^ accelerometer; diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp index 6ea23ebb28..f2848268fc 100644 --- a/platform/windows/joypad.cpp +++ b/platform/windows/joypad.cpp @@ -249,7 +249,7 @@ BOOL CALLBACK JoypadWindows::enumCallback(const DIDEVICEINSTANCE* instance, void JoypadWindows* self = (JoypadWindows*)pContext; - if (self->is_xinput_device(&instance->guidProduct)) {; + if (self->is_xinput_device(&instance->guidProduct)) { return DIENUM_CONTINUE; } self->setup_dinput_joypad(instance); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 8910b23a2e..d1d769adf7 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -30,30 +30,25 @@ #include "os_windows.h" #include "drivers/gles3/rasterizer_gles3.h" - #include "drivers/windows/thread_windows.h" #include "drivers/windows/semaphore_windows.h" #include "drivers/windows/mutex_windows.h" #include "drivers/windows/rw_lock_windows.h" -#include "main/main.h" #include "drivers/windows/file_access_windows.h" #include "drivers/windows/dir_access_windows.h" - - #include "servers/visual/visual_server_raster.h" -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" //#include "servers/visual/visual_server_wrap_mt.h" - +#include "main/main.h" #include "tcp_server_winsock.h" #include "packet_peer_udp_winsock.h" #include "stream_peer_winsock.h" #include "lang_table.h" - #include "globals.h" #include "io/marshalls.h" #include "joypad.h" -#include "shlobj.h" +#include <shlobj.h> #include <regstr.h> #include <process.h> @@ -158,13 +153,13 @@ OS::VideoMode OS_Windows::get_default_video_mode() const { int OS_Windows::get_audio_driver_count() const { - return AudioDriverManagerSW::get_driver_count(); + return AudioDriverManager::get_driver_count(); } const char * OS_Windows::get_audio_driver_name(int p_driver) const { - AudioDriverSW* driver = AudioDriverManagerSW::get_driver(p_driver); + AudioDriver* driver = AudioDriverManager::get_driver(p_driver); ERR_FAIL_COND_V( !driver, "" ); - return AudioDriverManagerSW::get_driver(p_driver)->get_name(); + return AudioDriverManager::get_driver(p_driver)->get_name(); } @@ -1124,23 +1119,13 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_ input = memnew( InputDefault ); joypad = memnew (JoypadWindows(input, &hWnd)); - AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); + AudioDriverManager::get_driver(p_audio_driver)->set_singleton(); - if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) { + if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) { ERR_PRINT("Initializing audio failed."); } - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - - audio_server->init(); - - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - TRACKMOUSEEVENT tme; tme.cbSize=sizeof(TRACKMOUSEEVENT); tme.dwFlags=TME_LEAVE; @@ -1271,22 +1256,12 @@ void OS_Windows::finalize() { SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc); }; - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); - /* if (debugger_connection_console) { memdelete(debugger_connection_console); } */ - memdelete(sample_manager); - - audio_server->finish(); - memdelete(audio_server); - physics_server->finish(); memdelete(physics_server); @@ -1325,18 +1300,10 @@ void OS_Windows::vprint(const char* p_format, va_list p_list, bool p_stderr) { MultiByteToWideChar(CP_UTF8,0,buf,len,wbuf,wlen); wbuf[wlen]=0; -// Recent MinGW and MSVC compilers seem to disagree on the case here -#ifdef __MINGW32__ - if (p_stderr) - fwprintf(stderr, L"%S", wbuf); - else - wprintf(L"%S", wbuf); -#else // MSVC if (p_stderr) - fwprintf(stderr, L"%s", wbuf); + fwprintf(stderr, L"%ls", wbuf); else - wprintf(L"%s", wbuf); -#endif + wprintf(L"%ls", wbuf); #ifdef STDOUT_FILE //vwfprintf(stdo,p_format,p_list); @@ -2432,10 +2399,10 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) { user_proc = NULL; #ifdef RTAUDIO_ENABLED - AudioDriverManagerSW::add_driver(&driver_rtaudio); + AudioDriverManager::add_driver(&driver_rtaudio); #endif #ifdef XAUDIO2_ENABLED - AudioDriverManagerSW::add_driver(&driver_xaudio2); + AudioDriverManager::add_driver(&driver_xaudio2); #endif } diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 7ca89e6366..a5c8ecbe1b 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -35,29 +35,24 @@ #include "servers/visual_server.h" #include "servers/visual/rasterizer.h" #include "servers/physics/physics_server_sw.h" - -#include "servers/audio/audio_server_sw.h" -#include "servers/audio/sample_manager_sw.h" +#include "servers/audio_server.h" #include "drivers/rtaudio/audio_driver_rtaudio.h" #ifdef XAUDIO2_ENABLED #include "drivers/xaudio2/audio_driver_xaudio2.h" #endif -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" #include "drivers/unix/ip_unix.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/physics_2d/physics_2d_server_wrap_mt.h" - #include "main/input_default.h" +#include "key_mapping_win.h" -#include <windows.h> -#include "key_mapping_win.h" +#include <windows.h> #include <windowsx.h> #include <io.h> - #include <fcntl.h> #include <stdio.h> + /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -116,11 +111,6 @@ class OS_Windows : public OS { WNDPROC user_proc; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; - MouseMode mouse_mode; bool alt_mem; bool gr_mem; diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp index b388d4b89f..9d3e3623da 100644 --- a/platform/windows/stream_peer_winsock.cpp +++ b/platform/windows/stream_peer_winsock.cpp @@ -98,7 +98,7 @@ Error StreamPeerWinsock::_poll_connection(bool p_block) const { return OK; }; - if (errno == WSAEINPROGRESS || errno == WSAEALREADY) { + if (err == WSAEINPROGRESS || err == WSAEALREADY) { return OK; } @@ -136,13 +136,11 @@ Error StreamPeerWinsock::write(const uint8_t* p_data,int p_bytes, int &r_sent, b int data_to_send = p_bytes; const uint8_t *offset = p_data; if (sockfd == -1) return FAILED; - errno = 0; int total_sent = 0; while (data_to_send) { int sent_amount = send(sockfd, (const char*)offset, data_to_send, 0); - //printf("Sent TCP data of %d bytes, errno %d\n", sent_amount, errno); if (sent_amount == -1) { @@ -195,7 +193,6 @@ Error StreamPeerWinsock::read(uint8_t* p_buffer, int p_bytes,int &r_received, bo int to_read = p_bytes; int total_read = 0; - errno = 0; while (to_read) { diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 13e01ab6ac..41746c2431 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -82,14 +82,14 @@ OS::VideoMode OS_X11::get_default_video_mode() const { } int OS_X11::get_audio_driver_count() const { - return AudioDriverManagerSW::get_driver_count(); + return AudioDriverManager::get_driver_count(); } const char *OS_X11::get_audio_driver_name(int p_driver) const { - AudioDriverSW* driver = AudioDriverManagerSW::get_driver(p_driver); + AudioDriver* driver = AudioDriverManager::get_driver(p_driver); ERR_FAIL_COND_V( !driver, "" ); - return AudioDriverManagerSW::get_driver(p_driver)->get_name(); + return AudioDriverManager::get_driver(p_driver)->get_name(); } void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { @@ -269,21 +269,21 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XFree(xsh); } - AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); + AudioDriverManager::get_driver(p_audio_driver)->set_singleton(); audio_driver_index=p_audio_driver; - if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) { + if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) { bool success=false; audio_driver_index=-1; - for(int i=0;i<AudioDriverManagerSW::get_driver_count();i++) { + for(int i=0;i<AudioDriverManager::get_driver_count();i++) { if (i==p_audio_driver) continue; - AudioDriverManagerSW::get_driver(i)->set_singleton(); - if (AudioDriverManagerSW::get_driver(i)->init()==OK) { + AudioDriverManager::get_driver(i)->set_singleton(); + if (AudioDriverManager::get_driver(i)->init()==OK) { success=true; - print_line("Audio Driver Failed: "+String(AudioDriverManagerSW::get_driver(p_audio_driver)->get_name())); - print_line("Using alternate audio driver: "+String(AudioDriverManagerSW::get_driver(i)->get_name())); + print_line("Audio Driver Failed: "+String(AudioDriverManager::get_driver(p_audio_driver)->get_name())); + print_line("Using alternate audio driver: "+String(AudioDriverManager::get_driver(i)->get_name())); audio_driver_index=i; break; } @@ -294,14 +294,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi } - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - audio_server->init(); - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - ERR_FAIL_COND(!visual_server); ERR_FAIL_COND(x11_window==0); @@ -469,10 +461,6 @@ void OS_X11::finalize() { memdelete(main_loop); main_loop=NULL; - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); /* if (debugger_connection_console) { @@ -485,10 +473,6 @@ void OS_X11::finalize() { #endif memdelete(input); - memdelete(sample_manager); - - audio_server->finish(); - memdelete(audio_server); visual_server->finish(); memdelete(visual_server); @@ -561,11 +545,10 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) { } } - if (XGrabPointer(x11_display, x11_window, True, - ButtonPressMask | ButtonReleaseMask | - PointerMotionMask, GrabModeAsync, GrabModeAsync, - x11_window, None, CurrentTime) != - GrabSuccess) { + if (XGrabPointer( + x11_display, x11_window, True, + ButtonPressMask | ButtonReleaseMask | PointerMotionMask, + GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime) != GrabSuccess) { ERR_PRINT("NO GRAB"); } @@ -1306,10 +1289,10 @@ void OS_X11::process_xevents() { minimized = false; main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN); if (mouse_mode==MOUSE_MODE_CAPTURED) { - XGrabPointer(x11_display, x11_window, True, - ButtonPressMask | ButtonReleaseMask | - PointerMotionMask, GrabModeAsync, GrabModeAsync, - x11_window, None, CurrentTime); + XGrabPointer( + x11_display, x11_window, True, + ButtonPressMask | ButtonReleaseMask | PointerMotionMask, + GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime); } break; @@ -1984,20 +1967,20 @@ void OS_X11::set_context(int p_context) { OS_X11::OS_X11() { #ifdef RTAUDIO_ENABLED - AudioDriverManagerSW::add_driver(&driver_rtaudio); + AudioDriverManager::add_driver(&driver_rtaudio); #endif #ifdef PULSEAUDIO_ENABLED - AudioDriverManagerSW::add_driver(&driver_pulseaudio); + AudioDriverManager::add_driver(&driver_pulseaudio); #endif #ifdef ALSA_ENABLED - AudioDriverManagerSW::add_driver(&driver_alsa); + AudioDriverManager::add_driver(&driver_alsa); #endif - if(AudioDriverManagerSW::get_driver_count() == 0){ + if(AudioDriverManager::get_driver_count() == 0){ WARN_PRINT("No sound driver found... Defaulting to dummy driver"); - AudioDriverManagerSW::add_driver(&driver_dummy); + AudioDriverManager::add_driver(&driver_dummy); } minimized = false; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index bf676b5edf..3245df32c6 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -37,10 +37,7 @@ //#include "servers/visual/visual_server_wrap_mt.h" #include "servers/visual/rasterizer.h" #include "servers/physics_server.h" -#include "servers/audio/audio_server_sw.h" -#include "servers/audio/sample_manager_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" +#include "servers/audio_server.h" #include "drivers/rtaudio/audio_driver_rtaudio.h" #include "drivers/alsa/audio_driver_alsa.h" #include "drivers/pulseaudio/audio_driver_pulseaudio.h" @@ -135,11 +132,6 @@ class OS_X11 : public OS_Unix { virtual void delete_main_loop(); IP_Unix *ip_unix; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; - bool force_quit; bool minimized; diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 67c596421f..61ed362cf0 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -675,7 +675,7 @@ void Area2D::_bind_methods() { Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_create(),true) { space_override=SPACE_OVERRIDE_DISABLED; - set_gravity(98);; + set_gravity(98); set_gravity_vector(Vector2(0,1)); gravity_is_point=false; gravity_distance_scale=0; diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index 03c2c698eb..ec1109b41b 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -127,7 +127,7 @@ void Navigation2D::_navpoly_link(int p_id) { C->get().B=&p; C->get().B_edge=j; C->get().A->edges[C->get().A_edge].C=&p; - C->get().A->edges[C->get().A_edge].C_edge=j;; + C->get().A->edges[C->get().A_edge].C_edge=j; p.edges[j].C=C->get().A; p.edges[j].C_edge=C->get().A_edge; //connection successful. @@ -679,7 +679,7 @@ debug path path.push_back(begin_point); - path.invert();; + path.invert(); } return path; diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index 012120d023..88d6a90e81 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -137,7 +137,7 @@ PoolVector<Vector2> NavigationPolygon::get_outline(int p_idx) const { void NavigationPolygon::clear_outlines(){ - outlines.clear();; + outlines.clear(); } void NavigationPolygon::make_polygons_from_outlines(){ diff --git a/scene/2d/sample_player_2d.cpp b/scene/2d/sample_player_2d.cpp deleted file mode 100644 index 62eabea98e..0000000000 --- a/scene/2d/sample_player_2d.cpp +++ /dev/null @@ -1,263 +0,0 @@ -/*************************************************************************/ -/* sample_player_2d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "sample_player_2d.h" - -#include "servers/audio_server.h" -#include "servers/audio_server.h" -#include "servers/spatial_sound_server.h" - - -bool SamplePlayer2D::_set(const StringName& p_name, const Variant& p_value) { - - String name=p_name; - - if (name=="play/play") { - if (library.is_valid()) { - - String what=p_value; - if (what=="") - stop_all(); - else - play(what); - - played_back=what; - } - } else - return false; - - return true; -} - -bool SamplePlayer2D::_get(const StringName& p_name,Variant &r_ret) const { - - - String name=p_name; - - if (name=="play/play") { - r_ret=played_back; - } else - return false; - - return true; -} - -void SamplePlayer2D::_get_property_list(List<PropertyInfo> *p_list) const { - - String en=""; - if (library.is_valid()) { - List<StringName> samples; - Ref<SampleLibrary> ncl=library; - ncl->get_sample_list(&samples); - for (List<StringName>::Element *E=samples.front();E;E=E->next()) { - - en+=","; - en+=E->get(); - } - } - - p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER)); -} - -void SamplePlayer2D::_notification(int p_what) { - - - switch(p_what) { - - case NOTIFICATION_ENTER_TREE: { - - SpatialSound2DServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony); - - - } break; - } - -} - -void SamplePlayer2D::set_sample_library(const Ref<SampleLibrary>& p_library) { - - library=p_library; - _change_notify(); - update_configuration_warning(); -} - -Ref<SampleLibrary> SamplePlayer2D::get_sample_library() const { - - return library; -} - -void SamplePlayer2D::set_polyphony(int p_voice_count) { - - ERR_FAIL_COND(p_voice_count<0 || p_voice_count>64); - polyphony=p_voice_count; - if (get_source_rid().is_valid()) - SpatialSound2DServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony); - -} - -int SamplePlayer2D::get_polyphony() const { - - return polyphony; -} - -SamplePlayer2D::VoiceID SamplePlayer2D::play(const String& p_sample,int p_voice) { - - if (!get_source_rid().is_valid()) - return INVALID_VOICE; - if (library.is_null()) - return INVALID_VOICE; - if (!library->has_sample(p_sample)) - return INVALID_VOICE; - Ref<Sample> sample = library->get_sample(p_sample); - float vol_change = library->sample_get_volume_db(p_sample); - float pitch_change = library->sample_get_pitch_scale(p_sample); - - VoiceID vid = SpatialSound2DServer::get_singleton()->source_play_sample(get_source_rid(),sample->get_rid(),sample->get_mix_rate()*pitch_change,p_voice); - if (vol_change) - SpatialSound2DServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),vid,vol_change); - - - if (random_pitch_scale) { - float ps = Math::random(-random_pitch_scale,random_pitch_scale); - if (ps>0) - ps=1.0+ps; - else - ps=1.0/(1.0-ps); - SpatialSound2DServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(),vid,ps*pitch_change); - - } - - return vid; -} -//voices -void SamplePlayer2D::voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale) { - - if (!get_source_rid().is_valid()) - return; - - SpatialSound2DServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(),p_voice,p_pitch_scale); - -} - -void SamplePlayer2D::voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db) { - - if (!get_source_rid().is_valid()) - return; - SpatialSound2DServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),p_voice,p_volume_db); - -} - -bool SamplePlayer2D::is_voice_active(VoiceID p_voice) const { - - if (!get_source_rid().is_valid()) - return false; - return SpatialSound2DServer::get_singleton()->source_is_voice_active(get_source_rid(),p_voice); - -} - -void SamplePlayer2D::stop_voice(VoiceID p_voice) { - - if (!get_source_rid().is_valid()) - return; - SpatialSound2DServer::get_singleton()->source_stop_voice(get_source_rid(),p_voice); - -} - -void SamplePlayer2D::stop_all() { - - if (!get_source_rid().is_valid()) - return; - - for(int i=0;i<polyphony;i++) { - - SpatialSound2DServer::get_singleton()->source_stop_voice(get_source_rid(),i); - } -} - -void SamplePlayer2D::set_random_pitch_scale(float p_scale) { - random_pitch_scale=p_scale; -} - -float SamplePlayer2D::get_random_pitch_scale() const { - - return random_pitch_scale; -} - -String SamplePlayer2D::get_configuration_warning() const { - - if (library.is_null()) { - return TTR("A SampleLibrary resource must be created or set in the 'samples' property in order for SamplePlayer to play sound."); - } - - return String(); -} - -void SamplePlayer2D::_bind_methods() { - - - ClassDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer2D::set_sample_library); - ClassDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer2D::get_sample_library); - - ClassDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer2D::set_polyphony); - ClassDB::bind_method(_MD("get_polyphony"),&SamplePlayer2D::get_polyphony); - - ClassDB::bind_method(_MD("play","sample","voice"),&SamplePlayer2D::play,DEFVAL(NEXT_VOICE)); - //voices,DEV - ClassDB::bind_method(_MD("voice_set_pitch_scale","voice","ratio"),&SamplePlayer2D::voice_set_pitch_scale); - ClassDB::bind_method(_MD("voice_set_volume_scale_db","voice","db"),&SamplePlayer2D::voice_set_volume_scale_db); - - ClassDB::bind_method(_MD("is_voice_active","voice"),&SamplePlayer2D::is_voice_active); - ClassDB::bind_method(_MD("stop_voice","voice"),&SamplePlayer2D::stop_voice); - ClassDB::bind_method(_MD("stop_all"),&SamplePlayer2D::stop_all); - - ClassDB::bind_method(_MD("set_random_pitch_scale","val"),&SamplePlayer2D::set_random_pitch_scale); - ClassDB::bind_method(_MD("get_random_pitch_scale"),&SamplePlayer2D::get_random_pitch_scale); - - BIND_CONSTANT( INVALID_VOICE ); - BIND_CONSTANT( NEXT_VOICE ); - - ADD_GROUP("Config",""); - ADD_PROPERTY( PropertyInfo( Variant::INT, "polyphony", PROPERTY_HINT_RANGE, "1,64,1"),_SCS("set_polyphony"),_SCS("get_polyphony")); - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "samples", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_sample_library"),_SCS("get_sample_library")); - ADD_PROPERTY( PropertyInfo( Variant::REAL, "pitch_random", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_random_pitch_scale"),_SCS("get_random_pitch_scale")); - - -} - - -SamplePlayer2D::SamplePlayer2D() { - - polyphony=1; - random_pitch_scale=0; - -} - -SamplePlayer2D::~SamplePlayer2D() { - - -} diff --git a/scene/2d/sample_player_2d.h b/scene/2d/sample_player_2d.h deleted file mode 100644 index 5cf598327b..0000000000 --- a/scene/2d/sample_player_2d.h +++ /dev/null @@ -1,94 +0,0 @@ -/*************************************************************************/ -/* sample_player_2d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SAMPLE_PLAYER_2D_H -#define SAMPLE_PLAYER_2D_H - -#include "scene/2d/sound_player_2d.h" -#include "scene/resources/sample_library.h" - -class SamplePlayer2D : public SoundPlayer2D { - - GDCLASS(SamplePlayer2D,SoundPlayer2D); -public: - - enum { - - INVALID_VOICE=SpatialSoundServer::SOURCE_INVALID_VOICE, - NEXT_VOICE=SpatialSoundServer::SOURCE_NEXT_VOICE - }; - - typedef int VoiceID; - - -private: - - Ref<SampleLibrary> library; - int polyphony; - String played_back; - float random_pitch_scale; - -protected: - - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; - void _get_property_list(List<PropertyInfo> *p_list) const; - - void _notification(int p_what); - - static void _bind_methods(); - -public: - - void set_sample_library(const Ref<SampleLibrary>& p_library); - Ref<SampleLibrary> get_sample_library() const; - - void set_polyphony(int p_voice_count); - int get_polyphony() const; - - VoiceID play(const String& p_sample,int p_voice=NEXT_VOICE); - //voices - void voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale); - void voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db); - - bool is_voice_active(VoiceID p_voice) const; - void stop_voice(VoiceID p_voice); - void stop_all(); - - void set_random_pitch_scale(float p_scale); - float get_random_pitch_scale() const; - - String get_configuration_warning() const; - - SamplePlayer2D(); - ~SamplePlayer2D(); - - -}; - -#endif // SAMPLE_PLAYER_2D_H diff --git a/scene/2d/sound_player_2d.cpp b/scene/2d/sound_player_2d.cpp deleted file mode 100644 index 7861fb5855..0000000000 --- a/scene/2d/sound_player_2d.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************/ -/* sound_player_2d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "sound_player_2d.h" - -#include "servers/audio_server.h" - -#include "servers/spatial_sound_2d_server.h" -#include "scene/resources/surface_tool.h" - - -void SoundPlayer2D::_notification(int p_what) { - - - switch(p_what) { - - case NOTIFICATION_ENTER_TREE: { - //find the sound space - - source_rid = SpatialSound2DServer::get_singleton()->source_create(get_world_2d()->get_sound_space()); - - for(int i=0;i<PARAM_MAX;i++) - set_param(Param(i),params[i]); - - SpatialSound2DServer::get_singleton()->source_set_transform(source_rid,get_global_transform()); - - - } break; - case NOTIFICATION_TRANSFORM_CHANGED: { - - SpatialSound2DServer::get_singleton()->source_set_transform(source_rid,get_global_transform()); - - } break; - case NOTIFICATION_EXIT_TREE: { - - if (source_rid.is_valid()) - SpatialSound2DServer::get_singleton()->free(source_rid); - - } break; - } - -} - - -void SoundPlayer2D::set_param( Param p_param, float p_value) { - - ERR_FAIL_INDEX(p_param,PARAM_MAX); - params[p_param]=p_value; - if (source_rid.is_valid()) - SpatialSound2DServer::get_singleton()->source_set_param(source_rid,(SpatialSound2DServer::SourceParam)p_param,p_value); - -} - -float SoundPlayer2D::get_param( Param p_param) const { - - ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0); - return params[p_param]; - -} - - -void SoundPlayer2D::_bind_methods() { - - - ClassDB::bind_method(_MD("set_param","param","value"),&SoundPlayer2D::set_param); - ClassDB::bind_method(_MD("get_param","param"),&SoundPlayer2D::get_param); - - BIND_CONSTANT( PARAM_VOLUME_DB ); - BIND_CONSTANT( PARAM_PITCH_SCALE ); - BIND_CONSTANT( PARAM_ATTENUATION_MIN_DISTANCE ); - BIND_CONSTANT( PARAM_ATTENUATION_MAX_DISTANCE ); - BIND_CONSTANT( PARAM_ATTENUATION_DISTANCE_EXP ); - BIND_CONSTANT( PARAM_MAX ); - - ADD_GROUP("Parameters",""); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "volume_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_VOLUME_DB); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "pitch_scale",PROPERTY_HINT_RANGE, "0.001,32,0.001"),_SCS("set_param"),_SCS("get_param"),PARAM_PITCH_SCALE); - ADD_GROUP("Attenuation","attenuation_"); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_min_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MIN_DISTANCE); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_max_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MAX_DISTANCE); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_distance_exp",PROPERTY_HINT_EXP_EASING, "attenuation"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_DISTANCE_EXP); - -} - - -SoundPlayer2D::SoundPlayer2D() { - - params[PARAM_VOLUME_DB]=0.0; - params[PARAM_PITCH_SCALE]=1.0; - params[PARAM_ATTENUATION_MIN_DISTANCE]=1; - params[PARAM_ATTENUATION_MAX_DISTANCE]=2048; - params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good) - - set_notify_transform(true); -} - -SoundPlayer2D::~SoundPlayer2D() { - - -} diff --git a/scene/2d/sound_player_2d.h b/scene/2d/sound_player_2d.h deleted file mode 100644 index bfabda4ec9..0000000000 --- a/scene/2d/sound_player_2d.h +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************/ -/* sound_player_2d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SOUND_PLAYER_2D_H -#define SOUND_PLAYER_2D_H - - -#include "scene/2d/node_2d.h" -#include "scene/resources/sample_library.h" -#include "servers/spatial_sound_2d_server.h" -#include "scene/main/viewport.h" - -class SoundPlayer2D : public Node2D { - - GDCLASS(SoundPlayer2D,Node2D); -public: - - - enum Param { - - PARAM_VOLUME_DB=SpatialSound2DServer::SOURCE_PARAM_VOLUME_DB, - PARAM_PITCH_SCALE=SpatialSound2DServer::SOURCE_PARAM_PITCH_SCALE, - PARAM_ATTENUATION_MIN_DISTANCE=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_MIN_DISTANCE, - PARAM_ATTENUATION_MAX_DISTANCE=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_MAX_DISTANCE, - PARAM_ATTENUATION_DISTANCE_EXP=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_DISTANCE_EXP, - PARAM_MAX=SpatialSound2DServer::SOURCE_PARAM_MAX - }; - -private: - - float params[PARAM_MAX]; - RID source_rid; - - -protected: - - _FORCE_INLINE_ RID get_source_rid() const { return source_rid; } - - void _notification(int p_what); - - static void _bind_methods(); - -public: - - void set_param( Param p_param, float p_value); - float get_param( Param p_param) const; - - - SoundPlayer2D(); - ~SoundPlayer2D(); - - -}; - -VARIANT_ENUM_CAST(SoundPlayer2D::Param ); - -#endif // SOUND_PLAYER_2D_H diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h index 05c0bd9eec..ab4487ef7b 100644 --- a/scene/2d/sprite.h +++ b/scene/2d/sprite.h @@ -58,7 +58,7 @@ protected: void _notification(int p_what); - static void _bind_methods();; + static void _bind_methods(); virtual void _validate_property(PropertyInfo& property) const; @@ -119,7 +119,7 @@ protected: void _notification(int p_what); - static void _bind_methods();; + static void _bind_methods(); public: diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 99e40984c5..3301c4d754 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -664,7 +664,7 @@ void Area::_bind_methods() { Area::Area() : CollisionObject(PhysicsServer::get_singleton()->area_create(),true) { space_override=SPACE_OVERRIDE_DISABLED; - set_gravity(9.8);; + set_gravity(9.8); locked=false; set_gravity_vector(Vector3(0,-1,0)); gravity_is_point=false; diff --git a/scene/3d/baked_light_instance.cpp b/scene/3d/baked_light_instance.cpp index e42439bf3b..514c73a488 100644 --- a/scene/3d/baked_light_instance.cpp +++ b/scene/3d/baked_light_instance.cpp @@ -943,7 +943,7 @@ void BakedLight::_bake_light(Light* p_light) { Vector3 light_dir = -rel_xf.basis.get_axis(2); Color color = dl->get_color(); - float nrg = dl->get_param(Light::PARAM_ENERGY);; + float nrg = dl->get_param(Light::PARAM_ENERGY); color.r*=nrg; color.g*=nrg; color.b*=nrg; @@ -1705,7 +1705,6 @@ void BakedLight::create_debug_mesh(DebugMode p_mode) { #else mmi->set_owner(get_owner()); #endif - } void BakedLight::_debug_mesh_albedo() { diff --git a/scene/3d/body_shape.cpp b/scene/3d/body_shape.cpp index f6ec8639d3..f3c839d525 100644 --- a/scene/3d/body_shape.cpp +++ b/scene/3d/body_shape.cpp @@ -506,7 +506,7 @@ void CollisionShape::_create_debug_shape() { if (debug_shape) { - debug_shape->queue_delete();; + debug_shape->queue_delete(); debug_shape=NULL; } diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp index c3ab2df939..825cf1c535 100644 --- a/scene/3d/bone_attachment.cpp +++ b/scene/3d/bone_attachment.cpp @@ -79,7 +79,7 @@ void BoneAttachment::_check_bind() { Skeleton *sk = get_parent()->cast_to<Skeleton>(); int idx = sk->find_bone(bone_name); if (idx!=-1) { - sk->bind_child_node_to_bone(idx,this);; + sk->bind_child_node_to_bone(idx,this); set_transform(sk->get_bone_global_pose(idx)); bound=true; } @@ -94,7 +94,7 @@ void BoneAttachment::_check_unbind() { Skeleton *sk = get_parent()->cast_to<Skeleton>(); int idx = sk->find_bone(bone_name); if (idx!=-1) { - sk->unbind_child_node_from_bone(idx,this);; + sk->unbind_child_node_from_bone(idx,this); } } bound=false; diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index 3f36caf62c..5bd2c771ee 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -644,7 +644,7 @@ Vector<Plane> Camera::get_frustum() const { void Camera::set_v_offset(float p_offset) { v_offset=p_offset; - _update_camera();; + _update_camera(); } float Camera::get_v_offset() const { diff --git a/scene/3d/character_camera.cpp b/scene/3d/character_camera.cpp index b4cd46bd35..211619d0df 100644 --- a/scene/3d/character_camera.cpp +++ b/scene/3d/character_camera.cpp @@ -97,7 +97,7 @@ void CharacterCamera::_get_property_list( List<PropertyInfo> *p_list) const { p_list->push_back( PropertyInfo( Variant::INT, "type", PROPERTY_HINT_ENUM, "Fixed,Follow") ); p_list->push_back( PropertyInfo( Variant::VECTOR2, "orbit" ) ); p_list->push_back( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "inclination", PROPERTY_HINT_RANGE,"-90,90,0.01" ) ); ; + p_list->push_back( PropertyInfo( Variant::REAL, "inclination", PROPERTY_HINT_RANGE,"-90,90,0.01" ) ); p_list->push_back( PropertyInfo( Variant::REAL, "max_orbit_x", PROPERTY_HINT_RANGE,"-90,90,0.01" ) ); p_list->push_back( PropertyInfo( Variant::REAL, "min_orbit_x", PROPERTY_HINT_RANGE,"-90,90,0.01" ) ); p_list->push_back( PropertyInfo( Variant::REAL, "min_distance", PROPERTY_HINT_RANGE,"0,100,0.01" ) ); @@ -168,7 +168,7 @@ void CharacterCamera::_compute_camera() { Vector3 vec1 = accepted.origin; Vector3 vec2 = proposed.origin; - final.origin = vec2.linear_interpolate(vec1, pos_ratio * time);; + final.origin = vec2.linear_interpolate(vec1, pos_ratio * time); Quat q1 = accepted.basis; Quat q2 = proposed.basis; diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 54d7cb6b9e..8035ce1cc7 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -1324,7 +1324,6 @@ void GIProbe::_create_debug_mesh(Baker *p_baker) { #else mmi->set_owner(get_owner()); #endif - } void GIProbe::_debug_bake() { diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index d685cd8ce7..0c6c113dd2 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -47,7 +47,7 @@ void Light::set_param(Param p_param, float p_value) { VS::get_singleton()->light_set_param(light,VS::LightParam(p_param),p_value); if (p_param==PARAM_SPOT_ANGLE || p_param==PARAM_RANGE) { - update_gizmo();; + update_gizmo(); } diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index 764aff1c08..2198f538b8 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -91,7 +91,7 @@ void MeshInstance::_get_property_list( List<PropertyInfo> *p_list) const { ls.push_back(E->key()); } - ls.sort();; + ls.sort(); for(List<String>::Element *E=ls.front();E;E=E->next()) { p_list->push_back( PropertyInfo(Variant::REAL,E->get(),PROPERTY_HINT_RANGE,"0,1,0.01")); diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp index 9bb19880bf..38893598d6 100644 --- a/scene/3d/navigation.cpp +++ b/scene/3d/navigation.cpp @@ -129,7 +129,7 @@ void Navigation::_navmesh_link(int p_id) { C->get().B=&p; C->get().B_edge=j; C->get().A->edges[C->get().A_edge].C=&p; - C->get().A->edges[C->get().A_edge].C_edge=j;; + C->get().A->edges[C->get().A_edge].C_edge=j; p.edges[j].C=C->get().A; p.edges[j].C_edge=C->get().A_edge; //connection successful. @@ -550,7 +550,7 @@ Vector<Vector3> Navigation::get_simple_path(const Vector3& p_start, const Vector path.push_back(begin_point); - path.invert();; + path.invert(); } return path; diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp index cdca54cd84..a2e1a48781 100644 --- a/scene/3d/room_instance.cpp +++ b/scene/3d/room_instance.cpp @@ -56,17 +56,11 @@ void Room::_notification(int p_what) { } - if (sound_enabled) - SpatialSoundServer::get_singleton()->room_set_space(sound_room,get_world()->get_sound_space()); - } break; case NOTIFICATION_TRANSFORM_CHANGED: { - SpatialSoundServer::get_singleton()->room_set_transform(sound_room,get_global_transform()); } break; case NOTIFICATION_EXIT_WORLD: { - if (sound_enabled) - SpatialSoundServer::get_singleton()->room_set_space(sound_room,RID()); } break; @@ -158,61 +152,27 @@ void Room::_parse_node_faces(PoolVector<Face3> &all_faces,const Node *p_node) co -void Room::set_simulate_acoustics(bool p_enable) { - - if (sound_enabled==p_enable) - return; - - sound_enabled=p_enable; - if (!is_inside_world()) - return; //nothing to do - - if (sound_enabled) - SpatialSoundServer::get_singleton()->room_set_space(sound_room,get_world()->get_sound_space()); - else - SpatialSoundServer::get_singleton()->room_set_space(sound_room,RID()); - - -} - void Room::_bounds_changed() { update_gizmo(); } -bool Room::is_simulating_acoustics() const { - - return sound_enabled; -} - -RID Room::get_sound_room() const { - - return RID(); -} - void Room::_bind_methods() { ClassDB::bind_method(_MD("set_room","room:Room"),&Room::set_room ); ClassDB::bind_method(_MD("get_room:Room"),&Room::get_room ); - - ClassDB::bind_method(_MD("set_simulate_acoustics","enable"),&Room::set_simulate_acoustics ); - ClassDB::bind_method(_MD("is_simulating_acoustics"),&Room::is_simulating_acoustics ); - - - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "room/room", PROPERTY_HINT_RESOURCE_TYPE, "Area" ), _SCS("set_room"), _SCS("get_room") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "room/simulate_acoustics"), _SCS("set_simulate_acoustics"), _SCS("is_simulating_acoustics") ); + } Room::Room() { - sound_enabled=false; - sound_room=SpatialSoundServer::get_singleton()->room_create(); +// sound_enabled=false; level=0; @@ -222,6 +182,6 @@ Room::Room() { Room::~Room() { - SpatialSoundServer::get_singleton()->free(sound_room); + } diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h index 145589a780..cbc1b12b7e 100644 --- a/scene/3d/room_instance.h +++ b/scene/3d/room_instance.h @@ -31,7 +31,7 @@ #include "scene/3d/visual_instance.h" #include "scene/resources/room.h" -#include "servers/spatial_sound_server.h" + /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -58,9 +58,6 @@ public: private: Ref<RoomBounds> room; - RID sound_room; - - bool sound_enabled; int level; void _parse_node_faces(PoolVector<Face3> &all_faces,const Node *p_node) const; @@ -88,11 +85,6 @@ public: void set_room( const Ref<RoomBounds>& p_room ); Ref<RoomBounds> get_room() const; - void set_simulate_acoustics(bool p_enable); - bool is_simulating_acoustics() const; - - - RID get_sound_room() const; Room(); ~Room(); diff --git a/scene/3d/spatial_player.cpp b/scene/3d/spatial_player.cpp deleted file mode 100644 index 6a368d771a..0000000000 --- a/scene/3d/spatial_player.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/*************************************************************************/ -/* spatial_player.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "spatial_player.h" - -#include "servers/audio_server.h" -#include "camera.h" -#include "servers/spatial_sound_server.h" -#include "scene/resources/surface_tool.h" - - -void SpatialPlayer::_notification(int p_what) { - - - switch(p_what) { - - case NOTIFICATION_ENTER_WORLD: { - //find the sound space - - source_rid = SpatialSoundServer::get_singleton()->source_create(get_world()->get_sound_space()); - for(int i=0;i<PARAM_MAX;i++) - set_param(Param(i),params[i]); - - - } break; - case NOTIFICATION_TRANSFORM_CHANGED: { - - SpatialSoundServer::get_singleton()->source_set_transform(source_rid,get_global_transform()); - - } break; - case NOTIFICATION_EXIT_WORLD: { - - if (source_rid.is_valid()) - SpatialSoundServer::get_singleton()->free(source_rid); - - } break; - } - -} - - -void SpatialPlayer::set_param( Param p_param, float p_value) { - - ERR_FAIL_INDEX(p_param,PARAM_MAX); - params[p_param]=p_value; - if (p_param==PARAM_EMISSION_CONE_DEGREES) { - update_gizmo(); - } - if (source_rid.is_valid()) - SpatialSoundServer::get_singleton()->source_set_param(source_rid,(SpatialSoundServer::SourceParam)p_param,p_value); - -} - -float SpatialPlayer::get_param( Param p_param) const { - - ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0); - return params[p_param]; - -} - -bool SpatialPlayer::_can_gizmo_scale() const { - - return false; -} - -void SpatialPlayer::_bind_methods() { - - - ClassDB::bind_method(_MD("set_param","param","value"),&SpatialPlayer::set_param); - ClassDB::bind_method(_MD("get_param","param"),&SpatialPlayer::get_param); - - BIND_CONSTANT( PARAM_VOLUME_DB ); - BIND_CONSTANT( PARAM_PITCH_SCALE ); - BIND_CONSTANT( PARAM_ATTENUATION_MIN_DISTANCE ); - BIND_CONSTANT( PARAM_ATTENUATION_MAX_DISTANCE ); - BIND_CONSTANT( PARAM_ATTENUATION_DISTANCE_EXP ); - BIND_CONSTANT( PARAM_EMISSION_CONE_DEGREES ); - BIND_CONSTANT( PARAM_EMISSION_CONE_ATTENUATION_DB ); - BIND_CONSTANT( PARAM_MAX ); - - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "volume_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_VOLUME_DB); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "pitch_scale",PROPERTY_HINT_RANGE, "0.001,32,0.001"),_SCS("set_param"),_SCS("get_param"),PARAM_PITCH_SCALE); - ADD_GROUP("Attenuation","attenuation_"); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_min_distance",PROPERTY_HINT_RANGE, "0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MIN_DISTANCE); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_max_distance",PROPERTY_HINT_RANGE, "0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MAX_DISTANCE); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_distance_exp",PROPERTY_HINT_EXP_EASING, "attenuation"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_DISTANCE_EXP); - ADD_GROUP("Emission Cone","emission_cone_"); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "emission_cone_degrees",PROPERTY_HINT_RANGE, "0,180,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_EMISSION_CONE_DEGREES); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "emission_cone_attenuation_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_EMISSION_CONE_ATTENUATION_DB); - -} - - -SpatialPlayer::SpatialPlayer() { - - params[PARAM_VOLUME_DB]=0.0; - params[PARAM_PITCH_SCALE]=1.0; - params[PARAM_ATTENUATION_MIN_DISTANCE]=1; - params[PARAM_ATTENUATION_MAX_DISTANCE]=100; - params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good) - params[PARAM_EMISSION_CONE_DEGREES]=180.0; //cone disabled - params[PARAM_EMISSION_CONE_ATTENUATION_DB]=-6.0; //minus 6 db attenuation - set_notify_transform(true); - -} - -SpatialPlayer::~SpatialPlayer() { - - -} diff --git a/scene/3d/spatial_player.h b/scene/3d/spatial_player.h deleted file mode 100644 index 16671a0cb5..0000000000 --- a/scene/3d/spatial_player.h +++ /dev/null @@ -1,87 +0,0 @@ -/*************************************************************************/ -/* spatial_player.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SPATIAL_PLAYER_H -#define SPATIAL_PLAYER_H - - -#include "scene/3d/spatial.h" -#include "scene/main/node.h" -#include "scene/resources/sample_library.h" -#include "servers/spatial_sound_server.h" -#include "scene/main/viewport.h" - -class SpatialPlayer : public Spatial { - - GDCLASS(SpatialPlayer,Spatial); -public: - - - enum Param { - - PARAM_VOLUME_DB=SpatialSoundServer::SOURCE_PARAM_VOLUME_DB, - PARAM_PITCH_SCALE=SpatialSoundServer::SOURCE_PARAM_PITCH_SCALE, - PARAM_ATTENUATION_MIN_DISTANCE=SpatialSoundServer::SOURCE_PARAM_ATTENUATION_MIN_DISTANCE, - PARAM_ATTENUATION_MAX_DISTANCE=SpatialSoundServer::SOURCE_PARAM_ATTENUATION_MAX_DISTANCE, - PARAM_ATTENUATION_DISTANCE_EXP=SpatialSoundServer::SOURCE_PARAM_ATTENUATION_DISTANCE_EXP, - PARAM_EMISSION_CONE_DEGREES=SpatialSoundServer::SOURCE_PARAM_EMISSION_CONE_DEGREES, - PARAM_EMISSION_CONE_ATTENUATION_DB=SpatialSoundServer::SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB, - PARAM_MAX=SpatialSoundServer::SOURCE_PARAM_MAX - }; - -private: - - float params[PARAM_MAX]; - RID source_rid; - - virtual bool _can_gizmo_scale() const; - - - -protected: - - _FORCE_INLINE_ RID get_source_rid() const { return source_rid; } - - void _notification(int p_what); - - static void _bind_methods(); - -public: - - void set_param( Param p_param, float p_value); - float get_param( Param p_param) const; - - - SpatialPlayer(); - ~SpatialPlayer(); - - -}; - -VARIANT_ENUM_CAST( SpatialPlayer::Param ); -#endif // SPATIAL_PLAYER_H diff --git a/scene/3d/spatial_sample_player.cpp b/scene/3d/spatial_sample_player.cpp deleted file mode 100644 index 3e1c0e9947..0000000000 --- a/scene/3d/spatial_sample_player.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/*************************************************************************/ -/* spatial_sample_player.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "spatial_sample_player.h" - -#include "servers/audio_server.h" -#include "camera.h" -#include "servers/spatial_sound_server.h" -#include "scene/scene_string_names.h" - -bool SpatialSamplePlayer::_set(const StringName& p_name, const Variant& p_value) { - - String name=p_name; - - if (name==SceneStringNames::get_singleton()->play_play) { - if (library.is_valid()) { - - String what=p_value; - if (what=="") - stop_all(); - else - play(what); - - played_back=what; - } - return true; - - } - - return false; -} - -bool SpatialSamplePlayer::_get(const StringName& p_name,Variant &r_ret) const { - - - String name=p_name; - - if (name==SceneStringNames::get_singleton()->play_play) { - r_ret=played_back; - return true; - } - - return false; -} - -void SpatialSamplePlayer::_get_property_list(List<PropertyInfo> *p_list) const { - - String en=""; - if (library.is_valid()) { - List<StringName> samples; - Ref<SampleLibrary> ncl=library; - ncl->get_sample_list(&samples); - for (List<StringName>::Element *E=samples.front();E;E=E->next()) { - - en+=","; - en+=E->get(); - } - } - - p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER)); - -} -void SpatialSamplePlayer::_notification(int p_what) { - - - switch(p_what) { - - case NOTIFICATION_ENTER_WORLD: { - - SpatialSoundServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony); - - - } break; - } - -} - -void SpatialSamplePlayer::set_sample_library(const Ref<SampleLibrary>& p_library) { - - library=p_library; - _change_notify(); - update_configuration_warning(); -} - -Ref<SampleLibrary> SpatialSamplePlayer::get_sample_library() const { - - return library; -} - -void SpatialSamplePlayer::set_polyphony(int p_voice_count) { - - ERR_FAIL_COND(p_voice_count<0 || p_voice_count>64); - polyphony=p_voice_count; - if (get_source_rid().is_valid()) - SpatialSoundServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony); - -} - -int SpatialSamplePlayer::get_polyphony() const { - - return polyphony; -} - -SpatialSamplePlayer::VoiceID SpatialSamplePlayer::play(const String& p_sample,int p_voice) { - - if (!get_source_rid().is_valid()) - return INVALID_VOICE; - if (library.is_null()) - return INVALID_VOICE; - if (!library->has_sample(p_sample)) - return INVALID_VOICE; - Ref<Sample> sample = library->get_sample(p_sample); - float vol_change = library->sample_get_volume_db(p_sample); - float pitch_change = library->sample_get_pitch_scale(p_sample); - - VoiceID vid = SpatialSoundServer::get_singleton()->source_play_sample(get_source_rid(),sample->get_rid(),sample->get_mix_rate()*pitch_change,p_voice); - if (vol_change) - SpatialSoundServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),vid,vol_change); - - return vid; - - -} -//voices -void SpatialSamplePlayer::voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale) { - - if (!get_source_rid().is_valid()) - return; - - SpatialSoundServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(),p_voice,p_pitch_scale); - -} - -void SpatialSamplePlayer::voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db) { - - if (!get_source_rid().is_valid()) - return; - SpatialSoundServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),p_voice,p_volume_db); - -} - -bool SpatialSamplePlayer::is_voice_active(VoiceID p_voice) const { - - if (!get_source_rid().is_valid()) - return false; - return SpatialSoundServer::get_singleton()->source_is_voice_active(get_source_rid(),p_voice); - -} - -void SpatialSamplePlayer::stop_voice(VoiceID p_voice) { - - if (!get_source_rid().is_valid()) - return; - SpatialSoundServer::get_singleton()->source_stop_voice(get_source_rid(),p_voice); - -} - -void SpatialSamplePlayer::stop_all() { - - if (!get_source_rid().is_valid()) - return; - - for(int i=0;i<polyphony;i++) { - - SpatialSoundServer::get_singleton()->source_stop_voice(get_source_rid(),i); - } -} - -String SpatialSamplePlayer::get_configuration_warning() const { - - if (library.is_null()) { - return TTR("A SampleLibrary resource must be created or set in the 'samples' property in order for SpatialSamplePlayer to play sound."); - } - - return String(); -} - - -void SpatialSamplePlayer::_bind_methods() { - - - ClassDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SpatialSamplePlayer::set_sample_library); - ClassDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SpatialSamplePlayer::get_sample_library); - - ClassDB::bind_method(_MD("set_polyphony","voices"),&SpatialSamplePlayer::set_polyphony); - ClassDB::bind_method(_MD("get_polyphony"),&SpatialSamplePlayer::get_polyphony); - - ClassDB::bind_method(_MD("play","sample","voice"),&SpatialSamplePlayer::play,DEFVAL(NEXT_VOICE)); - //voices,DEV - ClassDB::bind_method(_MD("voice_set_pitch_scale","voice","ratio"),&SpatialSamplePlayer::voice_set_pitch_scale); - ClassDB::bind_method(_MD("voice_set_volume_scale_db","voice","db"),&SpatialSamplePlayer::voice_set_volume_scale_db); - - ClassDB::bind_method(_MD("is_voice_active","voice"),&SpatialSamplePlayer::is_voice_active); - ClassDB::bind_method(_MD("stop_voice","voice"),&SpatialSamplePlayer::stop_voice); - ClassDB::bind_method(_MD("stop_all"),&SpatialSamplePlayer::stop_all); - - BIND_CONSTANT( INVALID_VOICE ); - BIND_CONSTANT( NEXT_VOICE ); - - ADD_PROPERTY( PropertyInfo( Variant::INT, "polyphony", PROPERTY_HINT_RANGE, "1,64,1"),_SCS("set_polyphony"),_SCS("get_polyphony")); - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "samples", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_sample_library"),_SCS("get_sample_library")); - - -} - - -SpatialSamplePlayer::SpatialSamplePlayer() { - - polyphony=1; - -} - -SpatialSamplePlayer::~SpatialSamplePlayer() { - - -} diff --git a/scene/3d/spatial_sample_player.h b/scene/3d/spatial_sample_player.h deleted file mode 100644 index d30ff6e908..0000000000 --- a/scene/3d/spatial_sample_player.h +++ /dev/null @@ -1,90 +0,0 @@ -/*************************************************************************/ -/* spatial_sample_player.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SPATIAL_SAMPLE_PLAYER_H -#define SPATIAL_SAMPLE_PLAYER_H - -#include "scene/3d/spatial_player.h" -#include "scene/resources/sample_library.h" -#include "servers/spatial_sound_server.h" - -class SpatialSamplePlayer : public SpatialPlayer { - - GDCLASS(SpatialSamplePlayer,SpatialPlayer); -public: - - enum { - - INVALID_VOICE=SpatialSoundServer::SOURCE_INVALID_VOICE, - NEXT_VOICE=SpatialSoundServer::SOURCE_NEXT_VOICE - }; - - typedef int VoiceID; - - -private: - - Ref<SampleLibrary> library; - int polyphony; - String played_back; -protected: - - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; - void _get_property_list(List<PropertyInfo> *p_list) const; - - void _notification(int p_what); - static void _bind_methods(); - -public: - - void set_sample_library(const Ref<SampleLibrary>& p_library); - Ref<SampleLibrary> get_sample_library() const; - - void set_polyphony(int p_voice_count); - int get_polyphony() const; - - VoiceID play(const String& p_sample,int p_voice=NEXT_VOICE); - //voices - void voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale); - void voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db); - - bool is_voice_active(VoiceID p_voice) const; - void stop_voice(VoiceID p_voice); - void stop_all(); - - String get_configuration_warning() const; - - SpatialSamplePlayer(); - ~SpatialSamplePlayer(); - - -}; - - -#endif // SPATIAL_SAMPLE_PLAYER_H diff --git a/scene/3d/spatial_stream_player.cpp b/scene/3d/spatial_stream_player.cpp deleted file mode 100644 index 1f9765c1d3..0000000000 --- a/scene/3d/spatial_stream_player.cpp +++ /dev/null @@ -1,407 +0,0 @@ -/*************************************************************************/ -/* spatial_stream_player.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "spatial_stream_player.h" - - - -int SpatialStreamPlayer::InternalStream::get_channel_count() const { - - return player->sp_get_channel_count(); -} -void SpatialStreamPlayer::InternalStream::set_mix_rate(int p_rate){ - - return player->sp_set_mix_rate(p_rate); -} -bool SpatialStreamPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){ - - return player->sp_mix(p_buffer,p_frames); -} -void SpatialStreamPlayer::InternalStream::update(){ - - player->sp_update(); -} - - -int SpatialStreamPlayer::sp_get_channel_count() const { - - return playback->get_channels(); -} - -void SpatialStreamPlayer::sp_set_mix_rate(int p_rate){ - - server_mix_rate=p_rate; -} - -bool SpatialStreamPlayer::sp_mix(int32_t *p_buffer,int p_frames) { - - if (resampler.is_ready() && !paused) { - return resampler.mix(p_buffer,p_frames); - } - - return false; -} - -void SpatialStreamPlayer::sp_update() { - - _THREAD_SAFE_METHOD_ - if (!paused && resampler.is_ready() && playback.is_valid()) { - - if (!playback->is_playing()) { - //stream depleted data, but there's still audio in the ringbuffer - //check that all this audio has been flushed before stopping the stream - int to_mix = resampler.get_total() - resampler.get_todo(); - if (to_mix==0) { - stop(); - return; - } - - return; - } - - int todo =resampler.get_todo(); - int wrote = playback->mix(resampler.get_write_buffer(),todo); - resampler.write(wrote); - } -} - - - -void SpatialStreamPlayer::_notification(int p_what) { - - switch(p_what) { - - case NOTIFICATION_ENTER_TREE: { - - //set_idle_process(false); //don't annoy - if (stream.is_valid() && autoplay && !get_tree()->is_editor_hint()) - play(); - } break; - case NOTIFICATION_EXIT_TREE: { - - stop(); //wathever it may be doing, stop - } break; - } -} - - - -void SpatialStreamPlayer::set_stream(const Ref<AudioStream> &p_stream) { - - stop(); - - stream=p_stream; - - if (!stream.is_null()) { - playback=stream->instance_playback(); - playback->set_loop(loops); - playback->set_loop_restart_time(loop_point); - AudioServer::get_singleton()->lock(); - resampler.setup(playback->get_channels(),playback->get_mix_rate(),server_mix_rate,buffering_ms,playback->get_minimum_buffer_size()); - AudioServer::get_singleton()->unlock(); - } else { - AudioServer::get_singleton()->lock(); - resampler.clear(); - playback.unref(); - AudioServer::get_singleton()->unlock(); - } -} - -Ref<AudioStream> SpatialStreamPlayer::get_stream() const { - - return stream; -} - - -void SpatialStreamPlayer::play(float p_from_offset) { - - ERR_FAIL_COND(!is_inside_tree()); - if (playback.is_null()) - return; - if (playback->is_playing()) - stop(); - - _THREAD_SAFE_METHOD_ - playback->play(p_from_offset); - //feed the ringbuffer as long as no update callback is going on - sp_update(); - - SpatialSoundServer::get_singleton()->source_set_audio_stream(get_source_rid(),&internal_stream); - - /* - AudioServer::get_singleton()->stream_set_active(stream_rid,true); - AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume); - if (stream->get_update_mode()!=AudioStream::UPDATE_NONE) - set_idle_process(true); - */ - -} - -void SpatialStreamPlayer::stop() { - - if (!is_inside_tree()) - return; - if (playback.is_null()) - return; - - _THREAD_SAFE_METHOD_ - //AudioServer::get_singleton()->stream_set_active(stream_rid,false); - SpatialSoundServer::get_singleton()->source_set_audio_stream(get_source_rid(),NULL); - playback->stop(); - resampler.flush(); - //set_idle_process(false); -} - -bool SpatialStreamPlayer::is_playing() const { - - if (playback.is_null()) - return false; - - return playback->is_playing(); -} - -void SpatialStreamPlayer::set_loop(bool p_enable) { - - loops=p_enable; - if (playback.is_null()) - return; - playback->set_loop(loops); - -} -bool SpatialStreamPlayer::has_loop() const { - - return loops; -} - -void SpatialStreamPlayer::set_volume(float p_vol) { - - volume=p_vol; - if (stream_rid.is_valid()) - AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume); -} - -float SpatialStreamPlayer::get_volume() const { - - return volume; -} - -void SpatialStreamPlayer::set_loop_restart_time(float p_secs) { - - loop_point=p_secs; - if (playback.is_valid()) - playback->set_loop_restart_time(p_secs); -} - -float SpatialStreamPlayer::get_loop_restart_time() const { - - return loop_point; -} - - -void SpatialStreamPlayer::set_volume_db(float p_db) { - - if (p_db<-79) - set_volume(0); - else - set_volume(Math::db2linear(p_db)); -} - -float SpatialStreamPlayer::get_volume_db() const { - - if (volume==0) - return -80; - else - return Math::linear2db(volume); -} - - -String SpatialStreamPlayer::get_stream_name() const { - - if (stream.is_null()) - return "<No Stream>"; - return stream->get_name(); - -} - -int SpatialStreamPlayer::get_loop_count() const { - - if (playback.is_null()) - return 0; - return playback->get_loop_count(); - -} - -float SpatialStreamPlayer::get_pos() const { - - if (playback.is_null()) - return 0; - return playback->get_pos(); - -} - -float SpatialStreamPlayer::get_length() const { - - if (playback.is_null()) - return 0; - return playback->get_length(); -} -void SpatialStreamPlayer::seek_pos(float p_time) { - - if (playback.is_null()) - return; - return playback->seek_pos(p_time); - -} - -void SpatialStreamPlayer::set_autoplay(bool p_enable) { - - autoplay=p_enable; -} - -bool SpatialStreamPlayer::has_autoplay() const { - - return autoplay; -} - -void SpatialStreamPlayer::set_paused(bool p_paused) { - - paused=p_paused; - /* - if (stream.is_valid()) - stream->set_paused(p_paused); - */ -} - -bool SpatialStreamPlayer::is_paused() const { - - return paused; -} - -void SpatialStreamPlayer::_set_play(bool p_play) { - - _play=p_play; - if (is_inside_tree()) { - if(_play) - play(); - else - stop(); - } - -} - -bool SpatialStreamPlayer::_get_play() const{ - - return _play; -} - -void SpatialStreamPlayer::set_buffering_msec(int p_msec) { - - buffering_ms=p_msec; -} - -int SpatialStreamPlayer::get_buffering_msec() const{ - - return buffering_ms; -} - - - -void SpatialStreamPlayer::_bind_methods() { - - ClassDB::bind_method(_MD("set_stream","stream:AudioStream"),&SpatialStreamPlayer::set_stream); - ClassDB::bind_method(_MD("get_stream:AudioStream"),&SpatialStreamPlayer::get_stream); - - ClassDB::bind_method(_MD("play","offset"),&SpatialStreamPlayer::play,DEFVAL(0)); - ClassDB::bind_method(_MD("stop"),&SpatialStreamPlayer::stop); - - ClassDB::bind_method(_MD("is_playing"),&SpatialStreamPlayer::is_playing); - - ClassDB::bind_method(_MD("set_paused","paused"),&SpatialStreamPlayer::set_paused); - ClassDB::bind_method(_MD("is_paused"),&SpatialStreamPlayer::is_paused); - - ClassDB::bind_method(_MD("set_loop","enabled"),&SpatialStreamPlayer::set_loop); - ClassDB::bind_method(_MD("has_loop"),&SpatialStreamPlayer::has_loop); - - ClassDB::bind_method(_MD("set_volume","volume"),&SpatialStreamPlayer::set_volume); - ClassDB::bind_method(_MD("get_volume"),&SpatialStreamPlayer::get_volume); - - ClassDB::bind_method(_MD("set_volume_db","db"),&SpatialStreamPlayer::set_volume_db); - ClassDB::bind_method(_MD("get_volume_db"),&SpatialStreamPlayer::get_volume_db); - - ClassDB::bind_method(_MD("set_buffering_msec","msec"),&SpatialStreamPlayer::set_buffering_msec); - ClassDB::bind_method(_MD("get_buffering_msec"),&SpatialStreamPlayer::get_buffering_msec); - - ClassDB::bind_method(_MD("set_loop_restart_time","secs"),&SpatialStreamPlayer::set_loop_restart_time); - ClassDB::bind_method(_MD("get_loop_restart_time"),&SpatialStreamPlayer::get_loop_restart_time); - - ClassDB::bind_method(_MD("get_stream_name"),&SpatialStreamPlayer::get_stream_name); - ClassDB::bind_method(_MD("get_loop_count"),&SpatialStreamPlayer::get_loop_count); - - ClassDB::bind_method(_MD("get_pos"),&SpatialStreamPlayer::get_pos); - ClassDB::bind_method(_MD("seek_pos","time"),&SpatialStreamPlayer::seek_pos); - - ClassDB::bind_method(_MD("set_autoplay","enabled"),&SpatialStreamPlayer::set_autoplay); - ClassDB::bind_method(_MD("has_autoplay"),&SpatialStreamPlayer::has_autoplay); - - ClassDB::bind_method(_MD("get_length"),&SpatialStreamPlayer::get_length); - - ClassDB::bind_method(_MD("_set_play","play"),&SpatialStreamPlayer::_set_play); - ClassDB::bind_method(_MD("_get_play"),&SpatialStreamPlayer::_get_play); - - ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "play"), _SCS("_set_play"), _SCS("_get_play") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "loop"), _SCS("set_loop"), _SCS("has_loop") ); - ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") ); - ADD_PROPERTY( PropertyInfo(Variant::INT, "loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time") ); - ADD_PROPERTY( PropertyInfo(Variant::INT, "buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec") ); -} - - -SpatialStreamPlayer::SpatialStreamPlayer() { - - volume=1; - loops=false; - paused=false; - autoplay=false; - _play=false; - server_mix_rate=1; - internal_stream.player=this; - stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream); - buffering_ms=500; - loop_point=0; - -} - -SpatialStreamPlayer::~SpatialStreamPlayer() { - AudioServer::get_singleton()->free(stream_rid); - resampler.clear(); - - -} diff --git a/scene/3d/spatial_stream_player.h b/scene/3d/spatial_stream_player.h deleted file mode 100644 index 27533d3f6e..0000000000 --- a/scene/3d/spatial_stream_player.h +++ /dev/null @@ -1,120 +0,0 @@ -/*************************************************************************/ -/* spatial_stream_player.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SPATIAL_STREAM_PLAYER_H -#define SPATIAL_STREAM_PLAYER_H - -#include "scene/resources/audio_stream.h" -#include "scene/3d/spatial_player.h" -#include "servers/audio/audio_rb_resampler.h" - -class SpatialStreamPlayer : public SpatialPlayer { - - GDCLASS(SpatialStreamPlayer,SpatialPlayer); - - _THREAD_SAFE_CLASS_ - - struct InternalStream : public AudioServer::AudioStream { - SpatialStreamPlayer *player; - virtual int get_channel_count() const; - virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate - virtual bool mix(int32_t *p_buffer,int p_frames); - virtual void update(); - }; - - - InternalStream internal_stream; - Ref<AudioStreamPlayback> playback; - Ref<AudioStream> stream; - - int sp_get_channel_count() const; - void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate - bool sp_mix(int32_t *p_buffer,int p_frames); - void sp_update(); - - int server_mix_rate; - - RID stream_rid; - bool paused; - bool autoplay; - bool loops; - float volume; - float loop_point; - int buffering_ms; - - AudioRBResampler resampler; - - bool _play; - void _set_play(bool p_play); - bool _get_play() const; -protected: - void _notification(int p_what); - - static void _bind_methods(); -public: - - void set_stream(const Ref<AudioStream> &p_stream); - Ref<AudioStream> get_stream() const; - - void play(float p_from_offset=0); - void stop(); - bool is_playing() const; - - void set_paused(bool p_paused); - bool is_paused() const; - - void set_loop(bool p_enable); - bool has_loop() const; - - void set_volume(float p_vol); - float get_volume() const; - - void set_loop_restart_time(float p_secs); - float get_loop_restart_time() const; - - void set_volume_db(float p_db); - float get_volume_db() const; - - String get_stream_name() const; - - int get_loop_count() const; - - float get_pos() const; - void seek_pos(float p_time); - float get_length() const; - void set_autoplay(bool p_vol); - bool has_autoplay() const; - - void set_buffering_msec(int p_msec); - int get_buffering_msec() const; - - SpatialStreamPlayer(); - ~SpatialStreamPlayer(); -}; - -#endif // SPATIAL_STREAM_PLAYER_H diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 9f0c91c4b8..479fe1fed9 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -1190,7 +1190,7 @@ void AnimatedSprite3D::set_frame(int p_frame) { frame=p_frame; _reset_timeout(); - _queue_update();; + _queue_update(); _change_notify("frame"); emit_signal(SceneStringNames::get_singleton()->frame_changed); @@ -1293,7 +1293,7 @@ void AnimatedSprite3D::set_animation(const StringName& p_animation){ _reset_timeout(); set_frame(0); _change_notify(); - _queue_update();; + _queue_update(); } StringName AnimatedSprite3D::get_animation() const{ diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp index 25ca74de9f..bcbda5a781 100644 --- a/scene/animation/animation_cache.cpp +++ b/scene/animation/animation_cache.cpp @@ -62,7 +62,7 @@ void AnimationCache::_clear_cache() { connected_nodes.front()->get()->disconnect("tree_exited",this,"_node_exit_tree"); connected_nodes.erase(connected_nodes.front()); } - path_cache.clear();; + path_cache.clear(); cache_valid=false; cache_dirty=true; } diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 8b81c45597..7fa8458fe9 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -855,7 +855,7 @@ void AnimationPlayer::rename_animation(const StringName& p_name,const StringName while(to_erase.size()) { blend_times.erase(to_erase.front()->get()); - to_erase.pop_front();; + to_erase.pop_front(); } while(to_insert.size()) { diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index c3a05240bb..a3347dadcf 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -1643,7 +1643,7 @@ void AnimationTreePlayer::_recompute_caches(const StringName& p_node) { if (nb->type==NODE_ANIMATION) { AnimationNode *an = static_cast<AnimationNode*>(nb); - an->tref.clear();; + an->tref.clear(); if (!an->animation.is_null()) { diff --git a/scene/audio/event_player.cpp b/scene/audio/event_player.cpp deleted file mode 100644 index c46f4e3b89..0000000000 --- a/scene/audio/event_player.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/*************************************************************************/ -/* event_player.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "event_player.h" - - -void EventPlayer::_notification(int p_what) { - - switch(p_what) { - - case NOTIFICATION_ENTER_TREE: { - - //set_idle_process(false); //don't annoy - if (playback.is_valid() && autoplay && !get_tree()->is_editor_hint()) - play(); - } break; - case NOTIFICATION_EXIT_TREE: { - - stop(); //wathever it may be doing, stop - } break; - } -} - - - -void EventPlayer::set_stream(const Ref<EventStream> &p_stream) { - - stop(); - stream=p_stream; - if (stream.is_valid()) - playback=stream->instance_playback(); - else - playback.unref(); - - if (playback.is_valid()) { - - playback->set_loop(loops); - playback->set_paused(paused); - playback->set_volume(volume); - for(int i=0;i<(MIN(MAX_CHANNELS,stream->get_channel_count()));i++) - playback->set_channel_volume(i,channel_volume[i]); - } - - -} - -Ref<EventStream> EventPlayer::get_stream() const { - - return stream; -} - - -void EventPlayer::play() { - - ERR_FAIL_COND(!is_inside_tree()); - if (playback.is_null()) { - return; - } - if (playback->is_playing()) { - AudioServer::get_singleton()->lock(); - stop(); - AudioServer::get_singleton()->unlock(); - } - - AudioServer::get_singleton()->lock(); - playback->play(); - AudioServer::get_singleton()->unlock(); - -} - -void EventPlayer::stop() { - - if (!is_inside_tree()) - return; - if (playback.is_null()) - return; - - AudioServer::get_singleton()->lock(); - playback->stop(); - AudioServer::get_singleton()->unlock(); -} - -bool EventPlayer::is_playing() const { - - if (playback.is_null()) - return false; - - return playback->is_playing(); -} - -void EventPlayer::set_loop(bool p_enable) { - - loops=p_enable; - if (playback.is_null()) - return; - playback->set_loop(loops); - -} -bool EventPlayer::has_loop() const { - - return loops; -} - -void EventPlayer::set_volume(float p_volume) { - - volume=p_volume; - if (playback.is_valid()) - playback->set_volume(volume); -} - -float EventPlayer::get_volume() const { - - return volume; -} - - -void EventPlayer::set_volume_db(float p_db) { - - if (p_db<-79) - set_volume(0); - else - set_volume(Math::db2linear(p_db)); -} - -float EventPlayer::get_volume_db() const { - - if (volume==0) - return -80; - else - return Math::linear2db(volume); -} - -void EventPlayer::set_pitch_scale(float p_pitch_scale) { - - pitch_scale=p_pitch_scale; - if (playback.is_valid()) - playback->set_pitch_scale(pitch_scale); -} - -float EventPlayer::get_pitch_scale() const { - - return pitch_scale; -} - -void EventPlayer::set_tempo_scale(float p_tempo_scale) { - - tempo_scale=p_tempo_scale; - if (playback.is_valid()) - playback->set_tempo_scale(tempo_scale); -} - -float EventPlayer::get_tempo_scale() const { - - return tempo_scale; -} - - -String EventPlayer::get_stream_name() const { - - if (stream.is_null()) - return "<No Stream>"; - return stream->get_name(); - -} - -int EventPlayer::get_loop_count() const { - - if (playback.is_null()) - return 0; - return playback->get_loop_count(); - -} - -float EventPlayer::get_pos() const { - - if (playback.is_null()) - return 0; - return playback->get_pos(); - -} - -float EventPlayer::get_length() const { - - if (stream.is_null()) - return 0; - return stream->get_length(); -} -void EventPlayer::seek_pos(float p_time) { - - if (playback.is_null()) - return; - return playback->seek_pos(p_time); - -} - -void EventPlayer::set_autoplay(bool p_enable) { - - autoplay=p_enable; -} - -bool EventPlayer::has_autoplay() const { - - return autoplay; -} - -void EventPlayer::set_paused(bool p_paused) { - - paused=p_paused; - if (playback.is_valid()) - playback->set_paused(p_paused); -} - -bool EventPlayer::is_paused() const { - - return paused; -} - -void EventPlayer::_set_play(bool p_play) { - - _play=p_play; - if (is_inside_tree()) { - if(_play) - play(); - else - stop(); - } - -} - -bool EventPlayer::_get_play() const{ - - return _play; -} - -void EventPlayer::set_channel_volume(int p_channel,float p_volume) { - - ERR_FAIL_INDEX(p_channel,MAX_CHANNELS); - channel_volume[p_channel]=p_volume; - if (playback.is_valid()) - playback->set_channel_volume(p_channel,p_volume); -} - -float EventPlayer::get_channel_volume(int p_channel) const{ - - ERR_FAIL_INDEX_V(p_channel,MAX_CHANNELS,0); - return channel_volume[p_channel]; - -} - -float EventPlayer::get_channel_last_note_time(int p_channel) const { - - if (playback.is_valid()) - return playback->get_last_note_time(p_channel); - - return 0; -} - -void EventPlayer::_bind_methods() { - - ClassDB::bind_method(_MD("set_stream","stream:EventStream"),&EventPlayer::set_stream); - ClassDB::bind_method(_MD("get_stream:EventStream"),&EventPlayer::get_stream); - - ClassDB::bind_method(_MD("play"),&EventPlayer::play); - ClassDB::bind_method(_MD("stop"),&EventPlayer::stop); - - ClassDB::bind_method(_MD("is_playing"),&EventPlayer::is_playing); - - ClassDB::bind_method(_MD("set_paused","paused"),&EventPlayer::set_paused); - ClassDB::bind_method(_MD("is_paused"),&EventPlayer::is_paused); - - ClassDB::bind_method(_MD("set_loop","enabled"),&EventPlayer::set_loop); - ClassDB::bind_method(_MD("has_loop"),&EventPlayer::has_loop); - - ClassDB::bind_method(_MD("set_volume","volume"),&EventPlayer::set_volume); - ClassDB::bind_method(_MD("get_volume"),&EventPlayer::get_volume); - - ClassDB::bind_method(_MD("set_pitch_scale","pitch_scale"),&EventPlayer::set_pitch_scale); - ClassDB::bind_method(_MD("get_pitch_scale"),&EventPlayer::get_pitch_scale); - - ClassDB::bind_method(_MD("set_tempo_scale","tempo_scale"),&EventPlayer::set_tempo_scale); - ClassDB::bind_method(_MD("get_tempo_scale"),&EventPlayer::get_tempo_scale); - - ClassDB::bind_method(_MD("set_volume_db","db"),&EventPlayer::set_volume_db); - ClassDB::bind_method(_MD("get_volume_db"),&EventPlayer::get_volume_db); - - ClassDB::bind_method(_MD("get_stream_name"),&EventPlayer::get_stream_name); - ClassDB::bind_method(_MD("get_loop_count"),&EventPlayer::get_loop_count); - - ClassDB::bind_method(_MD("get_pos"),&EventPlayer::get_pos); - ClassDB::bind_method(_MD("seek_pos","time"),&EventPlayer::seek_pos); - - ClassDB::bind_method(_MD("get_length"),&EventPlayer::get_length); - - ClassDB::bind_method(_MD("set_autoplay","enabled"),&EventPlayer::set_autoplay); - ClassDB::bind_method(_MD("has_autoplay"),&EventPlayer::has_autoplay); - - ClassDB::bind_method(_MD("set_channel_volume","channel","channel_volume"),&EventPlayer::set_channel_volume); - ClassDB::bind_method(_MD("get_channel_volume","channel"),&EventPlayer::get_channel_volume); - ClassDB::bind_method(_MD("get_channel_last_note_time","channel"),&EventPlayer::get_channel_last_note_time); - - ClassDB::bind_method(_MD("_set_play","play"),&EventPlayer::_set_play); - ClassDB::bind_method(_MD("_get_play"),&EventPlayer::_get_play); - - ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"EventStream"), _SCS("set_stream"), _SCS("get_stream") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "play"), _SCS("_set_play"), _SCS("_get_play") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "loop"), _SCS("set_loop"), _SCS("has_loop") ); - ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") ); - ADD_PROPERTY( PropertyInfo(Variant::REAL, "pitch_scale", PROPERTY_HINT_RANGE,"0.001,16,0.001"), _SCS("set_pitch_scale"), _SCS("get_pitch_scale") ); - ADD_PROPERTY( PropertyInfo(Variant::REAL, "tempo_scale", PROPERTY_HINT_RANGE,"0.001,16,0.001"), _SCS("set_tempo_scale"), _SCS("get_tempo_scale") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") ); -} - - -EventPlayer::EventPlayer() { - - volume=1; - loops=false; - paused=false; - autoplay=false; - _play=false; - pitch_scale=1.0; - tempo_scale=1.0; - for(int i=0;i<MAX_CHANNELS;i++) - channel_volume[i]=1.0; - -} - -EventPlayer::~EventPlayer() { - - -} diff --git a/scene/audio/event_player.h b/scene/audio/event_player.h deleted file mode 100644 index 715017e0d6..0000000000 --- a/scene/audio/event_player.h +++ /dev/null @@ -1,109 +0,0 @@ -/*************************************************************************/ -/* event_player.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 EVENT_PLAYER_H -#define EVENT_PLAYER_H - - -#include "scene/main/node.h" -#include "scene/resources/event_stream.h" -class EventPlayer : public Node { - - GDCLASS(EventPlayer,Node); - - - enum { - MAX_CHANNELS=256 - }; - - Ref<EventStreamPlayback> playback; - Ref<EventStream> stream; - bool paused; - bool autoplay; - bool loops; - float volume; - - float tempo_scale; - float pitch_scale; - - float channel_volume[MAX_CHANNELS]; - bool _play; - void _set_play(bool p_play); - bool _get_play() const; -protected: - void _notification(int p_what); - - static void _bind_methods(); - -public: - - void set_stream(const Ref<EventStream> &p_stream); - Ref<EventStream> get_stream() const; - - void play(); - void stop(); - bool is_playing() const; - - void set_paused(bool p_paused); - bool is_paused() const; - - void set_loop(bool p_enable); - bool has_loop() const; - - void set_volume(float p_vol); - float get_volume() const; - - void set_volume_db(float p_db); - float get_volume_db() const; - - void set_pitch_scale(float p_scale); - float get_pitch_scale() const; - - void set_tempo_scale(float p_scale); - float get_tempo_scale() const; - - String get_stream_name() const; - - int get_loop_count() const; - - float get_pos() const; - void seek_pos(float p_time); - float get_length() const; - void set_autoplay(bool p_vol); - bool has_autoplay() const; - - void set_channel_volume(int p_channel,float p_volume); - float get_channel_volume(int p_channel) const; - - float get_channel_last_note_time(int p_channel) const; - - EventPlayer(); - ~EventPlayer(); -}; - -#endif // EVENT_PLAYER_H diff --git a/scene/audio/sample_player.cpp b/scene/audio/sample_player.cpp deleted file mode 100644 index ba2d379311..0000000000 --- a/scene/audio/sample_player.cpp +++ /dev/null @@ -1,718 +0,0 @@ -/*************************************************************************/ -/* sample_player.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "sample_player.h" - -#include "servers/audio_server.h" - - -bool SamplePlayer::_set(const StringName& p_name, const Variant& p_value) { - - String name=p_name; - - if (name=="play/play") { - if (library.is_valid()) { - - String what=p_value; - if (what=="") - stop_all(); - else - play(what); - - played_back=what; - } - } else if (name=="config/samples") - set_sample_library(p_value); - else if (name=="config/polyphony") - set_polyphony(p_value); - else if (name.begins_with("default/")) { - - String what=name.right(8); - - if (what=="volume_db") - set_default_volume_db(p_value); - else if (what=="pitch_scale") - set_default_pitch_scale(p_value); - else if (what=="pan") - _default.pan=p_value; - else if (what=="depth") - _default.depth=p_value; - else if (what=="height") - _default.height=p_value; - else if (what=="filter/type") - _default.filter_type=FilterType(p_value.operator int()); - else if (what=="filter/cutoff") - _default.filter_cutoff=p_value; - else if (what=="filter/resonance") - _default.filter_resonance=p_value; - else if (what=="filter/gain") - _default.filter_gain=p_value; - else if (what=="reverb_room") - _default.reverb_room=ReverbRoomType(p_value.operator int()); - else if (what=="reverb_send") - _default.reverb_send=p_value; - else if (what=="chorus_send") - _default.chorus_send=p_value; - else - return false; - - - } else - return false; - - return true; -} - -bool SamplePlayer::_get(const StringName& p_name,Variant &r_ret) const { - - - String name=p_name; - - if (name=="play/play") { - r_ret=played_back; - } else if (name=="config/polyphony") { - r_ret= get_polyphony(); - } else if (name=="config/samples") { - - r_ret= get_sample_library(); - } else if (name.begins_with("default/")) { - - String what=name.right(8); - - if (what=="volume_db") - r_ret= get_default_volume_db(); - else if (what=="pitch_scale") - r_ret= get_default_pitch_scale(); - else if (what=="pan") - r_ret= _default.pan; - else if (what=="depth") - r_ret= _default.depth; - else if (what=="height") - r_ret= _default.height; - else if (what=="filter/type") - r_ret= _default.filter_type; - else if (what=="filter/cutoff") - r_ret= _default.filter_cutoff; - else if (what=="filter/resonance") - r_ret= _default.filter_resonance; - else if (what=="filter/gain") - r_ret= _default.filter_gain; - else if (what=="reverb_room") - r_ret= _default.reverb_room; - else if (what=="reverb_send") - r_ret= _default.reverb_send; - else if (what=="chorus_send") - r_ret= _default.chorus_send; - else - return false; - - - } else - return false; - - return true; -} - -void SamplePlayer::_get_property_list(List<PropertyInfo> *p_list) const { - - String en=""; - if (library.is_valid()) { - List<StringName> samples; - Ref<SampleLibrary> ncl=library; - ncl->get_sample_list(&samples); - for (List<StringName>::Element *E=samples.front();E;E=E->next()) { - - en+=","; - en+=E->get(); - } - } - - p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER)); - p_list->push_back( PropertyInfo( Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,256,1")); - p_list->push_back( PropertyInfo( Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE, "SampleLibrary")); - p_list->push_back( PropertyInfo( Variant::REAL, "default/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01")); - p_list->push_back( PropertyInfo( Variant::REAL, "default/pitch_scale", PROPERTY_HINT_RANGE, "0.01,48,0.01")); - p_list->push_back( PropertyInfo( Variant::REAL, "default/pan", PROPERTY_HINT_RANGE, "-1,1,0.01")); - p_list->push_back( PropertyInfo( Variant::REAL, "default/depth", PROPERTY_HINT_RANGE, "-1,1,0.01")); - p_list->push_back( PropertyInfo( Variant::REAL, "default/height", PROPERTY_HINT_RANGE, "-1,1,0.01")); - p_list->push_back( PropertyInfo( Variant::INT, "default/filter/type", PROPERTY_HINT_ENUM, "Disabled,Lowpass,Bandpass,Highpass,Notch,Peak,BandLimit,LowShelf,HighShelf")); - p_list->push_back( PropertyInfo( Variant::REAL, "default/filter/cutoff", PROPERTY_HINT_RANGE, "20,16384.0,0.01")); - p_list->push_back( PropertyInfo( Variant::REAL, "default/filter/resonance", PROPERTY_HINT_RANGE, "0,4,0.01")); - p_list->push_back( PropertyInfo( Variant::REAL, "default/filter/gain", PROPERTY_HINT_RANGE, "0,2,0.01")); - p_list->push_back( PropertyInfo( Variant::INT, "default/reverb_room", PROPERTY_HINT_ENUM, "Small,Medium,Large,Hall")); - p_list->push_back( PropertyInfo( Variant::REAL, "default/reverb_send", PROPERTY_HINT_RANGE, "0,1,0.01")); - p_list->push_back( PropertyInfo( Variant::REAL, "default/chorus_send", PROPERTY_HINT_RANGE, "0,1,0.01")); - - -} - - -SamplePlayer::Voice::Voice() { - - voice=AudioServer::get_singleton()->voice_create(); - clear(); -} - - -void SamplePlayer::Voice::clear() { - - check=0; - - mix_rate=44100; - volume=1; - pan=0; - pan_depth=0; - pan_height=0; - filter_type=FILTER_NONE; - filter_cutoff=0; - filter_resonance=0; - chorus_send=0; - reverb_room=REVERB_HALL; - reverb_send=0; - active=false; - -} -SamplePlayer::Voice::~Voice() { - - AudioServer::get_singleton()->free(voice); -} - - -void SamplePlayer::set_polyphony(int p_voice_count) { - - ERR_FAIL_COND( p_voice_count <1 || p_voice_count >0xFFFE ); - - voices.resize(p_voice_count); -} - -int SamplePlayer::get_polyphony() const { - - return voices.size(); -} - -SamplePlayer::VoiceID SamplePlayer::play(const String& p_name,bool unique) { - - if (library.is_null()) - return INVALID_VOICE_ID; - ERR_FAIL_COND_V( !library->has_sample(p_name), INVALID_VOICE_ID ); - - Ref<Sample> sample = library->get_sample(p_name); - float vol_change = library->sample_get_volume_db(p_name); - float pitch_change = library->sample_get_pitch_scale(p_name); - - last_check++; - last_id = (last_id + 1) % voices.size(); - - Voice&v = voices[last_id]; - v.clear(); - - - v.mix_rate=sample->get_mix_rate()*(_default.pitch_scale*pitch_change); - v.sample_mix_rate=sample->get_mix_rate(); - v.check=last_check; - v.volume=Math::db2linear(_default.volume_db+vol_change); - v.pan=_default.pan; - v.pan_depth=_default.depth; - v.pan_height=_default.height; - v.filter_type=_default.filter_type; - v.filter_cutoff=_default.filter_cutoff; - v.filter_resonance=_default.filter_resonance; - v.filter_gain=_default.filter_gain; - v.chorus_send=_default.chorus_send; - v.reverb_room=_default.reverb_room; - v.reverb_send=_default.reverb_send; - - AudioServer::get_singleton()->voice_play(v.voice,sample->get_rid()); - AudioServer::get_singleton()->voice_set_mix_rate(v.voice,v.mix_rate); - AudioServer::get_singleton()->voice_set_volume(v.voice,v.volume); - AudioServer::get_singleton()->voice_set_pan(v.voice,v.pan,v.pan_depth,v.pan_height); - AudioServer::get_singleton()->voice_set_filter(v.voice,(AudioServer::FilterType)v.filter_type,v.filter_cutoff,v.filter_resonance,v.filter_gain); - AudioServer::get_singleton()->voice_set_chorus(v.voice,v.chorus_send); - AudioServer::get_singleton()->voice_set_reverb(v.voice,(AudioServer::ReverbRoomType)v.reverb_room,v.reverb_send); - - v.active=true; - - if (unique) { - - for(int i=0;i<voices.size();i++) { - - if (!voices[i].active || uint32_t(i)==last_id) - continue; - - AudioServer::get_singleton()->voice_stop(voices[i].voice); - - voices[i].clear(); - } - - } - - return last_id | (last_check<<16); -} - -void SamplePlayer::stop_all() { - - - for(int i=0;i<voices.size();i++) { - - if (!voices[i].active) - continue; - - AudioServer::get_singleton()->voice_stop(voices[i].voice); - voices[i].clear(); - } - -} - -#define _GET_VOICE\ - uint32_t voice=p_voice&0xFFFF;\ - ERR_FAIL_COND(voice >= (uint32_t)voices.size());\ - Voice &v=voices[voice];\ - if (v.check!=uint32_t(p_voice>>16))\ - return;\ - ERR_FAIL_COND(!v.active); - -void SamplePlayer::stop(VoiceID p_voice) { - - _GET_VOICE - - AudioServer::get_singleton()->voice_stop(v.voice); - v.active=false; - -} - -void SamplePlayer::set_mix_rate(VoiceID p_voice, int p_mix_rate) { - - _GET_VOICE - - v.mix_rate=p_mix_rate; - AudioServer::get_singleton()->voice_set_mix_rate(v.voice,v.mix_rate); - -} -void SamplePlayer::set_pitch_scale(VoiceID p_voice, float p_pitch_scale) { - - _GET_VOICE - - v.mix_rate=v.sample_mix_rate*p_pitch_scale; - AudioServer::get_singleton()->voice_set_mix_rate(v.voice,v.mix_rate); - -} -void SamplePlayer::set_volume(VoiceID p_voice, float p_volume) { - - - _GET_VOICE - v.volume=p_volume; - AudioServer::get_singleton()->voice_set_volume(v.voice,v.volume); - -} - -void SamplePlayer::set_volume_db(VoiceID p_voice, float p_db) { - - //@TODO handle 0 volume as -80db or something - _GET_VOICE - v.volume=Math::db2linear(p_db); - AudioServer::get_singleton()->voice_set_volume(v.voice,v.volume); - -} - -void SamplePlayer::set_pan(VoiceID p_voice, float p_pan,float p_pan_depth,float p_pan_height) { - - _GET_VOICE - v.pan=p_pan; - v.pan_depth=p_pan_depth; - v.pan_height=p_pan_height; - - AudioServer::get_singleton()->voice_set_pan(v.voice,v.pan,v.pan_depth,v.pan_height); - -} - -void SamplePlayer::set_filter(VoiceID p_voice,FilterType p_filter,float p_cutoff,float p_resonance,float p_gain) { - - _GET_VOICE - v.filter_type=p_filter; - v.filter_cutoff=p_cutoff; - v.filter_resonance=p_resonance; - v.filter_gain=p_gain; - - AudioServer::get_singleton()->voice_set_filter(v.voice,(AudioServer::FilterType)p_filter,p_cutoff,p_resonance); - -} -void SamplePlayer::set_chorus(VoiceID p_voice,float p_send) { - - _GET_VOICE - v.chorus_send=p_send; - - AudioServer::get_singleton()->voice_set_chorus(v.voice,p_send); - -} -void SamplePlayer::set_reverb(VoiceID p_voice,ReverbRoomType p_room,float p_send) { - - _GET_VOICE - v.reverb_room=p_room; - v.reverb_send=p_send; - - AudioServer::get_singleton()->voice_set_reverb(v.voice,(AudioServer::ReverbRoomType)p_room,p_send); - -} - -#define _GET_VOICE_V(m_ret)\ - uint32_t voice=p_voice&0xFFFF;\ - ERR_FAIL_COND_V(voice >= (uint32_t)voices.size(),m_ret);\ - const Voice &v=voices[voice];\ - if (v.check!=(p_voice>>16))\ - return m_ret;\ - ERR_FAIL_COND_V(!v.active,m_ret); - - -int SamplePlayer::get_mix_rate(VoiceID p_voice) const { - - _GET_VOICE_V(0); - - return v.mix_rate; -} -float SamplePlayer::get_pitch_scale(VoiceID p_voice) const { - - _GET_VOICE_V(0); - return v.sample_mix_rate/(float)v.mix_rate; -} -float SamplePlayer::get_volume(VoiceID p_voice) const { - - _GET_VOICE_V(0); - return v.volume; -} - - -float SamplePlayer::get_volume_db(VoiceID p_voice) const { - - _GET_VOICE_V(0); - return Math::linear2db(v.volume); -} - -float SamplePlayer::get_pan(VoiceID p_voice) const { - - _GET_VOICE_V(0); - return v.pan; -} -float SamplePlayer::get_pan_depth(VoiceID p_voice) const { - - - _GET_VOICE_V(0); - return v.pan_depth; -} -float SamplePlayer::get_pan_height(VoiceID p_voice) const { - - _GET_VOICE_V(0); - - return v.pan_height; -} -SamplePlayer::FilterType SamplePlayer::get_filter_type(VoiceID p_voice) const { - - _GET_VOICE_V(FILTER_NONE); - - return v.filter_type; -} -float SamplePlayer::get_filter_cutoff(VoiceID p_voice) const { - - _GET_VOICE_V(0); - - return v.filter_cutoff; -} -float SamplePlayer::get_filter_resonance(VoiceID p_voice) const { - - _GET_VOICE_V(0); - - return v.filter_resonance; -} - -float SamplePlayer::get_filter_gain(VoiceID p_voice) const { - - _GET_VOICE_V(0); - - return v.filter_gain; -} -float SamplePlayer::get_chorus(VoiceID p_voice) const { - - _GET_VOICE_V(0); - - return v.chorus_send; -} -SamplePlayer::ReverbRoomType SamplePlayer::get_reverb_room(VoiceID p_voice) const { - - _GET_VOICE_V(REVERB_SMALL); - - return v.reverb_room; -} - -float SamplePlayer::get_reverb(VoiceID p_voice) const { - - _GET_VOICE_V(0); - - return v.reverb_send; -} - -bool SamplePlayer::is_voice_active(VoiceID p_voice) const { - - _GET_VOICE_V(false); - return v.active && AudioServer::get_singleton()->voice_is_active(v.voice); - -} -bool SamplePlayer::is_active() const { - - for(int i=0;i<voices.size();i++) { - - if (voices[i].active && AudioServer::get_singleton()->voice_is_active(voices[i].voice)) - return true; - - - } - - return false; -} - - - -void SamplePlayer::set_sample_library(const Ref<SampleLibrary>& p_library) { - - library=p_library; - _change_notify(); -} - -Ref<SampleLibrary> SamplePlayer::get_sample_library() const { - - return library; -} - - - -void SamplePlayer::set_default_pitch_scale(float p_pitch_scale) { - - _default.pitch_scale=p_pitch_scale; -} -void SamplePlayer::set_default_volume(float p_volume) { - - _default.volume_db=Math::linear2db(p_volume); -} -void SamplePlayer::set_default_volume_db(float p_db) { - - _default.volume_db=p_db; -} -void SamplePlayer::set_default_pan(float p_pan,float p_pan_depth,float p_pan_height) { - - _default.pan=p_pan; - _default.depth=p_pan_depth; - _default.height=p_pan_height; - -} -void SamplePlayer::set_default_filter(FilterType p_filter,float p_cutoff,float p_resonance,float p_gain) { - - _default.filter_type=p_filter; - _default.filter_cutoff=p_cutoff; - _default.filter_resonance=p_resonance; - _default.filter_gain=p_gain; -} -void SamplePlayer::set_default_chorus(float p_send) { - - _default.chorus_send=p_send; - -} -void SamplePlayer::set_default_reverb(ReverbRoomType p_room,float p_send) { - - _default.reverb_room=p_room; - _default.reverb_send=p_send; -} - -float SamplePlayer::get_default_volume() const { - - return Math::db2linear(_default.volume_db); -} -float SamplePlayer::get_default_volume_db() const { - - return _default.volume_db; -} -float SamplePlayer::get_default_pitch_scale() const { - - return _default.pitch_scale; -} - - -float SamplePlayer::get_default_pan() const { - - return _default.pan; -} -float SamplePlayer::get_default_pan_depth() const { - - return _default.depth; -} -float SamplePlayer::get_default_pan_height() const { - - return _default.height; -} -SamplePlayer::FilterType SamplePlayer::get_default_filter_type() const { - - return _default.filter_type; -} -float SamplePlayer::get_default_filter_cutoff() const { - - return _default.filter_cutoff; -} -float SamplePlayer::get_default_filter_resonance() const { - - return _default.filter_resonance; -} -float SamplePlayer::get_default_filter_gain() const { - - return _default.filter_gain; -} -float SamplePlayer::get_default_chorus() const { - - return _default.chorus_send; -} -SamplePlayer::ReverbRoomType SamplePlayer::get_default_reverb_room() const { - - return _default.reverb_room; -} -float SamplePlayer::get_default_reverb() const { - - return _default.reverb_send; -} - -String SamplePlayer::get_configuration_warning() const { - - if (library.is_null()) { - return TTR("A SampleLibrary resource must be created or set in the 'samples' property in order for SamplePlayer to play sound."); - } - - return String(); -} - -void SamplePlayer::_bind_methods() { - - ClassDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer::set_sample_library ); - ClassDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer::get_sample_library ); - - ClassDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer::set_polyphony ); - ClassDB::bind_method(_MD("get_polyphony"),&SamplePlayer::get_polyphony ); - - ClassDB::bind_method(_MD("play","name","unique"),&SamplePlayer::play, DEFVAL(false) ); - ClassDB::bind_method(_MD("stop","voice"),&SamplePlayer::stop ); - ClassDB::bind_method(_MD("stop_all"),&SamplePlayer::stop_all ); - - ClassDB::bind_method(_MD("set_mix_rate","voice","hz"),&SamplePlayer::set_mix_rate ); - ClassDB::bind_method(_MD("set_pitch_scale","voice","ratio"),&SamplePlayer::set_pitch_scale ); - ClassDB::bind_method(_MD("set_volume","voice","volume"),&SamplePlayer::set_volume ); - ClassDB::bind_method(_MD("set_volume_db","voice","db"),&SamplePlayer::set_volume_db ); - ClassDB::bind_method(_MD("set_pan","voice","pan","depth","height"),&SamplePlayer::set_pan,DEFVAL(0),DEFVAL(0) ); - ClassDB::bind_method(_MD("set_filter","voice","type","cutoff_hz","resonance","gain"),&SamplePlayer::set_filter,DEFVAL(0) ); - ClassDB::bind_method(_MD("set_chorus","voice","send"),&SamplePlayer::set_chorus ); - ClassDB::bind_method(_MD("set_reverb","voice","room_type","send"),&SamplePlayer::set_reverb ); - - ClassDB::bind_method(_MD("get_mix_rate","voice"),&SamplePlayer::get_mix_rate ); - ClassDB::bind_method(_MD("get_pitch_scale","voice"),&SamplePlayer::get_pitch_scale ); - ClassDB::bind_method(_MD("get_volume","voice"),&SamplePlayer::get_volume ); - ClassDB::bind_method(_MD("get_volume_db","voice"),&SamplePlayer::get_volume_db ); - ClassDB::bind_method(_MD("get_pan","voice"),&SamplePlayer::get_pan ); - ClassDB::bind_method(_MD("get_pan_depth","voice"),&SamplePlayer::get_pan_depth ); - ClassDB::bind_method(_MD("get_pan_height","voice"),&SamplePlayer::get_pan_height ); - ClassDB::bind_method(_MD("get_filter_type","voice"),&SamplePlayer::get_filter_type ); - ClassDB::bind_method(_MD("get_filter_cutoff","voice"),&SamplePlayer::get_filter_cutoff ); - ClassDB::bind_method(_MD("get_filter_resonance","voice"),&SamplePlayer::get_filter_resonance ); - ClassDB::bind_method(_MD("get_filter_gain","voice"),&SamplePlayer::get_filter_gain ); - ClassDB::bind_method(_MD("get_chorus","voice"),&SamplePlayer::get_chorus ); - ClassDB::bind_method(_MD("get_reverb_room","voice"),&SamplePlayer::get_reverb_room ); - ClassDB::bind_method(_MD("get_reverb","voice"),&SamplePlayer::get_reverb ); - - ClassDB::bind_method(_MD("set_default_pitch_scale","ratio"),&SamplePlayer::set_default_pitch_scale ); - ClassDB::bind_method(_MD("set_default_volume","volume"),&SamplePlayer::set_default_volume ); - ClassDB::bind_method(_MD("set_default_volume_db","db"),&SamplePlayer::set_default_volume_db ); - ClassDB::bind_method(_MD("set_default_pan","pan","depth","height"),&SamplePlayer::set_default_pan,DEFVAL(0),DEFVAL(0) ); - ClassDB::bind_method(_MD("set_default_filter","type","cutoff_hz","resonance","gain"),&SamplePlayer::set_default_filter,DEFVAL(0) ); - ClassDB::bind_method(_MD("set_default_chorus","send"),&SamplePlayer::set_default_chorus ); - ClassDB::bind_method(_MD("set_default_reverb","room_type","send"),&SamplePlayer::set_default_reverb ); - - ClassDB::bind_method(_MD("get_default_pitch_scale"),&SamplePlayer::get_default_pitch_scale ); - ClassDB::bind_method(_MD("get_default_volume"),&SamplePlayer::get_default_volume ); - ClassDB::bind_method(_MD("get_default_volume_db"),&SamplePlayer::get_default_volume_db ); - ClassDB::bind_method(_MD("get_default_pan"),&SamplePlayer::get_default_pan ); - ClassDB::bind_method(_MD("get_default_pan_depth"),&SamplePlayer::get_default_pan_depth ); - ClassDB::bind_method(_MD("get_default_pan_height"),&SamplePlayer::get_default_pan_height ); - ClassDB::bind_method(_MD("get_default_filter_type"),&SamplePlayer::get_default_filter_type ); - ClassDB::bind_method(_MD("get_default_filter_cutoff"),&SamplePlayer::get_default_filter_cutoff ); - ClassDB::bind_method(_MD("get_default_filter_resonance"),&SamplePlayer::get_default_filter_resonance ); - ClassDB::bind_method(_MD("get_default_filter_gain"),&SamplePlayer::get_default_filter_gain ); - ClassDB::bind_method(_MD("get_default_chorus"),&SamplePlayer::get_default_chorus ); - ClassDB::bind_method(_MD("get_default_reverb_room"),&SamplePlayer::get_default_reverb_room ); - ClassDB::bind_method(_MD("get_default_reverb"),&SamplePlayer::get_default_reverb ); - - ClassDB::bind_method(_MD("is_active"),&SamplePlayer::is_active ); - ClassDB::bind_method(_MD("is_voice_active","voice"),&SamplePlayer::is_voice_active ); - - BIND_CONSTANT( FILTER_NONE); - BIND_CONSTANT( FILTER_LOWPASS); - BIND_CONSTANT( FILTER_BANDPASS); - BIND_CONSTANT( FILTER_HIPASS); - BIND_CONSTANT( FILTER_NOTCH); - BIND_CONSTANT( FILTER_PEAK); - BIND_CONSTANT( FILTER_BANDLIMIT); ///< cutoff is LP resonace is HP - BIND_CONSTANT( FILTER_LOW_SHELF); - BIND_CONSTANT( FILTER_HIGH_SHELF); - - BIND_CONSTANT( REVERB_SMALL ); - BIND_CONSTANT( REVERB_MEDIUM ); - BIND_CONSTANT( REVERB_LARGE ); - BIND_CONSTANT( REVERB_HALL ); - - BIND_CONSTANT( INVALID_VOICE_ID ); - -} - - -SamplePlayer::SamplePlayer() { - - voices.resize(1); - - _default.pitch_scale=1; - _default.volume_db=0; - _default.pan=0; - _default.depth=0; - _default.height=0; - _default.filter_type=FILTER_NONE; - _default.filter_cutoff=5000; - _default.filter_resonance=1; - _default.filter_gain=1; - _default.chorus_send=0; - _default.reverb_room=REVERB_LARGE; - _default.reverb_send=0; - last_id=0; - last_check=0; - - -} - -SamplePlayer::~SamplePlayer() { - - -} diff --git a/scene/audio/sample_player.h b/scene/audio/sample_player.h deleted file mode 100644 index 8c4e6418aa..0000000000 --- a/scene/audio/sample_player.h +++ /dev/null @@ -1,200 +0,0 @@ -/*************************************************************************/ -/* sample_player.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SAMPLE_PLAYER_H -#define SAMPLE_PLAYER_H - -#include "scene/main/node.h" -#include "scene/resources/sample_library.h" - -class SamplePlayer : public Node { - - GDCLASS( SamplePlayer, Node ); - OBJ_CATEGORY("Audio Nodes"); -public: - - - enum FilterType { - FILTER_NONE, - FILTER_LOWPASS, - FILTER_BANDPASS, - FILTER_HIPASS, - FILTER_NOTCH, - FILTER_PEAK, - FILTER_BANDLIMIT, ///< cutoff is LP resonace is HP - FILTER_LOW_SHELF, - FILTER_HIGH_SHELF, - }; - - enum ReverbRoomType { - - REVERB_SMALL, - REVERB_MEDIUM, - REVERB_LARGE, - REVERB_HALL - }; - - enum { - - INVALID_VOICE_ID=0xFFFFFFFF - }; - - typedef uint32_t VoiceID; - -private: - - Ref<SampleLibrary> library; - - struct Voice { - - RID voice; - uint32_t check; - bool active; - - int sample_mix_rate; - int mix_rate; - float volume; - float pan; - float pan_depth; - float pan_height; - FilterType filter_type; - float filter_cutoff; - float filter_resonance; - float filter_gain; - float chorus_send; - ReverbRoomType reverb_room; - float reverb_send; - - void clear(); - Voice(); - ~Voice(); - }; - - Vector<Voice> voices; - - struct Default { - - float reverb_send; - float pitch_scale; - float volume_db; - float pan; - float depth; - float height; - FilterType filter_type; - float filter_cutoff; - float filter_resonance; - float filter_gain; - float chorus_send; - ReverbRoomType reverb_room; - - } _default; - - uint32_t last_id; - uint16_t last_check; - String played_back; -protected: - - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; - void _get_property_list(List<PropertyInfo> *p_list) const; - - static void _bind_methods(); - -public: - - void set_sample_library(const Ref<SampleLibrary>& p_library); - Ref<SampleLibrary> get_sample_library() const; - - void set_polyphony(int p_voice_count); - int get_polyphony() const; - - VoiceID play(const String& p_name,bool unique=false); - void stop(VoiceID p_voice); - void stop_all(); - bool is_voice_active(VoiceID) const; - bool is_active() const; - - void set_mix_rate(VoiceID p_voice, int p_mix_rate); - void set_pitch_scale(VoiceID p_voice, float p_pitch_scale); - void set_volume(VoiceID p_voice, float p_volume); - void set_volume_db(VoiceID p_voice, float p_db); - void set_pan(VoiceID p_voice, float p_pan,float p_pan_depth=0,float p_pan_height=0); - void set_filter(VoiceID p_voice,FilterType p_filter,float p_cutoff,float p_resonance,float p_gain); - void set_chorus(VoiceID p_voice,float p_send); - void set_reverb(VoiceID p_voice,ReverbRoomType p_room,float p_send); - - int get_mix_rate(VoiceID p_voice) const; - float get_pitch_scale(VoiceID p_voice) const; - float get_volume(VoiceID p_voice) const; - float get_volume_db(VoiceID p_voice) const; - - float get_pan(VoiceID p_voice) const; - float get_pan_depth(VoiceID p_voice) const; - float get_pan_height(VoiceID p_voice) const; - FilterType get_filter_type(VoiceID p_voice) const; - float get_filter_cutoff(VoiceID p_voice) const; - float get_filter_resonance(VoiceID p_voice) const; - float get_filter_gain(VoiceID p_voice) const; - float get_chorus(VoiceID p_voice) const; - ReverbRoomType get_reverb_room(VoiceID p_voice) const; - float get_reverb(VoiceID p_voice) const; - - - - void set_default_pitch_scale(float p_pitch_scale); - void set_default_volume(float p_volume); - void set_default_volume_db(float p_db); - void set_default_pan(float p_pan,float p_pan_depth=0,float p_pan_height=0); - void set_default_filter(FilterType p_filter,float p_cutoff,float p_resonance,float p_gain); - void set_default_chorus(float p_send); - void set_default_reverb(ReverbRoomType p_room,float p_send); - - float get_default_volume() const; - float get_default_volume_db() const; - float get_default_pitch_scale() const; - float get_default_pan() const; - float get_default_pan_depth() const; - float get_default_pan_height() const; - FilterType get_default_filter_type() const; - float get_default_filter_cutoff() const; - float get_default_filter_resonance() const; - float get_default_filter_gain() const; - float get_default_chorus() const; - ReverbRoomType get_default_reverb_room() const; - float get_default_reverb() const; - - String get_configuration_warning() const; - - SamplePlayer(); - ~SamplePlayer(); -}; - -VARIANT_ENUM_CAST( SamplePlayer::FilterType ); -VARIANT_ENUM_CAST( SamplePlayer::ReverbRoomType ); - -#endif // SAMPLE_PLAYER_H diff --git a/scene/audio/sound_room_params.cpp b/scene/audio/sound_room_params.cpp deleted file mode 100644 index d08bc5d6b8..0000000000 --- a/scene/audio/sound_room_params.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/*************************************************************************/ -/* sound_room_params.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "sound_room_params.h" - -#include "scene/main/viewport.h" - -#ifndef _3D_DISABLED -void SoundRoomParams::_update_sound_room() { - - if (!room.is_valid()) - return; - - for(int i=0;i<PARAM_MAX;i++) { - - SpatialSoundServer::get_singleton()->room_set_param(room,SpatialSoundServer::RoomParam(i),params[i]); - - } - - SpatialSoundServer::get_singleton()->room_set_reverb(room,SpatialSoundServer::RoomReverb(reverb)); - SpatialSoundServer::get_singleton()->room_set_force_params_to_all_sources(room,force_params_for_all_sources); -} - - -void SoundRoomParams::_notification(int p_what) { - - - switch(p_what) { - - - case NOTIFICATION_ENTER_TREE: { -//#if 0 - Node *n=this; - Room *room_instance=NULL; - while(n) { - - room_instance=n->cast_to<Room>(); - if (room_instance) { - - break; - } - if (n->cast_to<Viewport>()) - break; - - n=n->get_parent(); - } - - - if (room_instance) { - room=room_instance->get_sound_room(); - } else { - room=get_viewport()->find_world()->get_sound_space(); - } - - _update_sound_room(); -//#endif - - } break; - case NOTIFICATION_EXIT_TREE: { - - room=RID(); - - } break; - } -} - - -void SoundRoomParams::set_param(Params p_param, float p_value) { - - ERR_FAIL_INDEX(p_param,PARAM_MAX); - params[p_param]=p_value; - if (room.is_valid()) - SpatialSoundServer::get_singleton()->room_set_param(room,SpatialSoundServer::RoomParam(p_param),p_value); -} - -float SoundRoomParams::get_param(Params p_param) const { - - ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0); - return params[p_param]; -} - - -void SoundRoomParams::set_reverb_mode(Reverb p_mode) { - - ERR_FAIL_INDEX(p_mode,4); - reverb=p_mode; - if (room.is_valid()) - SpatialSoundServer::get_singleton()->room_set_reverb(room,SpatialSoundServer::RoomReverb(p_mode)); -} - -SoundRoomParams::Reverb SoundRoomParams::get_reverb_mode() const { - - return reverb; -} - - -void SoundRoomParams::set_force_params_to_all_sources(bool p_force) { - - force_params_for_all_sources=p_force; - if (room.is_valid()) - SpatialSoundServer::get_singleton()->room_set_force_params_to_all_sources(room,p_force); -} - -bool SoundRoomParams::is_forcing_params_to_all_sources() { - - return force_params_for_all_sources; -} - - -void SoundRoomParams::_bind_methods() { - - ClassDB::bind_method(_MD("set_param","param","value"),&SoundRoomParams::set_param ); - ClassDB::bind_method(_MD("get_param","param"),&SoundRoomParams::get_param ); - - ClassDB::bind_method(_MD("set_reverb_mode","reverb_mode","value"),&SoundRoomParams::set_reverb_mode ); - ClassDB::bind_method(_MD("get_reverb_mode","reverb_mode"),&SoundRoomParams::get_reverb_mode ); - - ClassDB::bind_method(_MD("set_force_params_to_all_sources","enabled"),&SoundRoomParams::set_force_params_to_all_sources ); - ClassDB::bind_method(_MD("is_forcing_params_to_all_sources"),&SoundRoomParams::is_forcing_params_to_all_sources ); - - - ADD_PROPERTY( PropertyInfo( Variant::INT, "reverb/mode", PROPERTY_HINT_ENUM, "Small,Medium,Large,Hall"), _SCS("set_reverb_mode"), _SCS("get_reverb_mode") ); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/speed_of_scale", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SPEED_OF_SOUND_SCALE); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/doppler_factor",PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_DOPPLER_FACTOR ); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/pitch_scale",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_PITCH_SCALE ); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/volume_scale_db",PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_VOLUME_SCALE_DB ); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/reverb_send",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_REVERB_SEND ); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/chorus_send",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_CHORUS_SEND ); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_scale",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_SCALE ); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_hf_cutoff",PROPERTY_HINT_RANGE, "30,16384,1"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_CUTOFF ); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_hf_floor_db",PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_FLOOR_DB ); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_hf_ratio_exp",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_RATIO_EXP ); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_reverb_scale",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_REVERB_SCALE ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "force_to_all_sources"),_SCS("set_force_params_to_all_sources"),_SCS("is_forcing_params_to_all_sources") ); - -} - - -SoundRoomParams::SoundRoomParams() { - - reverb=REVERB_HALL; - params[PARAM_SPEED_OF_SOUND_SCALE]=1; - params[PARAM_DOPPLER_FACTOR]=1.0; - params[PARAM_PITCH_SCALE]=1.0; - params[PARAM_VOLUME_SCALE_DB]=0; - params[PARAM_REVERB_SEND]=0; - params[PARAM_CHORUS_SEND]=0; - params[PARAM_ATTENUATION_SCALE]=1.0; - params[PARAM_ATTENUATION_HF_CUTOFF]=5000; - params[PARAM_ATTENUATION_HF_FLOOR_DB]=-24.0; - params[PARAM_ATTENUATION_HF_RATIO_EXP]=1.0; - params[PARAM_ATTENUATION_REVERB_SCALE]=0.0; - force_params_for_all_sources=false; -} -#endif diff --git a/scene/audio/sound_room_params.h b/scene/audio/sound_room_params.h deleted file mode 100644 index 3cdffda652..0000000000 --- a/scene/audio/sound_room_params.h +++ /dev/null @@ -1,100 +0,0 @@ -/*************************************************************************/ -/* sound_room_params.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SOUND_ROOM_PARAMS_H -#define SOUND_ROOM_PARAMS_H - -#include "scene/main/node.h" -#include "servers/spatial_sound_server.h" - - -#ifndef _3D_DISABLED - -#include "scene/3d/room_instance.h" -class SoundRoomParams : public Node { - - GDCLASS( SoundRoomParams, Node ); -public: - - enum Params { - PARAM_SPEED_OF_SOUND_SCALE=SpatialSoundServer::ROOM_PARAM_SPEED_OF_SOUND_SCALE, - PARAM_DOPPLER_FACTOR=SpatialSoundServer::ROOM_PARAM_DOPPLER_FACTOR, - PARAM_PITCH_SCALE=SpatialSoundServer::ROOM_PARAM_PITCH_SCALE, - PARAM_VOLUME_SCALE_DB=SpatialSoundServer::ROOM_PARAM_VOLUME_SCALE_DB, - PARAM_REVERB_SEND=SpatialSoundServer::ROOM_PARAM_REVERB_SEND, - PARAM_CHORUS_SEND=SpatialSoundServer::ROOM_PARAM_CHORUS_SEND, - PARAM_ATTENUATION_SCALE=SpatialSoundServer::ROOM_PARAM_ATTENUATION_SCALE, - PARAM_ATTENUATION_HF_CUTOFF=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_CUTOFF, - PARAM_ATTENUATION_HF_FLOOR_DB=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_FLOOR_DB, - PARAM_ATTENUATION_HF_RATIO_EXP=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_RATIO_EXP, - PARAM_ATTENUATION_REVERB_SCALE=SpatialSoundServer::ROOM_PARAM_ATTENUATION_REVERB_SCALE, - PARAM_MAX=SpatialSoundServer::ROOM_PARAM_MAX - }; - - enum Reverb { - REVERB_SMALL, - REVERB_MEDIUM, - REVERB_LARGE, - REVERB_HALL - }; -private: - - RID room; - - float params[PARAM_MAX]; - Reverb reverb; - bool force_params_for_all_sources; - void _update_sound_room(); - - -protected: - - void _notification(int p_what); - static void _bind_methods(); - -public: - - - void set_param(Params p_param, float p_value); - float get_param(Params p_param) const; - - void set_reverb_mode(Reverb p_mode); - Reverb get_reverb_mode() const; - - void set_force_params_to_all_sources(bool p_force); - bool is_forcing_params_to_all_sources(); - - SoundRoomParams(); -}; - -VARIANT_ENUM_CAST(SoundRoomParams::Params); -VARIANT_ENUM_CAST(SoundRoomParams::Reverb); - -#endif - -#endif // SOUND_ROOM_PARAMS_H diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp deleted file mode 100644 index 9e506034a6..0000000000 --- a/scene/audio/stream_player.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/*************************************************************************/ -/* stream_player.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "stream_player.h" - -int StreamPlayer::InternalStream::get_channel_count() const { - - return player->sp_get_channel_count(); -} -void StreamPlayer::InternalStream::set_mix_rate(int p_rate){ - - return player->sp_set_mix_rate(p_rate); -} -bool StreamPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){ - - return player->sp_mix(p_buffer,p_frames); -} -void StreamPlayer::InternalStream::update(){ - - player->sp_update(); -} - - -int StreamPlayer::sp_get_channel_count() const { - - return playback->get_channels(); -} - -void StreamPlayer::sp_set_mix_rate(int p_rate){ - - server_mix_rate=p_rate; -} - -bool StreamPlayer::sp_mix(int32_t *p_buffer,int p_frames) { - - if (resampler.is_ready() && !paused) { - return resampler.mix(p_buffer,p_frames); - } - - return false; -} - -void StreamPlayer::sp_update() { - - //_THREAD_SAFE_METHOD_ - if (!paused && resampler.is_ready() && playback.is_valid()) { - - if (!playback->is_playing()) { - //stream depleted data, but there's still audio in the ringbuffer - //check that all this audio has been flushed before stopping the stream - int to_mix = resampler.get_total() - resampler.get_todo(); - if (to_mix==0) { - if (!stop_request) { - stop_request=true; - call_deferred("_do_stop"); - } - return; - } - - return; - } - - int todo =resampler.get_todo(); - int wrote = playback->mix(resampler.get_write_buffer(),todo); - resampler.write(wrote); - } -} - -void StreamPlayer::_do_stop() { - stop(); - emit_signal("finished"); -} - -void StreamPlayer::_notification(int p_what) { - - switch(p_what) { - - case NOTIFICATION_ENTER_TREE: { - - //set_idle_process(false); //don't annoy - if (stream.is_valid() && !get_tree()->is_editor_hint()) { - if (resume_pos>=0) { - play(resume_pos); - resume_pos=-1; - } else if (autoplay) { - play(); - autoplay = false; //this line fix autoplay issues - } - } - - } break; - case NOTIFICATION_EXIT_TREE: { - - if (is_playing()) { - resume_pos=get_pos(); - } - stop(); //wathever it may be doing, stop - } break; - } -} - - - -void StreamPlayer::set_stream(const Ref<AudioStream> &p_stream) { - - stop(); - - stream=p_stream; - - if (!stream.is_null()) { - playback=stream->instance_playback(); - playback->set_loop(loops); - playback->set_loop_restart_time(loop_point); - AudioServer::get_singleton()->lock(); - resampler.setup(playback->get_channels(),playback->get_mix_rate(),server_mix_rate,buffering_ms,playback->get_minimum_buffer_size()); - AudioServer::get_singleton()->unlock(); - } else { - AudioServer::get_singleton()->lock(); - resampler.clear(); - playback.unref(); - AudioServer::get_singleton()->unlock(); - } -} - -Ref<AudioStream> StreamPlayer::get_stream() const { - - return stream; -} - - -void StreamPlayer::play(float p_from_offset) { - - ERR_FAIL_COND(!is_inside_tree()); - if (playback.is_null()) - return; - //if (is_playing()) - stop(); - - //_THREAD_SAFE_METHOD_ - playback->play(p_from_offset); - //feed the ringbuffer as long as no update callback is going on - sp_update(); - AudioServer::get_singleton()->stream_set_active(stream_rid,true); - AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume); - /* - if (stream->get_update_mode()!=AudioStream::UPDATE_NONE) - set_idle_process(true); - */ - -} - -void StreamPlayer::stop() { - - if (!is_inside_tree()) - return; - if (playback.is_null()) - return; - - //_THREAD_SAFE_METHOD_ - AudioServer::get_singleton()->stream_set_active(stream_rid,false); - stop_request=false; - playback->stop(); - resampler.flush(); - - - //set_idle_process(false); -} - -bool StreamPlayer::is_playing() const { - - if (playback.is_null()) - return false; - - return playback->is_playing() || resampler.has_data(); -} - -void StreamPlayer::set_loop(bool p_enable) { - - loops=p_enable; - if (playback.is_null()) - return; - playback->set_loop(loops); - -} -bool StreamPlayer::has_loop() const { - - return loops; -} - -void StreamPlayer::set_volume(float p_vol) { - - volume=p_vol; - if (stream_rid.is_valid()) - AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume); -} - -float StreamPlayer::get_volume() const { - - return volume; -} - -void StreamPlayer::set_loop_restart_time(float p_secs) { - - loop_point=p_secs; - if (playback.is_valid()) - playback->set_loop_restart_time(p_secs); -} - -float StreamPlayer::get_loop_restart_time() const { - - return loop_point; -} - - -void StreamPlayer::set_volume_db(float p_db) { - - if (p_db<-79) - set_volume(0); - else - set_volume(Math::db2linear(p_db)); -} - -float StreamPlayer::get_volume_db() const { - - if (volume==0) - return -80; - else - return Math::linear2db(volume); -} - - -String StreamPlayer::get_stream_name() const { - - if (stream.is_null()) - return "<No Stream>"; - return stream->get_name(); - -} - -int StreamPlayer::get_loop_count() const { - - if (playback.is_null()) - return 0; - return playback->get_loop_count(); - -} - -float StreamPlayer::get_pos() const { - - if (playback.is_null()) - return 0; - return playback->get_pos(); - -} - -float StreamPlayer::get_length() const { - - if (playback.is_null()) - return 0; - return playback->get_length(); -} -void StreamPlayer::seek_pos(float p_time) { - - if (playback.is_null()) - return; - //works better... - stop(); - playback->play(p_time); - -} - -void StreamPlayer::set_autoplay(bool p_enable) { - - autoplay=p_enable; -} - -bool StreamPlayer::has_autoplay() const { - - return autoplay; -} - -void StreamPlayer::set_paused(bool p_paused) { - - paused=p_paused; - /* - if (stream.is_valid()) - stream->set_paused(p_paused); - */ -} - -bool StreamPlayer::is_paused() const { - - return paused; -} - -void StreamPlayer::_set_play(bool p_play) { - - _play=p_play; - if (is_inside_tree()) { - if(_play) - play(); - else - stop(); - } - -} - -bool StreamPlayer::_get_play() const{ - - return _play; -} - -void StreamPlayer::set_buffering_msec(int p_msec) { - - buffering_ms=p_msec; -} - -int StreamPlayer::get_buffering_msec() const{ - - return buffering_ms; -} - - - -void StreamPlayer::_bind_methods() { - - ClassDB::bind_method(_MD("set_stream","stream:AudioStream"),&StreamPlayer::set_stream); - ClassDB::bind_method(_MD("get_stream:AudioStream"),&StreamPlayer::get_stream); - - ClassDB::bind_method(_MD("play","offset"),&StreamPlayer::play,DEFVAL(0)); - ClassDB::bind_method(_MD("stop"),&StreamPlayer::stop); - - ClassDB::bind_method(_MD("is_playing"),&StreamPlayer::is_playing); - - ClassDB::bind_method(_MD("set_paused","paused"),&StreamPlayer::set_paused); - ClassDB::bind_method(_MD("is_paused"),&StreamPlayer::is_paused); - - ClassDB::bind_method(_MD("set_loop","enabled"),&StreamPlayer::set_loop); - ClassDB::bind_method(_MD("has_loop"),&StreamPlayer::has_loop); - - ClassDB::bind_method(_MD("set_volume","volume"),&StreamPlayer::set_volume); - ClassDB::bind_method(_MD("get_volume"),&StreamPlayer::get_volume); - - ClassDB::bind_method(_MD("set_volume_db","db"),&StreamPlayer::set_volume_db); - ClassDB::bind_method(_MD("get_volume_db"),&StreamPlayer::get_volume_db); - - ClassDB::bind_method(_MD("set_buffering_msec","msec"),&StreamPlayer::set_buffering_msec); - ClassDB::bind_method(_MD("get_buffering_msec"),&StreamPlayer::get_buffering_msec); - - ClassDB::bind_method(_MD("set_loop_restart_time","secs"),&StreamPlayer::set_loop_restart_time); - ClassDB::bind_method(_MD("get_loop_restart_time"),&StreamPlayer::get_loop_restart_time); - - ClassDB::bind_method(_MD("get_stream_name"),&StreamPlayer::get_stream_name); - ClassDB::bind_method(_MD("get_loop_count"),&StreamPlayer::get_loop_count); - - ClassDB::bind_method(_MD("get_pos"),&StreamPlayer::get_pos); - ClassDB::bind_method(_MD("seek_pos","time"),&StreamPlayer::seek_pos); - - ClassDB::bind_method(_MD("set_autoplay","enabled"),&StreamPlayer::set_autoplay); - ClassDB::bind_method(_MD("has_autoplay"),&StreamPlayer::has_autoplay); - - ClassDB::bind_method(_MD("get_length"),&StreamPlayer::get_length); - - ClassDB::bind_method(_MD("_set_play","play"),&StreamPlayer::_set_play); - ClassDB::bind_method(_MD("_get_play"),&StreamPlayer::_get_play); - ClassDB::bind_method(_MD("_do_stop"),&StreamPlayer::_do_stop); - - ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "play"), _SCS("_set_play"), _SCS("_get_play") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "loop"), _SCS("set_loop"), _SCS("has_loop") ); - ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") ); - ADD_PROPERTY( PropertyInfo(Variant::REAL, "loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time") ); - ADD_PROPERTY( PropertyInfo(Variant::INT, "buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec") ); - - ADD_SIGNAL(MethodInfo("finished")); -} - - -StreamPlayer::StreamPlayer() { - - volume=1; - loops=false; - paused=false; - autoplay=false; - _play=false; - server_mix_rate=1; - internal_stream.player=this; - stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream); - buffering_ms=500; - loop_point=0; - stop_request=false; - resume_pos=-1; - -} - -StreamPlayer::~StreamPlayer() { - AudioServer::get_singleton()->free(stream_rid); - resampler.clear(); - - -} diff --git a/scene/audio/stream_player.h b/scene/audio/stream_player.h deleted file mode 100644 index 6031d86aa2..0000000000 --- a/scene/audio/stream_player.h +++ /dev/null @@ -1,124 +0,0 @@ -/*************************************************************************/ -/* stream_player.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 STREAM_PLAYER_H -#define STREAM_PLAYER_H - -#include "scene/resources/audio_stream.h" -#include "scene/main/node.h" -#include "servers/audio/audio_rb_resampler.h" - -class StreamPlayer : public Node { - - GDCLASS(StreamPlayer,Node); - - //_THREAD_SAFE_CLASS_ - - struct InternalStream : public AudioServer::AudioStream { - StreamPlayer *player; - virtual int get_channel_count() const; - virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate - virtual bool mix(int32_t *p_buffer,int p_frames); - virtual void update(); - }; - - - InternalStream internal_stream; - Ref<AudioStreamPlayback> playback; - Ref<AudioStream> stream; - - int sp_get_channel_count() const; - void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate - bool sp_mix(int32_t *p_buffer,int p_frames); - void sp_update(); - - int server_mix_rate; - - RID stream_rid; - bool paused; - bool autoplay; - bool loops; - float volume; - float loop_point; - int buffering_ms; - volatile bool stop_request; - float resume_pos; - - AudioRBResampler resampler; - - void _do_stop(); - - bool _play; - void _set_play(bool p_play); - bool _get_play() const; -protected: - void _notification(int p_what); - - static void _bind_methods(); -public: - - void set_stream(const Ref<AudioStream> &p_stream); - Ref<AudioStream> get_stream() const; - - void play(float p_from_offset=0); - void stop(); - bool is_playing() const; - - void set_paused(bool p_paused); - bool is_paused() const; - - void set_loop(bool p_enable); - bool has_loop() const; - - void set_volume(float p_vol); - float get_volume() const; - - void set_loop_restart_time(float p_secs); - float get_loop_restart_time() const; - - void set_volume_db(float p_db); - float get_volume_db() const; - - String get_stream_name() const; - - int get_loop_count() const; - - float get_pos() const; - void seek_pos(float p_time); - float get_length() const; - void set_autoplay(bool p_vol); - bool has_autoplay() const; - - void set_buffering_msec(int p_msec); - int get_buffering_msec() const; - - StreamPlayer(); - ~StreamPlayer(); -}; - -#endif // AUDIO_STREAM_PLAYER_H diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index 7ca44ac27b..9c5ddb3e7c 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -42,7 +42,7 @@ void BoxContainer::_resort() { /** First pass, determine minimum size AND amount of stretchable elements */ - Size2i new_size=get_size();; + Size2i new_size=get_size(); int sep=get_constant("separation");//,vertical?"VBoxContainer":"HBoxContainer"); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 533d24f998..e012874f5b 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1715,7 +1715,7 @@ Control *Control::find_next_valid_focus() const { if (!next_child) { - next_child=const_cast<Control*>(this);; + next_child=const_cast<Control*>(this); while(next_child) { if (next_child->data.SI || next_child->data.RI) diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index a3ed0a91cf..a42ef08bf3 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -300,7 +300,7 @@ void ItemList::move_item(int p_item,int p_to_pos) { ERR_FAIL_INDEX(p_to_pos,items.size()+1); Item it=items[p_item]; - items.remove(p_item);; + items.remove(p_item); if (p_to_pos>p_item) { p_to_pos--; @@ -905,7 +905,7 @@ void ItemList::_notification(int p_what) { Vector2 ofs; int col=0; int max_h=0; - separators.clear();; + separators.clear(); for(int i=0;i<items.size();i++) { if (current_columns>1 && items[i].rect_cache.size.width+ofs.x > fit_size) { diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index cd500a62bc..d32b4c6de4 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -204,7 +204,7 @@ void Label::_notification(int p_what) { } break; case ALIGN_CENTER: { - x_ofs=int(size.width-(taken+spaces*space_w))/2;; + x_ofs=int(size.width-(taken+spaces*space_w))/2; } break; case ALIGN_RIGHT: { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 3a72e0e445..fe242ee708 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1320,7 +1320,7 @@ void LineEdit::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "placeholder_text" ), _SCS("set_placeholder"),_SCS("get_placeholder") ); ADD_PROPERTYNZ( PropertyInfo( Variant::REAL, "placeholder_alpha",PROPERTY_HINT_RANGE,"0,1,0.001" ), _SCS("set_placeholder_alpha"),_SCS("get_placeholder_alpha") ); ADD_GROUP("Caret","caret_"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));; + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled")); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") ); } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 434fb36e24..5fe5f47d1b 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -103,7 +103,7 @@ void RichTextLabel::_process_line(ItemFrame *p_frame,const Vector2& p_ofs,int &y int line_ofs=0; int margin=_find_margin(it,p_base_font); - Align align=_find_align(it);; + Align align=_find_align(it); int line=0; int spaces=0; diff --git a/scene/gui/separator.h b/scene/gui/separator.h index 5fb17e1c2e..56d8a9724f 100644 --- a/scene/gui/separator.h +++ b/scene/gui/separator.h @@ -45,7 +45,7 @@ protected: void _notification(int p_what); public: - virtual Size2 get_minimum_size() const;; + virtual Size2 get_minimum_size() const; Separator(); ~Separator(); diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 52d26b29de..11802ab0fb 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -40,7 +40,7 @@ int TabContainer::_get_top_margin() const { int h = MAX( tab_bg->get_minimum_size().height,tab_fg->get_minimum_size().height); - int ch = font->get_height();; + int ch = font->get_height(); for(int i=0;i<get_child_count();i++) { Control *c = get_child(i)->cast_to<Control>(); @@ -99,7 +99,7 @@ void TabContainer::_gui_input(const InputEvent& p_event) { pp_pos.y+=menu->get_height(); popup->set_global_pos( pp_pos ); - popup->popup();; + popup->popup(); return; } pos.x-=tabs_ofs_cache; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 8efff21fc9..d1a8c458ba 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -247,7 +247,7 @@ void TextEdit::Text::clear_caches() { void TextEdit::Text::clear() { - text.clear();; + text.clear(); insert(0,""); } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 58c829690f..2cfebb7c1e 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -611,7 +611,7 @@ void TreeItem::clear_custom_color(int p_column) { ERR_FAIL_INDEX( p_column, cells.size() ); cells[p_column].custom_color=false; - cells[p_column].color=Color();; + cells[p_column].color=Color(); _changed_notify(p_column); } @@ -642,7 +642,7 @@ void TreeItem::clear_custom_bg_color(int p_column) { ERR_FAIL_INDEX( p_column, cells.size() ); cells[p_column].custom_bg_color=false; - cells[p_column].bg_color=Color();; + cells[p_column].bg_color=Color(); _changed_notify(p_column); } @@ -1258,7 +1258,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& icon_ofs+=item_rect.pos; - draw_texture_rect(p_item->cells[i].icon,Rect2(icon_ofs,icon_size));; + draw_texture_rect(p_item->cells[i].icon,Rect2(icon_ofs,icon_size)); //p_item->cells[i].icon->draw(ci, icon_ofs); } break; @@ -2675,7 +2675,7 @@ void Tree::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { - update_cache();; + update_cache(); } if (p_what==NOTIFICATION_DRAG_END) { @@ -3330,7 +3330,7 @@ TreeItem* Tree::_find_item_at_pos(TreeItem*p_item, const Point2& p_pos,int& r_co if (root!=p_item || ! hide_root) { - h = compute_item_height(p_item)+cache.vseparation;; + h = compute_item_height(p_item)+cache.vseparation; if (pos.y<h) { if (drop_mode_flags==DROP_MODE_ON_ITEM) { diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 4c177ea53c..907b5a771f 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "video_player.h" #include "os/os.h" - +/* int VideoPlayer::InternalStream::get_channel_count() const { @@ -46,7 +46,7 @@ void VideoPlayer::InternalStream::update(){ player->sp_update(); } - +*/ int VideoPlayer::sp_get_channel_count() const { @@ -234,8 +234,8 @@ void VideoPlayer::play() { playback->stop(); playback->play(); set_process_internal(true); - AudioServer::get_singleton()->stream_set_active(stream_rid,true); - AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume); +// AudioServer::get_singleton()->stream_set_active(stream_rid,true); +// AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume); last_audio_time=0; }; @@ -247,7 +247,7 @@ void VideoPlayer::stop() { return; playback->stop(); - AudioServer::get_singleton()->stream_set_active(stream_rid,false); +// AudioServer::get_singleton()->stream_set_active(stream_rid,false); resampler.flush(); set_process_internal(false); last_audio_time=0; @@ -416,16 +416,16 @@ VideoPlayer::VideoPlayer() { buffering_ms=500; server_mix_rate=44100; - internal_stream.player=this; - stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream); +// internal_stream.player=this; +// stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream); last_audio_time=0; }; VideoPlayer::~VideoPlayer() { - if (stream_rid.is_valid()) - AudioServer::get_singleton()->free(stream_rid); +// if (stream_rid.is_valid()) +// AudioServer::get_singleton()->free(stream_rid); resampler.clear(); //Not necessary here, but make in consistent with other "stream_player" classes }; diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index 694cb253a4..168ea805b1 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -37,16 +37,16 @@ class VideoPlayer : public Control { GDCLASS(VideoPlayer,Control); - struct InternalStream : public AudioServer::AudioStream { +/* struct InternalStream : public AudioServer::AudioStream { VideoPlayer *player; virtual int get_channel_count() const; virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate virtual bool mix(int32_t *p_buffer,int p_frames); virtual void update(); }; +*/ - - InternalStream internal_stream; +// InternalStream internal_stream; Ref<VideoStreamPlayback> playback; Ref<VideoStream> stream; diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp index 0a19e6f72b..1e14d01f4e 100644 --- a/scene/io/resource_format_wav.cpp +++ b/scene/io/resource_format_wav.cpp @@ -26,6 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#if 0 #include "resource_format_wav.h" #include "os/file_access.h" #include "scene/resources/sample.h" @@ -272,3 +273,4 @@ String ResourceFormatLoaderWAV::get_resource_type(const String &p_path) const { return ""; } +#endif diff --git a/scene/io/resource_format_wav.h b/scene/io/resource_format_wav.h index 3a278b455b..fd274625f9 100644 --- a/scene/io/resource_format_wav.h +++ b/scene/io/resource_format_wav.h @@ -29,6 +29,7 @@ #ifndef RESOURCE_FORMAT_WAV_H #define RESOURCE_FORMAT_WAV_H +#if 0 #include "io/resource_loader.h" class ResourceFormatLoaderWAV : public ResourceFormatLoader { @@ -40,4 +41,5 @@ public: }; +#endif #endif // RESOURCE_FORMAT_WAV_H diff --git a/scene/main/node.cpp b/scene/main/node.cpp index aba8afd727..039dce37de 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1631,7 +1631,7 @@ Node *Node::_get_node(const NodePath& p_path) const { current=const_cast<Node*>(this); //start from this } else { - root=const_cast<Node*>(this);; + root=const_cast<Node*>(this); while (root->data.parent) root=root->data.parent; //start from root } diff --git a/scene/main/node.h b/scene/main/node.h index 14fd19a76f..d88db8ecb0 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -33,7 +33,7 @@ #include "object.h" #include "path_db.h" #include "map.h" -#include "object_type_db.h" +#include "class_db.h" #include "script_language.h" #include "scene/main/scene_main_loop.h" diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index 147409a862..9db1d3fd77 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -35,7 +35,7 @@ #include "globals.h" #include <stdio.h> #include "os/keyboard.h" -#include "servers/spatial_sound_2d_server.h" +//#include "servers/spatial_sound_2d_server.h" #include "servers/physics_2d_server.h" #include "servers/physics_server.h" #include "scene/scene_string_names.h" diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index c3ece76b05..14acf9583d 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -33,8 +33,7 @@ #include "servers/physics_2d_server.h" //#include "scene/3d/camera.h" -#include "servers/spatial_sound_server.h" -#include "servers/spatial_sound_2d_server.h" + #include "scene/gui/control.h" #include "scene/3d/camera.h" #include "scene/3d/listener.h" @@ -468,7 +467,7 @@ void Viewport::_notification(int p_what) { */ VisualServer::get_singleton()->viewport_set_scenario(viewport,RID()); - SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID()); +// SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID()); VisualServer::get_singleton()->viewport_remove_canvas(viewport,current_canvas); if (contact_2d_debug.is_valid()) { VisualServer::get_singleton()->free(contact_2d_debug); @@ -783,23 +782,24 @@ Size2 Viewport::get_size() const { void Viewport::_update_listener() { - +/* if (is_inside_tree() && audio_listener && (camera || listener) && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible_in_tree()))) { SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, find_world()->get_sound_space()); } else { SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID()); } - +*/ } void Viewport::_update_listener_2d() { + /* if (is_inside_tree() && audio_listener && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible_in_tree()))) SpatialSound2DServer::get_singleton()->listener_set_space(internal_listener_2d, find_world_2d()->get_sound_space()); else SpatialSound2DServer::get_singleton()->listener_set_space(internal_listener_2d, RID()); - +*/ } @@ -842,12 +842,12 @@ void Viewport::set_canvas_transform(const Transform2D& p_transform) { Transform2D xform = (global_canvas_transform * canvas_transform).affine_inverse(); Size2 ss = get_visible_rect().size; - SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5))); + /*SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5))); Vector2 ss2 = ss*xform.get_scale(); float panrange = MAX(ss2.x,ss2.y); SpatialSound2DServer::get_singleton()->listener_set_param(internal_listener_2d, SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE, panrange); - +*/ } @@ -867,12 +867,12 @@ void Viewport::_update_global_transform() { Transform2D xform = (sxform * canvas_transform).affine_inverse(); Size2 ss = get_visible_rect().size; - SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5))); + /*SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5))); Vector2 ss2 = ss*xform.get_scale(); float panrange = MAX(ss2.x,ss2.y); SpatialSound2DServer::get_singleton()->listener_set_param(internal_listener_2d, SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE, panrange); - +*/ } @@ -893,8 +893,8 @@ Transform2D Viewport::get_global_canvas_transform() const{ void Viewport::_listener_transform_changed_notify() { #ifndef _3D_DISABLED - if (listener) - SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, listener->get_listener_transform()); + //if (listener) +// SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, listener->get_listener_transform()); #endif } @@ -957,8 +957,8 @@ void Viewport::_camera_transform_changed_notify() { #ifndef _3D_DISABLED // If there is an active listener in the scene, it takes priority over the camera - if (camera && !listener) - SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, camera->get_camera_transform()); +// if (camera && !listener) +// SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, camera->get_camera_transform()); #endif } @@ -1777,7 +1777,7 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g if (!ci || ci->is_set_as_toplevel()) continue; - Control *ret=_gui_find_control_at_pos(ci,p_global,matrix,r_inv_xform);; + Control *ret=_gui_find_control_at_pos(ci,p_global,matrix,r_inv_xform); if (ret) return ret; } @@ -2006,7 +2006,7 @@ void Viewport::_gui_input_event(InputEvent p_event) { // D&D if (!gui.drag_attempted && gui.mouse_focus && p_event.mouse_motion.button_mask&BUTTON_MASK_LEFT) { - gui.drag_accum+=Point2(p_event.mouse_motion.relative_x,p_event.mouse_motion.relative_y);; + gui.drag_accum+=Point2(p_event.mouse_motion.relative_x,p_event.mouse_motion.relative_y); float len = gui.drag_accum.length(); if (len>10) { gui.drag_data=gui.mouse_focus->get_drag_data(gui.focus_inv_xform.xform(mpos)-gui.drag_accum); @@ -2861,9 +2861,9 @@ Viewport::Viewport() { default_texture->vp=const_cast<Viewport*>(this); viewport_textures.insert(default_texture.ptr()); - internal_listener = SpatialSoundServer::get_singleton()->listener_create(); + //internal_listener = SpatialSoundServer::get_singleton()->listener_create(); audio_listener=false; - internal_listener_2d = SpatialSound2DServer::get_singleton()->listener_create(); + //internal_listener_2d = SpatialSound2DServer::get_singleton()->listener_create(); audio_listener_2d=false; transparent_bg=false; parent=NULL; @@ -2930,8 +2930,8 @@ Viewport::~Viewport() { E->get()->vp=NULL; } VisualServer::get_singleton()->free( viewport ); - SpatialSoundServer::get_singleton()->free(internal_listener); - SpatialSound2DServer::get_singleton()->free(internal_listener_2d); + //SpatialSoundServer::get_singleton()->free(internal_listener); + //SpatialSound2DServer::get_singleton()->free(internal_listener_2d); } diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index f68e5ca959..1932f9cbf6 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -34,7 +34,7 @@ //#include "scene/io/scene_format_script.h" #include "resources/default_theme/default_theme.h" -#include "object_type_db.h" +#include "class_db.h" #include "scene/main/canvas_layer.h" #include "scene/main/instance_placeholder.h" #include "scene/main/viewport.h" @@ -109,8 +109,8 @@ #include "scene/2d/collision_polygon_2d.h" #include "scene/2d/parallax_background.h" #include "scene/2d/parallax_layer.h" -#include "scene/2d/sound_player_2d.h" -#include "scene/2d/sample_player_2d.h" +//#include "scene/2d/sound_player_2d.h" +//#include "scene/2d/sample_player_2d.h" #include "scene/2d/screen_button.h" #include "scene/2d/remote_transform_2d.h" #include "scene/2d/y_sort.h" @@ -139,9 +139,9 @@ #include "scene/main/timer.h" -#include "scene/audio/stream_player.h" -#include "scene/audio/event_player.h" -#include "scene/audio/sound_room_params.h" +//#include "scene/audio/stream_player.h" +//#include "scene/audio/event_player.h" +//#include "scene/audio/sound_room_params.h" #include "scene/resources/sphere_shape.h" #include "scene/resources/ray_shape.h" #include "scene/resources/box_shape.h" @@ -163,8 +163,8 @@ #include "scene/resources/polygon_path_finder.h" -#include "scene/resources/sample.h" -#include "scene/audio/sample_player.h" +//#include "scene/resources/sample.h" +//#include "scene/audio/sample_player.h" #include "scene/resources/texture.h" #include "scene/resources/sky_box.h" #include "scene/resources/material.h" @@ -176,7 +176,7 @@ #include "scene/resources/world.h" #include "scene/resources/world_2d.h" -#include "scene/resources/sample_library.h" +//#include "scene/resources/sample_library.h" #include "scene/resources/audio_stream.h" #include "scene/resources/gibberish_stream.h" #include "scene/resources/bit_mask.h" @@ -220,8 +220,8 @@ #include "scene/3d/ray_cast.h" #include "scene/3d/immediate_geometry.h" #include "scene/3d/sprite_3d.h" -#include "scene/3d/spatial_sample_player.h" -#include "scene/3d/spatial_stream_player.h" +//#include "scene/3d/spatial_sample_player.h" +//#include "scene/3d/spatial_stream_player.h" #include "scene/3d/proximity_group.h" #include "scene/3d/navigation_mesh.h" #include "scene/3d/navigation.h" @@ -231,7 +231,7 @@ #include "scene/resources/scene_format_text.h" static ResourceFormatLoaderImage *resource_loader_image=NULL; -static ResourceFormatLoaderWAV *resource_loader_wav=NULL; +//static ResourceFormatLoaderWAV *resource_loader_wav=NULL; #ifdef TOOLS_ENABLED @@ -258,8 +258,8 @@ void register_scene_types() { resource_loader_image = memnew( ResourceFormatLoaderImage ); ResourceLoader::add_resource_format_loader( resource_loader_image ); - resource_loader_wav = memnew( ResourceFormatLoaderWAV ); - ResourceLoader::add_resource_format_loader( resource_loader_wav ); + //resource_loader_wav = memnew( ResourceFormatLoaderWAV ); + //ResourceLoader::add_resource_format_loader( resource_loader_wav ); resource_loader_dynamic_font = memnew( ResourceFormatLoaderDynamicFont ); ResourceLoader::add_resource_format_loader( resource_loader_dynamic_font ); @@ -474,18 +474,12 @@ void register_scene_types() { OS::get_singleton()->yield(); //may take time to init - ClassDB::register_class<SpatialSamplePlayer>(); - ClassDB::register_class<SpatialStreamPlayer>(); - ClassDB::register_class<SoundRoomParams>(); #endif ClassDB::register_class<MeshLibrary>(); AcceptDialog::set_swap_ok_cancel( GLOBAL_DEF("gui/common/swap_ok_cancel",bool(OS::get_singleton()->get_swap_ok_cancel())) ); - ClassDB::register_class<SamplePlayer>(); - ClassDB::register_class<StreamPlayer>(); - ClassDB::register_class<EventPlayer>(); ClassDB::register_class<CanvasItemMaterial>(); @@ -527,8 +521,6 @@ void register_scene_types() { ClassDB::register_class<TileMap>(); ClassDB::register_class<ParallaxBackground>(); ClassDB::register_class<ParallaxLayer>(); - ClassDB::register_virtual_class<SoundPlayer2D>(); - ClassDB::register_class<SamplePlayer2D>(); ClassDB::register_class<TouchScreenButton>(); ClassDB::register_class<RemoteTransform2D>(); @@ -600,8 +592,6 @@ void register_scene_types() { OS::get_singleton()->yield(); //may take time to init - ClassDB::register_class<Sample>(); - ClassDB::register_class<SampleLibrary>(); ClassDB::register_virtual_class<AudioStream>(); ClassDB::register_virtual_class<AudioStreamPlayback>(); //TODO: Adapt to the new AudioStream API or drop (GH-3307) @@ -657,7 +647,7 @@ void unregister_scene_types() { clear_default_theme(); memdelete( resource_loader_image ); - memdelete( resource_loader_wav ); +// memdelete( resource_loader_wav ); memdelete( resource_loader_dynamic_font ); diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 63a7829d26..ba4b12900f 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -938,7 +938,7 @@ RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String& p_ *r_error=ERR_FILE_CANT_OPEN; Ref<DynamicFontData> dfont; - dfont.instance();; + dfont.instance(); dfont->set_font_path(p_path); diff --git a/scene/resources/event_stream.cpp b/scene/resources/event_stream.cpp deleted file mode 100644 index 521f305327..0000000000 --- a/scene/resources/event_stream.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************/ -/* event_stream.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "event_stream.h" - - -Error EventStreamPlayback::play() { - if (stream.is_valid()) - stop(); - - Error err = _play(); - if (err) - return err; - - - playing=true; - AudioServer::get_singleton()->stream_set_active(stream,true); - - return OK; -} - -void EventStreamPlayback::stop(){ - - if (!playing) - return; - - AudioServer::get_singleton()->stream_set_active(stream,false); - _stop(); - playing=false; - - -} -bool EventStreamPlayback::is_playing() const{ - - return playing; -} - - -EventStreamPlayback::EventStreamPlayback() { - - playing=false; - estream.playback=this; - stream=AudioServer::get_singleton()->event_stream_create(&estream); - -} - -EventStreamPlayback::~EventStreamPlayback() { - - AudioServer::get_singleton()->free(stream); - -} - - - -EventStream::EventStream() -{ - - -} - diff --git a/scene/resources/event_stream.h b/scene/resources/event_stream.h deleted file mode 100644 index 40af78fcce..0000000000 --- a/scene/resources/event_stream.h +++ /dev/null @@ -1,118 +0,0 @@ -/*************************************************************************/ -/* event_stream.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 EVENT_STREAM_H -#define EVENT_STREAM_H - -#include "resource.h" -#include "servers/audio_server.h" - -class EventStreamPlayback : public Reference { - - GDCLASS(EventStreamPlayback,Reference); - - class InternalEventStream : public AudioServer::EventStream { - public: - AudioMixer *_get_mixer(){ return get_mixer(); } - EventStreamPlayback *playback; - virtual void update(uint64_t p_usec) { - - playback->_update(get_mixer(),p_usec); - } - - - virtual ~InternalEventStream() {} - }; - - - InternalEventStream estream; - - RID stream; - bool playing; - - -protected: - - virtual AudioMixer* _get_mixer() { return estream._get_mixer(); } - virtual Error _play()=0; - virtual bool _update(AudioMixer* p_mixer, uint64_t p_usec)=0; - virtual void _stop()=0; -public: - - virtual Error play(); - virtual void stop(); - virtual bool is_playing() const; - - virtual void set_paused(bool p_paused)=0; - virtual bool is_paused() const=0; - - virtual void set_loop(bool p_loop)=0; - virtual bool is_loop_enabled() const=0; - - virtual int get_loop_count() const=0; - - virtual float get_pos() const=0; - virtual void seek_pos(float p_time)=0; - - virtual void set_volume(float p_vol)=0; - virtual float get_volume() const=0; - - virtual void set_pitch_scale(float p_pitch_scale)=0; - virtual float get_pitch_scale() const=0; - - virtual void set_tempo_scale(float p_tempo_scale)=0; - virtual float get_tempo_scale() const=0; - - virtual void set_channel_volume(int p_channel,float p_volume)=0; - virtual float get_channel_volume(int p_channel) const=0; - - virtual float get_last_note_time(int p_channel) const=0; - EventStreamPlayback(); - ~EventStreamPlayback(); - -}; - -class EventStream : public Resource { - - GDCLASS(EventStream,Resource); - OBJ_SAVE_TYPE( EventStream ); //children are all saved as EventStream, so they can be exchanged - -public: - - virtual Ref<EventStreamPlayback> instance_playback()=0; - - virtual String get_stream_name() const=0; - virtual float get_length() const=0; - virtual int get_channel_count() const=0; - - - - EventStream(); -}; - -#endif // EVENT_STREAM_H diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 5cefca348b..2707dd6198 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -332,7 +332,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { //remove nodes that could not be added, likely as a result that while(stray_instances.size()) { memdelete(stray_instances.front()->get()); - stray_instances.pop_front();; + stray_instances.pop_front(); } for(int i=0;i<editable_instances.size();i++) { diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp index 2156487407..568f086d34 100644 --- a/scene/resources/polygon_path_finder.cpp +++ b/scene/resources/polygon_path_finder.cpp @@ -419,7 +419,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector path.push_back(points[at].pos); } while (at!=aidx); - path.invert();; + path.invert(); } for(int i=0;i<points.size()-2;i++) { diff --git a/scene/resources/sample.cpp b/scene/resources/sample.cpp deleted file mode 100644 index e07e4d3767..0000000000 --- a/scene/resources/sample.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/*************************************************************************/ -/* sample.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "sample.h" - - -void Sample::_set_data(const Dictionary& p_data) { - - ERR_FAIL_COND(!p_data.has("packing")); - String packing = p_data["packing"]; - - if (packing=="raw") { - - ERR_FAIL_COND( !p_data.has("stereo")); - ERR_FAIL_COND( !p_data.has("format")); - ERR_FAIL_COND( !p_data.has("length")); - bool stereo=p_data["stereo"]; - int length=p_data["length"]; - Format fmt; - String fmtstr=p_data["format"]; - if (fmtstr=="pcm8") - fmt=FORMAT_PCM8; - else if (fmtstr=="pcm16") - fmt=FORMAT_PCM16; - else if (fmtstr=="ima_adpcm") - fmt=FORMAT_IMA_ADPCM; - else { - ERR_EXPLAIN("Invalid format for sample: "+fmtstr); - ERR_FAIL(); - } - - ERR_FAIL_COND(!p_data.has("data")); - - create(fmt,stereo,length); - set_data(p_data["data"]); - } else { - - ERR_EXPLAIN("Invalid packing for sample data: "+packing); - ERR_FAIL(); - } -} - -Dictionary Sample::_get_data() const { - - Dictionary d; - switch(get_format()) { - - case FORMAT_PCM8: d["format"]="pcm8"; break; - case FORMAT_PCM16: d["format"]="pcm16"; break; - case FORMAT_IMA_ADPCM: d["format"]="ima_adpcm"; break; - } - - d["stereo"]=is_stereo(); - d["length"]=get_length(); - d["packing"]="raw"; - d["data"]=get_data(); - return d; - -} - -void Sample::create(Format p_format, bool p_stereo, int p_length) { - - if (p_length<1) - return; - - if (sample.is_valid()) - AudioServer::get_singleton()->free(sample); - - - mix_rate=44100; - stereo=p_stereo; - length=p_length; - format=p_format; - loop_format=LOOP_NONE; - loop_begin=0; - loop_end=0; - - sample=AudioServer::get_singleton()->sample_create((AudioServer::SampleFormat)p_format,p_stereo,p_length); -} - - -Sample::Format Sample::get_format() const { - - return format; -} -bool Sample::is_stereo() const { - - - return stereo; -} -int Sample::get_length() const { - - - return length; -} - -void Sample::set_data(const PoolVector<uint8_t>& p_buffer) { - - if (sample.is_valid()) - AudioServer::get_singleton()->sample_set_data(sample,p_buffer); - -} -PoolVector<uint8_t> Sample::get_data() const { - - if (sample.is_valid()) - return AudioServer::get_singleton()->sample_get_data(sample); - - return PoolVector<uint8_t>(); - -} - -void Sample::set_mix_rate(int p_rate) { - - mix_rate=p_rate; - if (sample.is_valid()) - return AudioServer::get_singleton()->sample_set_mix_rate(sample,mix_rate); - -} -int Sample::get_mix_rate() const { - - return mix_rate; -} - -void Sample::set_loop_format(LoopFormat p_format) { - - if (sample.is_valid()) - AudioServer::get_singleton()->sample_set_loop_format(sample,(AudioServer::SampleLoopFormat)p_format); - loop_format=p_format; -} - -Sample::LoopFormat Sample::get_loop_format() const { - - return loop_format; -} - -void Sample::set_loop_begin(int p_pos) { - - if (sample.is_valid()) - AudioServer::get_singleton()->sample_set_loop_begin(sample,p_pos); - loop_begin=p_pos; - -} -int Sample::get_loop_begin() const { - - return loop_begin; -} - -void Sample::set_loop_end(int p_pos) { - - if (sample.is_valid()) - AudioServer::get_singleton()->sample_set_loop_end(sample,p_pos); - loop_end=p_pos; -} - -int Sample::get_loop_end() const { - - return loop_end; -} - -RID Sample::get_rid() const { - - return sample; -} - - - -void Sample::_bind_methods(){ - - - ClassDB::bind_method(_MD("create","format","stereo","length"),&Sample::create); - ClassDB::bind_method(_MD("get_format"),&Sample::get_format); - ClassDB::bind_method(_MD("is_stereo"),&Sample::is_stereo); - ClassDB::bind_method(_MD("get_length"),&Sample::get_length); - ClassDB::bind_method(_MD("set_data","data"),&Sample::set_data); - ClassDB::bind_method(_MD("get_data"),&Sample::get_data); - ClassDB::bind_method(_MD("set_mix_rate","hz"),&Sample::set_mix_rate); - ClassDB::bind_method(_MD("get_mix_rate"),&Sample::get_mix_rate); - ClassDB::bind_method(_MD("set_loop_format","format"),&Sample::set_loop_format); - ClassDB::bind_method(_MD("get_loop_format"),&Sample::get_loop_format); - ClassDB::bind_method(_MD("set_loop_begin","pos"),&Sample::set_loop_begin); - ClassDB::bind_method(_MD("get_loop_begin"),&Sample::get_loop_begin); - ClassDB::bind_method(_MD("set_loop_end","pos"),&Sample::set_loop_end); - ClassDB::bind_method(_MD("get_loop_end"),&Sample::get_loop_end); - - ClassDB::bind_method(_MD("_set_data"),&Sample::_set_data); - ClassDB::bind_method(_MD("_get_data"),&Sample::_get_data); - - ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"), _SCS("_get_data") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "stereo"), _SCS(""), _SCS("is_stereo") ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "length",PROPERTY_HINT_RANGE,"0,999999999"), _SCS(""), _SCS("get_length") ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "mix_rate", PROPERTY_HINT_RANGE,"1,192000,1" ), _SCS("set_mix_rate"), _SCS("get_mix_rate") ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "loop_format", PROPERTY_HINT_ENUM,"None,Forward,PingPong" ), _SCS("set_loop_format"), _SCS("get_loop_format") ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "loop_begin", PROPERTY_HINT_RANGE,"0,"+itos(999999999)+",1"), _SCS("set_loop_begin"), _SCS("get_loop_begin") ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "loop_end", PROPERTY_HINT_RANGE,"0,"+itos(999999999)+",1"), _SCS("set_loop_end"), _SCS("get_loop_end") ); - - BIND_CONSTANT( FORMAT_PCM8 ); - BIND_CONSTANT( FORMAT_PCM16 ); - BIND_CONSTANT( FORMAT_IMA_ADPCM ); - - BIND_CONSTANT( LOOP_NONE ); - BIND_CONSTANT( LOOP_FORWARD ); - BIND_CONSTANT( LOOP_PING_PONG ); - -} - -Sample::Sample() { - - format=FORMAT_PCM8; - length=0; - stereo=false; - - loop_format=LOOP_NONE; - loop_begin=0; - loop_end=0; - mix_rate=44100; - -} - -Sample::~Sample() { - - if (sample.is_valid()) - AudioServer::get_singleton()->free(sample); -} diff --git a/scene/resources/sample.h b/scene/resources/sample.h deleted file mode 100644 index be2cf67954..0000000000 --- a/scene/resources/sample.h +++ /dev/null @@ -1,108 +0,0 @@ -/*************************************************************************/ -/* sample.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SAMPLE_H -#define SAMPLE_H - -#include "servers/audio_server.h" -#include "resource.h" - -class Sample : public Resource { - - GDCLASS(Sample, Resource ); - RES_BASE_EXTENSION("smp"); -public: - - enum Format { - - FORMAT_PCM8, - FORMAT_PCM16, - FORMAT_IMA_ADPCM - }; - - enum LoopFormat { - LOOP_NONE, - LOOP_FORWARD, - LOOP_PING_PONG // not supported in every platform - - }; - -private: - - Format format; - int length; - bool stereo; - - LoopFormat loop_format; - int loop_begin; - int loop_end; - int mix_rate; - - RID sample; - - - void _set_data(const Dictionary& p_data); - Dictionary _get_data() const; - -protected: - - static void _bind_methods(); - -public: - - - void create(Format p_format, bool p_stereo, int p_length); - - Format get_format() const; - bool is_stereo() const; - int get_length() const; - - void set_data(const PoolVector<uint8_t>& p_buffer); - PoolVector<uint8_t> get_data() const; - - void set_mix_rate(int p_rate); - int get_mix_rate() const; - - void set_loop_format(LoopFormat p_format); - LoopFormat get_loop_format() const; - - void set_loop_begin(int p_pos); - int get_loop_begin() const; - - void set_loop_end(int p_pos); - int get_loop_end() const; - - virtual RID get_rid() const; - Sample(); - ~Sample(); -}; - -VARIANT_ENUM_CAST( Sample::Format ); -VARIANT_ENUM_CAST( Sample::LoopFormat ); - -#endif // SAMPLE_H diff --git a/scene/resources/sample_library.cpp b/scene/resources/sample_library.cpp deleted file mode 100644 index 44895df8fa..0000000000 --- a/scene/resources/sample_library.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/*************************************************************************/ -/* sample_library.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "sample_library.h" - - -bool SampleLibrary::_set(const StringName& p_name, const Variant& p_value) { - - - if (String(p_name).begins_with("samples/")) { - - String name=String(p_name).get_slicec('/',1); - if (p_value.get_type()==Variant::NIL) - sample_map.erase(name); - else { - SampleData sd; - - if (p_value.get_type()==Variant::OBJECT) - sd.sample=p_value; - else if (p_value.get_type()==Variant::DICTIONARY) { - - Dictionary d = p_value; - ERR_FAIL_COND_V(!d.has("sample"),false); - ERR_FAIL_COND_V(!d.has("pitch"),false); - ERR_FAIL_COND_V(!d.has("db"),false); - sd.sample=d["sample"]; - sd.pitch_scale=d["pitch"]; - sd.db=d["db"]; - } - - sample_map[name]=sd; - } - - return true; - } - - return false; -} - -bool SampleLibrary::_get(const StringName& p_name,Variant &r_ret) const { - - if (String(p_name).begins_with("samples/")) { - - String name=String(p_name).get_slicec('/',1); - if(sample_map.has(name)) { - Dictionary d; - d["sample"]=sample_map[name].sample; - d["pitch"]=sample_map[name].pitch_scale; - d["db"]=sample_map[name].db; - r_ret=d; - } else { - return false; - } - - return true; - } - - return false; - - -} - -void SampleLibrary::add_sample(const StringName& p_name, const Ref<Sample>& p_sample) { - - ERR_FAIL_COND(p_sample.is_null()); - - SampleData sd; - sd.sample=p_sample; - sample_map[p_name]=sd; -} - -Ref<Sample> SampleLibrary::get_sample(const StringName& p_name) const { - - ERR_FAIL_COND_V(!sample_map.has(p_name),Ref<Sample>()); - - return sample_map[p_name].sample; -} - -void SampleLibrary::remove_sample(const StringName& p_name) { - - sample_map.erase(p_name); -} - -void SampleLibrary::get_sample_list(List<StringName> *p_samples) const { - - for(const Map<StringName,SampleData >::Element *E=sample_map.front();E;E=E->next()) { - - p_samples->push_back(E->key()); - } - -} - -bool SampleLibrary::has_sample(const StringName& p_name) const { - - return sample_map.has(p_name); -} - -void SampleLibrary::_get_property_list(List<PropertyInfo> *p_list) const { - - - List<PropertyInfo> tpl; - for(Map<StringName,SampleData>::Element *E=sample_map.front();E;E=E->next()) { - - tpl.push_back( PropertyInfo( Variant::DICTIONARY, "samples/"+E->key(),PROPERTY_HINT_RESOURCE_TYPE,"Sample",PROPERTY_USAGE_NOEDITOR ) ); - } - - tpl.sort(); - //sort so order is kept - for(List<PropertyInfo>::Element *E=tpl.front();E;E=E->next()) { - p_list->push_back(E->get()); - } -} - -StringName SampleLibrary::get_sample_idx(int p_idx) const { - - int idx=0; - for (Map<StringName, SampleData >::Element *E=sample_map.front();E;E=E->next()) { - - if (p_idx==idx) - return E->key(); - idx++; - } - - return ""; -} - -void SampleLibrary::sample_set_volume_db(const StringName& p_name, float p_db) { - - ERR_FAIL_COND( !sample_map.has(p_name) ); - sample_map[p_name].db=p_db; - -} - -float SampleLibrary::sample_get_volume_db(const StringName& p_name) const{ - - ERR_FAIL_COND_V( !sample_map.has(p_name),0 ); - - return sample_map[p_name].db; -} - -void SampleLibrary::sample_set_pitch_scale(const StringName& p_name, float p_pitch){ - - ERR_FAIL_COND( !sample_map.has(p_name) ); - - sample_map[p_name].pitch_scale=p_pitch; -} - -float SampleLibrary::sample_get_pitch_scale(const StringName& p_name) const{ - - ERR_FAIL_COND_V( !sample_map.has(p_name),0 ); - - return sample_map[p_name].pitch_scale; -} - -Array SampleLibrary::_get_sample_list() const { - - List<StringName> snames; - get_sample_list(&snames); - - snames.sort_custom<StringName::AlphCompare>(); - - Array ret; - for (List<StringName>::Element *E=snames.front();E;E=E->next()) { - ret.push_back(E->get()); - } - - return ret; -} - -void SampleLibrary::_bind_methods() { - - ClassDB::bind_method(_MD("add_sample","name","sample:Sample"),&SampleLibrary::add_sample ); - ClassDB::bind_method(_MD("get_sample:Sample","name"),&SampleLibrary::get_sample ); - ClassDB::bind_method(_MD("has_sample","name"),&SampleLibrary::has_sample ); - ClassDB::bind_method(_MD("remove_sample","name"),&SampleLibrary::remove_sample ); - - ClassDB::bind_method(_MD("get_sample_list"),&SampleLibrary::_get_sample_list ); - - ClassDB::bind_method(_MD("sample_set_volume_db","name","db"),&SampleLibrary::sample_set_volume_db ); - ClassDB::bind_method(_MD("sample_get_volume_db","name"),&SampleLibrary::sample_get_volume_db ); - - ClassDB::bind_method(_MD("sample_set_pitch_scale","name","pitch"),&SampleLibrary::sample_set_pitch_scale ); - ClassDB::bind_method(_MD("sample_get_pitch_scale","name"),&SampleLibrary::sample_get_pitch_scale ); - - -} - -SampleLibrary::SampleLibrary() -{ -} diff --git a/scene/resources/sample_library.h b/scene/resources/sample_library.h deleted file mode 100644 index d09eea64c5..0000000000 --- a/scene/resources/sample_library.h +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************/ -/* sample_library.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SAMPLE_LIBRARY_H -#define SAMPLE_LIBRARY_H - -#include "resource.h" -#include "scene/resources/sample.h" -#include "map.h" - -class SampleLibrary : public Resource { - - GDCLASS(SampleLibrary,Resource); - - struct SampleData { - - Ref<Sample> sample; - float db; - float pitch_scale; - - SampleData() { db=0; pitch_scale=1; } - }; - - Map<StringName,SampleData > sample_map; - - Array _get_sample_list() const; -protected: - - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; - void _get_property_list(List<PropertyInfo> *p_list) const; - - static void _bind_methods(); - -public: - - - - void add_sample(const StringName& p_name, const Ref<Sample>& p_sample); - bool has_sample(const StringName& p_name) const; - void sample_set_volume_db(const StringName& p_name, float p_db); - float sample_get_volume_db(const StringName& p_name) const; - void sample_set_pitch_scale(const StringName& p_name, float p_pitch); - float sample_get_pitch_scale(const StringName& p_name) const; - Ref<Sample> get_sample(const StringName& p_name) const; - void get_sample_list(List<StringName> *p_samples) const; - void remove_sample(const StringName& p_name); - StringName get_sample_idx(int p_idx) const; - - SampleLibrary(); -}; - -#endif // SAMPLE_LIBRARY_H diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 10f852f17c..22ee253b1a 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -1993,8 +1993,7 @@ void ShaderGraph::_plot_curve(const Vector2& p_a,const Vector2& p_b,const Vector /* compose the basis and geometry matrices */ - static const float CR_basis[4][4] = - { + static const float CR_basis[4][4] = { { -0.5, 1.5, -1.5, 0.5 }, { 1.0, -2.5, 2.0, -0.5 }, { -0.5, 0.0, 0.5, 0.0 }, @@ -2161,7 +2160,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str case SCALAR_OP_ATAN2: optxt = "atan2("+p_inputs[0]+","+p_inputs[1]+");"; break; } - code+=OUTNAME(p_node->id,0)+"="+optxt+"\n";; + code+=OUTNAME(p_node->id,0)+"="+optxt+"\n"; }break; case NODE_VEC_OP: { @@ -2364,7 +2363,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str code+="\t"+OUTVAR(p_node->id,0)+"=vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n"; code+="}\n"; } else if (func==VEC_FUNC_HSV2RGB) { - code += OUTNAME(p_node->id,0)+";\n";; + code += OUTNAME(p_node->id,0)+";\n"; code+="{\n"; code+="\tvec3 c = "+p_inputs[0]+";\n"; code+="\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n"; diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 27cc7e131b..1d0d323546 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -852,7 +852,7 @@ void SurfaceTool::clear() { begun=false; primitive=Mesh::PRIMITIVE_LINES; format=0; - last_bones.clear();; + last_bones.clear(); last_weights.clear(); index_array.clear(); vertex_array.clear(); diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index d950407f54..4793f8143b 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -233,7 +233,7 @@ void Theme::set_default_theme_font( const Ref<Font>& p_default_font ) { } _change_notify(); - emit_changed();; + emit_changed(); } @@ -275,7 +275,7 @@ void Theme::set_icon(const StringName& p_name,const StringName& p_type,const Ref if (new_value) { _change_notify(); - emit_changed();; + emit_changed(); } } Ref<Texture> Theme::get_icon(const StringName& p_name,const StringName& p_type) const { @@ -301,7 +301,7 @@ void Theme::clear_icon(const StringName& p_name,const StringName& p_type) { icon_map[p_type].erase(p_name); _change_notify(); - emit_changed();; + emit_changed(); } @@ -326,7 +326,7 @@ void Theme::set_shader(const StringName &p_name,const StringName &p_type,const R if (new_value) { _change_notify(); - emit_changed();; + emit_changed(); } } @@ -348,7 +348,7 @@ void Theme::clear_shader(const StringName &p_name, const StringName &p_type) { shader_map[p_type].erase(p_name); _change_notify(); - emit_changed();; + emit_changed(); } void Theme::get_shader_list(const StringName &p_type, List<StringName> *p_list) const { @@ -375,7 +375,7 @@ void Theme::set_stylebox(const StringName& p_name,const StringName& p_type,const if (new_value) _change_notify(); - emit_changed();; + emit_changed(); } @@ -403,7 +403,7 @@ void Theme::clear_stylebox(const StringName& p_name,const StringName& p_type) { style_map[p_type].erase(p_name); _change_notify(); - emit_changed();; + emit_changed(); } @@ -447,7 +447,7 @@ void Theme::set_font(const StringName& p_name,const StringName& p_type,const Ref if (new_value) { _change_notify(); - emit_changed();; + emit_changed(); } } Ref<Font> Theme::get_font(const StringName& p_name,const StringName& p_type) const { @@ -477,7 +477,7 @@ void Theme::clear_font(const StringName& p_name,const StringName& p_type) { font_map[p_type].erase(p_name); _change_notify(); - emit_changed();; + emit_changed(); } @@ -503,7 +503,7 @@ void Theme::set_color(const StringName& p_name,const StringName& p_type,const Co if (new_value) { _change_notify(); - emit_changed();; + emit_changed(); } } @@ -531,7 +531,7 @@ void Theme::clear_color(const StringName& p_name,const StringName& p_type) { color_map[p_type].erase(p_name); _change_notify(); - emit_changed();; + emit_changed(); } @@ -556,7 +556,7 @@ void Theme::set_constant(const StringName& p_name,const StringName& p_type,int p if (new_value) { _change_notify(); - emit_changed();; + emit_changed(); } } @@ -582,7 +582,7 @@ void Theme::clear_constant(const StringName& p_name,const StringName& p_type) { constant_map[p_type].erase(p_name); _change_notify(); - emit_changed();; + emit_changed(); } @@ -611,7 +611,7 @@ void Theme::copy_default_theme() { color_map=default_theme->color_map; constant_map=default_theme->constant_map; _change_notify(); - emit_changed();; + emit_changed(); } diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp index 3f7261c312..72cb8cc906 100644 --- a/scene/resources/world.cpp +++ b/scene/resources/world.cpp @@ -287,10 +287,6 @@ RID World::get_scenario() const{ return scenario; } -RID World::get_sound_space() const{ - - return sound_space; -} void World::set_environment(const Ref<Environment>& p_environment) { @@ -316,7 +312,6 @@ void World::_bind_methods() { ClassDB::bind_method(_MD("get_space"),&World::get_space); ClassDB::bind_method(_MD("get_scenario"),&World::get_scenario); - ClassDB::bind_method(_MD("get_sound_space"),&World::get_sound_space); ClassDB::bind_method(_MD("set_environment","env:Environment"),&World::set_environment); ClassDB::bind_method(_MD("get_environment:Environment"),&World::get_environment); ClassDB::bind_method(_MD("get_direct_space_state:PhysicsDirectSpaceState"),&World::get_direct_space_state); @@ -329,7 +324,6 @@ World::World() { space = PhysicsServer::get_singleton()->space_create(); scenario = VisualServer::get_singleton()->scenario_create(); - sound_space = SpatialSoundServer::get_singleton()->space_create(); PhysicsServer::get_singleton()->space_set_active(space,true); PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_GRAVITY,GLOBAL_DEF("physics/3d/default_gravity",9.8)); @@ -348,7 +342,6 @@ World::~World() { PhysicsServer::get_singleton()->free(space); VisualServer::get_singleton()->free(scenario); - SpatialSoundServer::get_singleton()->free(sound_space); #ifndef _3D_DISABLED memdelete( indexer ); diff --git a/scene/resources/world.h b/scene/resources/world.h index bea07882d7..1ad60f3405 100644 --- a/scene/resources/world.h +++ b/scene/resources/world.h @@ -32,7 +32,6 @@ #include "resource.h" #include "servers/physics_server.h" #include "servers/visual_server.h" -#include "servers/spatial_sound_server.h" #include "scene/resources/environment.h" class SpatialIndexer; @@ -45,7 +44,6 @@ class World : public Resource { private: RID space; RID scenario; - RID sound_space; SpatialIndexer* indexer; Ref<Environment> environment; @@ -71,7 +69,6 @@ public: RID get_space() const; RID get_scenario() const; - RID get_sound_space() const; void set_environment(const Ref<Environment>& p_environment); Ref<Environment> get_environment() const; diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index a8a87543c6..d4eff8d2b3 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -29,7 +29,7 @@ #include "world_2d.h" #include "servers/visual_server.h" #include "servers/physics_2d_server.h" -#include "servers/spatial_sound_2d_server.h" +//#include "servers/spatial_sound_2d_server.h" #include "globals.h" #include "scene/2d/visibility_notifier_2d.h" #include "scene/main/viewport.h" @@ -400,7 +400,6 @@ World2D::World2D() { canvas = VisualServer::get_singleton()->canvas_create(); space = Physics2DServer::get_singleton()->space_create(); - sound_space = SpatialSound2DServer::get_singleton()->space_create(); //set space2D to be more friendly with pixels than meters, by adjusting some constants Physics2DServer::get_singleton()->space_set_active(space,true); @@ -417,6 +416,5 @@ World2D::~World2D() { VisualServer::get_singleton()->free(canvas); Physics2DServer::get_singleton()->free(space); - SpatialSound2DServer::get_singleton()->free(sound_space); memdelete(indexer); } diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp index 6fe14b0fcb..6e0c0089ca 100644 --- a/servers/audio/audio_driver_dummy.cpp +++ b/servers/audio/audio_driver_dummy.cpp @@ -43,7 +43,7 @@ Error AudioDriverDummy::init() { mix_rate = 44100; - output_format = OUTPUT_STEREO; + speaker_mode = SPEAKER_MODE_STEREO; channels = 2; int latency = GLOBAL_DEF("audio/output_latency",25); @@ -97,16 +97,18 @@ int AudioDriverDummy::get_mix_rate() const { return mix_rate; }; -AudioDriverSW::OutputFormat AudioDriverDummy::get_output_format() const { +AudioDriver::SpeakerMode AudioDriverDummy::get_speaker_mode() const { - return output_format; + return speaker_mode; }; + void AudioDriverDummy::lock() { if (!thread || !mutex) return; mutex->lock(); }; + void AudioDriverDummy::unlock() { if (!thread || !mutex) diff --git a/servers/audio/audio_driver_dummy.h b/servers/audio/audio_driver_dummy.h index c91a0db43a..78ec41ea09 100644 --- a/servers/audio/audio_driver_dummy.h +++ b/servers/audio/audio_driver_dummy.h @@ -29,13 +29,13 @@ #ifndef AUDIO_DRIVER_DUMMY_H #define AUDIO_DRIVER_DUMMY_H -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include "core/os/thread.h" #include "core/os/mutex.h" -class AudioDriverDummy : public AudioDriverSW { +class AudioDriverDummy : public AudioDriver { Thread* thread; Mutex* mutex; @@ -46,7 +46,7 @@ class AudioDriverDummy : public AudioDriverSW { int buffer_size; unsigned int mix_rate; - OutputFormat output_format; + SpeakerMode speaker_mode; int channels; @@ -64,7 +64,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/servers/audio/audio_effect.cpp b/servers/audio/audio_effect.cpp new file mode 100644 index 0000000000..372c0cbc13 --- /dev/null +++ b/servers/audio/audio_effect.cpp @@ -0,0 +1,6 @@ +#include "audio_effect.h" + +AudioEffect::AudioEffect() +{ + +} diff --git a/servers/audio/audio_effect.h b/servers/audio/audio_effect.h new file mode 100644 index 0000000000..2fcd22251b --- /dev/null +++ b/servers/audio/audio_effect.h @@ -0,0 +1,26 @@ +#ifndef AUDIOEFFECT_H +#define AUDIOEFFECT_H + +#include "audio_frame.h" +#include "resource.h" + + +class AudioEffectInstance : public Reference { + GDCLASS(AudioEffectInstance,Reference) + +public: + + virtual void process(AudioFrame *p_frames,int p_frame_count)=0; + +}; + + +class AudioEffect : public Resource { + GDCLASS(AudioEffect,Resource) +public: + + virtual Ref<AudioEffectInstance> instance()=0; + AudioEffect(); +}; + +#endif // AUDIOEFFECT_H diff --git a/servers/audio/audio_mixer_sw.cpp b/servers/audio/audio_mixer_sw.cpp deleted file mode 100644 index 0123b66430..0000000000 --- a/servers/audio/audio_mixer_sw.cpp +++ /dev/null @@ -1,1222 +0,0 @@ -/*************************************************************************/ -/* audio_mixer_sw.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "audio_mixer_sw.h" -#include "print_string.h" -#include "os/os.h" -//TODO implement FAST_AUDIO macro - -#ifdef FAST_AUDIO -#define NO_REVERB -#endif - -template<class Depth,bool is_stereo,bool is_ima_adpcm,bool use_filter,bool use_fx,AudioMixerSW::InterpolationType type,AudioMixerSW::MixChannels mix_mode> -void AudioMixerSW::do_resample(const Depth* p_src, int32_t *p_dst, ResamplerState *p_state) { - - // this function will be compiled branchless by any decent compiler - - int32_t final,final_r,next,next_r; - int32_t *reverb_dst = p_state->reverb_buffer; - while (p_state->amount--) { - - int32_t pos=p_state->pos >> MIX_FRAC_BITS; - if (is_stereo && !is_ima_adpcm) - pos<<=1; - - if (is_ima_adpcm) { - - int sample_pos = pos + p_state->ima_adpcm[0].window_ofs; - - while(sample_pos>p_state->ima_adpcm[0].last_nibble) { - - - static const int16_t _ima_adpcm_step_table[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 - }; - - static const int8_t _ima_adpcm_index_table[16] = { - -1, -1, -1, -1, 2, 4, 6, 8, - -1, -1, -1, -1, 2, 4, 6, 8 - }; - - for(int i=0;i<(is_stereo?2:1);i++) { - - - int16_t nibble,diff,step; - - p_state->ima_adpcm[i].last_nibble++; - const uint8_t *src_ptr=p_state->ima_adpcm[i].ptr; - - - uint8_t nbb = src_ptr[ (p_state->ima_adpcm[i].last_nibble>>1) * (is_stereo?2:1) + i ]; - nibble = (p_state->ima_adpcm[i].last_nibble&1)?(nbb>>4):(nbb&0xF); - step=_ima_adpcm_step_table[p_state->ima_adpcm[i].step_index]; - - - p_state->ima_adpcm[i].step_index += _ima_adpcm_index_table[nibble]; - if (p_state->ima_adpcm[i].step_index<0) - p_state->ima_adpcm[i].step_index=0; - if (p_state->ima_adpcm[i].step_index>88) - p_state->ima_adpcm[i].step_index=88; - - diff = step >> 3 ; - if (nibble & 1) - diff += step >> 2 ; - if (nibble & 2) - diff += step >> 1 ; - if (nibble & 4) - diff += step ; - if (nibble & 8) - diff = -diff ; - - p_state->ima_adpcm[i].predictor+=diff; - if (p_state->ima_adpcm[i].predictor<-0x8000) - p_state->ima_adpcm[i].predictor=-0x8000; - else if (p_state->ima_adpcm[i].predictor>0x7FFF) - p_state->ima_adpcm[i].predictor=0x7FFF; - - - /* store loop if there */ - if (p_state->ima_adpcm[i].last_nibble==p_state->ima_adpcm[i].loop_pos) { - - p_state->ima_adpcm[i].loop_step_index = p_state->ima_adpcm[i].step_index; - p_state->ima_adpcm[i].loop_predictor = p_state->ima_adpcm[i].predictor; - } - - //printf("%i - %i - pred %i\n",int(p_state->ima_adpcm[i].last_nibble),int(nibble),int(p_state->ima_adpcm[i].predictor)); - - } - - } - - final=p_state->ima_adpcm[0].predictor; - if (is_stereo) { - final_r=p_state->ima_adpcm[1].predictor; - } - - } else { - final=p_src[pos]; - if (is_stereo) - final_r=p_src[pos+1]; - - if (sizeof(Depth)==1) { /* conditions will not exist anymore when compiled! */ - final<<=8; - if (is_stereo) - final_r<<=8; - } - - if (type==INTERPOLATION_LINEAR) { - - if (is_stereo) { - - next=p_src[pos+2]; - next_r=p_src[pos+3]; - } else { - next=p_src[pos+1]; - } - - if (sizeof(Depth)==1) { - next<<=8; - if (is_stereo) - next_r<<=8; - } - - int32_t frac=int32_t(p_state->pos&MIX_FRAC_MASK); - - final=final+((next-final)*frac >> MIX_FRAC_BITS); - if (is_stereo) - final_r=final_r+((next_r-final_r)*frac >> MIX_FRAC_BITS); - } - } - - if (use_filter) { - - Channel::Mix::Filter *f = p_state->filter_l; - float finalf=final; - float pre = finalf; - finalf = ((finalf*p_state->coefs.b0) + (f->hb[0]*p_state->coefs.b1) + (f->hb[1]*p_state->coefs.b2) + (f->ha[0]*p_state->coefs.a1) + (f->ha[1]*p_state->coefs.a2) - ); - - f->ha[1]=f->ha[0]; - f->hb[1]=f->hb[0]; - f->hb[0]=pre; - f->ha[0]=finalf; - - final=Math::fast_ftoi(finalf); - - if (is_stereo) { - - f = p_state->filter_r; - finalf=final_r; - pre = finalf; - finalf = ((finalf*p_state->coefs.b0) + (f->hb[0]*p_state->coefs.b1) + (f->hb[1]*p_state->coefs.b2) + (f->ha[0]*p_state->coefs.a1) + (f->ha[1]*p_state->coefs.a2) - ); - f->ha[1]=f->ha[0]; - f->hb[1]=f->hb[0]; - f->hb[0]=pre; - f->ha[0]=finalf; - - final_r=Math::fast_ftoi(finalf); - - } - - p_state->coefs.b0+=p_state->coefs_inc.b0; - p_state->coefs.b1+=p_state->coefs_inc.b1; - p_state->coefs.b2+=p_state->coefs_inc.b2; - p_state->coefs.a1+=p_state->coefs_inc.a1; - p_state->coefs.a2+=p_state->coefs_inc.a2; - } - - if (!is_stereo) { - final_r=final; //copy to right channel if stereo - } - - //convert back to 24 bits and mix to buffers - - if (mix_mode==MIX_STEREO) { - *p_dst++ +=(final*(p_state->vol[0]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - *p_dst++ +=(final_r*(p_state->vol[1]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - - p_state->vol[0]+=p_state->vol_inc[0]; - p_state->vol[1]+=p_state->vol_inc[1]; - - if (use_fx) { - *reverb_dst++ +=(final*(p_state->reverb_vol[0]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - *reverb_dst++ +=(final_r*(p_state->reverb_vol[1]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - p_state->reverb_vol[0]+=p_state->reverb_vol_inc[0]; - p_state->reverb_vol[1]+=p_state->reverb_vol_inc[1]; - } - - - } else if (mix_mode==MIX_QUAD) { - - *p_dst++ +=(final*(p_state->vol[0]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - *p_dst++ +=(final_r*(p_state->vol[1]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - - *p_dst++ +=(final*(p_state->vol[2]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - *p_dst++ +=(final_r*(p_state->vol[3]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - - p_state->vol[0]+=p_state->vol_inc[0]; - p_state->vol[1]+=p_state->vol_inc[1]; - p_state->vol[2]+=p_state->vol_inc[2]; - p_state->vol[3]+=p_state->vol_inc[3]; - - if (use_fx) { - *reverb_dst++ +=(final*(p_state->reverb_vol[0]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - *reverb_dst++ +=(final_r*(p_state->reverb_vol[1]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - *reverb_dst++ +=(final*(p_state->reverb_vol[2]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - *reverb_dst++ +=(final_r*(p_state->reverb_vol[3]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24; - p_state->reverb_vol[0]+=p_state->reverb_vol_inc[0]; - p_state->reverb_vol[1]+=p_state->reverb_vol_inc[1]; - p_state->reverb_vol[2]+=p_state->reverb_vol_inc[2]; - p_state->reverb_vol[3]+=p_state->reverb_vol_inc[3]; - } - } - - p_state->pos+=p_state->increment; - } -} - - -void AudioMixerSW::mix_channel(Channel& c) { - - - if (!sample_manager->is_sample(c.sample)) { - // sample is gone! - c.active=false; - return; - } - - - /* some 64-bit fixed point precaches */ - - int64_t loop_begin_fp=((int64_t)sample_manager->sample_get_loop_begin(c.sample) << MIX_FRAC_BITS); - int64_t loop_end_fp=((int64_t)sample_manager->sample_get_loop_end(c.sample) << MIX_FRAC_BITS); - int64_t length_fp=((int64_t)sample_manager->sample_get_length(c.sample) << MIX_FRAC_BITS); - int64_t begin_limit=(sample_manager->sample_get_loop_format(c.sample)!=AS::SAMPLE_LOOP_NONE)?loop_begin_fp:0; - int64_t end_limit=(sample_manager->sample_get_loop_format(c.sample)!=AS::SAMPLE_LOOP_NONE)?loop_end_fp:length_fp; - bool is_stereo=sample_manager->sample_is_stereo(c.sample); - - int32_t todo=mix_chunk_size; - //int mixed=0; - bool use_filter=false; - - ResamplerState rstate; - - /* compute voume ramps, increment, etc */ - - - - for(int i=0;i<mix_channels;i++) { - c.mix.old_vol[i]=c.mix.vol[i]; - c.mix.old_reverb_vol[i]=c.mix.reverb_vol[i]; - c.mix.old_chorus_vol[i]=c.mix.chorus_vol[i]; - } - - float vol = c.vol*channel_nrg; - - float reverb_vol = c.reverb_send*channel_nrg; - float chorus_vol = c.chorus_send*channel_nrg; - - if (mix_channels==2) { - //stereo pan - float pan = c.pan * 0.5 + 0.5; - float panv[2]={ - (1.0 - pan)*(1<<MIX_VOL_FRAC_BITS), - (pan)*(1<<MIX_VOL_FRAC_BITS) - }; - - for(int i=0;i<2;i++) { - - c.mix.vol[i]=Math::fast_ftoi(vol*panv[i]); - c.mix.reverb_vol[i]=Math::fast_ftoi(reverb_vol*panv[i]); - c.mix.chorus_vol[i]=Math::fast_ftoi(chorus_vol*panv[i]); - } - - } else { - //qudra pan - float panx = c.pan * 0.5 + 0.5; - float pany = c.depth * 0.5 + 0.5; - // with this model every speaker plays at 0.25 energy at the center.. i'm not sure if it's correct but it seems to be balanced - float panv[4]={ - (1.0-pany)*(1.0-panx)*(1<<MIX_VOL_FRAC_BITS), - (1.0-pany)*( panx)*(1<<MIX_VOL_FRAC_BITS), - ( pany)*(1.0-panx)*(1<<MIX_VOL_FRAC_BITS), - ( pany)*( panx)*(1<<MIX_VOL_FRAC_BITS) - }; - - for(int i=0;i<4;i++) { - - c.mix.vol[i]=Math::fast_ftoi(vol*panv[i]); - c.mix.reverb_vol[i]=Math::fast_ftoi(reverb_vol*panv[i]); - c.mix.chorus_vol[i]=Math::fast_ftoi(chorus_vol*panv[i]); - } - - } - - if (c.first_mix) { // avoid ramp up - - for(int i=0;i<mix_channels;i++) { - c.mix.old_vol[i]=c.mix.vol[i]; - c.mix.old_reverb_vol[i]=c.mix.reverb_vol[i]; - c.mix.old_chorus_vol[i]=c.mix.chorus_vol[i]; - } - - c.first_mix=false; - } - - - - Channel::Filter::Coefs filter_coefs; - Channel::Filter::Coefs filter_inc; - - if (c.filter.type!=AudioMixer::FILTER_NONE) { - - filter_coefs=c.filter.old_coefs; - filter_inc.b0=(c.filter.coefs.b0-filter_coefs.b0)/(1<<mix_chunk_bits); - filter_inc.b1=(c.filter.coefs.b1-filter_coefs.b1)/(1<<mix_chunk_bits); - filter_inc.b2=(c.filter.coefs.b2-filter_coefs.b2)/(1<<mix_chunk_bits); - filter_inc.a1=(c.filter.coefs.a1-filter_coefs.a1)/(1<<mix_chunk_bits); - filter_inc.a2=(c.filter.coefs.a2-filter_coefs.a2)/(1<<mix_chunk_bits); - use_filter=true; - } - - if (c.mix.increment>0) - c.mix.increment=((int64_t)c.speed<<MIX_FRAC_BITS)/mix_rate; - else - c.mix.increment=-((int64_t)c.speed<<MIX_FRAC_BITS)/mix_rate; - - //volume ramp - - - for(int i=0;i<mix_channels;i++) { - rstate.vol_inc[i]=((c.mix.vol[i]-c.mix.old_vol[i])<<MIX_VOLRAMP_FRAC_BITS)>>mix_chunk_bits; - rstate.vol[i]=c.mix.old_vol[i]<<MIX_VOLRAMP_FRAC_BITS; - rstate.reverb_vol_inc[i]=((c.mix.reverb_vol[i]-c.mix.old_reverb_vol[i])<<MIX_VOLRAMP_FRAC_BITS)>>mix_chunk_bits; - rstate.reverb_vol[i]=c.mix.old_reverb_vol[i]<<MIX_VOLRAMP_FRAC_BITS; - rstate.chorus_vol_inc[i]=((c.mix.chorus_vol[i]-c.mix.old_chorus_vol[i])<<MIX_VOLRAMP_FRAC_BITS)>>mix_chunk_bits; - rstate.chorus_vol[i]=c.mix.old_chorus_vol[i]<<MIX_VOLRAMP_FRAC_BITS; - } - - - //looping - - AS::SampleLoopFormat loop_format=sample_manager->sample_get_loop_format(c.sample); - AS::SampleFormat format=sample_manager->sample_get_format(c.sample); - - bool use_fx=false; - - if (fx_enabled) { - - for(int i=0;i<mix_channels;i++) { - if (c.mix.old_reverb_vol[i] || c.mix.reverb_vol[i] || c.mix.old_chorus_vol[i] || c.mix.chorus_vol[i] ) { - use_fx=true; - break; - } - } - } - - /* audio data */ - - const void *data=sample_manager->sample_get_data_ptr(c.sample); - int32_t *dst_buff=mix_buffer; - -#ifndef NO_REVERB - rstate.reverb_buffer=reverb_state[c.reverb_room].buffer; -#endif - - /* @TODO validar loops al registrar? */ - - rstate.coefs=filter_coefs; - rstate.coefs_inc=filter_inc; - rstate.filter_l=&c.mix.filter_l; - rstate.filter_r=&c.mix.filter_r; - - if (format==AS::SAMPLE_FORMAT_IMA_ADPCM) { - - rstate.ima_adpcm=c.mix.ima_adpcm; - if (loop_format!=AS::SAMPLE_LOOP_NONE) { - c.mix.ima_adpcm[0].loop_pos=loop_begin_fp>>MIX_FRAC_BITS; - c.mix.ima_adpcm[1].loop_pos=loop_begin_fp>>MIX_FRAC_BITS; - loop_format=AS::SAMPLE_LOOP_FORWARD; - } - } - - while (todo>0) { - - int64_t limit=0; - int32_t target=0,aux=0; - - /** LOOP CHECKING **/ - - if ( c.mix.increment < 0 ) { - /* going backwards */ - - if ( loop_format!=AS::SAMPLE_LOOP_NONE && c.mix.offset < loop_begin_fp ) { - /* loopstart reached */ - if ( loop_format==AS::SAMPLE_LOOP_PING_PONG ) { - /* bounce ping pong */ - c.mix.offset= loop_begin_fp + ( loop_begin_fp-c.mix.offset ); - c.mix.increment=-c.mix.increment; - } else { - /* go to loop-end */ - c.mix.offset=loop_end_fp-(loop_begin_fp-c.mix.offset); - } - } else { - /* check for sample not reaching begining */ - if(c.mix.offset < 0) { - - c.active=false; - break; - } - } - } else { - /* going forward */ - if( loop_format!=AS::SAMPLE_LOOP_NONE && c.mix.offset >= loop_end_fp ) { - /* loopend reached */ - - if ( loop_format==AS::SAMPLE_LOOP_PING_PONG ) { - /* bounce ping pong */ - c.mix.offset=loop_end_fp-(c.mix.offset-loop_end_fp); - c.mix.increment=-c.mix.increment; - } else { - /* go to loop-begin */ - - if (format==AS::SAMPLE_FORMAT_IMA_ADPCM) { - for(int i=0;i<2;i++) { - c.mix.ima_adpcm[i].step_index=c.mix.ima_adpcm[i].loop_step_index; - c.mix.ima_adpcm[i].predictor=c.mix.ima_adpcm[i].loop_predictor; - c.mix.ima_adpcm[i].last_nibble=loop_begin_fp>>MIX_FRAC_BITS; - } - c.mix.offset=loop_begin_fp; - } else { - c.mix.offset=loop_begin_fp+(c.mix.offset-loop_end_fp); - } - - } - } else { - /* no loop, check for end of sample */ - if(c.mix.offset >= length_fp) { - - c.active=false; - break; - } - } - } - - /** MIXCOUNT COMPUTING **/ - - /* next possible limit (looppoints or sample begin/end */ - limit=(c.mix.increment < 0) ?begin_limit:end_limit; - - /* compute what is shorter, the todo or the limit? */ - aux=(limit-c.mix.offset)/c.mix.increment+1; - target=(aux<todo)?aux:todo; /* mix target is the shorter buffer */ - - /* check just in case */ - if ( target<=0 ) { - c.active=false; - break; - } - - todo-=target; - - int32_t offset=c.mix.offset&mix_chunk_mask; /* strip integer */ - c.mix.offset-=offset; - - rstate.increment=c.mix.increment; - rstate.amount=target; - rstate.pos=offset; - -/* Macros to call the resample function for all possibilities, creating a dedicated-non branchy function call for each thanks to template magic*/ - -#define CALL_RESAMPLE_FUNC( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\ - do_resample<m_depth,m_stereo,m_ima_adpcm, m_use_filter,m_use_fx,m_interp, m_mode>(\ - src_ptr,\ - dst_buff,&rstate); - - -#define CALL_RESAMPLE_INTERP( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\ - if(m_interp==INTERPOLATION_RAW) {\ - CALL_RESAMPLE_FUNC(m_depth,m_stereo, m_ima_adpcm,m_use_filter,m_use_fx,INTERPOLATION_RAW,m_mode);\ - } else if(m_interp==INTERPOLATION_LINEAR) {\ - CALL_RESAMPLE_FUNC(m_depth,m_stereo, m_ima_adpcm,m_use_filter,m_use_fx,INTERPOLATION_LINEAR,m_mode);\ - } else if(m_interp==INTERPOLATION_CUBIC) {\ - CALL_RESAMPLE_FUNC(m_depth,m_stereo, m_ima_adpcm,m_use_filter,m_use_fx,INTERPOLATION_CUBIC,m_mode);\ - }\ - -#define CALL_RESAMPLE_FX( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\ - if(m_use_fx) {\ - CALL_RESAMPLE_INTERP(m_depth,m_stereo, m_ima_adpcm,m_use_filter,true,m_interp, m_mode);\ - } else {\ - CALL_RESAMPLE_INTERP(m_depth,m_stereo, m_ima_adpcm,m_use_filter,false,m_interp, m_mode);\ - }\ - - -#define CALL_RESAMPLE_FILTER( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\ - if(m_use_filter) {\ - CALL_RESAMPLE_FX(m_depth,m_stereo, m_ima_adpcm,true,m_use_fx,m_interp, m_mode);\ - } else {\ - CALL_RESAMPLE_FX(m_depth,m_stereo, m_ima_adpcm,false,m_use_fx,m_interp, m_mode);\ - }\ - -#define CALL_RESAMPLE_STEREO( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\ - if(m_stereo) {\ - CALL_RESAMPLE_FILTER(m_depth,true,m_ima_adpcm, m_use_filter,m_use_fx,m_interp, m_mode);\ - } else {\ - CALL_RESAMPLE_FILTER(m_depth,false,m_ima_adpcm,m_use_filter,m_use_fx,m_interp, m_mode);\ - }\ - -#define CALL_RESAMPLE_MODE( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\ - if(m_mode==MIX_STEREO) {\ - CALL_RESAMPLE_STEREO(m_depth,m_stereo, m_ima_adpcm,m_use_filter,m_use_fx,m_interp, MIX_STEREO);\ - } else {\ - CALL_RESAMPLE_STEREO(m_depth,m_stereo, m_ima_adpcm,m_use_filter,m_use_fx,m_interp, MIX_QUAD);\ - }\ - - - - - if (format==AS::SAMPLE_FORMAT_PCM8) { - - int8_t *src_ptr = &((int8_t*)data)[(c.mix.offset >> MIX_FRAC_BITS)<<(is_stereo?1:0) ]; - CALL_RESAMPLE_MODE(int8_t,is_stereo,false,use_filter,use_fx,interpolation_type,mix_channels); - - } else if (format==AS::SAMPLE_FORMAT_PCM16) { - int16_t *src_ptr = &((int16_t*)data)[(c.mix.offset >> MIX_FRAC_BITS)<<(is_stereo?1:0) ]; - CALL_RESAMPLE_MODE(int16_t,is_stereo,false,use_filter,use_fx,interpolation_type,mix_channels); - - } else if (format==AS::SAMPLE_FORMAT_IMA_ADPCM) { - for(int i=0;i<2;i++) { - c.mix.ima_adpcm[i].window_ofs=c.mix.offset>>MIX_FRAC_BITS; - c.mix.ima_adpcm[i].ptr=(const uint8_t*)data; - } - int8_t *src_ptr = NULL; - CALL_RESAMPLE_MODE(int8_t,is_stereo,true,use_filter,use_fx,interpolation_type,mix_channels); - - } - - c.mix.offset+=rstate.pos; - dst_buff+=target*mix_channels; - rstate.reverb_buffer+=target*mix_channels; - } - - c.filter.old_coefs=c.filter.coefs; -} - -void AudioMixerSW::mix_chunk() { - - ERR_FAIL_COND(mix_chunk_left); - - inside_mix=true; - - // emit tick in usecs - for (int i=0;i<mix_chunk_size*mix_channels;i++) { - - mix_buffer[i]=0; - } -#ifndef NO_REVERB - for(int i=0;i<max_reverbs;i++) - reverb_state[i].used_in_chunk=false; -#endif - - - audio_mixer_chunk_call(mix_chunk_size); - - int ac=0; - for (int i=0;i<MAX_CHANNELS;i++) { - - if (!channels[i].active) - continue; - ac++; - - /* process volume */ - Channel&c=channels[i]; -#ifndef NO_REVERB - bool has_reverb = c.reverb_send>CMP_EPSILON && fx_enabled; - if (has_reverb || c.had_prev_reverb) { - - if (!reverb_state[c.reverb_room].used_in_chunk) { - //zero the room - int32_t *buff = reverb_state[c.reverb_room].buffer; - int len = mix_chunk_size*mix_channels; - for (int j=0;j<len;j++) { - - buff[j]=0; // buffer in use, clear it for appending - } - reverb_state[c.reverb_room].used_in_chunk=true; - } - } -#else - bool has_reverb = false; -#endif - bool has_chorus = c.chorus_send>CMP_EPSILON && fx_enabled; - - - mix_channel(c); - - c.had_prev_reverb=has_reverb; - c.had_prev_chorus=has_chorus; - - } - - //process reverb -#ifndef NO_REVERB - if (fx_enabled) { - - - for(int i=0;i<max_reverbs;i++) { - - if (!reverb_state[i].enabled && !reverb_state[i].used_in_chunk) - continue; //this reverb is not in use - - int32_t *src=NULL; - - if (reverb_state[i].used_in_chunk) - src=reverb_state[i].buffer; - else - src=zero_buffer; - - bool in_use=false; - - int passes=mix_channels/2; - - for(int j=0;j<passes;j++) { - - if (reverb_state[i].reverb[j].process((int*)&src[j*2],(int*)&mix_buffer[j*2],mix_chunk_size,passes)) - in_use=true; - } - - if (in_use) { - reverb_state[i].enabled=true; - reverb_state[i].frames_idle=0; - //copy data over - - } else { - reverb_state[i].frames_idle+=mix_chunk_size; - if (false) { // go idle because too many frames passed - //disable this reverb, as nothing important happened on it - reverb_state[i].enabled=false; - reverb_state[i].frames_idle=0; - } - } - - } - } -#endif - mix_chunk_left=mix_chunk_size; - inside_mix=false; -} - -int AudioMixerSW::mix(int32_t *p_buffer,int p_frames) { - - int todo=p_frames; - int mixes=0; - - while(todo) { - - - if (!mix_chunk_left) { - - if (step_callback) - step_callback(step_udata); - mix_chunk(); - mixes++; - } - - int to_mix=MIN(mix_chunk_left,todo); - int from=mix_chunk_size-mix_chunk_left; - - for (int i=0;i<to_mix*2;i++) { - - (*p_buffer++)=mix_buffer[from*2+i]; - } - - mix_chunk_left-=to_mix; - todo-=to_mix; - } - - return mixes; -} - -uint64_t AudioMixerSW::get_step_usecs() const { - - double mct = (1<<mix_chunk_bits)/double(mix_rate); - return mct*1000000.0; -} - -int AudioMixerSW::_get_channel(ChannelID p_channel) const { - - if (p_channel<0) { - return -1; - } - - int idx=p_channel%MAX_CHANNELS; - int check=p_channel/MAX_CHANNELS; - ERR_FAIL_INDEX_V(idx,MAX_CHANNELS,-1); - if (channels[idx].check!=check) { - return -1; - } - if (!channels[idx].active) { - return -1; - } - - return idx; -} - -AudioMixer::ChannelID AudioMixerSW::channel_alloc(RID p_sample) { - - ERR_FAIL_COND_V( !sample_manager->is_sample(p_sample), INVALID_CHANNEL ); - - - int index=-1; - for (int i=0;i<MAX_CHANNELS;i++) { - - if (!channels[i].active) { - index=i; - break; - } - } - - if (index==-1) - return INVALID_CHANNEL; - - Channel &c=channels[index]; - - // init variables - c.sample=p_sample; - c.vol=1; - c.pan=0; - c.depth=0; - c.height=0; - c.chorus_send=0; - c.reverb_send=0; - c.reverb_room=REVERB_HALL; - c.positional=false; - c.filter.type=FILTER_NONE; - c.speed=sample_manager->sample_get_mix_rate(p_sample); - c.active=true; - c.check=channel_id_count++; - c.first_mix=true; - - // init mix variables - - c.mix.offset=0; - c.mix.increment=1; - //zero everything when this errors - for(int i=0;i<4;i++) { - c.mix.vol[i]=0; - c.mix.reverb_vol[i]=0; - c.mix.chorus_vol[i]=0; - - c.mix.old_vol[i]=0; - c.mix.old_reverb_vol[i]=0; - c.mix.old_chorus_vol[i]=0; - } - - c.had_prev_chorus=false; - c.had_prev_reverb=false; - c.had_prev_vol=false; - - - if (sample_manager->sample_get_format(c.sample)==AudioServer::SAMPLE_FORMAT_IMA_ADPCM) { - - for(int i=0;i<2;i++) { - c.mix.ima_adpcm[i].step_index=0; - c.mix.ima_adpcm[i].predictor=0; - c.mix.ima_adpcm[i].loop_step_index=0; - c.mix.ima_adpcm[i].loop_predictor=0; - c.mix.ima_adpcm[i].last_nibble=-1; - c.mix.ima_adpcm[i].loop_pos=0x7FFFFFFF; - c.mix.ima_adpcm[i].window_ofs=0; - c.mix.ima_adpcm[i].ptr=NULL; - } - } - - ChannelID ret_id = index+c.check*MAX_CHANNELS; - - return ret_id; - -} - -void AudioMixerSW::channel_set_volume(ChannelID p_channel, float p_gain) { - - if (p_gain>3) // avoid gain going too high - p_gain=3; - if (p_gain<0) - p_gain=0; - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return; - Channel &c = channels[chan]; - - //Math::exp( p_db * 0.11512925464970228420089957273422 ); - c.vol=p_gain; - -} - -void AudioMixerSW::channel_set_pan(ChannelID p_channel, float p_pan, float p_depth,float p_height) { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return; - Channel &c = channels[chan]; - - c.pan=p_pan; - c.depth=p_depth; - c.height=p_height; - -} -void AudioMixerSW::channel_set_filter(ChannelID p_channel, FilterType p_type, float p_cutoff, float p_resonance, float p_gain) { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return; - - Channel &c = channels[chan]; - - if (c.filter.type==p_type && c.filter.cutoff==p_cutoff && c.filter.resonance==p_resonance && c.filter.gain==p_gain) - return; //bye - - - bool type_changed = p_type!=c.filter.type; - - c.filter.type=p_type; - c.filter.cutoff=p_cutoff; - c.filter.resonance=p_resonance; - c.filter.gain=p_gain; - - - AudioFilterSW filter; - switch(p_type) { - case FILTER_NONE: { - - return; //do nothing else - } break; - case FILTER_LOWPASS: { - filter.set_mode(AudioFilterSW::LOWPASS); - } break; - case FILTER_BANDPASS: { - filter.set_mode(AudioFilterSW::BANDPASS); - } break; - case FILTER_HIPASS: { - filter.set_mode(AudioFilterSW::HIGHPASS); - } break; - case FILTER_NOTCH: { - filter.set_mode(AudioFilterSW::NOTCH); - } break; - case FILTER_PEAK: { - filter.set_mode(AudioFilterSW::PEAK); - } break; - case FILTER_BANDLIMIT: { - filter.set_mode(AudioFilterSW::BANDLIMIT); - } break; - case FILTER_LOW_SHELF: { - filter.set_mode(AudioFilterSW::LOWSHELF); - } break; - case FILTER_HIGH_SHELF: { - filter.set_mode(AudioFilterSW::HIGHSHELF); - } break; - } - - filter.set_cutoff(p_cutoff); - filter.set_resonance(p_resonance); - filter.set_gain(p_gain); - filter.set_sampling_rate(mix_rate); - filter.set_stages(1); - - AudioFilterSW::Coeffs coefs; - filter.prepare_coefficients(&coefs); - - if (!type_changed) - c.filter.old_coefs=c.filter.coefs; - - c.filter.coefs.b0=coefs.b0; - c.filter.coefs.b1=coefs.b1; - c.filter.coefs.b2=coefs.b2; - c.filter.coefs.a1=coefs.a1; - c.filter.coefs.a2=coefs.a2; - - - if (type_changed) { - //type changed reset filter - c.filter.old_coefs=c.filter.coefs; - c.mix.filter_l.ha[0]=0; - c.mix.filter_l.ha[1]=0; - c.mix.filter_l.hb[0]=0; - c.mix.filter_l.hb[1]=0; - c.mix.filter_r.ha[0]=0; - c.mix.filter_r.ha[1]=0; - c.mix.filter_r.hb[0]=0; - c.mix.filter_r.hb[1]=0; - } - - -} -void AudioMixerSW::channel_set_chorus(ChannelID p_channel, float p_chorus ) { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return; - - Channel &c = channels[chan]; - c.chorus_send=p_chorus; - -} -void AudioMixerSW::channel_set_reverb(ChannelID p_channel, ReverbRoomType p_room_type, float p_reverb) { - - ERR_FAIL_INDEX(p_room_type,MAX_REVERBS); - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return; - - Channel &c = channels[chan]; - c.reverb_room=p_room_type; - c.reverb_send=p_reverb; - -} - -void AudioMixerSW::channel_set_mix_rate(ChannelID p_channel, int p_mix_rate) { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return; - - Channel &c = channels[chan]; - c.speed=p_mix_rate; - -} -void AudioMixerSW::channel_set_positional(ChannelID p_channel, bool p_positional) { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return; - - Channel &c = channels[chan]; - c.positional=p_positional; -} - -float AudioMixerSW::channel_get_volume(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return 0; - - const Channel &c = channels[chan]; - //Math::log( c.vol ) * 8.6858896380650365530225783783321; - return c.vol; -} - -float AudioMixerSW::channel_get_pan(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return 0; - - const Channel &c = channels[chan]; - return c.pan; -} -float AudioMixerSW::channel_get_pan_depth(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return 0; - - const Channel &c = channels[chan]; - return c.depth; -} -float AudioMixerSW::channel_get_pan_height(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return 0; - - const Channel &c = channels[chan]; - return c.height; - -} -AudioMixer::FilterType AudioMixerSW::channel_get_filter_type(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return FILTER_NONE; - - const Channel &c = channels[chan]; - return c.filter.type; -} -float AudioMixerSW::channel_get_filter_cutoff(ChannelID p_channel) const { - - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return 0; - - const Channel &c = channels[chan]; - return c.filter.cutoff; - -} -float AudioMixerSW::channel_get_filter_resonance(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return 0; - - const Channel &c = channels[chan]; - return c.filter.resonance; - -} - -float AudioMixerSW::channel_get_filter_gain(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return 0; - - const Channel &c = channels[chan]; - return c.filter.gain; -} - - -float AudioMixerSW::channel_get_chorus(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return 0; - - const Channel &c = channels[chan]; - return c.chorus_send; - -} -AudioMixer::ReverbRoomType AudioMixerSW::channel_get_reverb_type(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return REVERB_HALL; - - const Channel &c = channels[chan]; - return c.reverb_room; - -} -float AudioMixerSW::channel_get_reverb(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return 0; - - const Channel &c = channels[chan]; - return c.reverb_send; -} - -int AudioMixerSW::channel_get_mix_rate(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return 0; - - const Channel &c = channels[chan]; - return c.speed; -} -bool AudioMixerSW::channel_is_positional(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return false; - - const Channel &c = channels[chan]; - return c.positional; -} - -bool AudioMixerSW::channel_is_valid(ChannelID p_channel) const { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return false; - return channels[chan].active; -} - - -void AudioMixerSW::channel_free(ChannelID p_channel) { - - int chan = _get_channel(p_channel); - if (chan<0 || chan >=MAX_CHANNELS) - return; - - Channel &c=channels[chan]; - - if (!c.active) - return; - - bool has_vol=false; - - for(int i=0;i<mix_channels;i++) { - - if (c.mix.vol[i]) - has_vol=true; - if (c.mix.reverb_vol[i]) - has_vol=true; - if (c.mix.chorus_vol[i]) - has_vol=true; - } - if (c.active && has_vol && inside_mix) { - // drive voice to zero, and run a chunk, the VRAMP will fade it good - c.vol=0; - c.reverb_send=0; - c.chorus_send=0; - mix_channel(c); - } - /* @TODO RAMP DOWN ON STOP */ - c.active=false; -} - - - -AudioMixerSW::AudioMixerSW(SampleManagerSW *p_sample_manager,int p_desired_latency_ms,int p_mix_rate,MixChannels p_mix_channels,bool p_use_fx,InterpolationType p_interp,MixStepCallback p_step_callback,void *p_step_udata) { - - if (OS::get_singleton()->is_stdout_verbose()) { - print_line("AudioServerSW Params: "); - print_line(" -mix chans: "+itos(p_mix_channels)); - print_line(" -mix rate: "+itos(p_mix_rate)); - print_line(" -latency: "+itos(p_desired_latency_ms)); - print_line(" -fx: "+itos(p_use_fx)); - print_line(" -interp: "+itos(p_interp)); - } - sample_manager=p_sample_manager; - mix_channels=p_mix_channels; - mix_rate=p_mix_rate; - step_callback=p_step_callback; - step_udata=p_step_udata; - - - mix_chunk_bits=nearest_shift( p_desired_latency_ms * p_mix_rate / 1000 ); - - mix_chunk_size=(1<<mix_chunk_bits); - mix_chunk_mask=mix_chunk_size-1; - mix_buffer = memnew_arr(int32_t,mix_chunk_size*mix_channels); -#ifndef NO_REVERB - zero_buffer = memnew_arr(int32_t,mix_chunk_size*mix_channels); - for(int i=0;i<mix_chunk_size*mix_channels;i++) - zero_buffer[i]=0; //zero buffer is zero... - - max_reverbs=MAX_REVERBS; - int reverberators=mix_channels/2; - - reverb_state = memnew_arr(ReverbState,max_reverbs); - for(int i=0;i<max_reverbs;i++) { - reverb_state[i].enabled=false; - reverb_state[i].reverb = memnew_arr(ReverbSW,reverberators); - reverb_state[i].buffer = memnew_arr(int32_t,mix_chunk_size*mix_channels); - reverb_state[i].frames_idle=0; - for(int j=0;j<reverberators;j++) { - static ReverbSW::ReverbMode modes[MAX_REVERBS]={ReverbSW::REVERB_MODE_STUDIO_SMALL,ReverbSW::REVERB_MODE_STUDIO_MEDIUM,ReverbSW::REVERB_MODE_STUDIO_LARGE,ReverbSW::REVERB_MODE_HALL}; - reverb_state[i].reverb[j].set_mix_rate(p_mix_rate); - reverb_state[i].reverb[j].set_mode(modes[i]); - } - - } - fx_enabled=p_use_fx; -#else - fx_enabled=false; -#endif - mix_chunk_left=0; - - interpolation_type=p_interp; - channel_id_count=1; - inside_mix=false; - channel_nrg=1.0; - -} - -void AudioMixerSW::set_mixer_volume(float p_volume) { - - channel_nrg=p_volume; -} - -AudioMixerSW::~AudioMixerSW() { - - memdelete_arr(mix_buffer); - -#ifndef NO_REVERB - memdelete_arr(zero_buffer); - for(int i=0;i<max_reverbs;i++) { - memdelete_arr(reverb_state[i].reverb); - memdelete_arr(reverb_state[i].buffer); - } - memdelete_arr(reverb_state); -#endif - - -} diff --git a/servers/audio/audio_mixer_sw.h b/servers/audio/audio_mixer_sw.h deleted file mode 100644 index 952cad4cfa..0000000000 --- a/servers/audio/audio_mixer_sw.h +++ /dev/null @@ -1,264 +0,0 @@ -/*************************************************************************/ -/* audio_mixer_sw.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 AUDIO_MIXER_SW_H -#define AUDIO_MIXER_SW_H - -#include "servers/audio_server.h" -#include "servers/audio/sample_manager_sw.h" -#include "servers/audio/audio_filter_sw.h" -#include "servers/audio/reverb_sw.h" - -class AudioMixerSW : public AudioMixer { -public: - - enum InterpolationType { - - INTERPOLATION_RAW, - INTERPOLATION_LINEAR, - INTERPOLATION_CUBIC - }; - - enum MixChannels { - - MIX_STEREO=2, - MIX_QUAD=4 - }; - - typedef void (*MixStepCallback)(void*); - -private: - SampleManagerSW *sample_manager; - - enum { - - MAX_CHANNELS=64, - // fixed point defs - - MIX_FRAC_BITS=13, - MIX_FRAC_LEN=(1<<MIX_FRAC_BITS), - MIX_FRAC_MASK=MIX_FRAC_LEN-1, - MIX_VOL_FRAC_BITS=12, - MIX_VOLRAMP_FRAC_BITS=16, - MIX_VOLRAMP_FRAC_LEN=(1<<MIX_VOLRAMP_FRAC_BITS), - MIX_VOLRAMP_FRAC_MASK=MIX_VOLRAMP_FRAC_LEN-1, - MIX_FILTER_FRAC_BITS=16, - MIX_FILTER_RAMP_FRAC_BITS=8, - MIX_VOL_MOVE_TO_24=4 - }; - - - struct Channel { - - RID sample; - struct Mix { - int64_t offset; - int32_t increment; - - int32_t vol[4]; - int32_t reverb_vol[4]; - int32_t chorus_vol[4]; - - int32_t old_vol[4]; - int32_t old_reverb_vol[4]; - int32_t old_chorus_vol[4]; - - - struct Filter { //history (stereo) - float ha[2],hb[2]; - } filter_l,filter_r; - - struct IMA_ADPCM_State { - - int16_t step_index; - int32_t predictor; - /* values at loop point */ - int16_t loop_step_index; - int32_t loop_predictor; - int32_t last_nibble; - int32_t loop_pos; - int32_t window_ofs; - const uint8_t *ptr; - } ima_adpcm[2]; - - } mix; - - float vol; - float pan; - float depth; - float height; - - float chorus_send; - ReverbRoomType reverb_room; - float reverb_send; - int speed; - int check; - bool positional; - - bool had_prev_reverb; - bool had_prev_chorus; - bool had_prev_vol; - - struct Filter { - - bool dirty; - - FilterType type; - float cutoff; - float resonance; - float gain; - - struct Coefs { - - float a1,a2,b0,b1,b2; // fixed point coefficients - } coefs,old_coefs; - - } filter; - - bool first_mix; - bool active; - Channel() { active=false; check=-1; first_mix=false; filter.dirty=true; filter.type=FILTER_NONE; filter.cutoff=8000; filter.resonance=0; filter.gain=0; } - }; - - Channel channels[MAX_CHANNELS]; - - uint32_t mix_rate; - bool fx_enabled; - InterpolationType interpolation_type; - - int mix_chunk_bits; - int mix_chunk_size; - int mix_chunk_mask; - - int32_t *mix_buffer; - int32_t *zero_buffer; // fx feed when no input was mixed - - struct ResamplerState { - - uint32_t amount; - int32_t increment; - - - int32_t pos; - - - int32_t vol[4]; - int32_t reverb_vol[4]; - int32_t chorus_vol[4]; - - int32_t vol_inc[4]; - int32_t reverb_vol_inc[4]; - int32_t chorus_vol_inc[4]; - - - - Channel::Mix::Filter *filter_l; - Channel::Mix::Filter *filter_r; - Channel::Filter::Coefs coefs; - Channel::Filter::Coefs coefs_inc; - - Channel::Mix::IMA_ADPCM_State *ima_adpcm; - - int32_t *reverb_buffer; - }; - - - - template<class Depth,bool is_stereo,bool use_filter,bool is_ima_adpcm,bool use_fx,InterpolationType type,MixChannels> - _FORCE_INLINE_ void do_resample(const Depth* p_src, int32_t *p_dst, ResamplerState *p_state); - - MixChannels mix_channels; - - void mix_channel(Channel& p_channel); - int mix_chunk_left; - void mix_chunk(); - - float channel_nrg; - int channel_id_count; - bool inside_mix; - MixStepCallback step_callback; - void *step_udata; - _FORCE_INLINE_ int _get_channel(ChannelID p_channel) const; - - int max_reverbs; - struct ReverbState { - - bool used_in_chunk; - bool enabled; - ReverbSW *reverb; - int frames_idle; - int32_t *buffer; //reverb is sent here - ReverbState() { enabled=false; frames_idle=0; used_in_chunk=false; } - }; - - ReverbState *reverb_state; - - -public: - - - virtual ChannelID channel_alloc(RID p_sample); - - virtual void channel_set_volume(ChannelID p_channel, float p_gain); - virtual void channel_set_pan(ChannelID p_channel, float p_pan, float p_depth=0,float height=0); //pan and depth go from -1 to 1 - virtual void channel_set_filter(ChannelID p_channel, FilterType p_type, float p_cutoff, float p_resonance, float p_gain=1.0); - virtual void channel_set_chorus(ChannelID p_channel, float p_chorus ); - virtual void channel_set_reverb(ChannelID p_channel, ReverbRoomType p_room_type, float p_reverb); - virtual void channel_set_mix_rate(ChannelID p_channel, int p_mix_rate); - virtual void channel_set_positional(ChannelID p_channel, bool p_positional); - - virtual float channel_get_volume(ChannelID p_channel) const; - virtual float channel_get_pan(ChannelID p_channel) const; //pan and depth go from -1 to 1 - virtual float channel_get_pan_depth(ChannelID p_channel) const; //pan and depth go from -1 to 1 - virtual float channel_get_pan_height(ChannelID p_channel) const; //pan and depth go from -1 to 1 - virtual FilterType channel_get_filter_type(ChannelID p_channel) const; - virtual float channel_get_filter_cutoff(ChannelID p_channel) const; - virtual float channel_get_filter_resonance(ChannelID p_channel) const; - virtual float channel_get_filter_gain(ChannelID p_channel) const; - - virtual float channel_get_chorus(ChannelID p_channel) const; - virtual ReverbRoomType channel_get_reverb_type(ChannelID p_channel) const; - virtual float channel_get_reverb(ChannelID p_channel) const; - - virtual int channel_get_mix_rate(ChannelID p_channel) const; - virtual bool channel_is_positional(ChannelID p_channel) const; - - virtual bool channel_is_valid(ChannelID p_channel) const; - - virtual void channel_free(ChannelID p_channel); - - int mix(int32_t *p_buffer,int p_frames); //return amount of mixsteps - uint64_t get_step_usecs() const; - - virtual void set_mixer_volume(float p_volume); - - AudioMixerSW(SampleManagerSW *p_sample_manager,int p_desired_latency_ms,int p_mix_rate,MixChannels p_mix_channels,bool p_use_fx=true,InterpolationType p_interp=INTERPOLATION_LINEAR,MixStepCallback p_step_callback=NULL,void *p_callback_udata=NULL); - ~AudioMixerSW(); -}; - -#endif // AUDIO_MIXER_SW_H diff --git a/servers/audio/audio_server_sw.cpp b/servers/audio/audio_server_sw.cpp deleted file mode 100644 index f508a130b4..0000000000 --- a/servers/audio/audio_server_sw.cpp +++ /dev/null @@ -1,1028 +0,0 @@ -/*************************************************************************/ -/* audio_server_sw.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "audio_server_sw.h" -#include "globals.h" -#include "os/os.h" - -struct _AudioDriverLock { - - _AudioDriverLock() { if (AudioDriverSW::get_singleton()) AudioDriverSW::get_singleton()->lock(); } - ~_AudioDriverLock() { if (AudioDriverSW::get_singleton()) AudioDriverSW::get_singleton()->unlock(); } - -}; - -#define AUDIO_LOCK _AudioDriverLock _adlock; - -AudioMixer *AudioServerSW::get_mixer() { - - return mixer; -} - -/* CALLBACKS */ - -void AudioServerSW::audio_mixer_chunk_callback(int p_frames) { -/* - for(List<Stream*>::Element *E=event_streams.front();E;E=E->next()) { - - if (E->get()->active) - E->get()->audio_stream->mix(NULL,p_frames); - } -*/ -} - -void AudioServerSW::_mixer_callback(void *p_udata) { - - AudioServerSW *self = (AudioServerSW*)p_udata; - for(List<Stream*>::Element *E=self->active_audio_streams.front();E;E=E->next()) { - - if (!E->get()->active) - continue; - - EventStream *es=E->get()->event_stream; - if (!es) - continue; - - es->update(self->mixer_step_usecs); - } - -} - -void AudioServerSW::driver_process_chunk(int p_frames,int32_t *p_buffer) { - - - - int samples=p_frames*internal_buffer_channels; - - for(int i=0;i<samples;i++) { - internal_buffer[i]=0; - } - - while(voice_rb.commands_left()) { - - VoiceRBSW::Command cmd = voice_rb.pop_command(); - - if (cmd.type==VoiceRBSW::Command::CMD_CHANGE_ALL_FX_VOLUMES) { - - SelfList<Voice>*al = active_list.first(); - while(al) { - - Voice *v=al->self(); - if (v->channel!=AudioMixer::INVALID_CHANNEL) { - mixer->channel_set_volume(v->channel,v->volume*fx_volume_scale); - } - al=al->next(); - } - - continue; - } - if (!voice_owner.owns(cmd.voice)) - continue; - - - Voice *v = voice_owner.get(cmd.voice); - - switch(cmd.type) { - case VoiceRBSW::Command::CMD_NONE: { - - - } break; - case VoiceRBSW::Command::CMD_PLAY: { - - if (v->channel!=AudioMixer::INVALID_CHANNEL) - mixer->channel_free(v->channel); - - RID sample = cmd.play.sample; - if (!sample_manager->is_sample(sample)) - continue; - - v->channel=mixer->channel_alloc(sample); - v->volume=1.0; - mixer->channel_set_volume(v->channel,fx_volume_scale); - if (v->channel==AudioMixer::INVALID_CHANNEL) { -#ifdef AUDIO_DEBUG - WARN_PRINT("AUDIO: all channels used, failed to allocate voice"); -#endif - v->active=false; - break; // no voices left? - } - - v->active=true; // this kind of ensures it works - if (!v->active_item.in_list()) - active_list.add(&v->active_item); - - } break; - case VoiceRBSW::Command::CMD_STOP: { - - if (v->channel!=AudioMixer::INVALID_CHANNEL) { - mixer->channel_free(v->channel); - if (v->active_item.in_list()) { - active_list.remove(&v->active_item); - } - } - v->active=false; - } break; - case VoiceRBSW::Command::CMD_SET_VOLUME: { - - - if (v->channel!=AudioMixer::INVALID_CHANNEL) { - v->volume=cmd.volume.volume; - mixer->channel_set_volume(v->channel,cmd.volume.volume*fx_volume_scale); - } - - } break; - case VoiceRBSW::Command::CMD_SET_PAN: { - - if (v->channel!=AudioMixer::INVALID_CHANNEL) - mixer->channel_set_pan(v->channel,cmd.pan.pan,cmd.pan.depth,cmd.pan.height); - - } break; - case VoiceRBSW::Command::CMD_SET_FILTER: { - - - if (v->channel!=AudioMixer::INVALID_CHANNEL) - mixer->channel_set_filter(v->channel,(AudioMixer::FilterType)cmd.filter.type,cmd.filter.cutoff,cmd.filter.resonance,cmd.filter.gain); - } break; - case VoiceRBSW::Command::CMD_SET_CHORUS: { - - if (v->channel!=AudioMixer::INVALID_CHANNEL) - mixer->channel_set_chorus(v->channel,cmd.chorus.send); - - } break; - case VoiceRBSW::Command::CMD_SET_REVERB: { - - if (v->channel!=AudioMixer::INVALID_CHANNEL) - mixer->channel_set_reverb(v->channel,(AudioMixer::ReverbRoomType)cmd.reverb.room,cmd.reverb.send); - - } break; - case VoiceRBSW::Command::CMD_SET_MIX_RATE: { - - if (v->channel!=AudioMixer::INVALID_CHANNEL) - mixer->channel_set_mix_rate(v->channel,cmd.mix_rate.mix_rate); - - } break; - case VoiceRBSW::Command::CMD_SET_POSITIONAL: { - - if (v->channel!=AudioMixer::INVALID_CHANNEL) - mixer->channel_set_positional(v->channel,cmd.positional.positional); - - } break; - default: {} - - } - } - - mixer->mix(internal_buffer,p_frames); - //uint64_t stepsize=mixer->get_step_usecs(); - - - for(List<Stream*>::Element *E=active_audio_streams.front();E;E=E->next()) { - - ERR_CONTINUE(!E->get()->active); // bug? - - - AudioStream *as=E->get()->audio_stream; - if (!as) - continue; - - int channels=as->get_channel_count(); - if (channels==0) - continue; // does not want mix - if (!as->mix(stream_buffer,p_frames)) - continue; //nothing was mixed!! - - int32_t stream_vol_scale=(stream_volume*stream_volume_scale*E->get()->volume_scale)*(1<<STREAM_SCALE_BITS); - -#define STRSCALE(m_val) (((m_val>>STREAM_SCALE_BITS)*stream_vol_scale)>>8) - switch(internal_buffer_channels) { - - case 2: { - - switch(channels) { - case 1: { - - for(int i=0;i<p_frames;i++) { - - internal_buffer[(i<<1)+0]+=STRSCALE(stream_buffer[i]); - internal_buffer[(i<<1)+1]+=STRSCALE(stream_buffer[i]); - } - } break; - case 2: { - - for(int i=0;i<p_frames*2;i++) { - - internal_buffer[i]+=STRSCALE(stream_buffer[i]); - } - } break; - case 4: { - - for(int i=0;i<p_frames;i++) { - - internal_buffer[(i<<2)+0]+=STRSCALE((stream_buffer[(i<<2)+0]+stream_buffer[(i<<2)+2])>>1); - internal_buffer[(i<<2)+1]+=STRSCALE((stream_buffer[(i<<2)+1]+stream_buffer[(i<<2)+3])>>1); - } - } break; - - } break; - - } break; - case 4: { - - switch(channels) { - case 1: { - - for(int i=0;i<p_frames;i++) { - - internal_buffer[(i<<2)+0]+=STRSCALE(stream_buffer[i]); - internal_buffer[(i<<2)+1]+=STRSCALE(stream_buffer[i]); - internal_buffer[(i<<2)+2]+=STRSCALE(stream_buffer[i]); - internal_buffer[(i<<2)+3]+=STRSCALE(stream_buffer[i]); - } - } break; - case 2: { - - for(int i=0;i<p_frames*2;i++) { - - internal_buffer[(i<<2)+0]+=STRSCALE(stream_buffer[(i<<1)+0]); - internal_buffer[(i<<2)+1]+=STRSCALE(stream_buffer[(i<<1)+1]); - internal_buffer[(i<<2)+2]+=STRSCALE(stream_buffer[(i<<1)+0]); - internal_buffer[(i<<2)+3]+=STRSCALE(stream_buffer[(i<<1)+1]); - } - } break; - case 4: { - - for(int i=0;i<p_frames*4;i++) { - internal_buffer[i]+=STRSCALE(stream_buffer[i]); - } - } break; - - } break; - - } break; - case 6: { - - - } break; - } - -#undef STRSCALE - } - - SelfList<Voice> *activeE=active_list.first(); - while(activeE) { - - SelfList<Voice> *activeN=activeE->next(); - if (activeE->self()->channel==AudioMixer::INVALID_CHANNEL || !mixer->channel_is_valid(activeE->self()->channel)) { - - active_list.remove(activeE); - activeE->self()->active=false; - - } - activeE=activeN; - } - - uint32_t peak=0; - for(int i=0;i<samples;i++) { - //clamp to (1<<24) using branchless code - int32_t in = internal_buffer[i]; -#ifdef DEBUG_ENABLED - { - int mask = (in >> (32 - 1)); - uint32_t p = (in + mask) ^ mask; - if (p>peak) - peak=p; - } -#endif - int32_t lo = -0x800000, hi=0x7FFFFF; - lo-=in; - hi-=in; - in += (lo & ((lo < 0) - 1)) + (hi & ((hi > 0) - 1)); - p_buffer[i]=in<<8; - } - - if (peak>max_peak) - max_peak=peak; -} - -void AudioServerSW::driver_process(int p_frames,int32_t *p_buffer) { - - - _output_delay=p_frames/double(AudioDriverSW::get_singleton()->get_mix_rate()); - //process in chunks to make sure to never process more than INTERNAL_BUFFER_SIZE - int todo=p_frames; - while(todo) { - - int tomix=MIN(todo,INTERNAL_BUFFER_SIZE); - driver_process_chunk(tomix,p_buffer); - p_buffer+=tomix; - todo-=tomix; - } - - -} - -/* SAMPLE API */ - -RID AudioServerSW::sample_create(SampleFormat p_format, bool p_stereo, int p_length) { - - AUDIO_LOCK - - return sample_manager->sample_create(p_format,p_stereo,p_length); -} - -void AudioServerSW::sample_set_description(RID p_sample, const String& p_description) { - - AUDIO_LOCK - sample_manager->sample_set_description(p_sample,p_description); -} -String AudioServerSW::sample_get_description(RID p_sample) const { - - AUDIO_LOCK - return sample_manager->sample_get_description(p_sample); -} - -AS::SampleFormat AudioServerSW::sample_get_format(RID p_sample) const { - //AUDIO_LOCK - return sample_manager->sample_get_format(p_sample); -} -bool AudioServerSW::sample_is_stereo(RID p_sample) const { - //AUDIO_LOCK - return sample_manager->sample_is_stereo(p_sample); -} -int AudioServerSW::sample_get_length(RID p_sample) const { - ///AUDIO_LOCK - return sample_manager->sample_get_length(p_sample); -} - -const void* AudioServerSW::sample_get_data_ptr(RID p_sample) const { - ///AUDIO_LOCK - return sample_manager->sample_get_data_ptr(p_sample); -} - -void AudioServerSW::sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer) { - AUDIO_LOCK - sample_manager->sample_set_data(p_sample,p_buffer); -} -PoolVector<uint8_t> AudioServerSW::sample_get_data(RID p_sample) const { - AUDIO_LOCK - return sample_manager->sample_get_data(p_sample); -} - -void AudioServerSW::sample_set_mix_rate(RID p_sample,int p_rate) { - AUDIO_LOCK - sample_manager->sample_set_mix_rate(p_sample,p_rate); -} -int AudioServerSW::sample_get_mix_rate(RID p_sample) const { - AUDIO_LOCK - return sample_manager->sample_get_mix_rate(p_sample); -} - -void AudioServerSW::sample_set_loop_format(RID p_sample,SampleLoopFormat p_format) { - AUDIO_LOCK - sample_manager->sample_set_loop_format(p_sample,p_format); -} -AS::SampleLoopFormat AudioServerSW::sample_get_loop_format(RID p_sample) const { - AUDIO_LOCK - return sample_manager->sample_get_loop_format(p_sample); -} - -void AudioServerSW::sample_set_loop_begin(RID p_sample,int p_pos) { - AUDIO_LOCK - sample_manager->sample_set_loop_begin(p_sample,p_pos); -} -int AudioServerSW::sample_get_loop_begin(RID p_sample) const { - AUDIO_LOCK - return sample_manager->sample_get_loop_begin(p_sample); -} - -void AudioServerSW::sample_set_loop_end(RID p_sample,int p_pos) { - AUDIO_LOCK - sample_manager->sample_set_loop_end(p_sample,p_pos); -} -int AudioServerSW::sample_get_loop_end(RID p_sample) const { - AUDIO_LOCK - return sample_manager->sample_get_loop_end(p_sample); -} - -/* VOICE API */ - -RID AudioServerSW::voice_create() { - - Voice * v = memnew( Voice ); - v->channel=AudioMixer::INVALID_CHANNEL; - - AUDIO_LOCK - return voice_owner.make_rid(v); - -} -void AudioServerSW::voice_play(RID p_voice, RID p_sample) { - - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND(!v); - v->active=true; // force actvive (will be disabled later i gues..) - - //stop old, start new - VoiceRBSW::Command cmd; - cmd.type=VoiceRBSW::Command::CMD_PLAY; - cmd.voice=p_voice; - cmd.play.sample=p_sample; - voice_rb.push_command(cmd); - -} - -void AudioServerSW::voice_set_volume(RID p_voice, float p_volume) { - - VoiceRBSW::Command cmd; - cmd.type=VoiceRBSW::Command::CMD_SET_VOLUME; - cmd.voice=p_voice; - cmd.volume.volume=p_volume; - voice_rb.push_command(cmd); - -} -void AudioServerSW::voice_set_pan(RID p_voice, float p_pan, float p_depth,float p_height) { - - VoiceRBSW::Command cmd; - cmd.type=VoiceRBSW::Command::CMD_SET_PAN; - cmd.voice=p_voice; - cmd.pan.pan=p_pan; - cmd.pan.depth=p_depth; - cmd.pan.height=p_height; - voice_rb.push_command(cmd); - -} -void AudioServerSW::voice_set_filter(RID p_voice, FilterType p_type, float p_cutoff, float p_resonance,float p_gain) { - - VoiceRBSW::Command cmd; - cmd.type=VoiceRBSW::Command::CMD_SET_FILTER; - cmd.voice=p_voice; - cmd.filter.type=p_type; - cmd.filter.cutoff=p_cutoff; - cmd.filter.resonance=p_resonance; - cmd.filter.gain=p_gain; - voice_rb.push_command(cmd); - -} -void AudioServerSW::voice_set_chorus(RID p_voice, float p_chorus ) { - - VoiceRBSW::Command cmd; - cmd.type=VoiceRBSW::Command::CMD_SET_CHORUS; - cmd.voice=p_voice; - cmd.chorus.send=p_chorus; - voice_rb.push_command(cmd); - -} -void AudioServerSW::voice_set_reverb(RID p_voice, ReverbRoomType p_room_type, float p_reverb) { - - VoiceRBSW::Command cmd; - cmd.type=VoiceRBSW::Command::CMD_SET_REVERB; - cmd.voice=p_voice; - cmd.reverb.room=p_room_type; - cmd.reverb.send=p_reverb; - - voice_rb.push_command(cmd); - -} -void AudioServerSW::voice_set_mix_rate(RID p_voice, int p_mix_rate) { - - VoiceRBSW::Command cmd; - cmd.type=VoiceRBSW::Command::CMD_SET_MIX_RATE; - cmd.voice=p_voice; - cmd.mix_rate.mix_rate=p_mix_rate; - voice_rb.push_command(cmd); - -} -void AudioServerSW::voice_set_positional(RID p_voice, bool p_positional) { - - VoiceRBSW::Command cmd; - cmd.type=VoiceRBSW::Command::CMD_SET_POSITIONAL; - cmd.voice=p_voice; - cmd.positional.positional=p_positional; - voice_rb.push_command(cmd); - -} - -float AudioServerSW::voice_get_volume(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, 0); - - return mixer->channel_get_volume( v->channel ); - -} -float AudioServerSW::voice_get_pan(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, 0); - - return mixer->channel_get_pan( v->channel ); - -} -float AudioServerSW::voice_get_pan_depth(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, 0); - - return mixer->channel_get_pan_depth( v->channel ); - -} -float AudioServerSW::voice_get_pan_height(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, 0); - - return mixer->channel_get_pan_height( v->channel ); - -} -AS::FilterType AudioServerSW::voice_get_filter_type(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, AS::FILTER_NONE); - - return (AS::FilterType)mixer->channel_get_filter_type(v->channel); - -} -float AudioServerSW::voice_get_filter_cutoff(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, 0); - - return mixer->channel_get_filter_cutoff( v->channel ); - -} -float AudioServerSW::voice_get_filter_resonance(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, 0); - - return mixer->channel_get_filter_resonance( v->channel ); - -} -float AudioServerSW::voice_get_chorus(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, 0); - - return mixer->channel_get_chorus( v->channel ); - -} -AS::ReverbRoomType AudioServerSW::voice_get_reverb_type(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, REVERB_SMALL); - - return (AS::ReverbRoomType)mixer->channel_get_reverb_type( v->channel ); - -} -float AudioServerSW::voice_get_reverb(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, 0); - - return mixer->channel_get_reverb( v->channel ); - -} - -int AudioServerSW::voice_get_mix_rate(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, 0); - - return mixer->channel_get_mix_rate( v->channel ); - -} -bool AudioServerSW::voice_is_positional(RID p_voice) const { - - AUDIO_LOCK - Voice *v = voice_owner.get( p_voice ); - ERR_FAIL_COND_V(!v, 0); - - return mixer->channel_is_positional( v->channel ); - -} - -void AudioServerSW::voice_stop(RID p_voice) { - - VoiceRBSW::Command cmd; - cmd.type=VoiceRBSW::Command::CMD_STOP; - cmd.voice=p_voice; - voice_rb.push_command(cmd); - - //return mixer->channel_free( v->channel ); - -} - -bool AudioServerSW::voice_is_active(RID p_voice) const { - - Voice *v = voice_owner.get(p_voice); - ERR_FAIL_COND_V(!v,false); - return v->active; - -} - -/* STREAM API */ - -RID AudioServerSW::audio_stream_create(AudioStream *p_stream) { - - AUDIO_LOCK - Stream *s = memnew(Stream); - s->audio_stream=p_stream; - s->event_stream=NULL; - s->active=false; - s->E=NULL; - s->volume_scale=1.0; - p_stream->set_mix_rate(AudioDriverSW::get_singleton()->get_mix_rate()); - - return stream_owner.make_rid(s); -} - -RID AudioServerSW::event_stream_create(EventStream *p_stream) { - - AUDIO_LOCK - Stream *s = memnew(Stream); - s->audio_stream=NULL; - s->event_stream=p_stream; - s->active=false; - s->E=NULL; - s->volume_scale=1.0; - //p_stream->set_mix_rate(AudioDriverSW::get_singleton()->get_mix_rate()); - - return stream_owner.make_rid(s); - - -} - - -void AudioServerSW::stream_set_active(RID p_stream, bool p_active) { - - - Stream *s = stream_owner.get(p_stream); - ERR_FAIL_COND(!s); - _THREAD_SAFE_METHOD_ - - if (s->active==p_active) - return; - AUDIO_LOCK; - s->active=p_active; - if (p_active) - s->E=active_audio_streams.push_back(s); - else { - active_audio_streams.erase(s->E); - s->E=NULL; - } - - -} - -bool AudioServerSW::stream_is_active(RID p_stream) const { - - Stream *s = stream_owner.get(p_stream); - ERR_FAIL_COND_V(!s,false); - return s->active; -} - -void AudioServerSW::stream_set_volume_scale(RID p_stream, float p_scale) { - - Stream *s = stream_owner.get(p_stream); - ERR_FAIL_COND(!s); - s->volume_scale=p_scale; - -} - -float AudioServerSW::stream_set_volume_scale(RID p_stream) const { - - Stream *s = stream_owner.get(p_stream); - ERR_FAIL_COND_V(!s,0); - return s->volume_scale; - -} - - -void AudioServerSW::free(RID p_id) { - - if(voice_owner.owns(p_id)) { - - Voice *v = voice_owner.get(p_id); - AUDIO_LOCK - mixer->channel_free( v->channel ); - voice_owner.free(p_id); - memdelete(v); - - } else if (stream_owner.owns(p_id)) { - - - Stream *s=stream_owner.get(p_id); - - if (s->active) { - stream_set_active(p_id,false); - } - - memdelete(s); - stream_owner.free(p_id); - - } else if (sample_manager->is_sample(p_id)) { - - AUDIO_LOCK - sample_manager->free(p_id); - } - -} - -void AudioServerSW::_thread_func(void *self) { - - Thread::set_name("AudioServerSW"); - - AudioServerSW *as=(AudioServerSW *)self; - - while (!as->exit_update_thread) { - as->_update_streams(true); - OS::get_singleton()->delay_usec(5000); - } - -} - -void AudioServerSW::init() { - - int latency = GLOBAL_DEF("audio/mixer_latency",10); - internal_buffer_channels=2; // read from driver - internal_buffer = memnew_arr(int32_t,INTERNAL_BUFFER_SIZE*internal_buffer_channels); - stream_buffer = memnew_arr(int32_t,INTERNAL_BUFFER_SIZE*4); //max 4 channels - AudioMixerSW::MixChannels mix_chans = AudioMixerSW::MIX_STEREO; - - switch(AudioDriverSW::get_singleton()->get_output_format()) { - - case AudioDriverSW::OUTPUT_MONO: - case AudioDriverSW::OUTPUT_STEREO: - mix_chans=AudioMixerSW::MIX_STEREO; - break; - case AudioDriverSW::OUTPUT_QUAD: - case AudioDriverSW::OUTPUT_5_1: - mix_chans=AudioMixerSW::MIX_QUAD; - break; - } - - mixer = memnew( AudioMixerSW( sample_manager, latency, AudioDriverSW::get_singleton()->get_mix_rate(),mix_chans,mixer_use_fx,mixer_interp,_mixer_callback,this ) ); - mixer_step_usecs=mixer->get_step_usecs(); - - _output_delay=0; - - stream_volume=0.3; - // start the audio driver - if (AudioDriverSW::get_singleton()) - AudioDriverSW::get_singleton()->start(); - -#ifndef NO_THREADS - exit_update_thread=false; - thread = Thread::create(_thread_func,this); -#endif - -} - -void AudioServerSW::finish() { - -#ifndef NO_THREADS - exit_update_thread=true; - Thread::wait_to_finish(thread); - memdelete(thread); -#endif - - if (AudioDriverSW::get_singleton()) - AudioDriverSW::get_singleton()->finish(); - - memdelete_arr(internal_buffer); - memdelete_arr(stream_buffer); - memdelete(mixer); - -} - -void AudioServerSW::_update_streams(bool p_thread) { - - _THREAD_SAFE_METHOD_ - for(List<Stream*>::Element *E=active_audio_streams.front();E;) { //stream might be removed durnig this callback - - List<Stream*>::Element *N=E->next(); - - if (E->get()->audio_stream && p_thread == E->get()->audio_stream->can_update_mt()) - E->get()->audio_stream->update(); - - E=N; - } - -} - -void AudioServerSW::update() { - - _update_streams(false); -#ifdef NO_THREADS - - _update_streams(true); -#endif -} - - -void AudioServerSW::lock() { - - AudioDriverSW::get_singleton()->lock(); -} - -void AudioServerSW::unlock() { - AudioDriverSW::get_singleton()->unlock(); - -} - -int AudioServerSW::get_default_mix_rate() const { - - return AudioDriverSW::get_singleton()->get_mix_rate(); -} -int AudioServerSW::get_default_channel_count() const { - return internal_buffer_channels; -} - -void AudioServerSW::set_mixer_params(AudioMixerSW::InterpolationType p_interp, bool p_use_fx) { - - mixer_interp=p_interp; - mixer_use_fx=p_use_fx; -} - -void AudioServerSW::set_stream_global_volume_scale(float p_volume) { - - stream_volume_scale=p_volume; -} - -float AudioServerSW::get_stream_global_volume_scale() const { - - return stream_volume_scale; - - -} - -void AudioServerSW::set_fx_global_volume_scale(float p_volume) { - - fx_volume_scale=p_volume; - //mixer->set_mixer_volume(fx_volume_scale); - VoiceRBSW::Command cmd; - cmd.type=VoiceRBSW::Command::CMD_CHANGE_ALL_FX_VOLUMES; - cmd.voice=RID(); - cmd.volume.volume=p_volume; - voice_rb.push_command(cmd); - -} - - -float AudioServerSW::get_fx_global_volume_scale() const { - - return fx_volume_scale; -} - -void AudioServerSW::set_event_voice_global_volume_scale(float p_volume) { - - event_voice_volume_scale=p_volume; - //mixer->set_mixer_volume(event_voice_volume_scale); -} - - -float AudioServerSW::get_event_voice_global_volume_scale() const { - - return event_voice_volume_scale; -} - -double AudioServerSW::get_output_delay() const { - - return _output_delay+AudioDriverSW::get_singleton()->get_latency(); -} - -double AudioServerSW::get_mix_time() const { - - return AudioDriverSW::get_singleton()->get_mix_time(); -} - -uint32_t AudioServerSW::read_output_peak() const { - - uint32_t val = max_peak; - uint32_t *p = (uint32_t*)&max_peak; - *p=0; - return val; -} - -AudioServerSW::AudioServerSW(SampleManagerSW *p_sample_manager) { - - sample_manager=p_sample_manager; - String interp = GLOBAL_DEF("audio/mixer_interp","linear"); - GlobalConfig::get_singleton()->set_custom_property_info("audio/mixer_interp",PropertyInfo(Variant::STRING,"audio/mixer_interp",PROPERTY_HINT_ENUM,"raw,linear,cubic")); - if (interp=="raw") - mixer_interp=AudioMixerSW::INTERPOLATION_RAW; - else if (interp=="cubic") - mixer_interp=AudioMixerSW::INTERPOLATION_CUBIC; - else - mixer_interp=AudioMixerSW::INTERPOLATION_LINEAR; - mixer_use_fx = GLOBAL_DEF("audio/use_chorus_reverb",true); - stream_volume_scale=GLOBAL_DEF("audio/stream_volume_scale",1.0); - fx_volume_scale=GLOBAL_DEF("audio/fx_volume_scale",1.0); - event_voice_volume_scale=GLOBAL_DEF("audio/event_voice_volume_scale",0.5); - max_peak=0; - - -} - -AudioServerSW::~AudioServerSW() { - -} - - -AudioDriverSW *AudioDriverSW::singleton=NULL; -AudioDriverSW *AudioDriverSW::get_singleton() { - - return singleton; -} - -void AudioDriverSW::set_singleton() { - - singleton=this; -} - -void AudioDriverSW::audio_server_process(int p_frames,int32_t *p_buffer,bool p_update_mix_time) { - - AudioServerSW * audio_server = static_cast<AudioServerSW*>(AudioServer::get_singleton()); - if (p_update_mix_time) - update_mix_time(p_frames); - audio_server->driver_process(p_frames,p_buffer); -} - -void AudioDriverSW::update_mix_time(int p_frames) { - - _mix_amount+=p_frames; - _last_mix_time=OS::get_singleton()->get_ticks_usec(); -} - -double AudioDriverSW::get_mix_time() const { - - double total = (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0; - total+=_mix_amount/(double)get_mix_rate(); - return total; - -} - - -AudioDriverSW::AudioDriverSW() { - - _last_mix_time=0; - _mix_amount=0; -} - - -AudioDriverSW *AudioDriverManagerSW::drivers[MAX_DRIVERS]; -int AudioDriverManagerSW::driver_count=0; - - - -void AudioDriverManagerSW::add_driver(AudioDriverSW *p_driver) { - - ERR_FAIL_COND(driver_count>=MAX_DRIVERS); - drivers[driver_count++]=p_driver; -} - -int AudioDriverManagerSW::get_driver_count() { - - return driver_count; -} -AudioDriverSW *AudioDriverManagerSW::get_driver(int p_driver) { - - ERR_FAIL_INDEX_V(p_driver,driver_count,NULL); - return drivers[p_driver]; -} - diff --git a/servers/audio/audio_server_sw.h b/servers/audio/audio_server_sw.h deleted file mode 100644 index 52b45351c3..0000000000 --- a/servers/audio/audio_server_sw.h +++ /dev/null @@ -1,286 +0,0 @@ -/*************************************************************************/ -/* audio_server_sw.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 AUDIO_SERVER_SW_H -#define AUDIO_SERVER_SW_H - -#include "servers/audio_server.h" -#include "servers/audio/audio_mixer_sw.h" -#include "servers/audio/voice_rb_sw.h" -#include "self_list.h" -#include "os/thread_safe.h" -#include "os/thread.h" -class AudioServerSW : public AudioServer { - - GDCLASS( AudioServerSW, AudioServer ); - - _THREAD_SAFE_CLASS_ - - enum { - INTERNAL_BUFFER_SIZE=4096, - STREAM_SCALE_BITS=12 - - }; - - SampleManagerSW *sample_manager; - AudioMixerSW *mixer; - - virtual AudioMixer *get_mixer(); - virtual void audio_mixer_chunk_callback(int p_frames); - - struct Voice : public RID_Data { - - float volume; - volatile bool active; - SelfList<Voice> active_item; - AudioMixer::ChannelID channel; - - - Voice () : active_item(this) { channel=AudioMixer::INVALID_CHANNEL; active=false;} - }; - - mutable RID_Owner<Voice> voice_owner; - SelfList<Voice>::List active_list; - - struct Stream : public RID_Data { - bool active; - List<Stream*>::Element *E; - AudioStream *audio_stream; - EventStream *event_stream; - float volume_scale; - }; - - List<Stream*> active_audio_streams; - - //List<Stream*> event_streams; - - int32_t * internal_buffer; - int internal_buffer_channels; - int32_t * stream_buffer; - - mutable RID_Owner<Stream> stream_owner; - - float stream_volume; - float stream_volume_scale; - float fx_volume_scale; - float event_voice_volume_scale; - float peak_left,peak_right; - uint32_t max_peak; - - double _output_delay; - - VoiceRBSW voice_rb; - - bool exit_update_thread; - Thread *thread; - static void _thread_func(void *self); - - void _update_streams(bool p_thread); - void driver_process_chunk(int p_frames,int32_t *p_buffer); - - AudioMixerSW::InterpolationType mixer_interp; - bool mixer_use_fx; - uint64_t mixer_step_usecs; - - static void _mixer_callback(void *p_udata); -friend class AudioDriverSW; - void driver_process(int p_frames,int32_t *p_buffer); -public: - - - /* SAMPLE API */ - - virtual RID sample_create(SampleFormat p_format, bool p_stereo, int p_length); - - virtual void sample_set_description(RID p_sample, const String& p_description); - virtual String sample_get_description(RID p_sample) const; - - virtual SampleFormat sample_get_format(RID p_sample) const; - virtual bool sample_is_stereo(RID p_sample) const; - virtual int sample_get_length(RID p_sample) const; - const void* sample_get_data_ptr(RID p_sample) const; - - virtual void sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer); - virtual PoolVector<uint8_t> sample_get_data(RID p_sample) const; - - virtual void sample_set_mix_rate(RID p_sample,int p_rate); - virtual int sample_get_mix_rate(RID p_sample) const; - - virtual void sample_set_loop_format(RID p_sample,SampleLoopFormat p_format); - virtual SampleLoopFormat sample_get_loop_format(RID p_sample) const; - - virtual void sample_set_loop_begin(RID p_sample,int p_pos); - virtual int sample_get_loop_begin(RID p_sample) const; - - virtual void sample_set_loop_end(RID p_sample,int p_pos); - virtual int sample_get_loop_end(RID p_sample) const; - - /* VOICE API */ - - virtual RID voice_create(); - - virtual void voice_play(RID p_voice, RID p_sample); - - virtual void voice_set_volume(RID p_voice, float p_volume); - virtual void voice_set_pan(RID p_voice, float p_pan, float p_depth=0,float height=0); //pan and depth go from -1 to 1 - virtual void voice_set_filter(RID p_voice, FilterType p_type, float p_cutoff, float p_resonance,float p_gain=0); - virtual void voice_set_chorus(RID p_voice, float p_chorus ); - virtual void voice_set_reverb(RID p_voice, ReverbRoomType p_room_type, float p_reverb); - virtual void voice_set_mix_rate(RID p_voice, int p_mix_rate); - virtual void voice_set_positional(RID p_voice, bool p_positional); - - virtual float voice_get_volume(RID p_voice) const; - virtual float voice_get_pan(RID p_voice) const; //pan and depth go from -1 to 1 - virtual float voice_get_pan_depth(RID p_voice) const; //pan and depth go from -1 to 1 - virtual float voice_get_pan_height(RID p_voice) const; //pan and depth go from -1 to 1 - virtual FilterType voice_get_filter_type(RID p_voice) const; - virtual float voice_get_filter_cutoff(RID p_voice) const; - virtual float voice_get_filter_resonance(RID p_voice) const; - virtual float voice_get_chorus(RID p_voice) const; - virtual ReverbRoomType voice_get_reverb_type(RID p_voice) const; - virtual float voice_get_reverb(RID p_voice) const; - - virtual int voice_get_mix_rate(RID p_voice) const; - virtual bool voice_is_positional(RID p_voice) const; - - virtual void voice_stop(RID p_voice); - virtual bool voice_is_active(RID p_voice) const; - - /* STREAM API */ - - virtual RID audio_stream_create(AudioStream *p_stream); - virtual RID event_stream_create(EventStream *p_stream); - - virtual void stream_set_active(RID p_stream, bool p_active); - virtual bool stream_is_active(RID p_stream) const; - - virtual void stream_set_volume_scale(RID p_stream, float p_scale); - virtual float stream_set_volume_scale(RID p_stream) const; - - virtual void free(RID p_id); - - virtual void init(); - virtual void finish(); - virtual void update(); - - virtual void lock(); - virtual void unlock(); - virtual int get_default_channel_count() const; - virtual int get_default_mix_rate() const; - - void set_mixer_params(AudioMixerSW::InterpolationType p_interp, bool p_use_fx); - - virtual void set_stream_global_volume_scale(float p_volume); - virtual void set_fx_global_volume_scale(float p_volume); - virtual void set_event_voice_global_volume_scale(float p_volume); - - - virtual float get_stream_global_volume_scale() const; - virtual float get_fx_global_volume_scale() const; - virtual float get_event_voice_global_volume_scale() const; - - virtual uint32_t read_output_peak() const; - - virtual double get_mix_time() const; //useful for video -> audio sync - - virtual double get_output_delay() const; - - - AudioServerSW(SampleManagerSW *p_sample_manager); - ~AudioServerSW(); - -}; - - -class AudioDriverSW { - - - static AudioDriverSW *singleton; - uint64_t _last_mix_time; - uint64_t _mix_amount; - - -protected: - - void audio_server_process(int p_frames,int32_t *p_buffer,bool p_update_mix_time=true); - void update_mix_time(int p_frames); - -public: - - - double get_mix_time() const; //useful for video -> audio sync - - enum OutputFormat { - - OUTPUT_MONO, - OUTPUT_STEREO, - OUTPUT_QUAD, - OUTPUT_5_1 - }; - - static AudioDriverSW *get_singleton(); - void set_singleton(); - - virtual const char* get_name() const=0; - - virtual Error init()=0; - virtual void start()=0; - virtual int get_mix_rate() const =0; - virtual OutputFormat get_output_format() const=0; - virtual void lock()=0; - virtual void unlock()=0; - virtual void finish()=0; - - virtual float get_latency() { return 0; } - - - - - AudioDriverSW(); - virtual ~AudioDriverSW() {}; -}; - - - -class AudioDriverManagerSW { - - enum { - - MAX_DRIVERS=10 - }; - - static AudioDriverSW *drivers[MAX_DRIVERS]; - static int driver_count; -public: - - static void add_driver(AudioDriverSW *p_driver); - static int get_driver_count(); - static AudioDriverSW *get_driver(int p_driver); -}; - -#endif // AUDIO_SERVER_SW_H diff --git a/servers/audio/sample_manager_sw.cpp b/servers/audio/sample_manager_sw.cpp deleted file mode 100644 index fe4cc36776..0000000000 --- a/servers/audio/sample_manager_sw.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/*************************************************************************/ -/* sample_manager_sw.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "sample_manager_sw.h" - -#include "print_string.h" - -SampleManagerSW::~SampleManagerSW() -{ -} - - - -RID SampleManagerMallocSW::sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length) { - - Sample *s = memnew( Sample ); - int datalen = p_length; - if (p_format==AS::SAMPLE_FORMAT_PCM16) - datalen*=2; - else if (p_format==AS::SAMPLE_FORMAT_IMA_ADPCM) { - if (datalen&1) { - datalen++; - } - datalen/=2; - datalen+=4; - } - - if (p_stereo) - datalen*=2; - -#define SAMPLE_EXTRA 16 - - s->data = memalloc(datalen+SAMPLE_EXTRA); //help the interpolator by allocating a little more.. - for(int i=0;i<SAMPLE_EXTRA;i++) { - - uint8_t *data = (uint8_t*)s->data; - data[datalen+i]=0; - } - if (!s->data) { - - memdelete(s); - ERR_EXPLAIN("Cannot allocate sample of requested size."); - ERR_FAIL_V(RID()); - } - - s->format=p_format; - s->length=p_length; - s->length_bytes=datalen; - s->stereo=p_stereo; - s->loop_begin=0; - s->loop_end=0; - s->loop_format=AS::SAMPLE_LOOP_NONE; - s->mix_rate=44100; - - AudioServer::get_singleton()->lock(); - RID rid = sample_owner.make_rid(s); - AudioServer::get_singleton()->unlock(); - - return rid; -} - -void SampleManagerMallocSW::sample_set_description(RID p_sample, const String& p_description) { - - Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND(!s); - - s->description=p_description; -} - -String SampleManagerMallocSW::sample_get_description(RID p_sample) const { - - const Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND_V(!s,String()); - - return s->description; -} - - -AS::SampleFormat SampleManagerMallocSW::sample_get_format(RID p_sample) const { - - const Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND_V(!s,AS::SAMPLE_FORMAT_PCM8); - - return s->format; -} - -bool SampleManagerMallocSW::sample_is_stereo(RID p_sample) const { - - const Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND_V(!s,false); - - return s->stereo; - -} -int SampleManagerMallocSW::sample_get_length(RID p_sample) const { - - const Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND_V(!s,-1); - - return s->length; -} - -void SampleManagerMallocSW::sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer) { - - Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND(!s); - - int buff_size=p_buffer.size(); - ERR_FAIL_COND(buff_size==0); - - - ERR_EXPLAIN("Sample buffer size does not match sample size."); - //print_line("len bytes: "+itos(s->length_bytes)+" bufsize: "+itos(buff_size)); - ERR_FAIL_COND(s->length_bytes!=buff_size); - PoolVector<uint8_t>::Read buffer_r=p_buffer.read(); - const uint8_t *src = buffer_r.ptr(); - uint8_t *dst = (uint8_t*)s->data; - //print_line("set data: "+itos(s->length_bytes)); - - for(int i=0;i<s->length_bytes;i++) { - - dst[i]=src[i]; - } - - switch(s->format) { - - case AS::SAMPLE_FORMAT_PCM8: { - - if (s->stereo) { - dst[s->length]=dst[s->length-2]; - dst[s->length+1]=dst[s->length-1]; - } else { - - dst[s->length]=dst[s->length-1]; - } - - } break; - case AS::SAMPLE_FORMAT_PCM16: { - - if (s->stereo) { - dst[s->length]=dst[s->length-4]; - dst[s->length+1]=dst[s->length-3]; - dst[s->length+2]=dst[s->length-2]; - dst[s->length+3]=dst[s->length-1]; - } else { - - dst[s->length]=dst[s->length-2]; - dst[s->length+1]=dst[s->length-1]; - } - - } break; - - } - - - -} - -const PoolVector<uint8_t> SampleManagerMallocSW::sample_get_data(RID p_sample) const { - - Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND_V(!s,PoolVector<uint8_t>()); - - PoolVector<uint8_t> ret_buffer; - ret_buffer.resize(s->length_bytes); - PoolVector<uint8_t>::Write buffer_w=ret_buffer.write(); - uint8_t *dst = buffer_w.ptr(); - const uint8_t *src = (const uint8_t*)s->data; - - for(int i=0;i<s->length_bytes;i++) { - - dst[i]=src[i]; - } - - buffer_w = PoolVector<uint8_t>::Write(); //unlock - - return ret_buffer; -} - -void *SampleManagerMallocSW::sample_get_data_ptr(RID p_sample) const { - - const Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND_V(!s,NULL); - - return s->data; - -} - -void SampleManagerMallocSW::sample_set_mix_rate(RID p_sample,int p_rate) { - - ERR_FAIL_COND(p_rate<1); - - Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND(!s); - - s->mix_rate=p_rate; - - -} -int SampleManagerMallocSW::sample_get_mix_rate(RID p_sample) const { - - const Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND_V(!s,-1); - - return s->mix_rate; - -} -void SampleManagerMallocSW::sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format) { - - Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND(!s); - - s->loop_format=p_format; - -} -AS::SampleLoopFormat SampleManagerMallocSW::sample_get_loop_format(RID p_sample) const { - - const Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND_V(!s,AS::SAMPLE_LOOP_NONE); - - return s->loop_format; -} - -void SampleManagerMallocSW::sample_set_loop_begin(RID p_sample,int p_pos) { - - Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND(!s); - ERR_FAIL_INDEX(p_pos,s->length); - - s->loop_begin=p_pos; -} -int SampleManagerMallocSW::sample_get_loop_begin(RID p_sample) const { - - const Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND_V(!s,-1); - - return s->loop_begin; -} - -void SampleManagerMallocSW::sample_set_loop_end(RID p_sample,int p_pos) { - - Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND(!s); - if (p_pos>s->length) - p_pos=s->length; - s->loop_end=p_pos; - -} -int SampleManagerMallocSW::sample_get_loop_end(RID p_sample) const { - - const Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND_V(!s,-1); - - return s->loop_end; -} - -bool SampleManagerMallocSW::is_sample(RID p_sample) const { - - return sample_owner.owns(p_sample); - -} -void SampleManagerMallocSW::free(RID p_sample) { - - Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND(!s); - AudioServer::get_singleton()->lock(); - sample_owner.free(p_sample); - AudioServer::get_singleton()->unlock(); - - memfree(s->data); - memdelete(s); - -} - -SampleManagerMallocSW::SampleManagerMallocSW() { - - -} - -SampleManagerMallocSW::~SampleManagerMallocSW() { - - // check for sample leakage - List<RID> owned_list; - sample_owner.get_owned_list(&owned_list); - - while(owned_list.size()) { - - Sample *s = sample_owner.get(owned_list.front()->get()); - String err="Leaked sample of size: "+itos(s->length_bytes)+" description: "+s->description; - ERR_PRINT(err.utf8().get_data()); - free(owned_list.front()->get()); - owned_list.pop_front(); - } - -} diff --git a/servers/audio/sample_manager_sw.h b/servers/audio/sample_manager_sw.h deleted file mode 100644 index 93cad96f1a..0000000000 --- a/servers/audio/sample_manager_sw.h +++ /dev/null @@ -1,129 +0,0 @@ -/*************************************************************************/ -/* sample_manager_sw.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SAMPLE_MANAGER_SW_H -#define SAMPLE_MANAGER_SW_H - -#include "servers/audio_server.h" - -class SampleManagerSW { -public: - - /* SAMPLE API */ - - virtual RID sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length)=0; - - virtual void sample_set_description(RID p_sample, const String& p_description)=0; - virtual String sample_get_description(RID p_sample) const=0; - - virtual AS::SampleFormat sample_get_format(RID p_sample) const=0; - virtual bool sample_is_stereo(RID p_sample) const=0; - virtual int sample_get_length(RID p_sample) const=0; - - virtual void sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer)=0; - virtual const PoolVector<uint8_t> sample_get_data(RID p_sample) const=0; - - virtual void *sample_get_data_ptr(RID p_sample) const=0; - - virtual void sample_set_mix_rate(RID p_sample,int p_rate)=0; - virtual int sample_get_mix_rate(RID p_sample) const=0; - - virtual void sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format)=0; - virtual AS::SampleLoopFormat sample_get_loop_format(RID p_sample) const=0; - - virtual void sample_set_loop_begin(RID p_sample,int p_pos)=0; - virtual int sample_get_loop_begin(RID p_sample) const=0; - - virtual void sample_set_loop_end(RID p_sample,int p_pos)=0; - virtual int sample_get_loop_end(RID p_sample) const=0; - - virtual bool is_sample(RID) const=0; - virtual void free(RID p_sample)=0; - - - - virtual ~SampleManagerSW(); -}; - - -class SampleManagerMallocSW : public SampleManagerSW { - - - struct Sample : public RID_Data { - - void *data; - int length; - int length_bytes; - AS::SampleFormat format; - bool stereo; - AS::SampleLoopFormat loop_format; - int loop_begin; - int loop_end; - int mix_rate; - String description; - }; - - mutable RID_Owner<Sample> sample_owner; -public: - - /* SAMPLE API */ - - virtual RID sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length); - - virtual void sample_set_description(RID p_sample, const String& p_description); - virtual String sample_get_description(RID p_sample) const; - - virtual AS::SampleFormat sample_get_format(RID p_sample) const; - virtual bool sample_is_stereo(RID p_sample) const; - virtual int sample_get_length(RID p_sample) const; - - virtual void sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer); - virtual const PoolVector<uint8_t> sample_get_data(RID p_sample) const; - - virtual void *sample_get_data_ptr(RID p_sample) const; - - virtual void sample_set_mix_rate(RID p_sample,int p_rate); - virtual int sample_get_mix_rate(RID p_sample) const; - - virtual void sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format); - virtual AS::SampleLoopFormat sample_get_loop_format(RID p_sample) const; - - virtual void sample_set_loop_begin(RID p_sample,int p_pos); - virtual int sample_get_loop_begin(RID p_sample) const; - - virtual void sample_set_loop_end(RID p_sample,int p_pos); - virtual int sample_get_loop_end(RID p_sample) const; - - virtual bool is_sample(RID) const; - virtual void free(RID p_sample); - - SampleManagerMallocSW(); - virtual ~SampleManagerMallocSW(); -}; - -#endif // SAMPLE_MANAGER_SW_H diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 5037b19924..9b938a7f86 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -28,171 +28,265 @@ /*************************************************************************/ #include "audio_server.h" #include "globals.h" +#include "os/os.h" +AudioDriver *AudioDriver::singleton=NULL; +AudioDriver *AudioDriver::get_singleton() { -void AudioMixer::audio_mixer_chunk_call(int p_frames) { + return singleton; +} + +void AudioDriver::set_singleton() { - AudioServer::get_singleton()->audio_mixer_chunk_callback(p_frames); + singleton=this; } -AudioMixer *AudioServer::EventStream::get_mixer() const { +void AudioDriver::audio_server_process(int p_frames,int32_t *p_buffer,bool p_update_mix_time) { - return AudioServer::get_singleton()->get_mixer(); + AudioServer * audio_server = static_cast<AudioServer*>(AudioServer::get_singleton()); + if (p_update_mix_time) + update_mix_time(p_frames); +// audio_server->driver_process(p_frames,p_buffer); } -AudioServer *AudioServer::singleton=NULL; +void AudioDriver::update_mix_time(int p_frames) { -AudioServer *AudioServer::get_singleton() { + _mix_amount+=p_frames; + _last_mix_time=OS::get_singleton()->get_ticks_usec(); +} - return singleton; +double AudioDriver::get_mix_time() const { + + double total = (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0; + total+=_mix_amount/(double)get_mix_rate(); + return total; + +} + + +AudioDriver::AudioDriver() { + + _last_mix_time=0; + _mix_amount=0; +} + + +AudioDriver *AudioDriverManager::drivers[MAX_DRIVERS]; +int AudioDriverManager::driver_count=0; + + + +void AudioDriverManager::add_driver(AudioDriver *p_driver) { + + ERR_FAIL_COND(driver_count>=MAX_DRIVERS); + drivers[driver_count++]=p_driver; +} + +int AudioDriverManager::get_driver_count() { + + return driver_count; +} +AudioDriver *AudioDriverManager::get_driver(int p_driver) { + + ERR_FAIL_INDEX_V(p_driver,driver_count,NULL); + return drivers[p_driver]; +} + + +////////////////////////////////////////////// +////////////////////////////////////////////// +////////////////////////////////////////////// +////////////////////////////////////////////// + +void AudioServer::set_bus_count(int p_count) { + + ERR_FAIL_COND(p_count<1); + ERR_FAIL_INDEX(p_count,256); + lock(); + buses.resize(p_count); + unlock(); +} + +int AudioServer::get_bus_count() const { + + return buses.size(); } -void AudioServer::sample_set_signed_data(RID p_sample, const PoolVector<float>& p_buffer) { +void AudioServer::set_bus_mode(int p_bus,BusMode p_mode) { - SampleFormat format = sample_get_format(p_sample); + ERR_FAIL_INDEX(p_bus,buses.size()); + +} +AudioServer::BusMode AudioServer::get_bus_mode(int p_bus) const { + + ERR_FAIL_INDEX_V(p_bus,buses.size(),BUS_MODE_STEREO); + + return buses[p_bus].mode; +} + +void AudioServer::set_bus_name(int p_bus,const String& p_name) { + + ERR_FAIL_INDEX(p_bus,buses.size()); + buses[p_bus].name=p_name; + +} +String AudioServer::get_bus_name(int p_bus) const { + + ERR_FAIL_INDEX_V(p_bus,buses.size(),String()); + return buses[p_bus].name; +} - ERR_EXPLAIN("IMA ADPCM is not supported."); - ERR_FAIL_COND(format==SAMPLE_FORMAT_IMA_ADPCM); +void AudioServer::set_bus_volume_db(int p_bus,float p_volume_db) { - int len = p_buffer.size(); - ERR_FAIL_COND( len == 0 ); + ERR_FAIL_INDEX(p_bus,buses.size()); + buses[p_bus].volume_db=p_volume_db; - PoolVector<uint8_t> data; - PoolVector<uint8_t>::Write w; - PoolVector<float>::Read r = p_buffer.read(); +} +float AudioServer::get_bus_volume_db(int p_bus) const { - switch(format) { - case SAMPLE_FORMAT_PCM8: { - data.resize(len); - w=data.write(); + ERR_FAIL_INDEX_V(p_bus,buses.size(),0); + return buses[p_bus].volume_db; - int8_t *samples8 = (int8_t*)w.ptr(); +} - for(int i=0;i<len;i++) { +void AudioServer::add_bus_effect(int p_bus,const Ref<AudioEffect>& p_effect,int p_at_pos) { - float sample = Math::floor( r[i] * (1<<8) ); - if (sample<-128) - sample=-128; - else if (sample>127) - sample=127; - samples8[i]=sample; - } - } break; - case SAMPLE_FORMAT_PCM16: { - data.resize(len*2); - w=data.write(); + ERR_FAIL_COND(p_effect.is_null()); + ERR_FAIL_INDEX(p_bus,buses.size()); - int16_t *samples16 = (int16_t*)w.ptr(); + lock(); - for(int i=0;i<len;i++) { + Bus::Effect fx; + fx.effect=p_effect; + //fx.instance=p_effect->instance(); + fx.enabled=true; - float sample = Math::floor( r[i] * (1<<16) ); - if (sample<-32768) - sample=-32768; - else if (sample>32767) - sample=32767; - samples16[i]=sample; - } - } break; + if (p_at_pos>=buses[p_bus].effects.size() || p_at_pos<0) { + buses[p_bus].effects.push_back(fx); + } else { + buses[p_bus].effects.insert(p_at_pos,fx); } - w = PoolVector<uint8_t>::Write(); + unlock(); +} + + +void AudioServer::remove_bus_effect(int p_bus,int p_effect) { + + ERR_FAIL_INDEX(p_bus,buses.size()); - sample_set_data(p_sample,data); + lock(); + buses[p_bus].effects.remove(p_effect); + unlock(); } -void AudioServer::_bind_methods() { +int AudioServer::get_bus_effect_count(int p_bus) { + + ERR_FAIL_INDEX_V(p_bus,buses.size(),0); + + return buses[p_bus].effects.size(); + +} + +Ref<AudioEffect> AudioServer::get_bus_effect(int p_bus,int p_effect) { + + ERR_FAIL_INDEX_V(p_bus,buses.size(),Ref<AudioEffect>()); + ERR_FAIL_INDEX_V(p_effect,buses[p_bus].effects.size(),Ref<AudioEffect>()); + + return buses[p_bus].effects[p_effect].effect; + +} + +void AudioServer::swap_bus_effects(int p_bus,int p_effect,int p_by_effect) { + + ERR_FAIL_INDEX(p_bus,buses.size()); + ERR_FAIL_INDEX(p_effect,buses[p_bus].effects.size()); + ERR_FAIL_INDEX(p_by_effect,buses[p_bus].effects.size()); + + lock(); + SWAP( buses[p_bus].effects[p_effect], buses[p_bus].effects[p_by_effect] ); + unlock(); +} + +void AudioServer::set_bus_effect_enabled(int p_bus,int p_effect,bool p_enabled) { + + ERR_FAIL_INDEX(p_bus,buses.size()); + ERR_FAIL_INDEX(p_effect,buses[p_bus].effects.size()); + buses[p_bus].effects[p_effect].enabled=p_enabled; - ClassDB::bind_method(_MD("sample_create","format","stereo","length"), &AudioServer::sample_create ); - ClassDB::bind_method(_MD("sample_set_description","sample","description"), &AudioServer::sample_set_description ); - ClassDB::bind_method(_MD("sample_get_description","sample"), &AudioServer::sample_get_description ); +} +bool AudioServer::is_bus_effect_enabled(int p_bus,int p_effect) const { + + ERR_FAIL_INDEX_V(p_bus,buses.size(),false); + ERR_FAIL_INDEX_V(p_effect,buses[p_bus].effects.size(),false); + return buses[p_bus].effects[p_effect].enabled; - ClassDB::bind_method(_MD("sample_get_format","sample"), &AudioServer::sample_get_format ); - ClassDB::bind_method(_MD("sample_is_stereo","sample"), &AudioServer::sample_is_stereo ); - ClassDB::bind_method(_MD("sample_get_length","sample"), &AudioServer::sample_get_length ); +} - ClassDB::bind_method(_MD("sample_set_signed_data","sample","data"), &AudioServer::sample_set_signed_data ); - ClassDB::bind_method(_MD("sample_set_data","sample","data"), &AudioServer::sample_set_data ); - ClassDB::bind_method(_MD("sample_get_data","sample"), &AudioServer::sample_get_data ); +void AudioServer::init() { - ClassDB::bind_method(_MD("sample_set_mix_rate","sample","mix_rate"), &AudioServer::sample_set_mix_rate ); - ClassDB::bind_method(_MD("sample_get_mix_rate","sample"), &AudioServer::sample_get_mix_rate ); + set_bus_count(1);; + set_bus_name(0,"Master"); +} +void AudioServer::finish() { - ClassDB::bind_method(_MD("sample_set_loop_format","sample","loop_format"), &AudioServer::sample_set_loop_format ); - ClassDB::bind_method(_MD("sample_get_loop_format","sample"), &AudioServer::sample_get_loop_format ); + buses.clear(); +} +void AudioServer::update() { - ClassDB::bind_method(_MD("sample_set_loop_begin","sample","pos"), &AudioServer::sample_set_loop_begin ); - ClassDB::bind_method(_MD("sample_get_loop_begin","sample"), &AudioServer::sample_get_loop_begin ); +} - ClassDB::bind_method(_MD("sample_set_loop_end","sample","pos"), &AudioServer::sample_set_loop_end ); - ClassDB::bind_method(_MD("sample_get_loop_end","sample"), &AudioServer::sample_get_loop_end ); +/* MISC config */ +void AudioServer::lock() { + + AudioDriver::get_singleton()->lock(); +} +void AudioServer::unlock() { + + AudioDriver::get_singleton()->unlock(); + +} - ClassDB::bind_method(_MD("voice_create"), &AudioServer::voice_create ); - ClassDB::bind_method(_MD("voice_play","voice","sample"), &AudioServer::voice_play ); - ClassDB::bind_method(_MD("voice_set_volume","voice","volume"), &AudioServer::voice_set_volume ); - ClassDB::bind_method(_MD("voice_set_pan","voice","pan","depth","height"), &AudioServer::voice_set_pan,DEFVAL(0),DEFVAL(0) ); - ClassDB::bind_method(_MD("voice_set_filter","voice","type","cutoff","resonance","gain"), &AudioServer::voice_set_filter,DEFVAL(0) ); - ClassDB::bind_method(_MD("voice_set_chorus","voice","chorus"), &AudioServer::voice_set_chorus ); - ClassDB::bind_method(_MD("voice_set_reverb","voice","room","reverb"), &AudioServer::voice_set_reverb ); - ClassDB::bind_method(_MD("voice_set_mix_rate","voice","rate"), &AudioServer::voice_set_mix_rate ); - ClassDB::bind_method(_MD("voice_set_positional","voice","enabled"), &AudioServer::voice_set_positional ); +AudioServer::SpeakerMode AudioServer::get_speaker_mode() const { + return (AudioServer::SpeakerMode)AudioDriver::get_singleton()->get_speaker_mode(); +} +float AudioServer::get_mix_rate() const { - ClassDB::bind_method(_MD("voice_get_volume","voice"), &AudioServer::voice_get_volume ); - ClassDB::bind_method(_MD("voice_get_pan","voice"), &AudioServer::voice_get_pan ); - ClassDB::bind_method(_MD("voice_get_pan_height","voice"), &AudioServer::voice_get_pan_height ); - ClassDB::bind_method(_MD("voice_get_pan_depth","voice"), &AudioServer::voice_get_pan_depth ); - ClassDB::bind_method(_MD("voice_get_filter_type","voice"), &AudioServer::voice_get_filter_type ); - ClassDB::bind_method(_MD("voice_get_filter_cutoff","voice"), &AudioServer::voice_get_filter_cutoff ); - ClassDB::bind_method(_MD("voice_get_filter_resonance","voice"), &AudioServer::voice_get_filter_resonance ); - ClassDB::bind_method(_MD("voice_get_chorus","voice"), &AudioServer::voice_get_chorus ); - ClassDB::bind_method(_MD("voice_get_reverb_type","voice"), &AudioServer::voice_get_reverb_type ); - ClassDB::bind_method(_MD("voice_get_reverb","voice"), &AudioServer::voice_get_reverb ); - ClassDB::bind_method(_MD("voice_get_mix_rate","voice"), &AudioServer::voice_get_mix_rate ); - ClassDB::bind_method(_MD("voice_is_positional","voice"), &AudioServer::voice_is_positional ); + return AudioDriver::get_singleton()->get_mix_rate(); +} - ClassDB::bind_method(_MD("voice_stop","voice"), &AudioServer::voice_stop ); +float AudioServer::read_output_peak_db() const { - ClassDB::bind_method(_MD("free_rid","rid"), &AudioServer::free ); + return 0; +} - ClassDB::bind_method(_MD("set_stream_global_volume_scale","scale"), &AudioServer::set_stream_global_volume_scale ); - ClassDB::bind_method(_MD("get_stream_global_volume_scale"), &AudioServer::get_stream_global_volume_scale ); +AudioServer *AudioServer::get_singleton() { - ClassDB::bind_method(_MD("set_fx_global_volume_scale","scale"), &AudioServer::set_fx_global_volume_scale ); - ClassDB::bind_method(_MD("get_fx_global_volume_scale"), &AudioServer::get_fx_global_volume_scale ); + return singleton; +} - ClassDB::bind_method(_MD("set_event_voice_global_volume_scale","scale"), &AudioServer::set_event_voice_global_volume_scale ); - ClassDB::bind_method(_MD("get_event_voice_global_volume_scale"), &AudioServer::get_event_voice_global_volume_scale ); +double AudioServer::get_mix_time() const { - BIND_CONSTANT( SAMPLE_FORMAT_PCM8 ); - BIND_CONSTANT( SAMPLE_FORMAT_PCM16 ); - BIND_CONSTANT( SAMPLE_FORMAT_IMA_ADPCM ); + return 0; +} +double AudioServer::get_output_delay() const { - BIND_CONSTANT( SAMPLE_LOOP_NONE ); - BIND_CONSTANT( SAMPLE_LOOP_FORWARD ); - BIND_CONSTANT( SAMPLE_LOOP_PING_PONG ); + return 0; +} - BIND_CONSTANT( FILTER_NONE ); - BIND_CONSTANT( FILTER_LOWPASS ); - BIND_CONSTANT( FILTER_BANDPASS ); - BIND_CONSTANT( FILTER_HIPASS ); - BIND_CONSTANT( FILTER_NOTCH ); - BIND_CONSTANT( FILTER_BANDLIMIT ); ///< cutoff is LP resonace is HP +AudioServer* AudioServer::singleton=NULL; - BIND_CONSTANT( REVERB_SMALL ); - BIND_CONSTANT( REVERB_MEDIUM ); - BIND_CONSTANT( REVERB_LARGE ); - BIND_CONSTANT( REVERB_HALL ); - GLOBAL_DEF("audio/stream_buffering_ms",500); - GLOBAL_DEF("audio/video_delay_compensation_ms",300); +void AudioServer::_bind_methods() { } + AudioServer::AudioServer() { singleton=this; @@ -202,3 +296,4 @@ AudioServer::~AudioServer() { } + diff --git a/servers/audio_server.h b/servers/audio_server.h index 1482b40d4c..77aca39760 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -31,261 +31,171 @@ #include "variant.h" #include "object.h" +#include "audio_frame.h" +#include "servers/audio/audio_effect.h" -class AudioMixer { -protected: - void audio_mixer_chunk_call(int p_frames); -public: +class AudioDriver { - enum { - INVALID_CHANNEL=0xFFFFFFFF - }; + static AudioDriver *singleton; + uint64_t _last_mix_time; + uint64_t _mix_amount; + - typedef uint32_t ChannelID; +protected: - /* CHANNEL API */ + void audio_server_process(int p_frames,int32_t *p_buffer,bool p_update_mix_time=true); + void update_mix_time(int p_frames); - enum FilterType { - FILTER_NONE, - FILTER_LOWPASS, - FILTER_BANDPASS, - FILTER_HIPASS, - FILTER_NOTCH, - FILTER_PEAK, - FILTER_BANDLIMIT, ///< cutoff is LP resonace is HP - FILTER_LOW_SHELF, - FILTER_HIGH_SHELF +public: - }; - enum ReverbRoomType { + double get_mix_time() const; //useful for video -> audio sync - REVERB_SMALL, - REVERB_MEDIUM, - REVERB_LARGE, - REVERB_HALL, - MAX_REVERBS + enum SpeakerMode { + SPEAKER_MODE_STEREO, + SPEAKER_SURROUND_51, + SPEAKER_SURROUND_71, }; - virtual ChannelID channel_alloc(RID p_sample)=0; + static AudioDriver *get_singleton(); + void set_singleton(); - virtual void channel_set_volume(ChannelID p_channel, float p_gain)=0; - virtual void channel_set_pan(ChannelID p_channel, float p_pan, float p_depth=0,float height=0)=0; //pan and depth go from -1 to 1 - virtual void channel_set_filter(ChannelID p_channel, FilterType p_type, float p_cutoff, float p_resonance, float p_gain=1.0)=0; - virtual void channel_set_chorus(ChannelID p_channel, float p_chorus )=0; - virtual void channel_set_reverb(ChannelID p_channel, ReverbRoomType p_room_type, float p_reverb)=0; - virtual void channel_set_mix_rate(ChannelID p_channel, int p_mix_rate)=0; - virtual void channel_set_positional(ChannelID p_channel, bool p_positional)=0; + virtual const char* get_name() const=0; - virtual float channel_get_volume(ChannelID p_channel) const=0; - virtual float channel_get_pan(ChannelID p_channel) const=0; //pan and depth go from -1 to 1 - virtual float channel_get_pan_depth(ChannelID p_channel) const=0; //pan and depth go from -1 to 1 - virtual float channel_get_pan_height(ChannelID p_channel) const=0; //pan and depth go from -1 to 1 - virtual FilterType channel_get_filter_type(ChannelID p_channel) const=0; - virtual float channel_get_filter_cutoff(ChannelID p_channel) const=0; - virtual float channel_get_filter_resonance(ChannelID p_channel) const=0; - virtual float channel_get_filter_gain(ChannelID p_channel) const=0; - virtual float channel_get_chorus(ChannelID p_channel) const=0; - virtual ReverbRoomType channel_get_reverb_type(ChannelID p_channel) const=0; - virtual float channel_get_reverb(ChannelID p_channel) const=0; - - virtual int channel_get_mix_rate(ChannelID p_channel) const=0; - virtual bool channel_is_positional(ChannelID p_channel) const=0; - virtual bool channel_is_valid(ChannelID p_channel) const=0; + virtual Error init()=0; + virtual void start()=0; + virtual int get_mix_rate() const =0; + virtual SpeakerMode get_speaker_mode() const=0; + virtual void lock()=0; + virtual void unlock()=0; + virtual void finish()=0; + virtual float get_latency() { return 0; } - virtual void channel_free(ChannelID p_channel)=0; - virtual void set_mixer_volume(float p_volume)=0; - virtual ~AudioMixer() {} + AudioDriver(); + virtual ~AudioDriver() {} }; -class AudioServer : public Object { - GDCLASS( AudioServer, Object ); +class AudioDriverManager { - static AudioServer *singleton; -protected: -friend class AudioStream; -friend class EventStream; -friend class AudioMixer; + enum { - virtual AudioMixer *get_mixer()=0; - virtual void audio_mixer_chunk_callback(int p_frames)=0; + MAX_DRIVERS=10 + }; - static void _bind_methods(); + static AudioDriver *drivers[MAX_DRIVERS]; + static int driver_count; public: - - class EventStream { - protected: - AudioMixer *get_mixer() const; - public: - virtual void update(uint64_t p_usec)=0; - - virtual ~EventStream() {} - }; - - class AudioStream { - public: - virtual int get_channel_count() const=0; - virtual void set_mix_rate(int p_rate)=0; //notify the stream of the mix rate - virtual bool mix(int32_t *p_buffer,int p_frames)=0; - virtual void update()=0; - virtual bool can_update_mt() const { return true; } - virtual ~AudioStream() {} - }; + static void add_driver(AudioDriver *p_driver); + static int get_driver_count(); + static AudioDriver *get_driver(int p_driver); +}; - enum SampleFormat { +class AudioServer : public Object { - SAMPLE_FORMAT_PCM8, - SAMPLE_FORMAT_PCM16, - SAMPLE_FORMAT_IMA_ADPCM + GDCLASS( AudioServer, Object ) +public: + enum BusMode { + BUS_MODE_STEREO, + BUS_MODE_SURROUND }; - enum SampleLoopFormat { - SAMPLE_LOOP_NONE, - SAMPLE_LOOP_FORWARD, - SAMPLE_LOOP_PING_PONG // not supported in every platform - + //re-expose this her, as AudioDriver is not exposed to script + enum SpeakerMode { + SPEAKER_MODE_STEREO, + SPEAKER_SURROUND_51, + SPEAKER_SURROUND_71, }; +private: + uint32_t buffer_size; - /* SAMPLE API */ - - virtual RID sample_create(SampleFormat p_format, bool p_stereo, int p_length)=0; - - virtual void sample_set_description(RID p_sample, const String& p_description)=0; - virtual String sample_get_description(RID p_sample) const=0; - - virtual SampleFormat sample_get_format(RID p_sample) const=0; - virtual bool sample_is_stereo(RID p_sample) const=0; - virtual int sample_get_length(RID p_sample) const=0; - virtual const void* sample_get_data_ptr(RID p_sample) const=0; - - virtual void sample_set_signed_data(RID p_sample, const PoolVector<float>& p_buffer); - virtual void sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer)=0; - virtual PoolVector<uint8_t> sample_get_data(RID p_sample) const=0; + struct Bus { - virtual void sample_set_mix_rate(RID p_sample,int p_rate)=0; - virtual int sample_get_mix_rate(RID p_sample) const=0; + String name; + BusMode mode; + Vector<AudioFrame> buffer; - virtual void sample_set_loop_format(RID p_sample,SampleLoopFormat p_format)=0; - virtual SampleLoopFormat sample_get_loop_format(RID p_sample) const=0; + struct Effect { + Ref<AudioEffect> effect; + Ref<AudioEffectInstance> instance; + bool enabled; + }; - virtual void sample_set_loop_begin(RID p_sample,int p_pos)=0; - virtual int sample_get_loop_begin(RID p_sample) const=0; + Vector<Effect> effects; - virtual void sample_set_loop_end(RID p_sample,int p_pos)=0; - virtual int sample_get_loop_end(RID p_sample) const=0; - - - /* VOICE API */ - - enum FilterType { - FILTER_NONE, - FILTER_LOWPASS, - FILTER_BANDPASS, - FILTER_HIPASS, - FILTER_NOTCH, - FILTER_PEAK, - FILTER_BANDLIMIT, ///< cutoff is LP resonace is HP - FILTER_LOW_SHELF, - FILTER_HIGH_SHELF + float volume_db; }; - enum ReverbRoomType { - REVERB_SMALL, - REVERB_MEDIUM, - REVERB_LARGE, - REVERB_HALL - }; + Vector<Bus> buses; - virtual RID voice_create()=0; - virtual void voice_play(RID p_voice, RID p_sample)=0; + static void _bind_methods(); - virtual void voice_set_volume(RID p_voice, float p_volume)=0; - virtual void voice_set_pan(RID p_voice, float p_pan, float p_depth=0,float height=0)=0; //pan and depth go from -1 to 1 - virtual void voice_set_filter(RID p_voice, FilterType p_type, float p_cutoff, float p_resonance, float p_gain=0)=0; - virtual void voice_set_chorus(RID p_voice, float p_chorus )=0; - virtual void voice_set_reverb(RID p_voice, ReverbRoomType p_room_type, float p_reverb)=0; - virtual void voice_set_mix_rate(RID p_voice, int p_mix_rate)=0; - virtual void voice_set_positional(RID p_voice, bool p_positional)=0; + static AudioServer* singleton; +public: - virtual float voice_get_volume(RID p_voice) const=0; - virtual float voice_get_pan(RID p_voice) const=0; //pan and depth go from -1 to 1 - virtual float voice_get_pan_depth(RID p_voice) const=0; //pan and depth go from -1 to 1 - virtual float voice_get_pan_height(RID p_voice) const=0; //pan and depth go from -1 to 1 - virtual FilterType voice_get_filter_type(RID p_voice) const=0; - virtual float voice_get_filter_cutoff(RID p_voice) const=0; - virtual float voice_get_filter_resonance(RID p_voice) const=0; - virtual float voice_get_chorus(RID p_voice) const=0; - virtual ReverbRoomType voice_get_reverb_type(RID p_voice) const=0; - virtual float voice_get_reverb(RID p_voice) const=0; - virtual int voice_get_mix_rate(RID p_voice) const=0; - virtual bool voice_is_positional(RID p_voice) const=0; + void set_bus_count(int p_count); + int get_bus_count() const; - virtual void voice_stop(RID p_voice)=0; - virtual bool voice_is_active(RID p_voice) const=0; + void set_bus_mode(int p_bus,BusMode p_mode); + BusMode get_bus_mode(int p_bus) const; - /* STREAM API */ + void set_bus_name(int p_bus,const String& p_name); + String get_bus_name(int p_bus) const; - virtual RID audio_stream_create(AudioStream *p_stream)=0; - virtual RID event_stream_create(EventStream *p_stream)=0; + void set_bus_volume_db(int p_bus,float p_volume_db); + float get_bus_volume_db(int p_bus) const; - virtual void stream_set_active(RID p_stream, bool p_active)=0; - virtual bool stream_is_active(RID p_stream) const=0; + void add_bus_effect(int p_bus,const Ref<AudioEffect>& p_effect,int p_at_pos=-1); + void remove_bus_effect(int p_bus,int p_effect); - virtual void stream_set_volume_scale(RID p_stream, float p_scale)=0; - virtual float stream_set_volume_scale(RID p_stream) const=0; + int get_bus_effect_count(int p_bus); + Ref<AudioEffect> get_bus_effect(int p_bus,int p_effect); - /* Audio Physics API */ + void swap_bus_effects(int p_bus,int p_effect,int p_by_effect); - virtual void free(RID p_id)=0; + void set_bus_effect_enabled(int p_bus,int p_effect,bool p_enabled); + bool is_bus_effect_enabled(int p_bus,int p_effect) const; - virtual void init()=0; - virtual void finish()=0; - virtual void update()=0; + virtual void init(); + virtual void finish(); + virtual void update(); /* MISC config */ - virtual void lock()=0; - virtual void unlock()=0; - virtual int get_default_channel_count() const=0; - virtual int get_default_mix_rate() const=0; + virtual void lock(); + virtual void unlock(); - virtual void set_stream_global_volume_scale(float p_volume)=0; - virtual void set_fx_global_volume_scale(float p_volume)=0; - virtual void set_event_voice_global_volume_scale(float p_volume)=0; - virtual float get_stream_global_volume_scale() const=0; - virtual float get_fx_global_volume_scale() const=0; - virtual float get_event_voice_global_volume_scale() const=0; + virtual SpeakerMode get_speaker_mode() const; + virtual float get_mix_rate() const; - virtual uint32_t read_output_peak() const=0; + virtual float read_output_peak_db() const; static AudioServer *get_singleton(); - virtual double get_mix_time() const=0; //useful for video -> audio sync - virtual double get_output_delay() const=0; + virtual double get_mix_time() const; //useful for video -> audio sync + virtual double get_output_delay() const; AudioServer(); virtual ~AudioServer(); }; -VARIANT_ENUM_CAST( AudioServer::SampleFormat ); -VARIANT_ENUM_CAST( AudioServer::SampleLoopFormat ); -VARIANT_ENUM_CAST( AudioServer::FilterType ); -VARIANT_ENUM_CAST( AudioServer::ReverbRoomType ); +VARIANT_ENUM_CAST( AudioServer::BusMode ) +VARIANT_ENUM_CAST( AudioServer::SpeakerMode ) typedef AudioServer AS; + #endif // AUDIO_SERVER_H diff --git a/servers/physics/area_sw.cpp b/servers/physics/area_sw.cpp index 84389c9b78..8aed07d5e5 100644 --- a/servers/physics/area_sw.cpp +++ b/servers/physics/area_sw.cpp @@ -126,14 +126,14 @@ void AreaSW::set_space_override_mode(PhysicsServer::AreaSpaceOverrideMode p_mode void AreaSW::set_param(PhysicsServer::AreaParameter p_param, const Variant& p_value) { switch(p_param) { - case PhysicsServer::AREA_PARAM_GRAVITY: gravity=p_value; ; break; - case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector=p_value; ; break; - case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point=p_value; ; break; - case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale=p_value; ; break; - case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation=p_value; ; break; - case PhysicsServer::AREA_PARAM_LINEAR_DAMP: linear_damp=p_value; ; break; - case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: angular_damp=p_value; ; break; - case PhysicsServer::AREA_PARAM_PRIORITY: priority=p_value; ; break; + case PhysicsServer::AREA_PARAM_GRAVITY: gravity=p_value; break; + case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector=p_value; break; + case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point=p_value; break; + case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale=p_value; break; + case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation=p_value; break; + case PhysicsServer::AREA_PARAM_LINEAR_DAMP: linear_damp=p_value; break; + case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: angular_damp=p_value; break; + case PhysicsServer::AREA_PARAM_PRIORITY: priority=p_value; break; } diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index 81604dd5e1..a67dda3a01 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -621,7 +621,7 @@ void BodySW::integrate_velocities(real_t p_step) { if (ang_vel!=0.0) { Vector3 ang_vel_axis = total_angular_velocity / ang_vel; - Basis rot( ang_vel_axis, -ang_vel*p_step ); + Basis rot( ang_vel_axis, ang_vel*p_step ); Basis identity3(1, 0, 0, 0, 1, 0, 0, 0, 1); transform.origin += ((identity3 - rot) * transform.basis).xform(center_of_mass_local); transform.basis = rot * transform.basis; diff --git a/servers/physics/broad_phase_sw.h b/servers/physics/broad_phase_sw.h index 2cc2d7d45e..20b3efc7fb 100644 --- a/servers/physics/broad_phase_sw.h +++ b/servers/physics/broad_phase_sw.h @@ -30,7 +30,7 @@ #define BROAD_PHASE_SW_H #include "math_funcs.h" -#include "aabb.h" +#include "rect3.h" class CollisionObjectSW; diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp index d02303e23d..d41012caa4 100644 --- a/servers/physics/collision_solver_sat.cpp +++ b/servers/physics/collision_solver_sat.cpp @@ -639,7 +639,7 @@ static void _collision_sphere_convex_polygon(const ShapeSW *p_a,const Transform Vector3 n1=v2-v1; Vector3 n2=v2-v3; - Vector3 axis = n1.cross(n2).cross(n1).normalized();; + Vector3 axis = n1.cross(n2).cross(n1).normalized(); if (!separator.test_axis( axis )) return; diff --git a/servers/physics/joints/hinge_joint_sw.cpp b/servers/physics/joints/hinge_joint_sw.cpp index 277346fbbb..d50d5a1a73 100644 --- a/servers/physics/joints/hinge_joint_sw.cpp +++ b/servers/physics/joints/hinge_joint_sw.cpp @@ -371,7 +371,7 @@ void HingeJointSW::solve(float p_step) { real_t desiredMotorVel = m_motorTargetVelocity; real_t motor_relvel = desiredMotorVel - projRelVel; - real_t unclippedMotorImpulse = m_kHinge * motor_relvel;; + real_t unclippedMotorImpulse = m_kHinge * motor_relvel; //todo: should clip against accumulated impulse real_t clippedMotorImpulse = unclippedMotorImpulse > m_maxMotorImpulse ? m_maxMotorImpulse : unclippedMotorImpulse; clippedMotorImpulse = clippedMotorImpulse < -m_maxMotorImpulse ? -m_maxMotorImpulse : clippedMotorImpulse; diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp index 9f8d1107f4..4114980b82 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics/shape_sw.cpp @@ -1620,7 +1620,7 @@ void HeightMapShapeSW::_setup(PoolVector<real_t> p_heights,int p_width,int p_dep heights=p_heights; width=p_width; - depth=p_depth;; + depth=p_depth; cell_size=p_cell_size; PoolVector<real_t>::Read r = heights. read(); diff --git a/servers/physics_2d/area_2d_sw.cpp b/servers/physics_2d/area_2d_sw.cpp index 8ccdd51067..2625502717 100644 --- a/servers/physics_2d/area_2d_sw.cpp +++ b/servers/physics_2d/area_2d_sw.cpp @@ -125,14 +125,14 @@ void Area2DSW::set_space_override_mode(Physics2DServer::AreaSpaceOverrideMode p_ void Area2DSW::set_param(Physics2DServer::AreaParameter p_param, const Variant& p_value) { switch(p_param) { - case Physics2DServer::AREA_PARAM_GRAVITY: gravity=p_value; ; break; - case Physics2DServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector=p_value; ; break; - case Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point=p_value; ; break; - case Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale=p_value; ; break; - case Physics2DServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation=p_value; ; break; - case Physics2DServer::AREA_PARAM_LINEAR_DAMP: linear_damp=p_value; ; break; - case Physics2DServer::AREA_PARAM_ANGULAR_DAMP: angular_damp=p_value; ; break; - case Physics2DServer::AREA_PARAM_PRIORITY: priority=p_value; ; break; + case Physics2DServer::AREA_PARAM_GRAVITY: gravity=p_value; break; + case Physics2DServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector=p_value; break; + case Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point=p_value; break; + case Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale=p_value; break; + case Physics2DServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation=p_value; break; + case Physics2DServer::AREA_PARAM_LINEAR_DAMP: linear_damp=p_value; break; + case Physics2DServer::AREA_PARAM_ANGULAR_DAMP: angular_damp=p_value; break; + case Physics2DServer::AREA_PARAM_PRIORITY: priority=p_value; break; } diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index 72ae221c39..e6b62ffa66 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -249,7 +249,7 @@ bool BodyPair2DSW::setup(float p_step) { Transform2D xform_A = xform_Au * A->get_shape_transform(shape_A); Transform2D xform_Bu = B->get_transform(); - xform_Bu.translate(-A->get_transform().get_origin()); + xform_Bu.elements[2]-=A->get_transform().get_origin(); Transform2D xform_B = xform_Bu * B->get_shape_transform(shape_B); Shape2DSW *shape_A_ptr=A->get_shape(shape_A); diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp index 02d59b69f0..20a5934eb8 100644 --- a/servers/physics_2d/collision_solver_2d_sw.cpp +++ b/servers/physics_2d/collision_solver_2d_sw.cpp @@ -203,14 +203,14 @@ bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A,const Transfo cinfo.aabb_tests=0; Transform2D rel_transform = p_transform_A; - rel_transform.translate(-p_transform_B.get_origin()); + rel_transform.elements[2]-=p_transform_B.get_origin(); //quickly compute a local Rect2 Rect2 local_aabb; for(int i=0;i<2;i++) { - Vector2 axis( p_transform_B.get_axis(i) ); + Vector2 axis( p_transform_B.elements[i] ); float axis_scale = 1.0/axis.length(); axis*=axis_scale; diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp index 8730bb9ee8..027f318d2d 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp +++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp @@ -95,7 +95,7 @@ void Physics2DServerWrapMT::sync() { else step_sem->wait(); //must not wait if a step was not issued } - physics_2d_server->sync();; + physics_2d_server->sync(); } void Physics2DServerWrapMT::flush_queries(){ @@ -105,7 +105,7 @@ void Physics2DServerWrapMT::flush_queries(){ void Physics2DServerWrapMT::end_sync() { - physics_2d_server->end_sync();; + physics_2d_server->end_sync(); } void Physics2DServerWrapMT::init() { diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h index 9160d064ef..07a9d84ec8 100644 --- a/servers/physics_2d/shape_2d_sw.h +++ b/servers/physics_2d/shape_2d_sw.h @@ -150,7 +150,7 @@ _FORCE_INLINE_ void project_range_cast(const Vector2& p_cast, const Vector2& p_n real_t mina,maxa;\ real_t minb,maxb;\ Transform2D ofsb=p_transform;\ - ofsb.translate(p_cast);\ + ofsb.elements[2]+=p_cast;\ project_range(p_normal,p_transform,mina,maxa);\ project_range(p_normal,ofsb,minb,maxb); \ r_min=MIN(mina,minb);\ diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index e95707f135..a48b6d3827 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -714,7 +714,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co break; } - body_transform.translate(recover_motion); + body_transform.elements[2]+=recover_motion; body_aabb.pos+=recover_motion; recover_attempts--; @@ -863,7 +863,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co //it collided, let's get the rest info in unsafe advance Transform2D ugt = body_transform; - ugt.translate(p_motion*unsafe); + ugt.elements[2]+=p_motion*unsafe; _RestCallbackData2D rcd; rcd.best_len=0; diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index bd5a58e57b..39b790111b 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -179,7 +179,7 @@ int Physics2DShapeQueryParameters::get_object_type_mask() const{ } void Physics2DShapeQueryParameters::set_exclude(const Vector<RID>& p_exclude) { - exclude.clear();; + exclude.clear(); for(int i=0;i<p_exclude.size();i++) exclude.insert(p_exclude[i]); diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp index 93553efb27..ab13e2b3a5 100644 --- a/servers/physics_server.cpp +++ b/servers/physics_server.cpp @@ -178,7 +178,7 @@ int PhysicsShapeQueryParameters::get_object_type_mask() const{ } void PhysicsShapeQueryParameters::set_exclude(const Vector<RID>& p_exclude) { - exclude.clear();; + exclude.clear(); for(int i=0;i<p_exclude.size();i++) exclude.insert(p_exclude[i]); diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 9a98890a26..8b831f4ff6 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -33,10 +33,9 @@ #include "audio_server.h" #include "physics_server.h" #include "physics_2d_server.h" -#include "spatial_sound_server.h" -#include "spatial_sound_2d_server.h" #include "script_debugger_remote.h" #include "visual/shader_types.h" + static void _debugger_get_resource_usage(List<ScriptDebuggerRemote::ResourceUsage>* r_usage) { List<VS::TextureInfo> tinfo; @@ -65,8 +64,6 @@ void register_server_types() { GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("AudioServer",AudioServer::get_singleton()) ); GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("PhysicsServer",PhysicsServer::get_singleton()) ); GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Physics2DServer",Physics2DServer::get_singleton()) ); - GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("SpatialSoundServer",SpatialSoundServer::get_singleton()) ); - GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("SpatialSound2DServer",SpatialSound2DServer::get_singleton()) ); shader_types = memnew( ShaderTypes ); diff --git a/servers/spatial_sound/SCsub b/servers/spatial_sound/SCsub deleted file mode 100644 index ccc76e823f..0000000000 --- a/servers/spatial_sound/SCsub +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.servers_sources, "*.cpp") - -Export('env') diff --git a/servers/spatial_sound/spatial_sound_server_sw.cpp b/servers/spatial_sound/spatial_sound_server_sw.cpp deleted file mode 100644 index d550134d82..0000000000 --- a/servers/spatial_sound/spatial_sound_server_sw.cpp +++ /dev/null @@ -1,1071 +0,0 @@ -/*************************************************************************/ -/* spatial_sound_server_sw.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "spatial_sound_server_sw.h" -#include "os/os.h" -#include "servers/audio/audio_filter_sw.h" - - - -int SpatialSoundServerSW::InternalAudioStream::get_channel_count() const { - - return AudioServer::get_singleton()->get_default_channel_count(); -} - -void SpatialSoundServerSW::InternalAudioStream::set_mix_rate(int p_rate) { - - -} - -void SpatialSoundServerSW::InternalAudioStream::update() { - - owner->_update_sources(); -} - -bool SpatialSoundServerSW::InternalAudioStream::mix(int32_t *p_buffer,int p_frames) { - - return owner->internal_buffer_mix(p_buffer,p_frames); -} - -void SpatialSoundServerSW::_update_sources() { - - _THREAD_SAFE_METHOD_ - for (Set<Source*>::Element *E=streaming_sources.front();E;E=E->next()) { - - Source *s=E->get(); - ERR_CONTINUE(!s->stream); - s->stream->update(); - } -} - - -SpatialSoundServerSW::Room::Room() { - - //params[ROOM_PARAM_SPEED_OF_SOUND]=343.0; - params[ROOM_PARAM_SPEED_OF_SOUND_SCALE]=1; - params[ROOM_PARAM_DOPPLER_FACTOR]=1.0; - params[ROOM_PARAM_PITCH_SCALE]=1.0; - params[ROOM_PARAM_VOLUME_SCALE_DB]=0; - params[ROOM_PARAM_REVERB_SEND]=0; - params[ROOM_PARAM_CHORUS_SEND]=0; - params[ROOM_PARAM_ATTENUATION_SCALE]=1.0; - params[ROOM_PARAM_ATTENUATION_HF_CUTOFF]=5000; - params[ROOM_PARAM_ATTENUATION_HF_FLOOR_DB]=-24.0; - params[ROOM_PARAM_ATTENUATION_HF_RATIO_EXP]=1.0; - params[ROOM_PARAM_ATTENUATION_REVERB_SCALE]=0.0; - override_other_sources=false; - reverb=ROOM_REVERB_HALL; - octree_id=0; - level=-1; - - -} - - -SpatialSoundServerSW::Source::Source() { - - params[SOURCE_PARAM_VOLUME_DB]=0.0; - params[SOURCE_PARAM_PITCH_SCALE]=1.0; - params[SOURCE_PARAM_ATTENUATION_MIN_DISTANCE]=1; - params[SOURCE_PARAM_ATTENUATION_MAX_DISTANCE]=100; - params[SOURCE_PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good) - params[SOURCE_PARAM_EMISSION_CONE_DEGREES]=180.0; //cone disabled - params[SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB]=-6.0; //minus 6 db attenuation - stream=NULL; - voices.resize(1); - last_voice=0; -} - -SpatialSoundServerSW::Source::Voice::Voice() { - - active=false; - restart=false; - pitch_scale=1.0; - volume_scale=0.0; - voice_rid=AudioServer::get_singleton()->voice_create(); - -} -SpatialSoundServerSW::Source::Voice::~Voice() { - - AudioServer::get_singleton()->free(voice_rid); -} - - -SpatialSoundServerSW::Listener::Listener() { - - params[LISTENER_PARAM_VOLUME_SCALE_DB]=0.0; - params[LISTENER_PARAM_PITCH_SCALE]=1.0; - params[LISTENER_PARAM_ATTENUATION_SCALE]=1.0; - params[LISTENER_PARAM_RECEPTION_CONE_DEGREES]=60.0; - params[LISTENER_PARAM_RECEPTION_CONE_ATTENUATION_DB]=-6; // minus six decibels - -} - -/* SPACE */ -RID SpatialSoundServerSW::space_create() { - - Space* space = memnew( Space ); - RID space_rid = space_owner.make_rid(space); - space->default_room=room_create(); - room_set_space(space->default_room,space_rid); - return space_rid; -} - -/* ROOM */ - -RID SpatialSoundServerSW::room_create() { - - Room *room = memnew( Room ); - return room_owner.make_rid(room); -} - -void SpatialSoundServerSW::room_set_space(RID p_room,RID p_space) { - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - - if (room->space.is_valid()) { - - Space *space = space_owner.get(room->space); - space->rooms.erase(p_room); - space->octree.erase(room->octree_id); - //room->octree_id=0; - } - - room->space=RID(); - - if (p_space.is_valid()) { - - Space *space = space_owner.get(p_space); - ERR_FAIL_COND(!space); - space->rooms.insert(p_room); - room->octree_id=space->octree.create(room,Rect3()); - //set bounds - Rect3 aabb = room->bounds.is_empty()?Rect3():room->bounds.get_aabb(); - space->octree.move(room->octree_id,room->transform.xform(aabb)); - room->space=p_space; - } - - -} - -RID SpatialSoundServerSW::room_get_space(RID p_room) const { - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,RID()); - - - return room->space; -} - - - -void SpatialSoundServerSW::room_set_bounds(RID p_room, const BSP_Tree& p_bounds) { - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - - room->bounds=p_bounds; - - if (!room->space.is_valid()) - return; - - Rect3 aabb = room->bounds.is_empty()?Rect3():room->bounds.get_aabb(); - Space* space = space_owner.get(room->space); - ERR_FAIL_COND(!space); - - space->octree.move(room->octree_id,room->transform.xform(aabb)); - -} -BSP_Tree SpatialSoundServerSW::room_get_bounds(RID p_room) const { - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,BSP_Tree()); - - return room->bounds; -} - -void SpatialSoundServerSW::room_set_transform(RID p_room, const Transform& p_transform) { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - room->transform=p_transform; - room->inverse_transform=p_transform.affine_inverse(); // needs to be done to unscale BSP properly - - if (!room->space.is_valid()) - return; - - if (!room->bounds.is_empty()) { - - Space* space = space_owner.get(room->space); - ERR_FAIL_COND(!space); - - space->octree.move(room->octree_id,room->transform.xform(room->bounds.get_aabb())); - } -} - -Transform SpatialSoundServerSW::room_get_transform(RID p_room) const { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,Transform()); - return room->transform; -} - - -void SpatialSoundServerSW::room_set_param(RID p_room, RoomParam p_param, float p_value) { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - ERR_FAIL_INDEX(p_param,ROOM_PARAM_MAX); - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - room->params[p_param]=p_value; - -} -float SpatialSoundServerSW::room_get_param(RID p_room, RoomParam p_param) const { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - ERR_FAIL_INDEX_V(p_param,ROOM_PARAM_MAX,0); - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,0); - return room->params[p_param]; -} - -void SpatialSoundServerSW::room_set_level(RID p_room, int p_level) { - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - room->level =p_level; - -} - -int SpatialSoundServerSW::room_get_level(RID p_room) const { - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,0); - return room->level; - -} - - -void SpatialSoundServerSW::room_set_reverb(RID p_room, RoomReverb p_reverb) { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - room->reverb=p_reverb; - -} -SpatialSoundServerSW::RoomReverb SpatialSoundServerSW::room_get_reverb(RID p_room) const { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,ROOM_REVERB_SMALL); - return room->reverb; -} - -//useful for underwater or rooms with very strange conditions -void SpatialSoundServerSW::room_set_force_params_to_all_sources(RID p_room, bool p_force) { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - room->override_other_sources=p_force; - -} -bool SpatialSoundServerSW::room_is_forcing_params_to_all_sources(RID p_room) const { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,false); - return room->override_other_sources; -} - -/* SOURCE */ - -RID SpatialSoundServerSW::source_create(RID p_space) { - - Space *space = space_owner.get(p_space); - ERR_FAIL_COND_V(!space,RID()); - - Source *source = memnew( Source ); - source->space=p_space; - RID source_rid = source_owner.make_rid(source); - space->sources.insert(source_rid); - - return source_rid; -} - - -void SpatialSoundServerSW::source_set_polyphony(RID p_source,int p_voice_count) { - - - ERR_FAIL_COND(p_voice_count<=0); // more than 32 is too much, change this if you really need more - if (p_voice_count>32) { - - ERR_PRINT("Voices will be clipped to 32"); - p_voice_count=32; - } - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - - if (p_voice_count<source->voices.size()) { - - for(int i=p_voice_count;i<source->voices.size();i++) { - active_voices.erase(ActiveVoice(source,i)); //erase from active voices - } - } - source->voices.resize(p_voice_count); - -} - -int SpatialSoundServerSW::source_get_polyphony(RID p_source) const { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND_V(!source,-1); - return source->voices.size(); - -} - -void SpatialSoundServerSW::source_set_transform(RID p_source, const Transform& p_transform) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - source->transform=p_transform; - source->transform.orthonormalize(); -} -Transform SpatialSoundServerSW::source_get_transform(RID p_source) const { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND_V(!source,Transform()); - return source->transform; -} - -void SpatialSoundServerSW::source_set_param(RID p_source, SourceParam p_param, float p_value) { - - ERR_FAIL_INDEX(p_param,SOURCE_PARAM_MAX); - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - source->params[p_param]=p_value; - -} -float SpatialSoundServerSW::source_get_param(RID p_source, SourceParam p_param) const { - ERR_FAIL_INDEX_V(p_param,SOURCE_PARAM_MAX,0); - Source *source = source_owner.get(p_source); - ERR_FAIL_COND_V(!source,0); - return source->params[p_param]; - - -} - -void SpatialSoundServerSW::source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - AudioServer::get_singleton()->lock(); - source->stream=p_stream; - _THREAD_SAFE_METHOD_ - - if (!p_stream) { - streaming_sources.erase(source); - active_voices.erase(ActiveVoice(source,VOICE_IS_STREAM)); - } else { - streaming_sources.insert(source); - active_voices.insert(ActiveVoice(source,VOICE_IS_STREAM)); - zeromem(source->stream_data.filter_state,sizeof(Source::StreamData::FilterState)*4); //reset filter for safetyness - p_stream->set_mix_rate(AudioServer::get_singleton()->get_default_mix_rate()); - } - - AudioServer::get_singleton()->unlock(); - -} //null to unset - -SpatialSoundServer::SourceVoiceID SpatialSoundServerSW::source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND_V(!source,SOURCE_INVALID_VOICE); - - int to_play=0; - - if (p_voice==SOURCE_NEXT_VOICE) { - to_play=source->last_voice+1; - if (to_play>=source->voices.size()) - to_play=0; - - } else - to_play=p_voice; - - ERR_FAIL_INDEX_V(to_play,source->voices.size(),SOURCE_INVALID_VOICE); - - source->voices[to_play].restart=true; - source->voices[to_play].sample_rid=p_sample; - source->voices[to_play].sample_mix_rate=p_mix_rate; - source->voices[to_play].pitch_scale=1; - source->voices[to_play].volume_scale=0; - source->last_voice=to_play; - active_voices.insert(ActiveVoice(source,to_play)); - return to_play; -} - -/* VOICES */ -void SpatialSoundServerSW::source_voice_set_pitch_scale(RID p_source, SourceVoiceID p_voice, float p_pitch_scale) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - ERR_FAIL_INDEX(p_voice,source->voices.size()); - source->voices[p_voice].pitch_scale=p_pitch_scale; - -} -void SpatialSoundServerSW::source_voice_set_volume_scale_db(RID p_source, SourceVoiceID p_voice, float p_db) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - ERR_FAIL_INDEX(p_voice,source->voices.size()); - source->voices[p_voice].volume_scale=p_db; - -} - -bool SpatialSoundServerSW::source_is_voice_active(RID p_source, SourceVoiceID p_voice) const { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND_V(!source,false); - ERR_FAIL_INDEX_V(p_voice,source->voices.size(),false); - return source->voices[p_voice].active || source->voices[p_voice].restart; - -} -void SpatialSoundServerSW::source_stop_voice(RID p_source, SourceVoiceID p_voice) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - ERR_FAIL_INDEX(p_voice,source->voices.size()); - if (source->voices[p_voice].active) { - AudioServer::get_singleton()->voice_stop(source->voices[p_voice].voice_rid); - } - source->voices[p_voice].active=false; - source->voices[p_voice].restart=false; - active_voices.erase(ActiveVoice(source,p_voice)); -} - -/* LISTENER */ - -RID SpatialSoundServerSW::listener_create() { - - Listener *listener = memnew( Listener ); - RID listener_rid = listener_owner.make_rid(listener); - return listener_rid; - -} - -void SpatialSoundServerSW::listener_set_space(RID p_listener,RID p_space) { - - Listener *listener = listener_owner.get(p_listener); - ERR_FAIL_COND(!listener); - - if (listener->space.is_valid()) { - - Space *lspace = space_owner.get(listener->space); - ERR_FAIL_COND(!lspace); - lspace->listeners.erase(p_listener); - } - - listener->space=RID(); - - if (p_space.is_valid()) { - Space *space = space_owner.get(p_space); - ERR_FAIL_COND(!space); - - listener->space=p_space; - space->listeners.insert(p_listener); - } - -} - -void SpatialSoundServerSW::listener_set_transform(RID p_listener, const Transform& p_transform) { - - Listener *listener = listener_owner.get(p_listener); - ERR_FAIL_COND(!listener); - listener->transform=p_transform; - listener->transform.orthonormalize(); //must be done.. -} -Transform SpatialSoundServerSW::listener_get_transform(RID p_listener) const { - - Listener *listener = listener_owner.get(p_listener); - ERR_FAIL_COND_V(!listener,Transform()); - return listener->transform; -} - -void SpatialSoundServerSW::listener_set_param(RID p_listener, ListenerParam p_param, float p_value) { - - ERR_FAIL_INDEX(p_param,LISTENER_PARAM_MAX); - Listener *listener = listener_owner.get(p_listener); - ERR_FAIL_COND(!listener); - listener->params[p_param]=p_value; -} - -float SpatialSoundServerSW::listener_get_param(RID p_listener, ListenerParam p_param) const { - - ERR_FAIL_INDEX_V(p_param,LISTENER_PARAM_MAX,0); - Listener *listener = listener_owner.get(p_listener); - ERR_FAIL_COND_V(!listener,0); - return listener->params[p_param]; -} - - -/* MISC */ - -void SpatialSoundServerSW::free(RID p_id) { - - - if (space_owner.owns(p_id)) { - - Space *space = space_owner.get(p_id); - free(space->default_room); - - while(space->listeners.size()) { - listener_set_space(space->listeners.front()->get(),RID()); - } - while(space->sources.size()) { - free(space->sources.front()->get()); - } - while(space->rooms.size()) { - room_set_space(space->rooms.front()->get(),RID()); - } - space_owner.free(p_id); - memdelete(space); - - } else if (source_owner.owns(p_id)) { - - Source *source = source_owner.get(p_id); - if (source->stream) - source_set_audio_stream(p_id,NULL); - - Space *space = space_owner.get(source->space); - ERR_FAIL_COND(!space); - space->sources.erase(p_id); - for(int i=0;i<source->voices.size();i++) { - active_voices.erase(ActiveVoice(source,i)); - } - source_owner.free(p_id); - memdelete(source); - } else if (listener_owner.owns(p_id)) { - - Listener *listener = listener_owner.get(p_id); - if (listener->space.is_valid()) { - Space *space = space_owner.get(listener->space); - ERR_FAIL_COND(!space); - space->listeners.erase(p_id); - } - listener_owner.free(p_id); - memdelete(listener); - - } else if (room_owner.owns(p_id)) { - - Room *room = room_owner.get(p_id); - - if (room->space.is_valid()) { - Space *space = space_owner.get(room->space); - ERR_FAIL_COND(!space); - space->octree.erase(room->octree_id); - space->rooms.erase(p_id); - } - room_owner.free(p_id); - memdelete(room); - } else { - ERR_PRINT("Attempt to free invalid ID") ; - } - -} - -void SpatialSoundServerSW::_clean_up_owner(RID_OwnerBase *p_owner, const char *p_area) { - - List<RID> rids; - p_owner->get_owned_list(&rids); - - for(List<RID>::Element *I=rids.front();I;I=I->next()) { - if (OS::get_singleton()->is_stdout_verbose()) { - - print_line("Leaked RID ("+itos(I->get().get_id())+") of type "+String(p_area)); - } - free(I->get()); - } -} - -void SpatialSoundServerSW::init() { - - internal_buffer = memnew_arr(int32_t, INTERNAL_BUFFER_SIZE*INTERNAL_BUFFER_MAX_CHANNELS); - internal_buffer_channels=AudioServer::get_singleton()->get_default_channel_count(); - - internal_audio_stream = memnew( InternalAudioStream ); - internal_audio_stream->owner=this; - internal_audio_stream_rid = AudioServer::get_singleton()->audio_stream_create(internal_audio_stream); - - AudioServer::get_singleton()->stream_set_active(internal_audio_stream_rid,true); - -} - - - -static float _get_attenuation(float cosine, float angle, float attenuation) { - - - float listener_ang = Math::rad2deg(Math::acos(cosine))-angle; - - if (listener_ang>0 && angle<180.0) { - listener_ang/=(180.0-angle); - return Math::db2linear(Math::sin(listener_ang*(Math_PI/2.0))*attenuation); - } - return 1.0; -} - - -bool SpatialSoundServerSW::internal_buffer_mix(int32_t *p_buffer,int p_frames) { - - if (streaming_sources.size()==0) - return false; //nothing to mix - - - for (Set<Source*>::Element *E=streaming_sources.front();E;E=E->next()) { - - Source *s=E->get(); - ERR_CONTINUE(!s->stream); - - int channels = s->stream->get_channel_count(); - Source::StreamData &sd=s->stream_data; - - int todo=p_frames; - - AudioFilterSW filter; - filter.set_sampling_rate(AudioServer::get_singleton()->get_default_mix_rate()); - filter.set_cutoff(sd.filter_cutoff); - filter.set_gain(sd.filter_gain); - filter.set_resonance(1); - filter.set_mode(AudioFilterSW::HIGHSHELF); - filter.set_stages(1); - AudioFilterSW::Coeffs coefs; - filter.prepare_coefficients(&coefs); - - int32_t in[4]; -#ifndef SPATIAL_SOUND_SERVER_NO_FILTER -#define DO_FILTER(m_c)\ - {\ - float val = in[m_c];\ - float pre=val;\ - val = val*coefs.b0 + sd.filter_state[m_c].hb[0]*coefs.b1 + sd.filter_state[m_c].hb[1]*coefs.b2 + sd.filter_state[m_c].ha[0]*coefs.a1 + sd.filter_state[m_c].ha[1]*coefs.a2;\ - sd.filter_state[m_c].ha[1]=sd.filter_state[m_c].ha[0];\ - sd.filter_state[m_c].hb[1]=sd.filter_state[m_c].hb[0]; \ - sd.filter_state[m_c].hb[0]=pre;\ - sd.filter_state[m_c].ha[0]=val;\ - in[m_c]=Math::fast_ftoi(val);\ - } -#else -#define DO_FILTER(m_c) -#endif - - while(todo) { - - int to_mix=MIN(todo,INTERNAL_BUFFER_SIZE); - - s->stream->mix(internal_buffer,to_mix); - - switch(internal_buffer_channels) { - - case 2: { - - float p = sd.panning.x*0.5+0.5; - float panf[2]={ (1.0-p),p }; - panf[0]*=sd.volume; - panf[1]*=sd.volume; - - int32_t pan[2]={Math::fast_ftoi(panf[0]*(1<<16)),Math::fast_ftoi(panf[1]*(1<<16))}; - - switch(channels) { - case 1: { - - for(int i=0;i<to_mix;i++) { - - in[0]=internal_buffer[i]; - in[1]=internal_buffer[i]; - DO_FILTER(0); - DO_FILTER(1); - p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]); - } - } break; - case 2: { - - for(int i=0;i<to_mix;i++) { - - in[0]=internal_buffer[(i<<1)+0]; - in[1]=internal_buffer[(i<<1)+1]; - DO_FILTER(0); - DO_FILTER(1); - p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]); - } - } break; - case 4: { - - for(int i=0;i<to_mix;i++) { - - in[0]=(internal_buffer[(i<<2)+0]+internal_buffer[(i<<2)+2])>>1; - in[1]=(internal_buffer[(i<<2)+1]+internal_buffer[(i<<2)+3])>>1; - DO_FILTER(0); - DO_FILTER(1); - p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]); - } - } break; - - } break; - - } break; - case 4: { - - float xp = sd.panning.x*0.5+0.5; - float yp = sd.panning.y*0.5+0.5; - float panf[4]={ (1.0-xp)*(1.0-yp),(xp)*(1.0-yp),(1.0-xp)*(yp),(xp)*(yp) }; - panf[0]*=sd.volume; - panf[1]*=sd.volume; - panf[2]*=sd.volume; - panf[3]*=sd.volume; - - int32_t pan[4]={ - Math::fast_ftoi(panf[0]*(1<<16)), - Math::fast_ftoi(panf[1]*(1<<16)), - Math::fast_ftoi(panf[2]*(1<<16)), - Math::fast_ftoi(panf[3]*(1<<16))}; - - switch(channels) { - case 1: { - - for(int i=0;i<to_mix;i++) { - - in[0]=internal_buffer[i]; - in[1]=internal_buffer[i]; - in[2]=internal_buffer[i]; - in[3]=internal_buffer[i]; - DO_FILTER(0); - DO_FILTER(1); - DO_FILTER(2); - DO_FILTER(3); - p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]); - p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]); - p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]); - } - } break; - case 2: { - - for(int i=0;i<to_mix;i++) { - - in[0]=internal_buffer[(i<<1)+0]; - in[1]=internal_buffer[(i<<1)+1]; - in[2]=internal_buffer[(i<<1)+0]; - in[3]=internal_buffer[(i<<1)+1]; - DO_FILTER(0); - DO_FILTER(1); - DO_FILTER(2); - DO_FILTER(3); - p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]); - p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]); - p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]); - } - } break; - case 4: { - - for(int i=0;i<to_mix;i++) { - - in[0]=internal_buffer[(i<<2)+0]; - in[1]=internal_buffer[(i<<2)+1]; - in[2]=internal_buffer[(i<<2)+2]; - in[3]=internal_buffer[(i<<2)+3]; - DO_FILTER(0); - DO_FILTER(1); - DO_FILTER(2); - DO_FILTER(3); - p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]); - p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]); - p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]); - } - } break; - - } break; - - } break; - case 6: { - - - } break; - } - p_buffer+=to_mix*internal_buffer_channels; - todo-=to_mix; - - } - - } - - return true; -} - -void SpatialSoundServerSW::update(float p_delta) { - - List<ActiveVoice> to_disable; - - - for(Set<ActiveVoice>::Element *E=active_voices.front();E;E=E->next()) { - - Source *source = E->get().source; - int voice = E->get().voice; - - if (voice!=VOICE_IS_STREAM) { - Source::Voice &v=source->voices[voice]; - ERR_CONTINUE(!v.active && !v.restart); // likely a bug... - } - - //this could be optimized at some point... am not sure - Space *space=space_owner.get(source->space); - Room *room=room_owner.get(space->default_room); - int max_level=-0x80000000; - int rooms_culled = space->octree.cull_point(source->transform.origin,cull_rooms,MAX_CULL_ROOMS); - for(int i=0;i<rooms_culled;i++) { - - Room *r=cull_rooms[i]; - ERR_CONTINUE( r->bounds.is_empty() ); // how did this happen?? - if (r->level<=max_level) //ignore optimization (level too low) - continue; - Vector3 local_point = r->inverse_transform.xform(source->transform.origin); - if (!r->bounds.point_is_inside(local_point)) - continue; - room=r; - max_level=r->level; - - } - - - //compute mixing weights (support for multiple listeners in the same output) - float total_distance=0; - for(Set<RID>::Element *L=space->listeners.front();L;L=L->next()) { - Listener *listener=listener_owner.get(L->get()); - total_distance+=listener->transform.origin.distance_to(source->transform.origin); - } - - //compute spatialization variables, weighted according to distance - float volume_attenuation = 0.0; - float air_absorption_hf_cutoff = 0.0; - float air_absorption = 0.0; - float pitch_scale=1.0; - Vector3 panning; - - - //print_line("listeners: "+itos(space->listeners.size())); - - - for(Set<RID>::Element *L=space->listeners.front();L;L=L->next()) { - - Listener *listener=listener_owner.get(L->get()); - - Vector3 rel_vector = listener->transform.xform_inv(source->transform.origin); - Vector3 source_rel_vector = source->transform.xform_inv(listener->transform.origin).normalized(); - float distance=rel_vector.length(); - float weight = distance/total_distance; - float pscale=1.0; - - float distance_scale=listener->params[LISTENER_PARAM_ATTENUATION_SCALE]*room->params[ROOM_PARAM_ATTENUATION_SCALE]; - float distance_min=source->params[SOURCE_PARAM_ATTENUATION_MIN_DISTANCE]*distance_scale; - float distance_max=source->params[SOURCE_PARAM_ATTENUATION_MAX_DISTANCE]*distance_scale; - float attenuation_exp=source->params[SOURCE_PARAM_ATTENUATION_DISTANCE_EXP]; - float attenuation=1; - - //print_line("DIST MIN: "+rtos(distance_min)); - //print_line("DIST MAX: "+rtos(distance_max)); - if (distance_max>0) { - distance = CLAMP(distance,distance_min,distance_max); - attenuation = Math::pow(1.0 - ((distance - distance_min)/(distance_max-distance_min)),CLAMP(attenuation_exp,0.001,16)); - } - - float hf_attenuation_cutoff = room->params[ROOM_PARAM_ATTENUATION_HF_CUTOFF]; - float hf_attenuation_exp = room->params[ROOM_PARAM_ATTENUATION_HF_RATIO_EXP]; - float hf_attenuation_floor = room->params[ROOM_PARAM_ATTENUATION_HF_FLOOR_DB]; - float absorption=Math::db2linear(Math::lerp(hf_attenuation_floor,0,Math::pow(attenuation,hf_attenuation_exp))); - - // source emission cone - - float emission_deg=source->params[SOURCE_PARAM_EMISSION_CONE_DEGREES]; - float emission_attdb=source->params[SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB]; - absorption*=_get_attenuation(source_rel_vector.dot(Vector3(0,0,-1)),emission_deg,emission_attdb); - - Vector3 vpanning=rel_vector.normalized(); - - //listener stuff - - { - - // head cone - - float reception_deg=listener->params[LISTENER_PARAM_RECEPTION_CONE_DEGREES]; - float reception_attdb=listener->params[LISTENER_PARAM_RECEPTION_CONE_ATTENUATION_DB]; - - absorption*=_get_attenuation(vpanning.dot(Vector3(0,0,-1)),reception_deg,reception_attdb); - - // scale - - attenuation*=Math::db2linear(listener->params[LISTENER_PARAM_VOLUME_SCALE_DB]); - pscale*=Math::db2linear(listener->params[LISTENER_PARAM_PITCH_SCALE]); - - - } - - - - - //add values - - volume_attenuation+=weight*attenuation; // plus other stuff i guess - air_absorption+=weight*absorption; - air_absorption_hf_cutoff+=weight*hf_attenuation_cutoff; - panning+=vpanning*weight; - //pitch_scale+=pscale*weight; - - } - - RoomReverb reverb_room; - float reverb_send; - - /* APPLY ROOM SETTINGS */ - - { - pitch_scale*=room->params[ROOM_PARAM_PITCH_SCALE]; - volume_attenuation*=Math::db2linear(room->params[ROOM_PARAM_VOLUME_SCALE_DB]); - reverb_room=room->reverb; - reverb_send=Math::lerp(1.0,volume_attenuation,room->params[ROOM_PARAM_ATTENUATION_REVERB_SCALE])*room->params[ROOM_PARAM_REVERB_SEND]; - - } - - /* UPDATE VOICE & STREAM */ - - - - if (voice==VOICE_IS_STREAM) { - - //update voice!! - source->stream_data.panning=panning; - source->stream_data.volume=volume_attenuation*Math::db2linear(source->params[SOURCE_PARAM_VOLUME_DB]); - source->stream_data.reverb=reverb_room; - source->stream_data.reverb_send=reverb_send; - source->stream_data.filter_gain=air_absorption; - source->stream_data.filter_cutoff=air_absorption_hf_cutoff; - - if (!source->stream) //stream is gone bye bye - to_disable.push_back(ActiveVoice(source,voice)); // oh well.. - - } else if (voice>=0) { - //update stream!! - Source::Voice &v=source->voices[voice]; - - if (v.restart) - AudioServer::get_singleton()->voice_play(v.voice_rid,v.sample_rid); - - float volume_scale = Math::db2linear(v.volume_scale)*Math::db2linear(source->params[SOURCE_PARAM_VOLUME_DB]); - float volume = volume_attenuation*volume_scale; - reverb_send*=volume_scale; - int mix_rate = v.sample_mix_rate*v.pitch_scale*pitch_scale*source->params[SOURCE_PARAM_PITCH_SCALE]; - - - if (mix_rate<=0) { - ERR_PRINT("Invalid mix rate for voice (0) check for invalid pitch_scale param."); - to_disable.push_back(ActiveVoice(source,voice)); // oh well.. - continue; //invalid mix rate, disabling - } - if (v.restart || v.last_volume!=volume) - AudioServer::get_singleton()->voice_set_volume(v.voice_rid,volume); - if (v.restart || v.last_mix_rate!=mix_rate) - AudioServer::get_singleton()->voice_set_mix_rate(v.voice_rid,mix_rate); - if (v.restart || v.last_filter_gain!=air_absorption || v.last_filter_cutoff!=air_absorption_hf_cutoff) - AudioServer::get_singleton()->voice_set_filter(v.voice_rid,AudioServer::FILTER_HIGH_SHELF,air_absorption_hf_cutoff,1.0,air_absorption); - if (v.restart || v.last_panning!=panning) - AudioServer::get_singleton()->voice_set_pan(v.voice_rid,panning.x,panning.y,panning.z); - if (v.restart || v.last_reverb_room!=reverb_room || v.last_reverb_send!=reverb_send) - AudioServer::get_singleton()->voice_set_reverb(v.voice_rid,AudioServer::ReverbRoomType(reverb_room),reverb_send); - - v.last_volume=volume; - v.last_mix_rate=mix_rate; - v.last_filter_gain=air_absorption; - v.last_filter_cutoff=air_absorption_hf_cutoff; - v.last_panning=panning; - v.restart=false; - v.active=true; - - if (!AudioServer::get_singleton()->voice_is_active(v.voice_rid)) - to_disable.push_back(ActiveVoice(source,voice)); // oh well.. - } - } - - while(to_disable.size()) { - - ActiveVoice av = to_disable.front()->get(); - av.source->voices[av.voice].active=false; - av.source->voices[av.voice].restart=false; - active_voices.erase(av); - to_disable.pop_front(); - } - -} -void SpatialSoundServerSW::finish() { - - AudioServer::get_singleton()->free(internal_audio_stream_rid); - memdelete(internal_audio_stream); - - _clean_up_owner(&source_owner,"Source"); - _clean_up_owner(&listener_owner,"Listener"); - _clean_up_owner(&room_owner,"Room"); - _clean_up_owner(&space_owner,"Space"); - - memdelete_arr(internal_buffer); -} - -SpatialSoundServerSW::SpatialSoundServerSW() { - -} diff --git a/servers/spatial_sound/spatial_sound_server_sw.h b/servers/spatial_sound/spatial_sound_server_sw.h deleted file mode 100644 index 901b781ac2..0000000000 --- a/servers/spatial_sound/spatial_sound_server_sw.h +++ /dev/null @@ -1,266 +0,0 @@ -/*************************************************************************/ -/* spatial_sound_server_sw.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SPATIAL_SOUND_SERVER_SW_H -#define SPATIAL_SOUND_SERVER_SW_H - -#include "servers/spatial_sound_server.h" -#include "octree.h" -#include "os/thread_safe.h" - - -class SpatialSoundServerSW : public SpatialSoundServer { - - GDCLASS(SpatialSoundServerSW,SpatialSoundServer); - - _THREAD_SAFE_CLASS_ - - enum { - MAX_CULL_ROOMS=128, - INTERNAL_BUFFER_SIZE=4096, - INTERNAL_BUFFER_MAX_CHANNELS=4, - VOICE_IS_STREAM=-1 - - }; - - - struct InternalAudioStream : public AudioServer::AudioStream { - - ::SpatialSoundServerSW *owner; - virtual int get_channel_count() const; - virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate - virtual bool mix(int32_t *p_buffer,int p_frames); - virtual void update(); - }; - - InternalAudioStream *internal_audio_stream; - RID internal_audio_stream_rid; - int32_t *internal_buffer; - int internal_buffer_channels; - - bool internal_buffer_mix(int32_t *p_buffer,int p_frames); - - struct Room; - - struct Space : public RID_Data { - - RID default_room; - Set<RID> rooms; - Set<RID> sources; - Set<RID> listeners; - - Octree<Room> octree; - }; - - mutable RID_Owner<Space> space_owner; - - struct Room : public RID_Data{ - RID space; - Transform transform; - Transform inverse_transform; - BSP_Tree bounds; - RoomReverb reverb; - float params[ROOM_PARAM_MAX]; - bool override_other_sources; - OctreeElementID octree_id; - int level; - - Room(); - }; - - mutable RID_Owner<Room> room_owner; - - - - struct Source : public RID_Data { - - struct Voice { - - RID voice_rid; - RID sample_rid; - bool active; - bool restart; - float pitch_scale; - float volume_scale; - int sample_mix_rate; - - - float last_volume; - float last_filter_gain; - float last_filter_cutoff; - Vector3 last_panning; - int last_mix_rate; - RoomReverb last_reverb_room; - float last_reverb_send; - - Voice(); - ~Voice(); - }; - - struct StreamData { - - - Vector3 panning; - RoomReverb reverb; - float reverb_send; - float volume; - float filter_gain; - float filter_cutoff; - - struct FilterState { - - float ha[2]; - float hb[2]; - } filter_state[4]; - - StreamData() { - - reverb_send=0; - reverb=ROOM_REVERB_HALL; - volume=1.0; - filter_gain=1; - filter_cutoff=5000; - - } - } stream_data; - - RID space; - Transform transform; - float params[SOURCE_PARAM_MAX]; - AudioServer::AudioStream *stream; - Vector<Voice> voices; - int last_voice; - - Source(); - }; - - mutable RID_Owner<Source> source_owner; - - struct Listener : public RID_Data { - - RID space; - Transform transform; - float params[LISTENER_PARAM_MAX]; - - Listener(); - }; - - mutable RID_Owner<Listener> listener_owner; - - struct ActiveVoice { - - Source *source; - int voice; - bool operator<(const ActiveVoice& p_voice) const { return (voice==p_voice.voice)?(source<p_voice.source):(voice<p_voice.voice); } - ActiveVoice(Source *p_source=NULL,int p_voice=0) { source=p_source; voice=p_voice; } - }; - - Room *cull_rooms[MAX_CULL_ROOMS]; - - Set<Source*> streaming_sources; - Set<ActiveVoice> active_voices; - - void _clean_up_owner(RID_OwnerBase *p_owner, const char *p_area); - void _update_sources(); - -public: - - /* SPACE */ - virtual RID space_create(); - - /* ROOM */ - - virtual RID room_create(); - virtual void room_set_space(RID p_room,RID p_space); - virtual RID room_get_space(RID p_room) const; - - virtual void room_set_bounds(RID p_room, const BSP_Tree& p_bounds); - virtual BSP_Tree room_get_bounds(RID p_room) const; - virtual void room_set_transform(RID p_room, const Transform& p_transform); - virtual Transform room_get_transform(RID p_room) const; - - - virtual void room_set_param(RID p_room, RoomParam p_param, float p_value); - virtual float room_get_param(RID p_room, RoomParam p_param) const; - - virtual void room_set_level(RID p_room, int p_level); - virtual int room_get_level(RID p_room) const; - - virtual void room_set_reverb(RID p_room, RoomReverb p_reverb); - virtual RoomReverb room_get_reverb(RID p_room) const; - - //useful for underwater or rooms with very strange conditions - virtual void room_set_force_params_to_all_sources(RID p_room, bool p_force); - virtual bool room_is_forcing_params_to_all_sources(RID p_room) const; - - /* SOURCE */ - - virtual RID source_create(RID p_space); - - virtual void source_set_polyphony(RID p_source,int p_voice_count); - virtual int source_get_polyphony(RID p_source) const; - - virtual void source_set_transform(RID p_source, const Transform& p_transform); - virtual Transform source_get_transform(RID p_source) const; - - virtual void source_set_param(RID p_source, SourceParam p_param, float p_value); - virtual float source_get_param(RID p_source, SourceParam p_param) const; - - virtual void source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream); //null to unset - virtual SourceVoiceID source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice=SOURCE_NEXT_VOICE); - /* VOICES */ - virtual void source_voice_set_pitch_scale(RID p_source, SourceVoiceID p_voice, float p_pitch_scale); - virtual void source_voice_set_volume_scale_db(RID p_source, SourceVoiceID p_voice, float p_volume); - - virtual bool source_is_voice_active(RID p_source, SourceVoiceID p_voice) const; - virtual void source_stop_voice(RID p_source, SourceVoiceID p_voice); - - /* LISTENER */ - - virtual RID listener_create(); - virtual void listener_set_space(RID p_listener, RID p_space); - - virtual void listener_set_transform(RID p_listener, const Transform& p_transform); - virtual Transform listener_get_transform(RID p_listener) const; - - virtual void listener_set_param(RID p_listener, ListenerParam p_param, float p_value); - virtual float listener_get_param(RID p_listener, ListenerParam p_param) const; - - - /* MISC */ - - virtual void free(RID p_id); - - virtual void init(); - virtual void update(float p_delta); - virtual void finish(); - - SpatialSoundServerSW(); -}; - -#endif // SPATIAL_SOUND_SERVER_SW_H diff --git a/servers/spatial_sound_2d/SCsub b/servers/spatial_sound_2d/SCsub deleted file mode 100644 index ccc76e823f..0000000000 --- a/servers/spatial_sound_2d/SCsub +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.servers_sources, "*.cpp") - -Export('env') diff --git a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp deleted file mode 100644 index 2bcc9644f1..0000000000 --- a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp +++ /dev/null @@ -1,1042 +0,0 @@ -/*************************************************************************/ -/* spatial_sound_2d_server_sw.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "spatial_sound_2d_server_sw.h" - -#include "os/os.h" -#include "servers/audio/audio_filter_sw.h" - - - -int SpatialSound2DServerSW::InternalAudioStream::get_channel_count() const { - - return AudioServer::get_singleton()->get_default_channel_count(); -} - -void SpatialSound2DServerSW::InternalAudioStream::set_mix_rate(int p_rate) { - - -} - -void SpatialSound2DServerSW::InternalAudioStream::update() { - - owner->_update_sources(); -} - -bool SpatialSound2DServerSW::InternalAudioStream::mix(int32_t *p_buffer,int p_frames) { - - return owner->internal_buffer_mix(p_buffer,p_frames); -} - -void SpatialSound2DServerSW::_update_sources() { - - _THREAD_SAFE_METHOD_ - for (Set<Source*>::Element *E=streaming_sources.front();E;E=E->next()) { - - Source *s=E->get(); - ERR_CONTINUE(!s->stream); - s->stream->update(); - } -} - - -SpatialSound2DServerSW::Room::Room() { - - //params[ROOM_PARAM_SPEED_OF_SOUND]=343.0; - params[ROOM_PARAM_PITCH_SCALE]=1.0; - params[ROOM_PARAM_VOLUME_SCALE_DB]=0; - params[ROOM_PARAM_REVERB_SEND]=0; - params[ROOM_PARAM_CHORUS_SEND]=0; - params[ROOM_PARAM_ATTENUATION_SCALE]=1.0; - params[ROOM_PARAM_ATTENUATION_HF_CUTOFF]=5000; - params[ROOM_PARAM_ATTENUATION_HF_FLOOR_DB]=-24.0; - params[ROOM_PARAM_ATTENUATION_HF_RATIO_EXP]=1.0; - params[ROOM_PARAM_ATTENUATION_REVERB_SCALE]=0.0; - override_other_sources=false; - reverb=ROOM_REVERB_HALL; - //octree_id=0; - level=-1; - - -} - - -SpatialSound2DServerSW::Source::Source() { - - params[SOURCE_PARAM_VOLUME_DB]=0.0; - params[SOURCE_PARAM_PITCH_SCALE]=1.0; - params[SOURCE_PARAM_ATTENUATION_MIN_DISTANCE]=1; - params[SOURCE_PARAM_ATTENUATION_MAX_DISTANCE]=100; - params[SOURCE_PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good) - stream=NULL; - voices.resize(1); - last_voice=0; -} - -SpatialSound2DServerSW::Source::Voice::Voice() { - - active=false; - restart=false; - pitch_scale=1.0; - volume_scale=0.0; - voice_rid=AudioServer::get_singleton()->voice_create(); - -} -SpatialSound2DServerSW::Source::Voice::~Voice() { - - AudioServer::get_singleton()->free(voice_rid); -} - - -SpatialSound2DServerSW::Listener::Listener() { - - params[LISTENER_PARAM_VOLUME_SCALE_DB]=0.0; - params[LISTENER_PARAM_PITCH_SCALE]=1.0; - params[LISTENER_PARAM_ATTENUATION_SCALE]=1.0; - params[LISTENER_PARAM_PAN_RANGE]=128; - -} - -/* SPACE */ -RID SpatialSound2DServerSW::space_create() { - - Space* space = memnew( Space ); - RID space_rid = space_owner.make_rid(space); - space->default_room=room_create(); - room_set_space(space->default_room,space_rid); - return space_rid; -} - -/* ROOM */ - -RID SpatialSound2DServerSW::room_create() { - - Room *room = memnew( Room ); - return room_owner.make_rid(room); -} - -void SpatialSound2DServerSW::room_set_space(RID p_room,RID p_space) { - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - - if (room->space.is_valid()) { - - Space *space = space_owner.get(room->space); - space->rooms.erase(p_room); - //space->octree.erase(room->octree_id); - //room->octree_id=0; - } - - room->space=RID(); - - if (p_space.is_valid()) { - - Space *space = space_owner.get(p_space); - ERR_FAIL_COND(!space); - space->rooms.insert(p_room); - //room->octree_id=space->octree.create(room,AABB()); - //set bounds - //AABB aabb = room->bounds.is_empty()?AABB():room->bounds.get_aabb(); - //space->octree.move(room->octree_id,room->transform.xform(aabb)); - room->space=p_space; - } - - -} - -RID SpatialSound2DServerSW::room_get_space(RID p_room) const { - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,RID()); - - - return room->space; -} - - - -void SpatialSound2DServerSW::room_set_bounds(RID p_room, const PoolVector<Point2>& p_bounds) { - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - - room->bounds=p_bounds; - - if (!room->space.is_valid()) - return; - - //AABB aabb = room->bounds.is_empty()?AABB():room->bounds.get_aabb(); - //Space* space = space_owner.get(room->space); - //ERR_FAIL_COND(!space); - - //space->octree.move(room->octree_id,room->transform.xform(aabb)); - -} -PoolVector<Point2> SpatialSound2DServerSW::room_get_bounds(RID p_room) const { - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,PoolVector<Point2>()); - - return room->bounds; -} - -void SpatialSound2DServerSW::room_set_transform(RID p_room, const Transform2D& p_transform) { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - room->transform=p_transform; - room->inverse_transform=p_transform.affine_inverse(); // needs to be done to unscale BSP properly - - if (!room->space.is_valid()) - return; - - /* - if (!room->bounds.is_empty()) { - - Space* space = space_owner.get(room->space); - ERR_FAIL_COND(!space); - - //space->octree.move(room->octree_id,room->transform.xform(room->bounds.get_aabb())); - }*/ -} - -Transform2D SpatialSound2DServerSW::room_get_transform(RID p_room) const { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,Transform2D()); - return room->transform; -} - - -void SpatialSound2DServerSW::room_set_param(RID p_room, RoomParam p_param, float p_value) { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - ERR_FAIL_INDEX(p_param,ROOM_PARAM_MAX); - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - room->params[p_param]=p_value; - -} -float SpatialSound2DServerSW::room_get_param(RID p_room, RoomParam p_param) const { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - ERR_FAIL_INDEX_V(p_param,ROOM_PARAM_MAX,0); - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,0); - return room->params[p_param]; -} - -void SpatialSound2DServerSW::room_set_level(RID p_room, int p_level) { - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - room->level =p_level; - -} - -int SpatialSound2DServerSW::room_get_level(RID p_room) const { - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,0); - return room->level; - -} - - -void SpatialSound2DServerSW::room_set_reverb(RID p_room, RoomReverb p_reverb) { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - room->reverb=p_reverb; - -} -SpatialSound2DServerSW::RoomReverb SpatialSound2DServerSW::room_get_reverb(RID p_room) const { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,ROOM_REVERB_SMALL); - return room->reverb; -} - -//useful for underwater or rooms with very strange conditions -void SpatialSound2DServerSW::room_set_force_params_to_all_sources(RID p_room, bool p_force) { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - room->override_other_sources=p_force; - -} -bool SpatialSound2DServerSW::room_is_forcing_params_to_all_sources(RID p_room) const { - - if (space_owner.owns(p_room)) - p_room=space_owner.get(p_room)->default_room; - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,false); - return room->override_other_sources; -} - -/* SOURCE */ - -RID SpatialSound2DServerSW::source_create(RID p_space) { - - Space *space = space_owner.get(p_space); - ERR_FAIL_COND_V(!space,RID()); - - Source *source = memnew( Source ); - source->space=p_space; - RID source_rid = source_owner.make_rid(source); - space->sources.insert(source_rid); - - return source_rid; -} - - -void SpatialSound2DServerSW::source_set_polyphony(RID p_source,int p_voice_count) { - - - ERR_FAIL_COND(p_voice_count<=0); // more than 32 is too much, change this if you really need more - if (p_voice_count>32) { - - ERR_PRINT("Voices will be clipped to 32"); - p_voice_count=32; - } - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - - if (p_voice_count<source->voices.size()) { - - for(int i=p_voice_count;i<source->voices.size();i++) { - active_voices.erase(ActiveVoice(source,i)); //erase from active voices - } - } - source->voices.resize(p_voice_count); - -} - -int SpatialSound2DServerSW::source_get_polyphony(RID p_source) const { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND_V(!source,-1); - return source->voices.size(); - -} - -void SpatialSound2DServerSW::source_set_transform(RID p_source, const Transform2D& p_transform) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - source->transform=p_transform; - source->transform.orthonormalize(); -} -Transform2D SpatialSound2DServerSW::source_get_transform(RID p_source) const { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND_V(!source,Transform2D()); - return source->transform; -} - -void SpatialSound2DServerSW::source_set_param(RID p_source, SourceParam p_param, float p_value) { - - ERR_FAIL_INDEX(p_param,SOURCE_PARAM_MAX); - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - source->params[p_param]=p_value; - -} -float SpatialSound2DServerSW::source_get_param(RID p_source, SourceParam p_param) const { - ERR_FAIL_INDEX_V(p_param,SOURCE_PARAM_MAX,0); - Source *source = source_owner.get(p_source); - ERR_FAIL_COND_V(!source,0); - return source->params[p_param]; - - -} - -void SpatialSound2DServerSW::source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - AudioServer::get_singleton()->lock(); - source->stream=p_stream; - _THREAD_SAFE_METHOD_ - - if (!p_stream) { - streaming_sources.erase(source); - active_voices.erase(ActiveVoice(source,VOICE_IS_STREAM)); - } else { - streaming_sources.insert(source); - active_voices.insert(ActiveVoice(source,VOICE_IS_STREAM)); - zeromem(source->stream_data.filter_state,sizeof(Source::StreamData::FilterState)*4); //reset filter for safetyness - p_stream->set_mix_rate(AudioServer::get_singleton()->get_default_mix_rate()); - } - - AudioServer::get_singleton()->unlock(); - -} //null to unset - -SpatialSound2DServer::SourceVoiceID SpatialSound2DServerSW::source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND_V(!source,SOURCE_INVALID_VOICE); - - int to_play=0; - - if (p_voice==SOURCE_NEXT_VOICE) { - to_play=source->last_voice+1; - if (to_play>=source->voices.size()) - to_play=0; - - } else - to_play=p_voice; - - ERR_FAIL_INDEX_V(to_play,source->voices.size(),SOURCE_INVALID_VOICE); - - source->voices[to_play].restart=true; - source->voices[to_play].sample_rid=p_sample; - source->voices[to_play].sample_mix_rate=p_mix_rate; - source->voices[to_play].pitch_scale=1; - source->voices[to_play].volume_scale=0; - source->last_voice=to_play; - active_voices.insert(ActiveVoice(source,to_play)); - return to_play; -} - -/* VOICES */ -void SpatialSound2DServerSW::source_voice_set_pitch_scale(RID p_source, SourceVoiceID p_voice, float p_pitch_scale) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - ERR_FAIL_INDEX(p_voice,source->voices.size()); - source->voices[p_voice].pitch_scale=p_pitch_scale; - -} -void SpatialSound2DServerSW::source_voice_set_volume_scale_db(RID p_source, SourceVoiceID p_voice, float p_db) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - ERR_FAIL_INDEX(p_voice,source->voices.size()); - source->voices[p_voice].volume_scale=p_db; - -} - -bool SpatialSound2DServerSW::source_is_voice_active(RID p_source, SourceVoiceID p_voice) const { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND_V(!source,false); - ERR_FAIL_INDEX_V(p_voice,source->voices.size(),false); - return source->voices[p_voice].active || source->voices[p_voice].restart; - -} -void SpatialSound2DServerSW::source_stop_voice(RID p_source, SourceVoiceID p_voice) { - - Source *source = source_owner.get(p_source); - ERR_FAIL_COND(!source); - ERR_FAIL_INDEX(p_voice,source->voices.size()); - if (source->voices[p_voice].active) { - AudioServer::get_singleton()->voice_stop(source->voices[p_voice].voice_rid); - } - source->voices[p_voice].active=false; - source->voices[p_voice].restart=false; - active_voices.erase(ActiveVoice(source,p_voice)); -} - -/* LISTENER */ - -RID SpatialSound2DServerSW::listener_create() { - - Listener *listener = memnew( Listener ); - RID listener_rid = listener_owner.make_rid(listener); - return listener_rid; - -} - -void SpatialSound2DServerSW::listener_set_space(RID p_listener,RID p_space) { - - Listener *listener = listener_owner.get(p_listener); - ERR_FAIL_COND(!listener); - - if (listener->space.is_valid()) { - - Space *lspace = space_owner.get(listener->space); - ERR_FAIL_COND(!lspace); - lspace->listeners.erase(p_listener); - } - - listener->space=RID(); - - if (p_space.is_valid()) { - Space *space = space_owner.get(p_space); - ERR_FAIL_COND(!space); - - listener->space=p_space; - space->listeners.insert(p_listener); - } - -} - -void SpatialSound2DServerSW::listener_set_transform(RID p_listener, const Transform2D& p_transform) { - - Listener *listener = listener_owner.get(p_listener); - ERR_FAIL_COND(!listener); - listener->transform=p_transform; - listener->transform.orthonormalize(); //must be done.. -} -Transform2D SpatialSound2DServerSW::listener_get_transform(RID p_listener) const { - - Listener *listener = listener_owner.get(p_listener); - ERR_FAIL_COND_V(!listener,Transform2D()); - return listener->transform; -} - -void SpatialSound2DServerSW::listener_set_param(RID p_listener, ListenerParam p_param, float p_value) { - - ERR_FAIL_INDEX(p_param,LISTENER_PARAM_MAX); - Listener *listener = listener_owner.get(p_listener); - ERR_FAIL_COND(!listener); - listener->params[p_param]=p_value; -} - -float SpatialSound2DServerSW::listener_get_param(RID p_listener, ListenerParam p_param) const { - - ERR_FAIL_INDEX_V(p_param,LISTENER_PARAM_MAX,0); - Listener *listener = listener_owner.get(p_listener); - ERR_FAIL_COND_V(!listener,0); - return listener->params[p_param]; -} - - -/* MISC */ - -void SpatialSound2DServerSW::free(RID p_id) { - - - if (space_owner.owns(p_id)) { - - Space *space = space_owner.get(p_id); - free(space->default_room); - - while(space->listeners.size()) { - listener_set_space(space->listeners.front()->get(),RID()); - } - while(space->sources.size()) { - free(space->sources.front()->get()); - } - while(space->rooms.size()) { - room_set_space(space->rooms.front()->get(),RID()); - } - space_owner.free(p_id); - memdelete(space); - - } else if (source_owner.owns(p_id)) { - - Source *source = source_owner.get(p_id); - if (source->stream) - source_set_audio_stream(p_id,NULL); - - Space *space = space_owner.get(source->space); - ERR_FAIL_COND(!space); - space->sources.erase(p_id); - for(int i=0;i<source->voices.size();i++) { - active_voices.erase(ActiveVoice(source,i)); - } - source_owner.free(p_id); - memdelete(source); - } else if (listener_owner.owns(p_id)) { - - Listener *listener = listener_owner.get(p_id); - if (listener->space.is_valid()) { - Space *space = space_owner.get(listener->space); - ERR_FAIL_COND(!space); - space->listeners.erase(p_id); - } - listener_owner.free(p_id); - memdelete(listener); - - } else if (room_owner.owns(p_id)) { - - Room *room = room_owner.get(p_id); - - if (room->space.is_valid()) { - Space *space = space_owner.get(room->space); - ERR_FAIL_COND(!space); - //space->octree.erase(room->octree_id); - space->rooms.erase(p_id); - } - room_owner.free(p_id); - memdelete(room); - } else { - ERR_PRINT("Attempt to free invalid ID") ; - } - -} - -void SpatialSound2DServerSW::_clean_up_owner(RID_OwnerBase *p_owner, const char *p_area) { - - List<RID> rids; - p_owner->get_owned_list(&rids); - - for(List<RID>::Element *I=rids.front();I;I=I->next()) { - if (OS::get_singleton()->is_stdout_verbose()) { - - print_line("Leaked RID ("+itos(I->get().get_id())+") of type "+String(p_area)); - } - free(I->get()); - } -} - -void SpatialSound2DServerSW::init() { - - internal_buffer = memnew_arr(int32_t, INTERNAL_BUFFER_SIZE*INTERNAL_BUFFER_MAX_CHANNELS); - internal_buffer_channels=AudioServer::get_singleton()->get_default_channel_count(); - - internal_audio_stream = memnew( InternalAudioStream ); - internal_audio_stream->owner=this; - internal_audio_stream_rid = AudioServer::get_singleton()->audio_stream_create(internal_audio_stream); - - AudioServer::get_singleton()->stream_set_active(internal_audio_stream_rid,true); - -} - - - -bool SpatialSound2DServerSW::internal_buffer_mix(int32_t *p_buffer,int p_frames) { - - if (streaming_sources.size()==0) - return false; //nothing to mix - - - for (Set<Source*>::Element *E=streaming_sources.front();E;E=E->next()) { - - Source *s=E->get(); - ERR_CONTINUE(!s->stream); - - int channels = s->stream->get_channel_count(); - Source::StreamData &sd=s->stream_data; - - int todo=p_frames; - - AudioFilterSW filter; - filter.set_sampling_rate(AudioServer::get_singleton()->get_default_mix_rate()); - filter.set_cutoff(sd.filter_cutoff); - filter.set_gain(sd.filter_gain); - filter.set_resonance(1); - filter.set_mode(AudioFilterSW::HIGHSHELF); - filter.set_stages(1); - AudioFilterSW::Coeffs coefs; - filter.prepare_coefficients(&coefs); - - int32_t in[4]; -#ifndef SPATIAL_SOUND_SERVER_NO_FILTER -#define DO_FILTER(m_c)\ - {\ - float val = in[m_c];\ - float pre=val;\ - val = val*coefs.b0 + sd.filter_state[m_c].hb[0]*coefs.b1 + sd.filter_state[m_c].hb[1]*coefs.b2 + sd.filter_state[m_c].ha[0]*coefs.a1 + sd.filter_state[m_c].ha[1]*coefs.a2;\ - sd.filter_state[m_c].ha[1]=sd.filter_state[m_c].ha[0];\ - sd.filter_state[m_c].hb[1]=sd.filter_state[m_c].hb[0]; \ - sd.filter_state[m_c].hb[0]=pre;\ - sd.filter_state[m_c].ha[0]=val;\ - in[m_c]=Math::fast_ftoi(val);\ - } -#else -#define DO_FILTER(m_c) -#endif - - while(todo) { - - int to_mix=MIN(todo,INTERNAL_BUFFER_SIZE); - - s->stream->mix(internal_buffer,to_mix); - - switch(internal_buffer_channels) { - - case 2: { - - float p = sd.panning.x*0.5+0.5; - float panf[2]={ (1.0-p),p }; - panf[0]*=sd.volume; - panf[1]*=sd.volume; - - int32_t pan[2]={Math::fast_ftoi(panf[0]*(1<<16)),Math::fast_ftoi(panf[1]*(1<<16))}; - - switch(channels) { - case 1: { - - for(int i=0;i<to_mix;i++) { - - in[0]=internal_buffer[i]; - in[1]=internal_buffer[i]; - DO_FILTER(0); - DO_FILTER(1); - p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]); - } - } break; - case 2: { - - for(int i=0;i<to_mix;i++) { - - in[0]=internal_buffer[(i<<1)+0]; - in[1]=internal_buffer[(i<<1)+1]; - DO_FILTER(0); - DO_FILTER(1); - p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]); - } - } break; - case 4: { - - for(int i=0;i<to_mix;i++) { - - in[0]=(internal_buffer[(i<<2)+0]+internal_buffer[(i<<2)+2])>>1; - in[1]=(internal_buffer[(i<<2)+1]+internal_buffer[(i<<2)+3])>>1; - DO_FILTER(0); - DO_FILTER(1); - p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]); - } - } break; - - } break; - - } break; - case 4: { - - float xp = sd.panning.x*0.5+0.5; - float yp = sd.panning.y*0.5+0.5; - float panf[4]={ (1.0-xp)*(1.0-yp),(xp)*(1.0-yp),(1.0-xp)*(yp),(xp)*(yp) }; - panf[0]*=sd.volume; - panf[1]*=sd.volume; - panf[2]*=sd.volume; - panf[3]*=sd.volume; - - int32_t pan[4]={ - Math::fast_ftoi(panf[0]*(1<<16)), - Math::fast_ftoi(panf[1]*(1<<16)), - Math::fast_ftoi(panf[2]*(1<<16)), - Math::fast_ftoi(panf[3]*(1<<16))}; - - switch(channels) { - case 1: { - - for(int i=0;i<to_mix;i++) { - - in[0]=internal_buffer[i]; - in[1]=internal_buffer[i]; - in[2]=internal_buffer[i]; - in[3]=internal_buffer[i]; - DO_FILTER(0); - DO_FILTER(1); - DO_FILTER(2); - DO_FILTER(3); - p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]); - p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]); - p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]); - } - } break; - case 2: { - - for(int i=0;i<to_mix;i++) { - - in[0]=internal_buffer[(i<<1)+0]; - in[1]=internal_buffer[(i<<1)+1]; - in[2]=internal_buffer[(i<<1)+0]; - in[3]=internal_buffer[(i<<1)+1]; - DO_FILTER(0); - DO_FILTER(1); - DO_FILTER(2); - DO_FILTER(3); - p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]); - p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]); - p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]); - } - } break; - case 4: { - - for(int i=0;i<to_mix;i++) { - - in[0]=internal_buffer[(i<<2)+0]; - in[1]=internal_buffer[(i<<2)+1]; - in[2]=internal_buffer[(i<<2)+2]; - in[3]=internal_buffer[(i<<2)+3]; - DO_FILTER(0); - DO_FILTER(1); - DO_FILTER(2); - DO_FILTER(3); - p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]); - p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]); - p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]); - p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]); - } - } break; - - } break; - - } break; - case 6: { - - - } break; - } - p_buffer+=to_mix*internal_buffer_channels; - todo-=to_mix; - - } - - } - - return true; -} - -void SpatialSound2DServerSW::update(float p_delta) { - - List<ActiveVoice> to_disable; - - for(Set<ActiveVoice>::Element *E=active_voices.front();E;E=E->next()) { - - Source *source = E->get().source; - int voice = E->get().voice; - - if (voice!=VOICE_IS_STREAM) { - Source::Voice &v=source->voices[voice]; - ERR_CONTINUE(!v.active && !v.restart); // likely a bug... - } - - //this could be optimized at some point... am not sure - Space *space=space_owner.get(source->space); - Room *room=room_owner.get(space->default_room); - - //compute mixing weights (support for multiple listeners in the same output) - float total_distance=0; - for(Set<RID>::Element *L=space->listeners.front();L;L=L->next()) { - Listener *listener=listener_owner.get(L->get()); - float d = listener->transform.get_origin().distance_to(source->transform.get_origin()); - if (d==0) - d=0.1; - total_distance+=d; - } - - //compute spatialization variables, weighted according to distance - float volume_attenuation = 0.0; - float air_absorption_hf_cutoff = 0.0; - float air_absorption = 0.0; - float pitch_scale=0.0; - Vector2 panning; - - for(Set<RID>::Element *L=space->listeners.front();L;L=L->next()) { - - Listener *listener=listener_owner.get(L->get()); - - Vector2 rel_vector = -listener->transform.xform_inv(source->transform.get_origin()); - //Vector2 source_rel_vector = source->transform.xform_inv(listener->transform.get_origin()).normalized(); - float distance=rel_vector.length(); - float weight = distance/total_distance; - float pscale=1.0; - - float distance_scale=listener->params[LISTENER_PARAM_ATTENUATION_SCALE]*room->params[ROOM_PARAM_ATTENUATION_SCALE]; - float distance_min=source->params[SOURCE_PARAM_ATTENUATION_MIN_DISTANCE]*distance_scale; - float distance_max=source->params[SOURCE_PARAM_ATTENUATION_MAX_DISTANCE]*distance_scale; - float attenuation_exp=source->params[SOURCE_PARAM_ATTENUATION_DISTANCE_EXP]; - float attenuation=1; - - if (distance_max>0) { - distance = CLAMP(distance,distance_min,distance_max); - attenuation = Math::pow(1.0 - ((distance - distance_min)/(distance_max-distance_min)),CLAMP(attenuation_exp,0.001,16)); - } - - float hf_attenuation_cutoff = room->params[ROOM_PARAM_ATTENUATION_HF_CUTOFF]; - float hf_attenuation_exp = room->params[ROOM_PARAM_ATTENUATION_HF_RATIO_EXP]; - float hf_attenuation_floor = room->params[ROOM_PARAM_ATTENUATION_HF_FLOOR_DB]; - float absorption=Math::db2linear(Math::lerp(hf_attenuation_floor,0,Math::pow(attenuation,hf_attenuation_exp))); - - // source emission cone -/* only for 3D - float emission_deg=source->params[SOURCE_PARAM_EMISSION_CONE_DEGREES]; - float emission_attdb=source->params[SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB]; - absorption*=_get_attenuation(source_rel_vector.dot(Vector2(0,0,-1)),emission_deg,emission_attdb); -*/ - Vector2 vpanning=rel_vector.normalized(); - if (distance < listener->params[LISTENER_PARAM_PAN_RANGE]) - vpanning*=distance/listener->params[LISTENER_PARAM_PAN_RANGE]; - - //listener stuff - - { - - // head cone -/* only for 3D - float reception_deg=listener->params[LISTENER_PARAM_RECEPTION_CONE_DEGREES]; - float reception_attdb=listener->params[LISTENER_PARAM_RECEPTION_CONE_ATTENUATION_DB]; - - absorption*=_get_attenuation(vpanning.dot(Vector2(0,0,-1)),reception_deg,reception_attdb); -*/ - - // scale - - attenuation*=Math::db2linear(listener->params[LISTENER_PARAM_VOLUME_SCALE_DB]); - pscale*=Math::db2linear(listener->params[LISTENER_PARAM_PITCH_SCALE]); - - - } - - - - - //add values - - volume_attenuation+=weight*attenuation; // plus other stuff i guess - air_absorption+=weight*absorption; - air_absorption_hf_cutoff+=weight*hf_attenuation_cutoff; - panning+=vpanning*weight; - pitch_scale+=pscale*weight; - - } - - RoomReverb reverb_room=ROOM_REVERB_HALL; - float reverb_send=0; - - /* APPLY ROOM SETTINGS */ - - { - pitch_scale*=room->params[ROOM_PARAM_PITCH_SCALE]; - volume_attenuation*=Math::db2linear(room->params[ROOM_PARAM_VOLUME_SCALE_DB]); - reverb_room=room->reverb; - reverb_send=Math::lerp(1.0,volume_attenuation,room->params[ROOM_PARAM_ATTENUATION_REVERB_SCALE])*room->params[ROOM_PARAM_REVERB_SEND]; - - } - - /* UPDATE VOICE & STREAM */ - - - - if (voice==VOICE_IS_STREAM) { - - //update voice!! - source->stream_data.panning=panning; - source->stream_data.volume=volume_attenuation*Math::db2linear(source->params[SOURCE_PARAM_VOLUME_DB]); - source->stream_data.reverb=reverb_room; - source->stream_data.reverb_send=reverb_send; - source->stream_data.filter_gain=air_absorption; - source->stream_data.filter_cutoff=air_absorption_hf_cutoff; - - if (!source->stream) //stream is gone bye bye - to_disable.push_back(ActiveVoice(source,voice)); // oh well.. - - } else if (voice>=0) { - //update stream!! - Source::Voice &v=source->voices[voice]; - - if (v.restart) - AudioServer::get_singleton()->voice_play(v.voice_rid,v.sample_rid); - - float volume_scale = Math::db2linear(v.volume_scale)*Math::db2linear(source->params[SOURCE_PARAM_VOLUME_DB]); - float volume = volume_attenuation*volume_scale; - reverb_send*=volume_scale; - int mix_rate = v.sample_mix_rate*v.pitch_scale*pitch_scale*source->params[SOURCE_PARAM_PITCH_SCALE]; - - - if (mix_rate<=0) { - - ERR_PRINT("Invalid mix rate for voice (0) check for invalid pitch_scale param."); - to_disable.push_back(ActiveVoice(source,voice)); // oh well.. - continue; //invalid mix rate, disabling - } - if (v.restart || v.last_volume!=volume) - AudioServer::get_singleton()->voice_set_volume(v.voice_rid,volume); - if (v.restart || v.last_mix_rate!=mix_rate) - AudioServer::get_singleton()->voice_set_mix_rate(v.voice_rid,mix_rate); - if (v.restart || v.last_filter_gain!=air_absorption || v.last_filter_cutoff!=air_absorption_hf_cutoff) - AudioServer::get_singleton()->voice_set_filter(v.voice_rid,AudioServer::FILTER_HIGH_SHELF,air_absorption_hf_cutoff,1.0,air_absorption); - if (v.restart || v.last_panning!=panning) { - AudioServer::get_singleton()->voice_set_pan(v.voice_rid,-panning.x,panning.y,0); - } - if (v.restart || v.last_reverb_room!=reverb_room || v.last_reverb_send!=reverb_send) - AudioServer::get_singleton()->voice_set_reverb(v.voice_rid,AudioServer::ReverbRoomType(reverb_room),reverb_send); - - v.last_volume=volume; - v.last_mix_rate=mix_rate; - v.last_filter_gain=air_absorption; - v.last_filter_cutoff=air_absorption_hf_cutoff; - v.last_panning=panning; - v.last_reverb_room=reverb_room; - v.last_reverb_send=reverb_send; - v.restart=false; - v.active=true; - - if (!AudioServer::get_singleton()->voice_is_active(v.voice_rid)) - to_disable.push_back(ActiveVoice(source,voice)); // oh well.. - } - } - - while(to_disable.size()) { - - ActiveVoice av = to_disable.front()->get(); - av.source->voices[av.voice].active=false; - av.source->voices[av.voice].restart=false; - active_voices.erase(av); - to_disable.pop_front(); - } - -} -void SpatialSound2DServerSW::finish() { - - AudioServer::get_singleton()->free(internal_audio_stream_rid); - memdelete(internal_audio_stream); - - _clean_up_owner(&source_owner,"Source"); - _clean_up_owner(&listener_owner,"Listener"); - _clean_up_owner(&room_owner,"Room"); - _clean_up_owner(&space_owner,"Space"); - - memdelete_arr(internal_buffer); -} - -SpatialSound2DServerSW::SpatialSound2DServerSW() { - -} diff --git a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h deleted file mode 100644 index 7999a8c22b..0000000000 --- a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h +++ /dev/null @@ -1,265 +0,0 @@ -/*************************************************************************/ -/* spatial_sound_2d_server_sw.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SPATIAL_SOUND_2D_SERVER_SW_H -#define SPATIAL_SOUND_2D_SERVER_SW_H - -#include "servers/spatial_sound_2d_server.h" - -#include "os/thread_safe.h" - - -class SpatialSound2DServerSW : public SpatialSound2DServer { - - GDCLASS(SpatialSound2DServerSW,SpatialSound2DServer); - - _THREAD_SAFE_CLASS_ - - enum { - INTERNAL_BUFFER_SIZE=4096, - INTERNAL_BUFFER_MAX_CHANNELS=4, - VOICE_IS_STREAM=-1 - - }; - - - struct InternalAudioStream : public AudioServer::AudioStream { - - ::SpatialSound2DServerSW *owner; - virtual int get_channel_count() const; - virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate - virtual bool mix(int32_t *p_buffer,int p_frames); - virtual void update(); - }; - - InternalAudioStream *internal_audio_stream; - RID internal_audio_stream_rid; - int32_t *internal_buffer; - int internal_buffer_channels; - - bool internal_buffer_mix(int32_t *p_buffer,int p_frames); - - struct Room; - - struct Space : public RID_Data { - - RID default_room; - Set<RID> rooms; - Set<RID> sources; - Set<RID> listeners; - - //Octree<Room> octree; - }; - - mutable RID_Owner<Space> space_owner; - - struct Room : public RID_Data { - RID space; - Transform2D transform; - Transform2D inverse_transform; - PoolVector<Point2> bounds; - RoomReverb reverb; - float params[ROOM_PARAM_MAX]; - bool override_other_sources; - //OctreeElementID octree_id; - int level; - - Room(); - }; - - mutable RID_Owner<Room> room_owner; - - - - struct Source : public RID_Data { - - struct Voice { - - RID voice_rid; - RID sample_rid; - bool active; - bool restart; - float pitch_scale; - float volume_scale; - int sample_mix_rate; - - - float last_volume; - float last_filter_gain; - float last_filter_cutoff; - Vector2 last_panning; - int last_mix_rate; - RoomReverb last_reverb_room; - float last_reverb_send; - - Voice(); - ~Voice(); - }; - - struct StreamData { - - - Vector2 panning; - RoomReverb reverb; - float reverb_send; - float volume; - float filter_gain; - float filter_cutoff; - - struct FilterState { - - float ha[2]; - float hb[2]; - } filter_state[4]; - - StreamData() { - - reverb_send=0; - reverb=ROOM_REVERB_HALL; - volume=1.0; - filter_gain=1; - filter_cutoff=5000; - - } - } stream_data; - - RID space; - Transform2D transform; - float params[SOURCE_PARAM_MAX]; - AudioServer::AudioStream *stream; - Vector<Voice> voices; - int last_voice; - - Source(); - }; - - mutable RID_Owner<Source> source_owner; - - struct Listener : public RID_Data { - - RID space; - Transform2D transform; - float params[LISTENER_PARAM_MAX]; - - Listener(); - }; - - mutable RID_Owner<Listener> listener_owner; - - struct ActiveVoice { - - Source *source; - int voice; - bool operator<(const ActiveVoice& p_voice) const { return (voice==p_voice.voice)?(source<p_voice.source):(voice<p_voice.voice); } - ActiveVoice(Source *p_source=NULL,int p_voice=0) { source=p_source; voice=p_voice; } - }; - - //Room *cull_rooms[MAX_CULL_ROOMS]; - - Set<Source*> streaming_sources; - Set<ActiveVoice> active_voices; - - void _clean_up_owner(RID_OwnerBase *p_owner, const char *p_area); - void _update_sources(); - -public: - - /* SPACE */ - virtual RID space_create(); - - /* ROOM */ - - virtual RID room_create(); - virtual void room_set_space(RID p_room,RID p_space); - virtual RID room_get_space(RID p_room) const; - - virtual void room_set_bounds(RID p_room, const PoolVector<Point2>& p_bounds); - virtual PoolVector<Point2> room_get_bounds(RID p_room) const; - virtual void room_set_transform(RID p_room, const Transform2D& p_transform); - virtual Transform2D room_get_transform(RID p_room) const; - - - virtual void room_set_param(RID p_room, RoomParam p_param, float p_value); - virtual float room_get_param(RID p_room, RoomParam p_param) const; - - virtual void room_set_level(RID p_room, int p_level); - virtual int room_get_level(RID p_room) const; - - virtual void room_set_reverb(RID p_room, RoomReverb p_reverb); - virtual RoomReverb room_get_reverb(RID p_room) const; - - //useful for underwater or rooms with very strange conditions - virtual void room_set_force_params_to_all_sources(RID p_room, bool p_force); - virtual bool room_is_forcing_params_to_all_sources(RID p_room) const; - - /* SOURCE */ - - virtual RID source_create(RID p_space); - - virtual void source_set_polyphony(RID p_source,int p_voice_count); - virtual int source_get_polyphony(RID p_source) const; - - virtual void source_set_transform(RID p_source, const Transform2D& p_transform); - virtual Transform2D source_get_transform(RID p_source) const; - - virtual void source_set_param(RID p_source, SourceParam p_param, float p_value); - virtual float source_get_param(RID p_source, SourceParam p_param) const; - - virtual void source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream); //null to unset - virtual SourceVoiceID source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice=SOURCE_NEXT_VOICE); - /* VOICES */ - virtual void source_voice_set_pitch_scale(RID p_source, SourceVoiceID p_voice, float p_pitch_scale); - virtual void source_voice_set_volume_scale_db(RID p_source, SourceVoiceID p_voice, float p_volume); - - virtual bool source_is_voice_active(RID p_source, SourceVoiceID p_voice) const; - virtual void source_stop_voice(RID p_source, SourceVoiceID p_voice); - - /* LISTENER */ - - virtual RID listener_create(); - virtual void listener_set_space(RID p_listener, RID p_space); - - virtual void listener_set_transform(RID p_listener, const Transform2D& p_transform); - virtual Transform2D listener_get_transform(RID p_listener) const; - - virtual void listener_set_param(RID p_listener, ListenerParam p_param, float p_value); - virtual float listener_get_param(RID p_listener, ListenerParam p_param) const; - - - /* MISC */ - - virtual void free(RID p_id); - - virtual void init(); - virtual void update(float p_delta); - virtual void finish(); - - SpatialSound2DServerSW(); -}; - -#endif // SPATIAL_SOUND_2D_SERVER_SW_H diff --git a/servers/spatial_sound_2d_server.cpp b/servers/spatial_sound_2d_server.cpp deleted file mode 100644 index 90f384ea2e..0000000000 --- a/servers/spatial_sound_2d_server.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************/ -/* spatial_sound_2d_server.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "spatial_sound_2d_server.h" - -SpatialSound2DServer *SpatialSound2DServer::singleton=NULL; - - -SpatialSound2DServer *SpatialSound2DServer::get_singleton() { - - return singleton; -} - - -SpatialSound2DServer::SpatialSound2DServer() { - - ERR_FAIL_COND(singleton!=NULL); - singleton=this; -} diff --git a/servers/spatial_sound_2d_server.h b/servers/spatial_sound_2d_server.h deleted file mode 100644 index 331caf8198..0000000000 --- a/servers/spatial_sound_2d_server.h +++ /dev/null @@ -1,164 +0,0 @@ -/*************************************************************************/ -/* spatial_sound_2d_server.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SPATIAL_SOUND_2D_SERVER_H -#define SPATIAL_SOUND_2D_SERVER_H - -#include "object.h" -#include "bsp_tree.h" -#include "servers/audio_server.h" - -class SpatialSound2DServer : public Object { - - GDCLASS(SpatialSound2DServer,Object); - static SpatialSound2DServer *singleton; -public: - - - enum { - SOURCE_INVALID_VOICE=-1, - SOURCE_NEXT_VOICE=-2, - }; - - typedef int SourceVoiceID; - - /* SPACE */ - virtual RID space_create()=0; - - /* ROOM */ - - virtual RID room_create()=0; - virtual void room_set_space(RID p_room,RID p_space)=0; - virtual RID room_get_space(RID p_room) const=0; - - - virtual void room_set_bounds(RID p_room, const PoolVector<Point2>& p_bounds)=0; - virtual PoolVector<Point2> room_get_bounds(RID p_room) const=0; - virtual void room_set_transform(RID p_room, const Transform2D& p_transform)=0; - virtual Transform2D room_get_transform(RID p_room) const=0; - - enum RoomParam { - ROOM_PARAM_PITCH_SCALE, - ROOM_PARAM_VOLUME_SCALE_DB, - ROOM_PARAM_REVERB_SEND, - ROOM_PARAM_CHORUS_SEND, - ROOM_PARAM_ATTENUATION_SCALE, - ROOM_PARAM_ATTENUATION_HF_CUTOFF, - ROOM_PARAM_ATTENUATION_HF_FLOOR_DB, - ROOM_PARAM_ATTENUATION_HF_RATIO_EXP, - ROOM_PARAM_ATTENUATION_REVERB_SCALE, - ROOM_PARAM_MAX - }; - - virtual void room_set_param(RID p_room, RoomParam p_param, float p_value)=0; - virtual float room_get_param(RID p_room, RoomParam p_param) const=0; - - enum RoomReverb { - ROOM_REVERB_SMALL, - ROOM_REVERB_MEDIUM, - ROOM_REVERB_LARGE, - ROOM_REVERB_HALL - }; - - virtual void room_set_reverb(RID p_room, RoomReverb p_reverb)=0; - virtual RoomReverb room_get_reverb(RID p_room) const=0; - - virtual void room_set_level(RID p_room, int p_level)=0; - virtual int room_get_level(RID p_room) const=0; - - //useful for underwater or rooms with very strange conditions - virtual void room_set_force_params_to_all_sources(RID p_room, bool p_force)=0; - virtual bool room_is_forcing_params_to_all_sources(RID p_room) const=0; - - /* SOURCE */ - - virtual RID source_create(RID p_space)=0; - - virtual void source_set_transform(RID p_source, const Transform2D& p_transform)=0; - virtual Transform2D source_get_transform(RID p_source) const=0; - - virtual void source_set_polyphony(RID p_source,int p_voice_count)=0; - virtual int source_get_polyphony(RID p_source) const=0; - - enum SourceParam { - - SOURCE_PARAM_VOLUME_DB, - SOURCE_PARAM_PITCH_SCALE, - SOURCE_PARAM_ATTENUATION_MIN_DISTANCE, - SOURCE_PARAM_ATTENUATION_MAX_DISTANCE, - SOURCE_PARAM_ATTENUATION_DISTANCE_EXP, - SOURCE_PARAM_MAX - }; - - virtual void source_set_param(RID p_source, SourceParam p_param, float p_value)=0; - virtual float source_get_param(RID p_source, SourceParam p_param) const=0; - - virtual void source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream)=0; //null to unset - virtual SourceVoiceID source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice=SOURCE_NEXT_VOICE)=0; - //voices - virtual void source_voice_set_pitch_scale(RID p_source,SourceVoiceID p_voice, float p_pitch_scale)=0; - virtual void source_voice_set_volume_scale_db(RID p_source,SourceVoiceID p_voice, float p_volume_db)=0; - - virtual bool source_is_voice_active(RID p_source,SourceVoiceID p_voice) const=0; - virtual void source_stop_voice(RID p_source,SourceVoiceID p_voice)=0; - - /* LISTENER */ - - enum ListenerParam { - - LISTENER_PARAM_VOLUME_SCALE_DB, - LISTENER_PARAM_PITCH_SCALE, - LISTENER_PARAM_ATTENUATION_SCALE, - LISTENER_PARAM_PAN_RANGE, - LISTENER_PARAM_MAX - }; - - virtual RID listener_create()=0; - virtual void listener_set_space(RID p_listener, RID p_space)=0; - - virtual void listener_set_transform(RID p_listener, const Transform2D& p_transform)=0; - virtual Transform2D listener_get_transform(RID p_listener) const=0; - - virtual void listener_set_param(RID p_listener, ListenerParam p_param, float p_value)=0; - virtual float listener_get_param(RID p_listener, ListenerParam p_param) const=0; - - /* MISC */ - - virtual void free(RID p_id)=0; - - virtual void init()=0; - virtual void update(float p_delta)=0; - virtual void finish()=0; - - static SpatialSound2DServer *get_singleton(); - - SpatialSound2DServer(); - -}; - -#endif // SPATIAL_SOUND_2D_SERVER_H diff --git a/servers/spatial_sound_server.cpp b/servers/spatial_sound_server.cpp deleted file mode 100644 index f49367d4c0..0000000000 --- a/servers/spatial_sound_server.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************/ -/* spatial_sound_server.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 "spatial_sound_server.h" - -SpatialSoundServer *SpatialSoundServer::singleton=NULL; - - -SpatialSoundServer *SpatialSoundServer::get_singleton() { - - return singleton; -} - - -SpatialSoundServer::SpatialSoundServer() { - - ERR_FAIL_COND(singleton!=NULL); - singleton=this; -} diff --git a/servers/spatial_sound_server.h b/servers/spatial_sound_server.h deleted file mode 100644 index 69ef71c84f..0000000000 --- a/servers/spatial_sound_server.h +++ /dev/null @@ -1,168 +0,0 @@ -/*************************************************************************/ -/* spatial_sound_server.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 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 SPATIAL_SOUND_SERVER_H -#define SPATIAL_SOUND_SERVER_H - -#include "object.h" -#include "bsp_tree.h" -#include "servers/audio_server.h" - -class SpatialSoundServer : public Object { - GDCLASS(SpatialSoundServer,Object); - - static SpatialSoundServer *singleton; -public: - - - enum { - SOURCE_INVALID_VOICE=-1, - SOURCE_NEXT_VOICE=-2, - }; - - typedef int SourceVoiceID; - - /* SPACE */ - virtual RID space_create()=0; - - /* ROOM */ - - virtual RID room_create()=0; - virtual void room_set_space(RID p_room,RID p_space)=0; - virtual RID room_get_space(RID p_room) const=0; - - - virtual void room_set_bounds(RID p_room, const BSP_Tree& p_bounds)=0; - virtual BSP_Tree room_get_bounds(RID p_room) const=0; - virtual void room_set_transform(RID p_room, const Transform& p_transform)=0; - virtual Transform room_get_transform(RID p_room) const=0; - - enum RoomParam { - ROOM_PARAM_SPEED_OF_SOUND_SCALE, - ROOM_PARAM_DOPPLER_FACTOR, - ROOM_PARAM_PITCH_SCALE, - ROOM_PARAM_VOLUME_SCALE_DB, - ROOM_PARAM_REVERB_SEND, - ROOM_PARAM_CHORUS_SEND, - ROOM_PARAM_ATTENUATION_SCALE, - ROOM_PARAM_ATTENUATION_HF_CUTOFF, - ROOM_PARAM_ATTENUATION_HF_FLOOR_DB, - ROOM_PARAM_ATTENUATION_HF_RATIO_EXP, - ROOM_PARAM_ATTENUATION_REVERB_SCALE, - ROOM_PARAM_MAX - }; - - virtual void room_set_param(RID p_room, RoomParam p_param, float p_value)=0; - virtual float room_get_param(RID p_room, RoomParam p_param) const=0; - - enum RoomReverb { - ROOM_REVERB_SMALL, - ROOM_REVERB_MEDIUM, - ROOM_REVERB_LARGE, - ROOM_REVERB_HALL - }; - - virtual void room_set_reverb(RID p_room, RoomReverb p_reverb)=0; - virtual RoomReverb room_get_reverb(RID p_room) const=0; - - virtual void room_set_level(RID p_room, int p_level)=0; - virtual int room_get_level(RID p_room) const=0; - - //useful for underwater or rooms with very strange conditions - virtual void room_set_force_params_to_all_sources(RID p_room, bool p_force)=0; - virtual bool room_is_forcing_params_to_all_sources(RID p_room) const=0; - - /* SOURCE */ - - virtual RID source_create(RID p_space)=0; - - virtual void source_set_transform(RID p_source, const Transform& p_transform)=0; - virtual Transform source_get_transform(RID p_source) const=0; - - virtual void source_set_polyphony(RID p_source,int p_voice_count)=0; - virtual int source_get_polyphony(RID p_source) const=0; - - enum SourceParam { - - SOURCE_PARAM_VOLUME_DB, - SOURCE_PARAM_PITCH_SCALE, - SOURCE_PARAM_ATTENUATION_MIN_DISTANCE, - SOURCE_PARAM_ATTENUATION_MAX_DISTANCE, - SOURCE_PARAM_ATTENUATION_DISTANCE_EXP, - SOURCE_PARAM_EMISSION_CONE_DEGREES, - SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB, - SOURCE_PARAM_MAX - }; - - virtual void source_set_param(RID p_source, SourceParam p_param, float p_value)=0; - virtual float source_get_param(RID p_source, SourceParam p_param) const=0; - - virtual void source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream)=0; //null to unset - virtual SourceVoiceID source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice=SOURCE_NEXT_VOICE)=0; - //voices - virtual void source_voice_set_pitch_scale(RID p_source,SourceVoiceID p_voice, float p_pitch_scale)=0; - virtual void source_voice_set_volume_scale_db(RID p_source,SourceVoiceID p_voice, float p_volume_db)=0; - - virtual bool source_is_voice_active(RID p_source,SourceVoiceID p_voice) const=0; - virtual void source_stop_voice(RID p_source,SourceVoiceID p_voice)=0; - - /* LISTENER */ - - enum ListenerParam { - - LISTENER_PARAM_VOLUME_SCALE_DB, - LISTENER_PARAM_PITCH_SCALE, - LISTENER_PARAM_ATTENUATION_SCALE, - LISTENER_PARAM_RECEPTION_CONE_DEGREES, - LISTENER_PARAM_RECEPTION_CONE_ATTENUATION_DB, - LISTENER_PARAM_MAX - }; - - virtual RID listener_create()=0; - virtual void listener_set_space(RID p_listener, RID p_space)=0; - - virtual void listener_set_transform(RID p_listener, const Transform& p_transform)=0; - virtual Transform listener_get_transform(RID p_listener) const=0; - - virtual void listener_set_param(RID p_listener, ListenerParam p_param, float p_value)=0; - virtual float listener_get_param(RID p_listener, ListenerParam p_param) const=0; - - /* MISC */ - - virtual void free(RID p_id)=0; - - virtual void init()=0; - virtual void update(float p_delta)=0; - virtual void finish()=0; - - static SpatialSoundServer *get_singleton(); - - SpatialSoundServer(); -}; - -#endif // SPATIAL_SOUND_SERVER_H diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 94a514e7c1..44bc9bfef5 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -1226,7 +1226,7 @@ public: virtual void multimesh_instance_set_color(RID p_multimesh,int p_index,const Color& p_color)=0; virtual RID multimesh_get_mesh(RID p_multimesh) const=0; - virtual AABB multimesh_get_aabb(RID p_multimesh) const=0;; + virtual AABB multimesh_get_aabb(RID p_multimesh) const=0; virtual Transform multimesh_instance_get_transform(RID p_multimesh,int p_index) const=0; virtual Color multimesh_instance_get_color(RID p_multimesh,int p_index) const=0; diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 6a6f437816..7dfd9822f7 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -374,7 +374,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() { char_idx++; return _make_token(TK_OP_GREATER_EQUAL); } else if (GETCHAR(0)=='<') { - char_idx++;; + char_idx++; if (GETCHAR(0)=='=') { char_idx++; return _make_token(TK_OP_ASSIGN_SHIFT_RIGHT); @@ -1966,7 +1966,7 @@ bool ShaderLanguage::_parse_function_arguments(BlockNode* p_block,const Map<Stri return true; } - _set_tkpos(pos);; + _set_tkpos(pos); while(true) { @@ -2557,7 +2557,7 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const } else if (l==2) { member_type=DataType(dt-2); } else if (l==3) { - member_type=DataType(dt-1);; + member_type=DataType(dt-1); } else if (l==4) { member_type=dt; } else { diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp index 2f7bcccf73..f4031b711d 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/visual/visual_server_canvas.cpp @@ -934,7 +934,7 @@ void VisualServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_ RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light); ERR_FAIL_COND(!clight); - int new_size = nearest_power_of_2(p_size);; + int new_size = nearest_power_of_2(p_size); if (new_size==clight->shadow_buffer_size) return; diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index e3bc0fb6c6..279da9149e 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -123,6 +123,7 @@ void VisualServerRaster::finish(){ VSG::rasterizer->finalize(); } + /* STATUS INFORMATION */ diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index da73980e08..1799585576 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -156,7 +156,7 @@ RID VisualServer::_make_test_cube() { PoolVector<Vector3> uvs; int vtx_idx=0; -#define ADD_VTX(m_idx);\ +#define ADD_VTX(m_idx) \ vertices.push_back( face_points[m_idx] );\ normals.push_back( normal_points[m_idx] );\ tangents.push_back( normal_points[m_idx][1] );\ diff --git a/thirdparty/README.md b/thirdparty/README.md index 42642c09b7..d0e8c05183 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -209,7 +209,7 @@ Files extracted from upstream source: ## zlib - Upstream: http://www.zlib.net/ -- Version: 1.2.10 +- Version: 1.2.11 - License: zlib Files extracted from upstream source: diff --git a/thirdparty/zlib/deflate.c b/thirdparty/zlib/deflate.c index 2ad890e354..1ec761448d 100644 --- a/thirdparty/zlib/deflate.c +++ b/thirdparty/zlib/deflate.c @@ -52,7 +52,7 @@ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.2.10 Copyright 1995-2017 Jean-loup Gailly and Mark Adler "; + " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -586,7 +586,8 @@ int ZEXPORT deflateParams(strm, level, strategy) } func = configuration_table[s->level].func; - if ((strategy != s->strategy || func != configuration_table[level].func)) { + if ((strategy != s->strategy || func != configuration_table[level].func) && + s->high_water) { /* Flush the last buffer: */ int err = deflate(strm, Z_BLOCK); if (err == Z_STREAM_ERROR) @@ -1671,8 +1672,6 @@ local block_state deflate_stored(s, flush) len = left + s->strm->avail_in; /* limit len to the input */ if (len > have) len = have; /* limit len to the output */ - if (left > len) - left = len; /* limit window pull to len */ /* If the stored block would be less than min_block in length, or if * unable to copy all of the available input when flushing, then try @@ -1681,13 +1680,13 @@ local block_state deflate_stored(s, flush) */ if (len < min_block && ((len == 0 && flush != Z_FINISH) || flush == Z_NO_FLUSH || - len - left != s->strm->avail_in)) + len != left + s->strm->avail_in)) break; /* Make a dummy stored block in pending to get the header bytes, * including any pending bits. This also updates the debugging counts. */ - last = flush == Z_FINISH && len - left == s->strm->avail_in ? 1 : 0; + last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0; _tr_stored_block(s, (char *)0, 0L, last); /* Replace the lengths in the dummy stored block with len. */ @@ -1699,14 +1698,16 @@ local block_state deflate_stored(s, flush) /* Write the stored block header bytes. */ flush_pending(s->strm); - /* Update debugging counts for the data about to be copied. */ #ifdef ZLIB_DEBUG + /* Update debugging counts for the data about to be copied. */ s->compressed_len += len << 3; s->bits_sent += len << 3; #endif /* Copy uncompressed bytes from the window to next_out. */ if (left) { + if (left > len) + left = len; zmemcpy(s->strm->next_out, s->window + s->block_start, left); s->strm->next_out += left; s->strm->avail_out -= left; @@ -1756,6 +1757,8 @@ local block_state deflate_stored(s, flush) s->block_start = s->strstart; s->insert += MIN(used, s->w_size - s->insert); } + if (s->high_water < s->strstart) + s->high_water = s->strstart; /* If the last block was written to next_out, then done. */ if (last) @@ -1783,6 +1786,8 @@ local block_state deflate_stored(s, flush) read_buf(s->strm, s->window + s->strstart, have); s->strstart += have; } + if (s->high_water < s->strstart) + s->high_water = s->strstart; /* There was not enough avail_out to write a complete worthy or flushed * stored block to next_out. Write a stored block to pending instead, if we diff --git a/thirdparty/zlib/gzlib.c b/thirdparty/zlib/gzlib.c index e142ffb3d7..4105e6aff9 100644 --- a/thirdparty/zlib/gzlib.c +++ b/thirdparty/zlib/gzlib.c @@ -1,5 +1,5 @@ /* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004, 2010, 2011, 2012, 2013, 2016 Mark Adler + * Copyright (C) 2004-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ diff --git a/thirdparty/zlib/gzwrite.c b/thirdparty/zlib/gzwrite.c index 1ec1da4095..c7b5651d70 100644 --- a/thirdparty/zlib/gzwrite.c +++ b/thirdparty/zlib/gzwrite.c @@ -1,5 +1,5 @@ /* gzwrite.c -- zlib functions for writing gzip files - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler + * Copyright (C) 2004-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ diff --git a/thirdparty/zlib/inffast.c b/thirdparty/zlib/inffast.c index 29eb7d8244..0dbd1dbc09 100644 --- a/thirdparty/zlib/inffast.c +++ b/thirdparty/zlib/inffast.c @@ -1,5 +1,5 @@ /* inffast.c -- fast decoding - * Copyright (C) 1995-2008, 2010, 2013, 2016 Mark Adler + * Copyright (C) 1995-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ diff --git a/thirdparty/zlib/inftrees.c b/thirdparty/zlib/inftrees.c index 8a904ddbce..2ea08fc13e 100644 --- a/thirdparty/zlib/inftrees.c +++ b/thirdparty/zlib/inftrees.c @@ -9,7 +9,7 @@ #define MAXBITS 15 const char inflate_copyright[] = - " inflate 1.2.10 Copyright 1995-2017 Mark Adler "; + " inflate 1.2.11 Copyright 1995-2017 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -62,7 +62,7 @@ unsigned short FAR *work; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 192, 202}; + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, diff --git a/thirdparty/zlib/trees.c b/thirdparty/zlib/trees.c index 357f313925..50cf4b4571 100644 --- a/thirdparty/zlib/trees.c +++ b/thirdparty/zlib/trees.c @@ -1,5 +1,5 @@ /* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2016 Jean-loup Gailly + * Copyright (C) 1995-2017 Jean-loup Gailly * detect_data_type() function provided freely by Cosmin Truta, 2006 * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -906,7 +906,7 @@ void ZLIB_INTERNAL _tr_align(s) /* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. + * trees or store, and write out the encoded block. */ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) deflate_state *s; diff --git a/thirdparty/zlib/zlib.h b/thirdparty/zlib/zlib.h index dc90dc8d22..f09cdaf1e0 100644 --- a/thirdparty/zlib/zlib.h +++ b/thirdparty/zlib/zlib.h @@ -1,5 +1,5 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.10, January 2nd, 2017 + version 1.2.11, January 15th, 2017 Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler @@ -37,11 +37,11 @@ extern "C" { #endif -#define ZLIB_VERSION "1.2.10" -#define ZLIB_VERNUM 0x12a0 +#define ZLIB_VERSION "1.2.11" +#define ZLIB_VERNUM 0x12b0 #define ZLIB_VER_MAJOR 1 #define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 10 +#define ZLIB_VER_REVISION 11 #define ZLIB_VER_SUBREVISION 0 /* @@ -712,10 +712,11 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression approach (which is a function of the level) or the - strategy is changed, then the input available so far is compressed with the - old level and strategy using deflate(strm, Z_BLOCK). There are three - approaches for the compression levels 0, 1..3, and 4..9 respectively. The - new level and strategy will take effect at the next call of deflate(). + strategy is changed, and if any input has been consumed in a previous + deflate() call, then the input available so far is compressed with the old + level and strategy using deflate(strm, Z_BLOCK). There are three approaches + for the compression levels 0, 1..3, and 4..9 respectively. The new level + and strategy will take effect at the next call of deflate(). If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does not have enough output space to complete, then the parameter change will not diff --git a/thirdparty/zlib/zutil.c b/thirdparty/zlib/zutil.c index 56534fba0f..a76c6b0c7e 100644 --- a/thirdparty/zlib/zutil.c +++ b/thirdparty/zlib/zutil.c @@ -1,5 +1,5 @@ /* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2005, 2010, 2011, 2012, 2016 Jean-loup Gailly + * Copyright (C) 1995-2017 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ diff --git a/tools/collada/collada.cpp b/tools/collada/collada.cpp index daf30b00d7..a23fd84aa0 100644 --- a/tools/collada/collada.cpp +++ b/tools/collada/collada.cpp @@ -29,6 +29,7 @@ #ifdef TOOLS_ENABLED #include "collada.h" + #include "stdio.h" //#define DEBUG_DEFAULT_ANIMATION @@ -1295,7 +1296,7 @@ void Collada::_parse_skin_controller(XMLParser& parser,String p_id) { int stride=1; if (parser.has_attribute("stride")) - stride=parser.get_attribute_value("stride").to_int();; + stride=parser.get_attribute_value("stride").to_int(); skindata.sources[current_source].stride=stride; COLLADA_PRINT("section: "+current_source+" stride "+itos(skindata.sources[current_source].stride)); @@ -1470,7 +1471,7 @@ void Collada::_parse_morph_controller(XMLParser& parser, String p_id) { int stride=1; if (parser.has_attribute("stride")) - stride=parser.get_attribute_value("stride").to_int();; + stride=parser.get_attribute_value("stride").to_int(); morphdata.sources[current_source].stride=stride; COLLADA_PRINT("section: "+current_source+" stride "+itos(morphdata.sources[current_source].stride)); diff --git a/tools/doc/doc_data.cpp b/tools/doc/doc_data.cpp index f18265c541..d51dc886b2 100644 --- a/tools/doc/doc_data.cpp +++ b/tools/doc/doc_data.cpp @@ -26,9 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "doc_data.h" +#include "version.h" #include "global_constants.h" #include "globals.h" #include "script_language.h" diff --git a/tools/doc/doc_dump.cpp b/tools/doc/doc_dump.cpp index e1ffcfbbb2..5ebba596e9 100644 --- a/tools/doc/doc_dump.cpp +++ b/tools/doc/doc_dump.cpp @@ -26,8 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "doc_dump.h" + +#include "version.h" #include "os/file_access.h" #include "scene/main/node.h" diff --git a/tools/doc/doc_dump.h b/tools/doc/doc_dump.h index 4577af078e..84629b89c8 100644 --- a/tools/doc/doc_dump.h +++ b/tools/doc/doc_dump.h @@ -29,7 +29,7 @@ #ifndef DOC_DUMP_H #define DOC_DUMP_H -#include "object_type_db.h" +#include "class_db.h" class DocDump { public: diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index cb95f5fb7d..759d33dea8 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "animation_editor.h" + #include "editor_settings.h" #include "os/keyboard.h" #include "os/os.h" @@ -518,7 +519,7 @@ public: case Animation::TYPE_VALUE: { if (name=="value") { - r_ret = animation->track_get_key_value(track,key);; + r_ret = animation->track_get_key_value(track,key); return true; } @@ -1916,7 +1917,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) { else _menu_track(TRACK_MENU_DUPLICATE); - accept_event();; + accept_event(); } else if (p_input.key.scancode==KEY_DELETE && p_input.key.pressed && click.click==ClickOver::CLICK_NONE) { @@ -2917,7 +2918,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) { } break; case Animation::TYPE_VALUE: { - Variant v = animation->track_get_key_value(idx,mouse_over.over_key);; + Variant v = animation->track_get_key_value(idx,mouse_over.over_key); //text+="value: "+String(v)+"\n"; bool prop_exists=false; @@ -3706,7 +3707,7 @@ void AnimationKeyEditor::_pane_drag(const Point2& p_delta) { ecs.y-=p_delta.y; if (ecs.y<100) ecs.y=100; - ec->set_custom_minimum_size(ecs);; + ec->set_custom_minimum_size(ecs); } diff --git a/tools/editor/asset_library_editor_plugin.cpp b/tools/editor/asset_library_editor_plugin.cpp index ad17364685..6ba7a7e79b 100644 --- a/tools/editor/asset_library_editor_plugin.cpp +++ b/tools/editor/asset_library_editor_plugin.cpp @@ -27,12 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "asset_library_editor_plugin.h" + #include "editor_node.h" #include "editor_settings.h" #include "io/json.h" - void EditorAssetLibraryItem::configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost) { title->set_text(p_title); @@ -789,7 +789,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons } } - image_queue[p_queue_id].request->queue_delete();; + image_queue[p_queue_id].request->queue_delete(); image_queue.erase(p_queue_id); _update_image_queue(); diff --git a/tools/editor/call_dialog.cpp b/tools/editor/call_dialog.cpp index f8966093f6..6dfeb87dfd 100644 --- a/tools/editor/call_dialog.cpp +++ b/tools/editor/call_dialog.cpp @@ -30,7 +30,7 @@ #if 0 #include "scene/gui/label.h" -#include "object_type_db.h" +#include "class_db.h" #include "print_string.h" diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index 00767fd297..0a25b43716 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "code_editor.h" + #include "editor_settings.h" #include "scene/gui/margin_container.h" #include "scene/gui/separator.h" diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp index 92dd206030..91ba419c97 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -28,10 +28,7 @@ /*************************************************************************/ #include "connections_dialog.h" - #include "scene/gui/label.h" - - #include "print_string.h" #include "editor_settings.h" #include "editor_node.h" diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp index b69234e704..53e968f389 100644 --- a/tools/editor/create_dialog.cpp +++ b/tools/editor/create_dialog.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "create_dialog.h" -#include "object_type_db.h" +#include "class_db.h" #include "print_string.h" #include "scene/gui/box_container.h" #include "editor_node.h" diff --git a/tools/editor/dependency_editor.cpp b/tools/editor/dependency_editor.cpp index 20e185104b..a01383a868 100644 --- a/tools/editor/dependency_editor.cpp +++ b/tools/editor/dependency_editor.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "dependency_editor.h" + #include "os/file_access.h" #include "scene/gui/margin_container.h" #include "io/resource_loader.h" diff --git a/tools/editor/editor_asset_installer.cpp b/tools/editor/editor_asset_installer.cpp index 9992100ff8..8af01012a4 100644 --- a/tools/editor/editor_asset_installer.cpp +++ b/tools/editor/editor_asset_installer.cpp @@ -27,10 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_asset_installer.h" + #include "io/zip_io.h" #include "os/dir_access.h" #include "os/file_access.h" #include "editor_node.h" + void EditorAssetInstaller::_update_subitems(TreeItem* p_item,bool p_check,bool p_first) { diff --git a/tools/editor/editor_autoload_settings.cpp b/tools/editor/editor_autoload_settings.cpp index 087bf1a3b7..0038ab48d5 100644 --- a/tools/editor/editor_autoload_settings.cpp +++ b/tools/editor/editor_autoload_settings.cpp @@ -26,12 +26,10 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "editor_autoload_settings.h" #include "globals.h" #include "global_constants.h" - #include "editor_node.h" #define PREVIEW_LIST_MAX_SIZE 10 diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp index 08b03ae65f..44de1836b6 100644 --- a/tools/editor/editor_data.cpp +++ b/tools/editor/editor_data.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_data.h" + #include "globals.h" #include "editor_settings.h" #include "os/dir_access.h" diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp index e2b7d475b0..bb9ddc2aef 100644 --- a/tools/editor/editor_dir_dialog.cpp +++ b/tools/editor/editor_dir_dialog.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_dir_dialog.h" + #include "os/os.h" #include "os/keyboard.h" #include "tools/editor/editor_settings.h" diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index d4ca515493..e23e2419d8 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_file_dialog.h" + #include "scene/gui/label.h" #include "scene/gui/center_container.h" #include "print_string.h" @@ -36,6 +37,7 @@ #include "scene/gui/margin_container.h" #include "os/file_access.h" #include "editor_scale.h" + EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func=NULL; EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func=NULL; @@ -1150,7 +1152,7 @@ void EditorFileDialog::set_display_mode(DisplayMode p_mode) { mode_list->set_pressed(true); } display_mode=p_mode; - invalidate();; + invalidate(); } EditorFileDialog::DisplayMode EditorFileDialog::get_display_mode() const{ diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index 1d32415be9..39869beef4 100644 --- a/tools/editor/editor_file_system.cpp +++ b/tools/editor/editor_file_system.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_file_system.h" + #include "globals.h" #include "io/resource_loader.h" #include "os/os.h" diff --git a/tools/editor/editor_fonts.cpp b/tools/editor/editor_fonts.cpp index 3c846fc538..3652a59978 100644 --- a/tools/editor/editor_fonts.cpp +++ b/tools/editor/editor_fonts.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_fonts.h" + #include "doc_font.h" #include "doc_title_font.h" #include "doc_code_font.h" diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index f96a02bc52..03e631cbc3 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -27,15 +27,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_help.h" + #include "editor_node.h" #include "editor_settings.h" #include "os/keyboard.h" #include "doc_data_compressed.h" #include "tools/editor/plugins/script_editor_plugin.h" - -#include "os/keyboard.h" - void EditorHelpSearch::popup() { popup_centered_ratio(0.6); if (search_box->get_text()!="") { diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index cf83052ee0..a94604743c 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -26,8 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "editor_import_export.h" + +#include "version.h" #include "script_language.h" #include "globals.h" #include "os/file_access.h" @@ -1174,7 +1175,7 @@ Error EditorExportPlatform::save_pack_file(void *p_userdata,const String& p_path pd->f->store_32(cs.length()); pd->f->store_buffer((uint8_t*)cs.get_data(),cs.length()); TempData td; - td.pos=pd->f->get_pos();; + td.pos=pd->f->get_pos(); td.ofs=pd->ftmp->get_pos(); td.size=p_data.size(); pd->file_ofs.push_back(td); diff --git a/tools/editor/editor_initialize_ssl.cpp b/tools/editor/editor_initialize_ssl.cpp index 9ac4f90e9f..c08dcc6656 100644 --- a/tools/editor/editor_initialize_ssl.cpp +++ b/tools/editor/editor_initialize_ssl.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_initialize_ssl.h" + #include "certs_compressed.h" #include "io/stream_peer_ssl.h" #include "io/compression.h" diff --git a/tools/editor/editor_log.cpp b/tools/editor/editor_log.cpp index fd2da2e4c0..6b6a1b9988 100644 --- a/tools/editor/editor_log.cpp +++ b/tools/editor/editor_log.cpp @@ -26,8 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "editor_log.h" + +#include "version.h" #include "scene/gui/center_container.h" #include "editor_node.h" diff --git a/tools/editor/editor_name_dialog.cpp b/tools/editor/editor_name_dialog.cpp index e7dcea4d40..da9f25f1e3 100644 --- a/tools/editor/editor_name_dialog.cpp +++ b/tools/editor/editor_name_dialog.cpp @@ -26,9 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "editor_name_dialog.h" -#include "object_type_db.h" + +#include "class_db.h" #include "os/keyboard.h" void EditorNameDialog::_line_gui_input(const InputEvent& p_event) { diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index bb33f19a2b..0c8d786f03 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -26,22 +26,20 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "editor_node.h" + +#include "version.h" #include "print_string.h" #include "editor_themes.h" - #include "editor_help.h" #include "core/io/resource_saver.h" #include "core/io/resource_loader.h" #include "servers/physics_2d_server.h" #include "scene/resources/packed_scene.h" #include "editor_settings.h" -#include "io_plugins/editor_import_collada.h" -#include "io_plugins/editor_scene_importer_fbxconv.h" #include "globals.h" #include <stdio.h> -#include "object_type_db.h" +#include "class_db.h" #include "os/keyboard.h" #include "os/os.h" #include "os/file_access.h" @@ -56,6 +54,8 @@ #include "io/config_file.h" #include "animation_editor.h" #include "io/stream_peer_ssl.h" +#include "main/input_default.h" + // plugins #include "plugins/sprite_frames_editor_plugin.h" #include "plugins/texture_region_editor_plugin.h" @@ -76,7 +76,6 @@ #include "plugins/mesh_instance_editor_plugin.h" #include "plugins/mesh_editor_plugin.h" #include "plugins/theme_editor_plugin.h" - #include "plugins/tile_map_editor_plugin.h" #include "plugins/cube_grid_theme_editor_plugin.h" #include "plugins/shader_editor_plugin.h" @@ -100,17 +99,19 @@ #include "plugins/color_ramp_editor_plugin.h" #include "plugins/collision_shape_2d_editor_plugin.h" #include "plugins/gi_probe_editor_plugin.h" -#include "main/input_default.h" + // end -#include "tools/editor/editor_settings.h" -#include "tools/editor/io_plugins/editor_texture_import_plugin.h" -#include "tools/editor/io_plugins/editor_scene_import_plugin.h" -#include "tools/editor/io_plugins/editor_font_import_plugin.h" -#include "tools/editor/io_plugins/editor_sample_import_plugin.h" -#include "tools/editor/io_plugins/editor_translation_import_plugin.h" -#include "tools/editor/io_plugins/editor_bitmask_import_plugin.h" -#include "tools/editor/io_plugins/editor_mesh_import_plugin.h" -#include "tools/editor/io_plugins/editor_export_scene.h" +#include "editor_settings.h" +#include "io_plugins/editor_texture_import_plugin.h" +#include "io_plugins/editor_scene_import_plugin.h" +#include "io_plugins/editor_font_import_plugin.h" +#include "io_plugins/editor_sample_import_plugin.h" +#include "io_plugins/editor_translation_import_plugin.h" +#include "io_plugins/editor_bitmask_import_plugin.h" +#include "io_plugins/editor_mesh_import_plugin.h" +#include "io_plugins/editor_export_scene.h" +#include "io_plugins/editor_import_collada.h" +#include "io_plugins/editor_scene_importer_fbxconv.h" #include "plugins/editor_preview_plugins.h" #include "editor_initialize_ssl.h" @@ -279,7 +280,7 @@ void EditorNode::_notification(int p_what) { editor_selection->update(); { - uint32_t p32 = AudioServer::get_singleton()->read_output_peak()>>8; + uint32_t p32 = 0;//AudioServer::get_singleton()->read_output_peak()>>8; float peak = p32==0? -80 : Math::linear2db(p32 / 65535.0); @@ -830,7 +831,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj,Map<RES,bool>& p case Variant::DICTIONARY: { - Dictionary d=obj->get(E->get().name);; + Dictionary d=obj->get(E->get().name); List<Variant> keys; d.get_key_list(&keys); for(List<Variant>::Element *E=keys.front();E;E=E->next()) { @@ -916,7 +917,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { save.step(TTR("Creating Thumbnail"),3); #if 0 Image img = VS::get_singleton()->viewport_texture(scree_capture(viewport); - int preview_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");; + int preview_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); preview_size*=EDSCALE; int width,height; if (img.get_width() > preview_size && img.get_width() >= img.get_height()) { @@ -1055,7 +1056,7 @@ void EditorNode::_import_action(const String& p_action) { //accept->get_cancel()->hide(); accept->get_ok()->set_text("Ugh"); accept->set_text("Error importing scene."); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); return; } @@ -1071,7 +1072,7 @@ void EditorNode::_import_action(const String& p_action) { //accept->get_cancel()->hide(); accept->get_ok()->set_text("Ugh"); accept->set_text("Error load scene to update."); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); return; } @@ -1112,7 +1113,7 @@ void EditorNode::_import(const String &p_file) { //accept->get_cancel()->hide(); accept->get_ok()->set_text("Ugh"); accept->set_text("Error importing scene."); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); return; } @@ -2254,7 +2255,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { //confirmation->get_cancel()->hide(); accept->get_ok()->set_text("I see.."); accept->set_text("This operation can't be done without a tree root."); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); break; } @@ -2276,7 +2277,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { //confirmation->get_cancel()->hide(); accept->get_ok()->set_text("I see.."); accept->set_text("Please save the scene first."); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); break; } @@ -2291,7 +2292,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { Ref<EditorExporter> exporter = export_db->get_exporter(target); if (exporter.is_null()) { accept->set_text("No exporter for platform '"+target+"' yet."); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); return; } @@ -2474,7 +2475,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { //accept->get_cancel()->hide(); accept->get_ok()->set_text("I see.."); accept->set_text("This operation can't be done without a selected node."); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); break; } @@ -2486,7 +2487,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { //confirmation->get_cancel()->hide(); accept->get_ok()->set_text("I see.."); accept->set_text("This operation can't be done without a selected node."); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); break; } @@ -2498,7 +2499,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { //accept->get_cancel()->hide(); accept->get_ok()->set_text("Ugh"); accept->set_text("Error loading scene from "+external_file); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); return; } @@ -2593,20 +2594,20 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case OBJECT_COPY_PARAMS: { - editor_data.apply_changes_in_editors();; + editor_data.apply_changes_in_editors(); if (current) editor_data.copy_object_params(current); } break; case OBJECT_PASTE_PARAMS: { - editor_data.apply_changes_in_editors();; + editor_data.apply_changes_in_editors(); if (current) editor_data.paste_object_params(current); editor_data.get_undo_redo().clear_history(); } break; case OBJECT_UNIQUE_RESOURCES: { - editor_data.apply_changes_in_editors();; + editor_data.apply_changes_in_editors(); if (current) { List<PropertyInfo> props; current->get_property_list(&props); @@ -2914,7 +2915,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { //accept->get_cancel()->hide(); accept->get_ok()->set_text("I see.."); accept->set_text("Can't import if edited scene was not saved."); //i dont think this code will ever run - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); break; } @@ -2934,7 +2935,16 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { default: { - if (p_option>=OBJECT_METHOD_BASE) { + if (p_option>=TOOL_MENU_BASE) { + int idx = p_option - TOOL_MENU_BASE; + + if (tool_menu_items[idx].submenu != "") + break; + + Object *handler = ObjectDB::get_instance(tool_menu_items[idx].handler); + ERR_FAIL_COND(!handler); + handler->call(tool_menu_items[idx].callback, tool_menu_items[idx].ud); + } else if (p_option>=OBJECT_METHOD_BASE) { ERR_FAIL_COND(!current); @@ -3372,7 +3382,7 @@ Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_pres //accept->"()->hide(); accept->get_ok()->set_text("I see.."); accept->set_text("Optimizer preset not found: "+p_preset); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); ERR_EXPLAIN("Optimizer preset not found: "+p_preset); ERR_FAIL_V(ERR_INVALID_PARAMETER); @@ -3432,7 +3442,7 @@ Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_pres //accept->get_cancel()->hide(); accept->get_ok()->set_text("I see.."); accept->set_text("Couldn't save scene. Likely dependencies (instances) couldn't be satisfied."); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); return ERR_INVALID_DATA; } @@ -3443,7 +3453,7 @@ Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_pres //accept->"()->hide(); accept->get_ok()->set_text("I see.."); accept->set_text("Error saving optimized scene: "+path); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); ERR_FAIL_COND_V(err,err); @@ -4028,7 +4038,7 @@ void EditorNode::_save_optimized() { //accept->"()->hide(); accept->get_ok()->set_text("I see.."); accept->set_text("Error saving optimized scene: "+path); - accept->popup_centered(Size2(300,70));; + accept->popup_centered(Size2(300,70)); return; } @@ -5269,6 +5279,100 @@ void EditorNode::add_plugin_init_callback(EditorPluginInitializeCallback p_callb EditorPluginInitializeCallback EditorNode::plugin_init_callbacks[EditorNode::MAX_INIT_CALLBACKS]; +void EditorNode::_tool_menu_insert_item(const ToolMenuItem& p_item) { + + int idx = tool_menu_items.size(); + + String cat; + if (p_item.name.find("/") >= 0) { + cat = p_item.name.get_slice("/", 0); + } else { + idx = 0; + cat = ""; + } + + for (int i = tool_menu_items.size() - 1; i >= 0; i--) { + String name = tool_menu_items[i].name; + + if (name.begins_with(cat) && (cat != "" || name.find("/") < 0)) { + idx = i + 1; + break; + } + } + + tool_menu_items.insert(idx, p_item); +} + +void EditorNode::_rebuild_tool_menu() const { + + if (_initializing_tool_menu) + return; + + PopupMenu *menu = tool_menu->get_popup(); + menu->clear(); + + for (int i = 0; i < tool_menu_items.size(); i++) { + menu->add_item(tool_menu_items[i].name.get_slice("/", 1), TOOL_MENU_BASE + i); + + if (tool_menu_items[i].submenu != "") + menu->set_item_submenu(i, tool_menu_items[i].submenu); + } +} + +void EditorNode::add_tool_menu_item(const String& p_name, Object *p_handler, const String& p_callback, const Variant& p_ud) { + + ERR_FAIL_COND(!p_handler); + + ToolMenuItem tmi; + tmi.name = p_name; + tmi.submenu = ""; + tmi.ud = p_ud; + tmi.handler = p_handler->get_instance_ID(); + tmi.callback = p_callback; + _tool_menu_insert_item(tmi); + + _rebuild_tool_menu(); +} + +void EditorNode::add_tool_submenu_item(const String& p_name, PopupMenu *p_submenu) { + + ERR_FAIL_COND(!p_submenu); + ERR_FAIL_COND(p_submenu->get_parent() != NULL); + + ToolMenuItem tmi; + tmi.name = p_name; + tmi.submenu = p_submenu->get_name(); + tmi.ud = Variant(); + tmi.handler = -1; + tmi.callback = ""; + _tool_menu_insert_item(tmi); + + tool_menu->get_popup()->add_child(p_submenu); + + _rebuild_tool_menu(); +} + +void EditorNode::remove_tool_menu_item(const String& p_name) { + + for (int i = 0; i < tool_menu_items.size(); i++) { + if (tool_menu_items[i].name == p_name) { + String submenu = tool_menu_items[i].submenu; + + if (submenu != "") { + Node *n = tool_menu->get_popup()->get_node(submenu); + + if (n) { + tool_menu->get_popup()->remove_child(n); + memdelete(n); + } + } + + tool_menu_items.remove(i); + } + } + + _rebuild_tool_menu(); +} int EditorNode::build_callback_count=0; @@ -5412,9 +5516,11 @@ EditorNode::EditorNode() { docks_visible = true; + _initializing_tool_menu = true; + FileAccess::set_backup_save(true); - PathRemap::get_singleton()->clear_remaps();; //editor uses no remaps + PathRemap::get_singleton()->clear_remaps(); //editor uses no remaps TranslationServer::get_singleton()->set_enabled(false); // load settings if (!EditorSettings::get_singleton()) @@ -5509,7 +5615,7 @@ EditorNode::EditorNode() { #if 0 PanelContainer *top_dark_panel = memnew( PanelContainer ); Ref<StyleBoxTexture> top_dark_sb; - top_dark_sb.instance();; + top_dark_sb.instance(); top_dark_sb->set_texture(theme->get_icon("PanelTop","EditorIcons")); for(int i=0;i<4;i++) { top_dark_sb->set_margin_size(Margin(i),3); @@ -5831,7 +5937,7 @@ EditorNode::EditorNode() { #if 0 node_menu = memnew( MenuButton ); node_menu->set_text("Node"); - node_menu->set_pos( Point2( 50,0) );; + node_menu->set_pos( Point2( 50,0) ); menu_panel->add_child( node_menu ); p=node_menu->get_popup(); @@ -5871,10 +5977,9 @@ EditorNode::EditorNode() { //tool_menu->set_icon(gui_base->get_icon("Save","EditorIcons")); left_menu_hb->add_child( tool_menu ); + tool_menu->get_popup()->connect("id_pressed", this, "_menu_option"); - p=tool_menu->get_popup(); - p->connect("id_pressed",this,"_menu_option"); - p->add_item(TTR("Orphan Resource Explorer"),TOOLS_ORPHAN_RESOURCES); + add_tool_menu_item(TTR("Orphan Resource Explorer"), this, "_menu_option", TOOLS_ORPHAN_RESOURCES); export_button = memnew( ToolButton ); export_button->set_tooltip(TTR("Export the project to many platforms.")); @@ -6350,7 +6455,7 @@ EditorNode::EditorNode() { animation_menu->set_focus_mode(Control::FOCUS_NONE); menu_panel->add_child(animation_menu); animation_menu->set_icon(gui_base->get_icon("Animation","EditorIcons")); - animation_menu->connect("pressed",this,"_animation_visibility_toggle");; + animation_menu->connect("pressed",this,"_animation_visibility_toggle"); */ @@ -6543,13 +6648,13 @@ EditorNode::EditorNode() { // editor_import_export->add_import_plugin( Ref<EditorSceneAnimationImportPlugin>( memnew(EditorSceneAnimationImportPlugin(this)))); editor_import_export->add_import_plugin( Ref<EditorMeshImportPlugin>( memnew(EditorMeshImportPlugin(this)))); editor_import_export->add_import_plugin( Ref<EditorFontImportPlugin>( memnew(EditorFontImportPlugin(this)))); - editor_import_export->add_import_plugin( Ref<EditorSampleImportPlugin>( memnew(EditorSampleImportPlugin(this)))); +// editor_import_export->add_import_plugin( Ref<EditorSampleImportPlugin>( memnew(EditorSampleImportPlugin(this)))); editor_import_export->add_import_plugin( Ref<EditorTranslationImportPlugin>( memnew(EditorTranslationImportPlugin(this)))); editor_import_export->add_import_plugin( Ref<EditorBitMaskImportPlugin>( memnew(EditorBitMaskImportPlugin(this)))); editor_import_export->add_export_plugin( Ref<EditorTextureExportPlugin>( memnew(EditorTextureExportPlugin))); - editor_import_export->add_export_plugin( Ref<EditorSampleExportPlugin>( memnew(EditorSampleExportPlugin))); +// editor_import_export->add_export_plugin( Ref<EditorSampleExportPlugin>( memnew(EditorSampleExportPlugin))); editor_import_export->add_export_plugin( Ref<EditorSceneExportPlugin>( memnew(EditorSceneExportPlugin))); @@ -6574,8 +6679,8 @@ EditorNode::EditorNode() { add_editor_plugin( memnew( ShaderEditorPlugin(this,false) ) );*/ add_editor_plugin( memnew( CameraEditorPlugin(this) ) ); - add_editor_plugin( memnew( SampleEditorPlugin(this) ) ); - add_editor_plugin( memnew( SampleLibraryEditorPlugin(this) ) ); +// add_editor_plugin( memnew( SampleEditorPlugin(this) ) ); +// add_editor_plugin( memnew( SampleLibraryEditorPlugin(this) ) ); add_editor_plugin( memnew( ThemeEditorPlugin(this) ) ); add_editor_plugin( memnew( MultiMeshEditorPlugin(this) ) ); add_editor_plugin( memnew( MeshInstanceEditorPlugin(this) ) ); @@ -6755,7 +6860,8 @@ EditorNode::EditorNode() { _initializing_addons=false; } - + _initializing_tool_menu = false; + _rebuild_tool_menu(); _load_docks(); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index dd5ff1e175..2baa9091ff 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -197,7 +197,9 @@ private: IMPORT_PLUGIN_BASE=100, - OBJECT_METHOD_BASE=500 + OBJECT_METHOD_BASE=500, + + TOOL_MENU_BASE=1000 }; @@ -593,6 +595,22 @@ private: void _call_build(); static int build_callback_count; static EditorBuildCallback build_callbacks[MAX_BUILD_CALLBACKS]; + + bool _initializing_tool_menu; + + struct ToolMenuItem { + String name; + String submenu; + Variant ud; + ObjectID handler; + String callback; + }; + + Vector<ToolMenuItem> tool_menu_items; + + void _tool_menu_insert_item(const ToolMenuItem& p_item); + void _rebuild_tool_menu() const; + protected: void _notification(int p_what); static void _bind_methods(); @@ -755,6 +773,9 @@ public: Variant drag_files(const Vector<String>& p_files,Control* p_from); Variant drag_files_and_dirs(const Vector<String>& p_files,Control* p_from); + void add_tool_menu_item(const String& p_name, Object *p_handler, const String& p_callback, const Variant& p_ud = Variant()); + void add_tool_submenu_item(const String& p_name, PopupMenu *p_submenu); + void remove_tool_menu_item(const String& p_name); EditorNode(); ~EditorNode(); diff --git a/tools/editor/editor_path.cpp b/tools/editor/editor_path.cpp index b359522e4f..8cd31c4bcc 100644 --- a/tools/editor/editor_path.cpp +++ b/tools/editor/editor_path.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_path.h" + #include "editor_scale.h" #include "editor_node.h" diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp index 8769fe2cd8..69be7f8a4d 100644 --- a/tools/editor/editor_plugin.cpp +++ b/tools/editor/editor_plugin.cpp @@ -27,6 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_plugin.h" + +#include "scene/gui/popup_menu.h" #include "scene/3d/camera.h" #include "plugins/canvas_item_editor_plugin.h" #include "plugins/spatial_editor_plugin.h" @@ -132,6 +134,24 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Co } } +void EditorPlugin::add_tool_menu_item(const String& p_name, Object *p_handler, const String& p_callback, const Variant& p_ud) { + + EditorNode::get_singleton()->add_tool_menu_item(p_name, p_handler, p_callback, p_ud); +} + +void EditorPlugin::add_tool_submenu_item(const String& p_name, Object *p_submenu) { + + ERR_FAIL_NULL(p_submenu); + PopupMenu *submenu = p_submenu->cast_to<PopupMenu>(); + ERR_FAIL_NULL(submenu); + EditorNode::get_singleton()->add_tool_submenu_item(p_name, submenu); +} + +void EditorPlugin::remove_tool_menu_item(const String& p_name) { + + EditorNode::get_singleton()->remove_tool_menu_item(p_name); +} + Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial* p_spatial) { //?? if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) { @@ -351,6 +371,9 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(_MD("add_control_to_dock","slot","control:Control"),&EditorPlugin::add_control_to_dock); ClassDB::bind_method(_MD("remove_control_from_docks","control:Control"),&EditorPlugin::remove_control_from_docks); ClassDB::bind_method(_MD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel); + ClassDB::bind_method(_MD("add_tool_menu_item", "name", "handler", "callback", "ud"),&EditorPlugin::add_tool_menu_item,DEFVAL(Variant())); + ClassDB::bind_method(_MD("add_tool_submenu_item", "name", "submenu:PopupMenu"),&EditorPlugin::add_tool_submenu_item); + ClassDB::bind_method(_MD("remove_tool_menu_item", "name"),&EditorPlugin::remove_tool_menu_item); ClassDB::bind_method(_MD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type); ClassDB::bind_method(_MD("remove_custom_type","type"),&EditorPlugin::remove_custom_type); ClassDB::bind_method(_MD("get_editor_viewport:Control"), &EditorPlugin::get_editor_viewport); diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h index 9943e94d98..928b096859 100644 --- a/tools/editor/editor_plugin.h +++ b/tools/editor/editor_plugin.h @@ -103,6 +103,10 @@ public: Control* get_editor_viewport(); void edit_resource(const Ref<Resource>& p_resource); + void add_tool_menu_item(const String& p_name, Object *p_handler, const String& p_callback, const Variant& p_ud = Variant()); + void add_tool_submenu_item(const String& p_name, Object *p_submenu); + void remove_tool_menu_item(const String& p_name); + virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial); virtual bool forward_canvas_gui_input(const Transform2D& p_canvas_xform, const InputEvent& p_event); virtual void forward_draw_over_canvas(const Transform2D& p_canvas_xform,Control *p_canvas); diff --git a/tools/editor/editor_plugin_settings.cpp b/tools/editor/editor_plugin_settings.cpp index 208e576a8a..2b6828e82f 100644 --- a/tools/editor/editor_plugin_settings.cpp +++ b/tools/editor/editor_plugin_settings.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_plugin_settings.h" + #include "scene/gui/margin_container.h" #include "io/config_file.h" #include "os/file_access.h" diff --git a/tools/editor/editor_profiler.cpp b/tools/editor/editor_profiler.cpp index 5279711b0f..94ec059ea7 100644 --- a/tools/editor/editor_profiler.cpp +++ b/tools/editor/editor_profiler.cpp @@ -1,4 +1,33 @@ +/*************************************************************************/ +/* editor_profiler.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 "editor_profiler.h" + #include "editor_settings.h" #include "os/os.h" @@ -349,7 +378,7 @@ void EditorProfiler::_update_plot() { } - graph_texture->set_data(img);; + graph_texture->set_data(img); graph->set_texture(graph_texture); diff --git a/tools/editor/editor_profiler.h b/tools/editor/editor_profiler.h index 52b38cdae8..bf89e3939c 100644 --- a/tools/editor/editor_profiler.h +++ b/tools/editor/editor_profiler.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* editor_profiler.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 EDITORPROFILER_H #define EDITORPROFILER_H diff --git a/tools/editor/editor_reimport_dialog.cpp b/tools/editor/editor_reimport_dialog.cpp index c6a8f13dc7..e5ae33e919 100644 --- a/tools/editor/editor_reimport_dialog.cpp +++ b/tools/editor/editor_reimport_dialog.cpp @@ -27,8 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_reimport_dialog.h" + #include "editor_file_system.h" #include "editor_node.h" + void EditorReImportDialog::popup_reimport() { if (EditorFileSystem::get_singleton()->is_scanning()) { diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp index 76ae53d821..b4c459a493 100644 --- a/tools/editor/editor_resource_preview.cpp +++ b/tools/editor/editor_resource_preview.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_resource_preview.h" + #include "editor_settings.h" #include "os/file_access.h" #include "io/resource_loader.h" diff --git a/tools/editor/editor_run.cpp b/tools/editor/editor_run.cpp index 7d79412b3b..813a8ee5b7 100644 --- a/tools/editor/editor_run.cpp +++ b/tools/editor/editor_run.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_run.h" + #include "globals.h" #include "editor_settings.h" diff --git a/tools/editor/editor_run_native.cpp b/tools/editor/editor_run_native.cpp index caa1bf5db7..12b7b761ed 100644 --- a/tools/editor/editor_run_native.cpp +++ b/tools/editor/editor_run_native.cpp @@ -27,8 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_run_native.h" -#include "editor_import_export.h" +#include "editor_import_export.h" void EditorRunNative::_notification(int p_what) { diff --git a/tools/editor/editor_run_script.cpp b/tools/editor/editor_run_script.cpp index 4a3cbfbccb..6a980019e4 100644 --- a/tools/editor/editor_run_script.cpp +++ b/tools/editor/editor_run_script.cpp @@ -27,11 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_run_script.h" -#include "editor_node.h" - - - +#include "editor_node.h" void EditorScript::add_root_node(Node *p_node) { diff --git a/tools/editor/editor_scale.cpp b/tools/editor/editor_scale.cpp index 8575e1c30a..5687f97b22 100644 --- a/tools/editor/editor_scale.cpp +++ b/tools/editor/editor_scale.cpp @@ -1,4 +1,33 @@ +/*************************************************************************/ +/* editor_scale.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 "editor_scale.h" + #include "os/os.h" static float scale = 1.0; diff --git a/tools/editor/editor_scale.h b/tools/editor/editor_scale.h index 90e575f771..035a5056c1 100644 --- a/tools/editor/editor_scale.h +++ b/tools/editor/editor_scale.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* editor_scale.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 EDITOR_SCALE_H #define EDITOR_SCALE_H diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 807183ae46..27aeaeb5b6 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http:/www.godotengine.org */ +/* http:/www.godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ @@ -27,13 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_settings.h" + #include "os/os.h" #include "os/dir_access.h" #include "os/file_access.h" - #include "version.h" #include "scene/main/scene_main_loop.h" -#include "os/os.h" #include "scene/main/node.h" #include "io/resource_loader.h" #include "io/resource_saver.h" @@ -127,7 +126,7 @@ bool EditorSettings::_get(const StringName& p_name,Variant &r_ret) const { const VariantContainer *v=props.getptr(p_name); if (!v) { - //print_line("WARNING NOT FOUND: "+String(p_name)); + print_line("EditorSettings::_get - Warning, not found: "+String(p_name)); return false; } r_ret = v->variant; diff --git a/tools/editor/editor_sub_scene.cpp b/tools/editor/editor_sub_scene.cpp index 34c3d47006..094cf049b3 100644 --- a/tools/editor/editor_sub_scene.cpp +++ b/tools/editor/editor_sub_scene.cpp @@ -27,10 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_sub_scene.h" + #include "scene/gui/margin_container.h" #include "scene/resources/packed_scene.h" -void EditorSubScene::_path_selected(const String& p_path) { +void EditorSubScene::_path_selected(const String& p_path) { path->set_text(p_path); _path_changed(p_path); diff --git a/tools/editor/editor_themes.cpp b/tools/editor/editor_themes.cpp index 56654cad7a..7657996b81 100644 --- a/tools/editor/editor_themes.cpp +++ b/tools/editor/editor_themes.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* editor_themes.cpp */ +/* editor_themes.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "editor_themes.h" + #include "editor_icons.h" #include "editor_fonts.h" #include "editor_settings.h" diff --git a/tools/editor/editor_themes.h b/tools/editor/editor_themes.h index 83e7dde78a..bf15420917 100644 --- a/tools/editor/editor_themes.h +++ b/tools/editor/editor_themes.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* editor_themes.h */ +/* editor_themes.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/tools/editor/file_type_cache.cpp b/tools/editor/file_type_cache.cpp index 176205a7df..aff99fbc05 100644 --- a/tools/editor/file_type_cache.cpp +++ b/tools/editor/file_type_cache.cpp @@ -27,10 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "file_type_cache.h" + #include "globals.h" #include "os/file_access.h" - FileTypeCache* FileTypeCache::singleton=NULL; bool FileTypeCache::has_file(const String& p_path) const { diff --git a/tools/editor/fileserver/editor_file_server.cpp b/tools/editor/fileserver/editor_file_server.cpp index 6330b06d3e..2e5dbf6248 100644 --- a/tools/editor/fileserver/editor_file_server.cpp +++ b/tools/editor/fileserver/editor_file_server.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_file_server.h" + #include "io/marshalls.h" #include "io/marshalls.h" #include "../editor_settings.h" diff --git a/tools/editor/filesystem_dock.cpp b/tools/editor/filesystem_dock.cpp index 792eb54dd4..b85bd6dfdb 100644 --- a/tools/editor/filesystem_dock.cpp +++ b/tools/editor/filesystem_dock.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* scenes_dock.cpp */ +/* filesystem_dock.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,14 +27,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "filesystem_dock.h" + #include "os/dir_access.h" #include "os/file_access.h" #include "globals.h" - #include "io/resource_loader.h" #include "os/os.h" #include "editor_node.h" - #include "editor_settings.h" #include "scene/main/viewport.h" @@ -990,7 +989,7 @@ void FileSystemDock::_file_option(int p_option) { } break; case FILE_MOVE: { - move_dirs.clear();; + move_dirs.clear(); move_files.clear(); for(int i=0;i<files->get_item_count();i++) { diff --git a/tools/editor/filesystem_dock.h b/tools/editor/filesystem_dock.h index 0b0a73b9a2..ccd43847d6 100644 --- a/tools/editor/filesystem_dock.h +++ b/tools/editor/filesystem_dock.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* scenes_dock.h */ +/* filesystem_dock.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/tools/editor/groups_editor.cpp b/tools/editor/groups_editor.cpp index 07b2bca385..90f0bab6dd 100644 --- a/tools/editor/groups_editor.cpp +++ b/tools/editor/groups_editor.cpp @@ -32,6 +32,7 @@ #include "scene/gui/label.h" #include "editor_node.h" #include "scene/resources/packed_scene.h" + void GroupsEditor::_add_group(const String& p_group) { if (!node) diff --git a/tools/editor/io_plugins/editor_atlas.cpp b/tools/editor/io_plugins/editor_atlas.cpp index ac776f4ff5..c5f1ee73cf 100644 --- a/tools/editor/io_plugins/editor_atlas.cpp +++ b/tools/editor/io_plugins/editor_atlas.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_atlas.h" + #include "print_string.h" struct _EditorAtlasWorkRect { diff --git a/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp b/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp index 722b02f77b..222a9d9517 100644 --- a/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp @@ -1,4 +1,33 @@ +/*************************************************************************/ +/* editor_bitmask_import_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 "editor_bitmask_import_plugin.h" + #include "io/image_loader.h" #include "tools/editor/editor_file_dialog.h" #include "tools/editor/editor_dir_dialog.h" diff --git a/tools/editor/io_plugins/editor_bitmask_import_plugin.h b/tools/editor/io_plugins/editor_bitmask_import_plugin.h index 28dddca50a..3a6aababe2 100644 --- a/tools/editor/io_plugins/editor_bitmask_import_plugin.h +++ b/tools/editor/io_plugins/editor_bitmask_import_plugin.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* editor_bitmask_import_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 EDITOR_BITMASK_IMPORT_PLUGIN_H #define EDITOR_BITMASK_IMPORT_PLUGIN_H diff --git a/tools/editor/io_plugins/editor_export_scene.cpp b/tools/editor/io_plugins/editor_export_scene.cpp index ea67128f3c..7d19258411 100644 --- a/tools/editor/io_plugins/editor_export_scene.cpp +++ b/tools/editor/io_plugins/editor_export_scene.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_export_scene.h" + #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/dir_access.h" diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index 099535b1ef..ada6000d82 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_font_import_plugin.h" + #include "scene/gui/dialogs.h" #include "tools/editor/editor_file_dialog.h" #include "tools/editor/editor_node.h" @@ -34,11 +35,10 @@ #include "editor_atlas.h" #include "io/image_loader.h" #include "io/resource_saver.h" -#ifdef FREETYPE_ENABLED +#ifdef FREETYPE_ENABLED #include <ft2build.h> #include FT_FREETYPE_H - #endif diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp index 1cbb594a51..a910b9c3ab 100644 --- a/tools/editor/io_plugins/editor_import_collada.cpp +++ b/tools/editor/io_plugins/editor_import_collada.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_import_collada.h" + #include "collada/collada.h" #include "scene/3d/spatial.h" #include "scene/3d/skeleton.h" diff --git a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp index fa0c36be98..d07a21fc7d 100644 --- a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp @@ -32,7 +32,7 @@ #include "tools/editor/editor_dir_dialog.h" #include "tools/editor/editor_node.h" #include "tools/editor/property_editor.h" -#include "scene/resources/sample.h" +//#include "scene/resources/sample.h" #include "io/resource_saver.h" #include "os/file_access.h" #include "io/marshalls.h" diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp index eeb61fc443..ca873cab72 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp @@ -27,16 +27,18 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_sample_import_plugin.h" + #include "tools/editor/editor_file_dialog.h" #include "tools/editor/editor_dir_dialog.h" #include "tools/editor/editor_node.h" #include "tools/editor/property_editor.h" -#include "scene/resources/sample.h" #include "io/resource_saver.h" #include "os/file_access.h" #include "io/marshalls.h" #include "tools/editor/editor_settings.h" +#if 0 + class _EditorSampleImportOptions : public Object { GDCLASS(_EditorSampleImportOptions,Object); @@ -923,3 +925,5 @@ Vector<uint8_t> EditorSampleExportPlugin::custom_export(String& p_path,const Ref EditorSampleExportPlugin::EditorSampleExportPlugin() { } + +#endif diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.h b/tools/editor/io_plugins/editor_sample_import_plugin.h index 6d781756b2..8e02d0e11d 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.h +++ b/tools/editor/io_plugins/editor_sample_import_plugin.h @@ -29,6 +29,7 @@ #ifndef EDITOR_SAMPLE_IMPORT_PLUGIN_H #define EDITOR_SAMPLE_IMPORT_PLUGIN_H +#if 0 #include "tools/editor/editor_import_export.h" #include "scene/resources/font.h" @@ -70,3 +71,4 @@ public: }; #endif // EDITOR_SAMPLE_IMPORT_PLUGIN_H +#endif diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index 79c88e7407..ce6c49fcba 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_scene_import_plugin.h" + #include "globals.h" #include "tools/editor/editor_node.h" #include "scene/resources/packed_scene.h" diff --git a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp index e1b0719941..af12d85650 100644 --- a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp +++ b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_scene_importer_fbxconv.h" + #include "os/file_access.h" #include "os/os.h" #include "tools/editor/editor_settings.h" diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 5ba7d0c417..8e1bcb8e4b 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_texture_import_plugin.h" + #include "io/image_loader.h" #include "tools/editor/editor_node.h" #include "io/resource_saver.h" @@ -779,7 +780,7 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* set_hide_on_ok(false); - texture_options = memnew( EditorImportTextureOptions );; + texture_options = memnew( EditorImportTextureOptions ); vbc->add_child(texture_options); texture_options->set_v_size_flags(SIZE_EXPAND_FILL); diff --git a/tools/editor/io_plugins/editor_translation_import_plugin.cpp b/tools/editor/io_plugins/editor_translation_import_plugin.cpp index d9288f5990..7079120feb 100644 --- a/tools/editor/io_plugins/editor_translation_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_translation_import_plugin.cpp @@ -27,11 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_translation_import_plugin.h" + #include "scene/gui/file_dialog.h" #include "tools/editor/editor_dir_dialog.h" #include "tools/editor/editor_node.h" #include "tools/editor/property_editor.h" -#include "scene/resources/sample.h" +//#include "scene/resources/sample.h" #include "io/resource_saver.h" #include "os/file_access.h" #include "translation.h" diff --git a/tools/editor/multi_node_edit.cpp b/tools/editor/multi_node_edit.cpp index 47b776ed06..97a996fe48 100644 --- a/tools/editor/multi_node_edit.cpp +++ b/tools/editor/multi_node_edit.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "multi_node_edit.h" + #include "editor_node.h" bool MultiNodeEdit::_set(const StringName& p_name, const Variant& p_value){ diff --git a/tools/editor/node_dock.cpp b/tools/editor/node_dock.cpp index a8e66a8680..3d906cf960 100644 --- a/tools/editor/node_dock.cpp +++ b/tools/editor/node_dock.cpp @@ -1,4 +1,33 @@ +/*************************************************************************/ +/* node_dock.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 "node_dock.h" + #include "editor_node.h" void NodeDock::show_groups() { diff --git a/tools/editor/node_dock.h b/tools/editor/node_dock.h index fd4105d1b2..df41ecf5bd 100644 --- a/tools/editor/node_dock.h +++ b/tools/editor/node_dock.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* node_dock.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 NODE_DOCK_H #define NODE_DOCK_H diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index a3f254ce49..b3d16bb660 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "animation_player_editor_plugin.h" + #include "globals.h" #include "io/resource_loader.h" #include "io/resource_saver.h" diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp index eedebab1c9..1ed52d2df6 100644 --- a/tools/editor/plugins/animation_tree_editor_plugin.cpp +++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp @@ -261,9 +261,9 @@ void AnimationTreeEditor::_popup_edit_dialog() { } edit_option->hide(); - edit_button->hide();; + edit_button->hide(); filter_button->hide(); - edit_check->hide();; + edit_check->hide(); Point2 pos = anim_tree->node_get_pos(edited_node)-Point2(h_scroll->get_value(),v_scroll->get_value()); Ref<StyleBox> style = get_stylebox("panel","PopupMenu"); @@ -450,7 +450,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { edit_label[1]->show(); edit_option->set_begin(Point2(15,75)); - edit_option->clear();; + edit_option->clear(); for(int i=0;i<anim_tree->transition_node_get_input_count(edited_node);i++) { edit_option->add_item(itos(i),i); @@ -1451,14 +1451,14 @@ AnimationTreeEditor::AnimationTreeEditor() { edit_button->set_anchor( MARGIN_RIGHT, ANCHOR_END ); edit_button->set_margin(MARGIN_RIGHT, 10); edit_dialog->add_child(edit_button); - edit_button->hide();; + edit_button->hide(); edit_button->connect("pressed", this,"_edit_oneshot_start"); edit_check = memnew( CheckButton ); edit_check->set_anchor( MARGIN_RIGHT, ANCHOR_END ); edit_check->set_margin(MARGIN_RIGHT, 10); edit_dialog->add_child(edit_check); - edit_check->hide();; + edit_check->hide(); edit_check->connect("pressed", this,"_edit_dialog_changed"); file_dialog = memnew( EditorFileDialog ); @@ -1480,7 +1480,7 @@ AnimationTreeEditor::AnimationTreeEditor() { filter_button->set_anchor( MARGIN_RIGHT, ANCHOR_END ); filter_button->set_margin(MARGIN_RIGHT, 10); edit_dialog->add_child(filter_button); - filter_button->hide();; + filter_button->hide(); filter_button->set_text(TTR("Filters..")); filter_button->connect("pressed", this,"_edit_filters"); diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp index 0b12d080e4..52220839d9 100644 --- a/tools/editor/plugins/baked_light_baker.cpp +++ b/tools/editor/plugins/baked_light_baker.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "baked_light_baker.h" + #include <stdlib.h> #include <cmath> #include "io/marshalls.h" @@ -1573,7 +1574,7 @@ double BakedLightBaker::get_normalization(int p_light_idx) const { double nrg=0; const LightData &dl=lights[p_light_idx]; - double cell_area = cell_size*cell_size;; + double cell_area = cell_size*cell_size; //nrg+= /*dl.energy */ (dl.rays_thrown * cell_area / dl.area); nrg=dl.rays_thrown * cell_area; nrg*=(Math_PI*plot_size*plot_size)*0.5; // damping of radial linear gradient kernel @@ -1591,7 +1592,7 @@ double BakedLightBaker::get_modifier(int p_light_idx) const { double nrg=0; const LightData &dl=lights[p_light_idx]; - double cell_area = cell_size*cell_size;; + double cell_area = cell_size*cell_size; //nrg+= /*dl.energy */ (dl.rays_thrown * cell_area / dl.area); nrg=cell_area; nrg*=(Math_PI*plot_size*plot_size)*0.5; // damping of radial linear gradient kernel @@ -2681,7 +2682,7 @@ void BakedLightBaker::clear() { materials.clear(); textures.clear(); lights.clear(); - triangles.clear();; + triangles.clear(); endpoint_normal.clear(); endpoint_normal_bits.clear(); baked_octree_texture_w=0; diff --git a/tools/editor/plugins/baked_light_editor_plugin.cpp b/tools/editor/plugins/baked_light_editor_plugin.cpp index 26c3144188..6a7e708b85 100644 --- a/tools/editor/plugins/baked_light_editor_plugin.cpp +++ b/tools/editor/plugins/baked_light_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "baked_light_editor_plugin.h" + #include "scene/gui/box_container.h" #include "scene/3d/mesh_instance.h" #include "io/marshalls.h" diff --git a/tools/editor/plugins/camera_editor_plugin.cpp b/tools/editor/plugins/camera_editor_plugin.cpp index 1c8c392d65..1e0ec2b4a0 100644 --- a/tools/editor/plugins/camera_editor_plugin.cpp +++ b/tools/editor/plugins/camera_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "camera_editor_plugin.h" + #include "spatial_editor_plugin.h" diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index f321a74c7e..9dbd2513a0 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "canvas_item_editor_plugin.h" + #include "print_string.h" #include "tools/editor/editor_node.h" #include "os/keyboard.h" @@ -391,7 +392,7 @@ void CanvasItemEditor::_remove_canvas_item(CanvasItem *p_canvas_item) { } void CanvasItemEditor::_clear_canvas_items() { - editor_selection->clear();; + editor_selection->clear(); #if 0 while(canvas_items.size()) _remove_canvas_item(canvas_items.front()->key()); @@ -601,7 +602,7 @@ bool CanvasItemEditor::_select(CanvasItem *item, Point2 p_click_pos, bool p_appe if (!item) { //clear because nothing clicked - editor_selection->clear();; + editor_selection->clear(); if (p_drag) { drag_from=transform.affine_inverse().xform(p_click_pos); @@ -1319,7 +1320,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) { { bone_ik_list.clear(); float closest_dist=1e20; - int bone_width = EditorSettings::get_singleton()->get("editors/2dbone_width"); + int bone_width = EditorSettings::get_singleton()->get("editors/2d/bone_width"); for(Map<ObjectID,BoneList>::Element *E=bone_list.front();E;E=E->next()) { if (E->get().from == E->get().to) @@ -2113,11 +2114,11 @@ void CanvasItemEditor::_viewport_draw() { } if (skeleton_show_bones) { - int bone_width = EditorSettings::get_singleton()->get("editors/2dbone_width"); - Color bone_color1 = EditorSettings::get_singleton()->get("editors/2dbone_color1"); - Color bone_color2 = EditorSettings::get_singleton()->get("editors/2dbone_color2"); - Color bone_ik_color = EditorSettings::get_singleton()->get("editors/2dbone_ik_color"); - Color bone_selected_color = EditorSettings::get_singleton()->get("editors/2dbone_selected_color"); + int bone_width = EditorSettings::get_singleton()->get("editors/2d/bone_width"); + Color bone_color1 = EditorSettings::get_singleton()->get("editors/2d/bone_color1"); + Color bone_color2 = EditorSettings::get_singleton()->get("editors/2d/bone_color2"); + Color bone_ik_color = EditorSettings::get_singleton()->get("editors/2d/bone_ik_color"); + Color bone_selected_color = EditorSettings::get_singleton()->get("editors/2d/bone_selected_color"); for(Map<ObjectID,BoneList>::Element*E=bone_list.front();E;E=E->next()) { @@ -2412,7 +2413,7 @@ void CanvasItemEditor::_update_scrollbars() { Rect2 canvas_item_rect=Rect2(Point2(),screen_rect); - lock_list.clear();; + lock_list.clear(); bone_last_frame++; @@ -2926,7 +2927,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break;*/ case ANIM_COPY_POSE: { - pose_clipboard.clear();; + pose_clipboard.clear(); Map<Node*,Object*> &selection = editor_selection->get_selection(); diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp index 010d6f1a47..c5cd15cf72 100644 --- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "collision_polygon_editor_plugin.h" + #include "spatial_editor_plugin.h" #include "os/file_access.h" #include "tools/editor/editor_settings.h" diff --git a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp index 626ca9e132..a05eeb7a27 100644 --- a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -29,7 +29,6 @@ #include "collision_shape_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" - #include "scene/resources/segment_shape_2d.h" #include "scene/resources/shape_line_2d.h" #include "scene/resources/circle_shape_2d.h" diff --git a/tools/editor/plugins/color_ramp_editor_plugin.cpp b/tools/editor/plugins/color_ramp_editor_plugin.cpp index 90ec1e9f4e..9509eb1b03 100644 --- a/tools/editor/plugins/color_ramp_editor_plugin.cpp +++ b/tools/editor/plugins/color_ramp_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "color_ramp_editor_plugin.h" + #include "spatial_editor_plugin.h" #include "canvas_item_editor_plugin.h" diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index 478fa2308d..5d9b281874 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -27,12 +27,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_preview_plugins.h" + #include "io/resource_loader.h" #include "tools/editor/editor_settings.h" #include "io/file_access_memory.h" #include "os/os.h" #include "scene/resources/material.h" -#include "scene/resources/sample.h" +//#include "scene/resources/sample.h" #include "scene/resources/mesh.h" #include "scene/resources/bit_mask.h" #include "tools/editor/editor_scale.h" @@ -521,7 +522,7 @@ EditorScriptPreviewPlugin::EditorScriptPreviewPlugin() { } /////////////////////////////////////////////////////////////////// - +#if 0 bool EditorSamplePreviewPlugin::handles(const String& p_type) const { return ClassDB::is_type(p_type,"Sample"); @@ -788,7 +789,7 @@ EditorSamplePreviewPlugin::EditorSamplePreviewPlugin() { } - +#endif /////////////////////////////////////////////////////////////////////////// bool EditorMeshPreviewPlugin::handles(const String& p_type) const { diff --git a/tools/editor/plugins/editor_preview_plugins.h b/tools/editor/plugins/editor_preview_plugins.h index 3c1689e61e..078e4cf8b5 100644 --- a/tools/editor/plugins/editor_preview_plugins.h +++ b/tools/editor/plugins/editor_preview_plugins.h @@ -94,7 +94,7 @@ public: EditorScriptPreviewPlugin(); }; - +#if 0 class EditorSamplePreviewPlugin : public EditorResourcePreviewGenerator { public: @@ -104,7 +104,7 @@ public: EditorSamplePreviewPlugin(); }; - +#endif class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator { RID scenario; diff --git a/tools/editor/plugins/gi_probe_editor_plugin.cpp b/tools/editor/plugins/gi_probe_editor_plugin.cpp index f550b7972a..39f32d0dc7 100644 --- a/tools/editor/plugins/gi_probe_editor_plugin.cpp +++ b/tools/editor/plugins/gi_probe_editor_plugin.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* gi_probe_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 "gi_probe_editor_plugin.h" @@ -44,7 +72,7 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) { editor=p_node; bake = memnew( Button ); bake->set_icon(editor->get_gui_base()->get_icon("BakedLight","EditorIcons")); - bake->hide();; + bake->hide(); bake->connect("pressed",this,"_bake"); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU,bake); gi_probe=NULL; diff --git a/tools/editor/plugins/gi_probe_editor_plugin.h b/tools/editor/plugins/gi_probe_editor_plugin.h index 8d2ec17d2f..35e0b93aae 100644 --- a/tools/editor/plugins/gi_probe_editor_plugin.h +++ b/tools/editor/plugins/gi_probe_editor_plugin.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* gi_probe_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 GIPROBEEDITORPLUGIN_H #define GIPROBEEDITORPLUGIN_H diff --git a/tools/editor/plugins/material_editor_plugin.cpp b/tools/editor/plugins/material_editor_plugin.cpp index e9bcf063fd..1aababa91b 100644 --- a/tools/editor/plugins/material_editor_plugin.cpp +++ b/tools/editor/plugins/material_editor_plugin.cpp @@ -1,4 +1,33 @@ +/*************************************************************************/ +/* material_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 "material_editor_plugin.h" + #include "scene/main/viewport.h" #if 0 diff --git a/tools/editor/plugins/material_editor_plugin.h b/tools/editor/plugins/material_editor_plugin.h index 556e56e66b..5daae124e0 100644 --- a/tools/editor/plugins/material_editor_plugin.h +++ b/tools/editor/plugins/material_editor_plugin.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* material_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 MATERIAL_EDITOR_PLUGIN_H #define MATERIAL_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/mesh_instance_editor_plugin.cpp b/tools/editor/plugins/mesh_instance_editor_plugin.cpp index de29991057..322e212534 100644 --- a/tools/editor/plugins/mesh_instance_editor_plugin.cpp +++ b/tools/editor/plugins/mesh_instance_editor_plugin.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* mesh_instance_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 "mesh_instance_editor_plugin.h" #include "scene/3d/physics_body.h" diff --git a/tools/editor/plugins/mesh_instance_editor_plugin.h b/tools/editor/plugins/mesh_instance_editor_plugin.h index 23dcbfc9b1..441d4d1d3f 100644 --- a/tools/editor/plugins/mesh_instance_editor_plugin.h +++ b/tools/editor/plugins/mesh_instance_editor_plugin.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* mesh_instance_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 MESH_INSTANCE_EDITOR_PLUGIN_H #define MESH_INSTANCE_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp index cce1c52215..80765be6c0 100644 --- a/tools/editor/plugins/multimesh_editor_plugin.cpp +++ b/tools/editor/plugins/multimesh_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "multimesh_editor_plugin.h" + #include "scene/gui/box_container.h" #include "scene/3d/mesh_instance.h" #include "spatial_editor_plugin.h" @@ -177,7 +178,7 @@ void MultiMeshEditor::_populate() { Map<float,int> triangle_area_map; for(int i=0;i<facecount;i++) { - float area = r[i].get_area();; + float area = r[i].get_area(); if (area<CMP_EPSILON) continue; triangle_area_map[area_accum]=i; diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp index b2d62af7bb..e70f2be9fa 100644 --- a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -127,7 +127,7 @@ bool NavigationPolygonEditor::forward_gui_input(const InputEvent& p_event) { create_nav->set_text("No NavigationPolygon resource on this node.\nCreate and assign one?"); create_nav->popup_centered_minsize(); } - return (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1);; + return (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1); } diff --git a/tools/editor/plugins/particles_2d_editor_plugin.cpp b/tools/editor/plugins/particles_2d_editor_plugin.cpp index 331a958518..20b1b9d1ca 100644 --- a/tools/editor/plugins/particles_2d_editor_plugin.cpp +++ b/tools/editor/plugins/particles_2d_editor_plugin.cpp @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "particles_2d_editor_plugin.h" + #include "canvas_item_editor_plugin.h" #include "io/image_loader.h" #include "scene/gui/separator.h" diff --git a/tools/editor/plugins/particles_editor_plugin.cpp b/tools/editor/plugins/particles_editor_plugin.cpp index 382dc29c61..fd5ec5b5b9 100644 --- a/tools/editor/plugins/particles_editor_plugin.cpp +++ b/tools/editor/plugins/particles_editor_plugin.cpp @@ -212,7 +212,7 @@ void ParticlesEditor::_generate_emission_points() { for(int i=0;i<geometry.size();i++) { - float area = geometry[i].get_area();; + float area = geometry[i].get_area(); if (area<CMP_EPSILON) continue; triangle_area_map[area_accum]=i; diff --git a/tools/editor/plugins/path_editor_plugin.cpp b/tools/editor/plugins/path_editor_plugin.cpp index 4f0afe9e94..2e148d6486 100644 --- a/tools/editor/plugins/path_editor_plugin.cpp +++ b/tools/editor/plugins/path_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "path_editor_plugin.h" + #include "spatial_editor_plugin.h" #include "scene/resources/curve.h" #include "os/keyboard.h" @@ -376,7 +377,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera* p_camera,const InputEve ur->create_action(TTR("Split Path")); ur->add_do_method(c.ptr(),"add_point",closest_seg_point,Vector3(),Vector3(),closest_seg+1); ur->add_undo_method(c.ptr(),"remove_point",closest_seg+1); - ur->commit_action();; + ur->commit_action(); return true; } else { @@ -396,7 +397,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera* p_camera,const InputEve ur->create_action(TTR("Add Point to Curve")); ur->add_do_method(c.ptr(),"add_point",it.xform(inters),Vector3(),Vector3(),-1); ur->add_undo_method(c.ptr(),"remove_point",c->get_point_count()); - ur->commit_action();; + ur->commit_action(); return true; } diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.cpp b/tools/editor/plugins/polygon_2d_editor_plugin.cpp index dc56348700..7958dce75a 100644 --- a/tools/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/tools/editor/plugins/polygon_2d_editor_plugin.cpp @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "polygon_2d_editor_plugin.h" + #include "canvas_item_editor_plugin.h" #include "os/file_access.h" #include "tools/editor/editor_settings.h" diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.cpp b/tools/editor/plugins/resource_preloader_editor_plugin.cpp index 0799732e02..cb139cbe24 100644 --- a/tools/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/tools/editor/plugins/resource_preloader_editor_plugin.cpp @@ -27,13 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resource_preloader_editor_plugin.h" + #include "io/resource_loader.h" #include "globals.h" #include "tools/editor/editor_settings.h" - - void ResourcePreloaderEditor::_gui_input(InputEvent p_event) { diff --git a/tools/editor/plugins/rich_text_editor_plugin.cpp b/tools/editor/plugins/rich_text_editor_plugin.cpp index f91af2fa60..8629d6ec8f 100644 --- a/tools/editor/plugins/rich_text_editor_plugin.cpp +++ b/tools/editor/plugins/rich_text_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "rich_text_editor_plugin.h" + #include "os/file_access.h" #include "canvas_item_editor_plugin.h" diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index cbeaeb7d60..c333ba017f 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -28,6 +28,7 @@ /*************************************************************************/ #include "sample_editor_plugin.h" +#if 0 #include "io/resource_loader.h" #include "globals.h" #include "tools/editor/editor_settings.h" @@ -447,4 +448,4 @@ SampleEditorPlugin::~SampleEditorPlugin() { } - +#endif diff --git a/tools/editor/plugins/sample_editor_plugin.h b/tools/editor/plugins/sample_editor_plugin.h index 6a416ddfbf..651cd14a84 100644 --- a/tools/editor/plugins/sample_editor_plugin.h +++ b/tools/editor/plugins/sample_editor_plugin.h @@ -29,7 +29,7 @@ #ifndef SAMPLE_EDITOR_PLUGIN_H #define SAMPLE_EDITOR_PLUGIN_H - +#if 0 #include "tools/editor/editor_plugin.h" #include "tools/editor/editor_node.h" #include "scene/audio/sample_player.h" @@ -87,4 +87,6 @@ public: }; +#endif + #endif // SAMPLE_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp index c3e2481b5a..116c5d11b6 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.cpp +++ b/tools/editor/plugins/sample_library_editor_plugin.cpp @@ -26,6 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ + +#if 0 #include "sample_library_editor_plugin.h" #include "io/resource_loader.h" @@ -541,3 +543,4 @@ SampleLibraryEditorPlugin::SampleLibraryEditorPlugin(EditorNode *p_node) { SampleLibraryEditorPlugin::~SampleLibraryEditorPlugin() { } +#endif diff --git a/tools/editor/plugins/sample_library_editor_plugin.h b/tools/editor/plugins/sample_library_editor_plugin.h index 1856d338ed..35028df859 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.h +++ b/tools/editor/plugins/sample_library_editor_plugin.h @@ -30,7 +30,7 @@ #define SAMPLE_LIBRARY_EDITOR_PLUGIN_H - +#if 0 #include "tools/editor/editor_plugin.h" #include "tools/editor/editor_node.h" #include "scene/audio/sample_player.h" @@ -104,4 +104,5 @@ public: }; +#endif #endif // SAMPLE_LIBRARY_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/sample_player_editor_plugin.cpp b/tools/editor/plugins/sample_player_editor_plugin.cpp index ae958a5c6e..dd6450bfe7 100644 --- a/tools/editor/plugins/sample_player_editor_plugin.cpp +++ b/tools/editor/plugins/sample_player_editor_plugin.cpp @@ -26,7 +26,11 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ + +#if 0 #include "sample_player_editor_plugin.h" + + #include "scene/resources/sample_library.h" @@ -89,7 +93,7 @@ void SamplePlayerEditor::_update_sample_library() { Ref<SampleLibrary> sl = node->call("get_sample_library"); if (sl.is_null()) { samples->add_item("<NO SAMPLE LIBRARY>"); - return; //no sample library;; + return; //no sample library; } List<StringName> samplenames; @@ -196,3 +200,4 @@ SamplePlayerEditorPlugin::~SamplePlayerEditorPlugin() } +#endif diff --git a/tools/editor/plugins/sample_player_editor_plugin.h b/tools/editor/plugins/sample_player_editor_plugin.h index d18496b4fd..ba1684497c 100644 --- a/tools/editor/plugins/sample_player_editor_plugin.h +++ b/tools/editor/plugins/sample_player_editor_plugin.h @@ -29,6 +29,8 @@ #ifndef SAMPLE_PLAYER_EDITOR_PLUGIN_H #define SAMPLE_PLAYER_EDITOR_PLUGIN_H +#if 0 + #include "tools/editor/editor_plugin.h" #include "tools/editor/editor_node.h" #include "scene/3d/spatial_sample_player.h" @@ -84,4 +86,5 @@ public: }; +#endif #endif // SAMPLE_PLAYER_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 61c2d5acfc..4738b348f4 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_editor_plugin.h" + #include "tools/editor/editor_settings.h" #include "io/resource_loader.h" #include "io/resource_saver.h" diff --git a/tools/editor/plugins/script_text_editor.cpp b/tools/editor/plugins/script_text_editor.cpp index 95e7afa04c..e26a3b23bc 100644 --- a/tools/editor/plugins/script_text_editor.cpp +++ b/tools/editor/plugins/script_text_editor.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_text_editor.h" + #include "tools/editor/editor_settings.h" #include "os/keyboard.h" #include "tools/editor/script_editor_debugger.h" diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp index 90d0f7fc93..56a8fccb9c 100644 --- a/tools/editor/plugins/shader_editor_plugin.cpp +++ b/tools/editor/plugins/shader_editor_plugin.cpp @@ -27,8 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "shader_editor_plugin.h" -#include "tools/editor/editor_settings.h" +#include "tools/editor/editor_settings.h" #include "spatial_editor_plugin.h" #include "scene/resources/shader_graph.h" #include "io/resource_loader.h" diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp index d989c5b30d..d86fec11d8 100644 --- a/tools/editor/plugins/shader_graph_editor_plugin.cpp +++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp @@ -464,8 +464,7 @@ void GraphCurveMapEdit::_plot_curve(const Vector2& p_a,const Vector2& p_b,const /* compose the basis and geometry matrices */ - static const float CR_basis[4][4] = - { + static const float CR_basis[4][4] = { { -0.5, 1.5, -1.5, 0.5 }, { 1.0, -2.5, 2.0, -0.5 }, { -0.5, 0.0, 0.5, 0.0 }, diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 97bc5a25e3..f45194f53f 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -27,8 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "spatial_editor_plugin.h" -#include "print_string.h" +#include "print_string.h" #include "os/keyboard.h" #include "scene/3d/visual_instance.h" #include "scene/3d/camera.h" @@ -1527,11 +1527,11 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { if (m.mod.meta) mod=KEY_META; - if (mod == _get_key_modifier("3d_editor/pan_modifier")) + if (mod == _get_key_modifier("editors/3d/pan_modifier")) nav_mode = NAVIGATION_PAN; - else if (mod == _get_key_modifier("3d_editor/zoom_modifier")) + else if (mod == _get_key_modifier("editors/3d/zoom_modifier")) nav_mode = NAVIGATION_ZOOM; - else if (mod == _get_key_modifier("3d_editor/orbit_modifier")) + else if (mod == _get_key_modifier("editors/3d/orbit_modifier")) nav_mode = NAVIGATION_ORBIT; } else if (nav_scheme == NAVIGATION_MAYA) { @@ -1552,11 +1552,11 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { mod=KEY_META; if(mod){ - if (mod == _get_key_modifier("3d_editor/pan_modifier")) + if (mod == _get_key_modifier("editors/3d/pan_modifier")) nav_mode = NAVIGATION_PAN; - else if (mod == _get_key_modifier("3d_editor/zoom_modifier")) + else if (mod == _get_key_modifier("editors/3d/zoom_modifier")) nav_mode = NAVIGATION_ZOOM; - else if (mod == _get_key_modifier("3d_editor/orbit_modifier")) + else if (mod == _get_key_modifier("editors/3d/orbit_modifier")) nav_mode = NAVIGATION_ORBIT; } } @@ -1587,7 +1587,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { if (nav_scheme==NAVIGATION_MAYA && m.mod.shift) zoom_speed *= zoom_speed_modifier; - NavigationZoomStyle zoom_style = (NavigationZoomStyle)EditorSettings::get_singleton()->get("3d_editor/zoom_style").operator int(); + NavigationZoomStyle zoom_style = (NavigationZoomStyle)EditorSettings::get_singleton()->get("editors/3d/zoom_style").operator int(); if (zoom_style == NAVIGATION_ZOOM_HORIZONTAL) { if ( m.relative_x > 0) cursor.distance*=1-m.relative_x*zoom_speed; @@ -2350,7 +2350,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed index=p_index; editor=p_editor; - editor_selection=editor->get_editor_selection();; + editor_selection=editor->get_editor_selection(); undo_redo=editor->get_undo_redo(); clicked=0; clicked_includes_current=false; @@ -2606,12 +2606,12 @@ Dictionary SpatialEditor::get_state() const { d["viewports"]=vpdata; - d["default_light"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT) );; + d["default_light"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT) ); d["ambient_light_color"]=settings_ambient_color->get_pick_color(); - d["default_srgb"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_SRGB) );; - d["show_grid"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_GRID) );; - d["show_origin"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN) );; + d["default_srgb"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_SRGB) ); + d["show_grid"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_GRID) ); + d["show_origin"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN) ); d["fov"]=get_fov(); d["znear"]=get_znear(); d["zfar"]=get_zfar(); @@ -3141,7 +3141,7 @@ void SpatialEditor::_init_indicators() { { - indicator_mat.instance();; + indicator_mat.instance(); indicator_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true); indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true); indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true); @@ -4095,7 +4095,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { add_to_group("_spatial_editor_group"); EDITOR_DEF("editors/3d/manipulator_gizmo_size",80); - EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT,"3d_editor/manipulator_gizmo_size",PROPERTY_HINT_RANGE,"16,1024,1")); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT,"editors/3d/manipulator_gizmo_size",PROPERTY_HINT_RANGE,"16,1024,1")); EDITOR_DEF("editors/3d/manipulator_gizmo_opacity",0.2); over_gizmo_handle=-1; diff --git a/tools/editor/plugins/stream_editor_plugin.cpp b/tools/editor/plugins/stream_editor_plugin.cpp index 00d7b208c8..991c29b6db 100644 --- a/tools/editor/plugins/stream_editor_plugin.cpp +++ b/tools/editor/plugins/stream_editor_plugin.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "stream_editor_plugin.h" - +#if 0 void StreamEditor::_notification(int p_what) { @@ -146,3 +146,4 @@ StreamEditorPlugin::~StreamEditorPlugin() { } +#endif diff --git a/tools/editor/plugins/stream_editor_plugin.h b/tools/editor/plugins/stream_editor_plugin.h index af29f64f93..cc853d4661 100644 --- a/tools/editor/plugins/stream_editor_plugin.h +++ b/tools/editor/plugins/stream_editor_plugin.h @@ -29,7 +29,7 @@ #ifndef STREAM_EDITOR_PLUGIN_H #define STREAM_EDITOR_PLUGIN_H - +#if 0 #include "tools/editor/editor_plugin.h" #include "tools/editor/editor_node.h" #include "scene/audio/stream_player.h" @@ -81,3 +81,4 @@ public: }; #endif // STREAM_EDITOR_PLUGIN_H +#endif diff --git a/tools/editor/plugins/texture_editor_plugin.cpp b/tools/editor/plugins/texture_editor_plugin.cpp index a846a908d2..82cba7ac0e 100644 --- a/tools/editor/plugins/texture_editor_plugin.cpp +++ b/tools/editor/plugins/texture_editor_plugin.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* texture_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 "texture_editor_plugin.h" #include "io/resource_loader.h" diff --git a/tools/editor/plugins/texture_editor_plugin.h b/tools/editor/plugins/texture_editor_plugin.h index 4b05f7f7ab..456a5249de 100644 --- a/tools/editor/plugins/texture_editor_plugin.h +++ b/tools/editor/plugins/texture_editor_plugin.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* texture_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 TEXTURE_EDITOR_PLUGIN_H #define TEXTURE_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/texture_region_editor_plugin.cpp b/tools/editor/plugins/texture_region_editor_plugin.cpp index 1ad880c4d6..9b0ca0a482 100644 --- a/tools/editor/plugins/texture_region_editor_plugin.cpp +++ b/tools/editor/plugins/texture_region_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* texture_region_editor_plugin.cpp */ +/* texture_region_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,9 +28,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#include "texture_region_editor_plugin.h" #include "core/core_string_names.h" -#include "texture_region_editor_plugin.h" #include "scene/gui/check_box.h" #include "os/input.h" #include "os/keyboard.h" diff --git a/tools/editor/plugins/texture_region_editor_plugin.h b/tools/editor/plugins/texture_region_editor_plugin.h index 35c0f18efa..da713a53d3 100644 --- a/tools/editor/plugins/texture_region_editor_plugin.h +++ b/tools/editor/plugins/texture_region_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* texture_region_editor_plugin.h */ +/* texture_region_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp index 027e91ade8..4b8fea5a45 100644 --- a/tools/editor/plugins/theme_editor_plugin.cpp +++ b/tools/editor/plugins/theme_editor_plugin.cpp @@ -26,8 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "theme_editor_plugin.h" + +#include "version.h" #include "os/file_access.h" void ThemeEditor::edit(const Ref<Theme>& p_theme) { @@ -584,7 +585,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { List<StringName> types; base_theme->get_type_list(&types); - type_menu->get_popup()->clear();; + type_menu->get_popup()->clear(); if (p_option==0 || p_option==1) {//add diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index 1a8c35a0be..7c232f0c32 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -26,12 +26,10 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "tile_map_editor_plugin.h" #include "os/keyboard.h" #include "os/input.h" - #include "canvas_item_editor_plugin.h" #include "tools/editor/editor_settings.h" #include "tools/editor/editor_scale.h" diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp index bb6236a6d6..3db6c94917 100644 --- a/tools/editor/plugins/tile_set_editor_plugin.cpp +++ b/tools/editor/plugins/tile_set_editor_plugin.cpp @@ -27,8 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "tile_set_editor_plugin.h" + #include "scene/2d/sprite.h" #include "scene/2d/physics_body_2d.h" + void TileSetEditor::edit(const Ref<TileSet>& p_tileset) { tileset=p_tileset; diff --git a/tools/editor/progress_dialog.cpp b/tools/editor/progress_dialog.cpp index 03303b8c48..76626c4556 100644 --- a/tools/editor/progress_dialog.cpp +++ b/tools/editor/progress_dialog.cpp @@ -27,10 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "progress_dialog.h" + #include "main/main.h" #include "message_queue.h" #include "os/os.h" #include "editor_scale.h" + void BackgroundProgress::_add_task(const String& p_task,const String& p_label, int p_steps) { _THREAD_SAFE_METHOD_ diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index 10005b6850..cacefaa1a2 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -31,12 +31,10 @@ #include "os/dir_access.h" #include "os/file_access.h" #include "globals.h" - #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/os.h" #include "scene/gui/box_container.h" - #include "scene/gui/tab_container.h" #include "scene/gui/scroll_container.h" #include "editor_data.h" diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index 2cf940a29a..fb8cccdb79 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -26,8 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "project_manager.h" + +#include "version.h" #include "os/os.h" #include "os/dir_access.h" #include "os/file_access.h" @@ -36,20 +37,16 @@ #include "scene/gui/separator.h" #include "scene/gui/tool_button.h" #include "io/config_file.h" - #include "scene/gui/line_edit.h" #include "scene/gui/panel_container.h" #include "scene/gui/center_container.h" #include "io/stream_peer_ssl.h" - #include "scene/gui/texture_rect.h" #include "scene/gui/margin_container.h" #include "io/resource_saver.h" - #include "editor_themes.h" #include "editor_initialize_ssl.h" #include "editor_scale.h" - #include "io/zip_io.h" class NewProjectDialog : public ConfirmationDialog { diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index 0396456c49..15d03b8a2b 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "project_settings.h" + #include "scene/gui/tab_container.h" #include "globals.h" #include "os/keyboard.h" @@ -779,7 +780,7 @@ void ProjectSettings::_copy_to_platform(int p_which) { String name = catname+"/"+propname; Variant value=GlobalConfig::get_singleton()->get(name); - catname+="."+popup_platform->get_popup()->get_item_text(p_which);; + catname+="."+popup_platform->get_popup()->get_item_text(p_which); name = catname+"/"+propname; GlobalConfig::get_singleton()->set(name,value); @@ -1362,7 +1363,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { Control *input_base = memnew( Control ); input_base->set_name(TTR("Input Map")); - input_base->set_area_as_parent_rect();; + input_base->set_area_as_parent_rect(); tab_container->add_child(input_base); VBoxContainer *vbc = memnew( VBoxContainer ); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 8f294a5102..fc1fe43cef 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -27,10 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "property_editor.h" + #include "scene/gui/label.h" #include "io/resource_loader.h" #include "io/image_loader.h" -#include "object_type_db.h" +#include "class_db.h" #include "print_string.h" #include "globals.h" #include "scene/resources/font.h" @@ -4660,7 +4661,7 @@ void SectionedPropertyEditor::_section_selected() { void SectionedPropertyEditor::set_current_section(const String& p_section) { if (section_map.has(p_section)) { - section_map[p_section]->select(0);; + section_map[p_section]->select(0); } } diff --git a/tools/editor/property_selector.cpp b/tools/editor/property_selector.cpp index 3d9695ac2a..3eeec1634d 100644 --- a/tools/editor/property_selector.cpp +++ b/tools/editor/property_selector.cpp @@ -1,6 +1,34 @@ +/*************************************************************************/ +/* property_selector.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 "property_selector.h" -#include "editor_scale.h" +#include "editor_scale.h" #include "os/keyboard.h" void PropertySelector::_text_changed(const String& p_newtext) { diff --git a/tools/editor/property_selector.h b/tools/editor/property_selector.h index 4823d50e0f..d29183f85e 100644 --- a/tools/editor/property_selector.h +++ b/tools/editor/property_selector.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* property_selector.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 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 PROPERTYSELECTOR_H #define PROPERTYSELECTOR_H diff --git a/tools/editor/pvrtc_compress.cpp b/tools/editor/pvrtc_compress.cpp index 7f84d8d00e..b130f6c773 100644 --- a/tools/editor/pvrtc_compress.cpp +++ b/tools/editor/pvrtc_compress.cpp @@ -27,12 +27,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "pvrtc_compress.h" + #include "editor_settings.h" #include "scene/resources/texture.h" #include "io/resource_saver.h" #include "io/resource_loader.h" #include "os/os.h" #include "os/file_access.h" + static void (*_base_image_compress_pvrtc2_func)(Image *)=NULL; static void (*_base_image_compress_pvrtc4_func)(Image *)=NULL; diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp index ff5ecdf01b..615b42b411 100644 --- a/tools/editor/quick_open.cpp +++ b/tools/editor/quick_open.cpp @@ -27,8 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "quick_open.h" -#include "os/keyboard.h" +#include "os/keyboard.h" void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) { diff --git a/tools/editor/reparent_dialog.cpp b/tools/editor/reparent_dialog.cpp index 4b6a032b64..c5b74d9006 100644 --- a/tools/editor/reparent_dialog.cpp +++ b/tools/editor/reparent_dialog.cpp @@ -30,8 +30,6 @@ #include "scene/gui/label.h" #include "scene/gui/box_container.h" - - #include "print_string.h" void ReparentDialog::_notification(int p_what) { @@ -107,7 +105,7 @@ ReparentDialog::ReparentDialog() { vbc->add_child(keep_transform); - //vbc->add_margin_child("Options:",node_only);; + //vbc->add_margin_child("Options:",node_only); //cancel->connect("pressed", this,"_cancel"); diff --git a/tools/editor/resources_dock.cpp b/tools/editor/resources_dock.cpp index ddd4a782e4..e89262db25 100644 --- a/tools/editor/resources_dock.cpp +++ b/tools/editor/resources_dock.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resources_dock.h" + #include "editor_node.h" #include "io/resource_loader.h" #include "io/resource_saver.h" @@ -122,7 +123,7 @@ void ResourcesDock::_notification(int p_what) { void ResourcesDock::save_resource(const String& p_path,const Ref<Resource>& p_resource) { - editor->get_editor_data().apply_changes_in_editors();; + editor->get_editor_data().apply_changes_in_editors(); int flg=0; if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources")) flg|=ResourceSaver::FLAG_COMPRESS; diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 6a1d1ed3b2..bd81c57676 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "scene_tree_dock.h" + #include "editor_node.h" #include "globals.h" #include "os/keyboard.h" diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index 7b6a03e20e..77640b9c80 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -27,13 +27,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "scene_tree_editor.h" + #include "scene/gui/label.h" #include "editor_node.h" #include "print_string.h" #include "message_queue.h" #include "scene/main/viewport.h" #include "tools/editor/plugins/canvas_item_editor_plugin.h" - #include "scene/resources/packed_scene.h" Node *SceneTreeEditor::get_scene_node() { diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp index 2a76224e33..da01cdefe5 100644 --- a/tools/editor/script_create_dialog.cpp +++ b/tools/editor/script_create_dialog.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_create_dialog.h" + #include "script_language.h" #include "globals.h" #include "io/resource_saver.h" diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index e53e69d9e0..42ab234d4b 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_editor_debugger.h" + #include "scene/gui/separator.h" #include "scene/gui/label.h" #include "scene/gui/split_container.h" @@ -1188,7 +1189,7 @@ void ScriptEditorDebugger::_profiler_seeked() { if (breaked) return; - debug_break();; + debug_break(); } diff --git a/tools/editor/settings_config_dialog.cpp b/tools/editor/settings_config_dialog.cpp index c72f2641b7..31cbcee5ae 100644 --- a/tools/editor/settings_config_dialog.cpp +++ b/tools/editor/settings_config_dialog.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "settings_config_dialog.h" + #include "editor_settings.h" #include "scene/gui/margin_container.h" #include "globals.h" diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp index 82dfa94c06..adbac4b12b 100644 --- a/tools/editor/spatial_editor_gizmos.cpp +++ b/tools/editor/spatial_editor_gizmos.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "spatial_editor_gizmos.h" + #include "geometry.h" #include "scene/3d/camera.h" #include "scene/resources/surface_tool.h" @@ -285,7 +286,8 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi Vector<Vector3> normals; int vtx_idx=0; -#define ADD_VTX(m_idx);\ + +#define ADD_VTX(m_idx) \ vertices.push_back( (face_points[m_idx]*HANDLE_HALF_SIZE+p_handles[ih]) );\ normals.push_back( normal_points[m_idx] );\ vtx_idx++;\ @@ -953,28 +955,6 @@ LightSpatialGizmo::LightSpatialGizmo(Light* p_light){ set_spatial_node(p_light); } -////// - -void ListenerSpatialGizmo::redraw() { - - clear(); - - add_unscaled_billboard(SpatialEditorGizmos::singleton->listener_icon, 0.05); - - add_mesh(SpatialEditorGizmos::singleton->listener_line_mesh); - Vector<Vector3> cursor_points; - cursor_points.push_back(Vector3(0, 0, 0)); - cursor_points.push_back(Vector3(0, 0, -1.0)); - add_collision_segments(cursor_points); - -} - -ListenerSpatialGizmo::ListenerSpatialGizmo(Listener* p_listener){ - - set_spatial_node(p_listener); - listener = p_listener; -} - ////// @@ -1391,32 +1371,6 @@ SkeletonSpatialGizmo::SkeletonSpatialGizmo(Skeleton* p_skel) { set_spatial_node(p_skel); } -///// - - -void SpatialPlayerSpatialGizmo::redraw() { - - clear(); - if (splayer->cast_to<SpatialStreamPlayer>()) { - - add_unscaled_billboard(SpatialEditorGizmos::singleton->stream_player_icon,0.05); - - } else if (splayer->cast_to<SpatialSamplePlayer>()) { - - add_unscaled_billboard(SpatialEditorGizmos::singleton->sample_player_icon,0.05); - - } - -} - -SpatialPlayerSpatialGizmo::SpatialPlayerSpatialGizmo(SpatialPlayer* p_splayer){ - - set_spatial_node(p_splayer); - splayer=p_splayer; -} - - -///// void RoomSpatialGizmo::redraw() { @@ -2168,7 +2122,7 @@ void VisibilityNotifierGizmo::set_handle(int p_idx,Camera *p_camera, const Point Vector3 ray_dir = p_camera->project_ray_normal(p_point); Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*4096)}; - Vector3 ofs = aabb.pos+aabb.size*0.5;; + Vector3 ofs = aabb.pos+aabb.size*0.5; Vector3 axis; axis[p_idx]=1.0; @@ -3165,11 +3119,7 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) { return lsg; } - if (p_spatial->cast_to<Listener>()) { - Ref<ListenerSpatialGizmo> misg = memnew(ListenerSpatialGizmo(p_spatial->cast_to<Listener>())); - return misg; - } if (p_spatial->cast_to<Camera>()) { @@ -3227,12 +3177,6 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) { return misg; } - if (p_spatial->cast_to<SpatialPlayer>()) { - - Ref<SpatialPlayerSpatialGizmo> misg = memnew( SpatialPlayerSpatialGizmo(p_spatial->cast_to<SpatialPlayer>()) ); - return misg; - } - if (p_spatial->cast_to<CollisionShape>()) { Ref<CollisionShapeSpatialGizmo> misg = memnew( CollisionShapeSpatialGizmo(p_spatial->cast_to<CollisionShape>()) ); @@ -3494,7 +3438,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() { PoolVector<Vector3> vertices; #undef ADD_VTX -#define ADD_VTX(m_idx);\ +#define ADD_VTX(m_idx) \ vertices.push_back( face_points[m_idx] ); for (int i=0;i<6;i++) { diff --git a/tools/editor/spatial_editor_gizmos.h b/tools/editor/spatial_editor_gizmos.h index 8fde52b05a..8a63d4f81e 100644 --- a/tools/editor/spatial_editor_gizmos.h +++ b/tools/editor/spatial_editor_gizmos.h @@ -35,8 +35,6 @@ #include "scene/3d/listener.h" #include "scene/3d/camera.h" #include "scene/3d/position_3d.h" -#include "scene/3d/spatial_sample_player.h" -#include "scene/3d/spatial_stream_player.h" #include "scene/3d/test_cube.h" #include "scene/3d/mesh_instance.h" #include "scene/3d/body_shape.h" @@ -146,19 +144,6 @@ public: }; -class ListenerSpatialGizmo : public EditorSpatialGizmo { - - GDCLASS(ListenerSpatialGizmo, EditorSpatialGizmo); - - Listener* listener; - -public: - - void redraw(); - ListenerSpatialGizmo(Listener* p_listener = NULL); - -}; - class CameraSpatialGizmo : public EditorSpatialGizmo { GDCLASS(CameraSpatialGizmo,EditorSpatialGizmo); @@ -220,23 +205,6 @@ public: }; - - -class SpatialPlayerSpatialGizmo : public EditorSpatialGizmo { - - GDCLASS(SpatialPlayerSpatialGizmo,EditorSpatialGizmo); - - SpatialPlayer* splayer; - -public: - - void redraw(); - SpatialPlayerSpatialGizmo(SpatialPlayer* p_splayer=NULL); - -}; - - - class TestCubeSpatialGizmo : public EditorSpatialGizmo { GDCLASS(TestCubeSpatialGizmo,EditorSpatialGizmo); |