feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
from misc.utility.scons_hints import *
|
||||
|
||||
Import("env")
|
||||
|
||||
|
|
|
|||
|
|
@ -60,11 +60,22 @@ float AudioEffectAmplify::get_volume_db() const {
|
|||
return volume_db;
|
||||
}
|
||||
|
||||
void AudioEffectAmplify::set_volume_linear(float p_volume) {
|
||||
set_volume_db(Math::linear_to_db(p_volume));
|
||||
}
|
||||
|
||||
float AudioEffectAmplify::get_volume_linear() const {
|
||||
return Math::db_to_linear(get_volume_db());
|
||||
}
|
||||
|
||||
void AudioEffectAmplify::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_volume_db", "volume"), &AudioEffectAmplify::set_volume_db);
|
||||
ClassDB::bind_method(D_METHOD("get_volume_db"), &AudioEffectAmplify::get_volume_db);
|
||||
ClassDB::bind_method(D_METHOD("set_volume_linear", "volume"), &AudioEffectAmplify::set_volume_linear);
|
||||
ClassDB::bind_method(D_METHOD("get_volume_linear"), &AudioEffectAmplify::get_volume_linear);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01,suffix:dB"), "set_volume_db", "get_volume_db");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume_linear", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_volume_linear", "get_volume_linear");
|
||||
}
|
||||
|
||||
AudioEffectAmplify::AudioEffectAmplify() {
|
||||
|
|
|
|||
|
|
@ -60,6 +60,9 @@ public:
|
|||
void set_volume_db(float p_volume);
|
||||
float get_volume_db() const;
|
||||
|
||||
void set_volume_linear(float p_volume);
|
||||
float get_volume_linear() const;
|
||||
|
||||
AudioEffectAmplify();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "audio_effect_capture.h"
|
||||
|
||||
#include "servers/audio_server.h"
|
||||
|
||||
bool AudioEffectCapture::can_get_buffer(int p_frames) const {
|
||||
return buffer.data_left() >= p_frames;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,13 +31,10 @@
|
|||
#ifndef AUDIO_EFFECT_CAPTURE_H
|
||||
#define AUDIO_EFFECT_CAPTURE_H
|
||||
|
||||
#include "core/config/engine.h"
|
||||
#include "core/math/audio_frame.h"
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/templates/ring_buffer.h"
|
||||
#include "core/templates/vector.h"
|
||||
#include "servers/audio/audio_effect.h"
|
||||
#include "servers/audio_server.h"
|
||||
|
||||
class AudioEffectCapture;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
/**************************************************************************/
|
||||
|
||||
#include "audio_effect_phaser.h"
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "servers/audio_server.h"
|
||||
|
||||
void AudioEffectPhaserInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
|
||||
|
|
|
|||
|
|
@ -286,6 +286,11 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign)
|
|||
/* clang-format on */
|
||||
|
||||
void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
|
||||
// Avoid distortion by skipping processing if pitch_scale is 1.0.
|
||||
if (Math::is_equal_approx(base->pitch_scale, 1.0f)) {
|
||||
return;
|
||||
}
|
||||
|
||||
float sample_rate = AudioServer::get_singleton()->get_mix_rate();
|
||||
|
||||
float *in_l = (float *)p_src_frames;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class AudioEffectPitchShift : public AudioEffect {
|
|||
public:
|
||||
friend class AudioEffectPitchShiftInstance;
|
||||
|
||||
enum FFTSize {
|
||||
enum FFTSize : unsigned int {
|
||||
FFT_SIZE_256,
|
||||
FFT_SIZE_512,
|
||||
FFT_SIZE_1024,
|
||||
|
|
|
|||
|
|
@ -30,10 +30,7 @@
|
|||
|
||||
#include "audio_effect_record.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
// FIXME: This file shouldn't depend on editor stuff.
|
||||
#include "editor/import/resource_importer_wav.h"
|
||||
#endif
|
||||
#include "core/io/marshalls.h"
|
||||
|
||||
void AudioEffectRecordInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
|
||||
if (!is_recording) {
|
||||
|
|
@ -125,7 +122,7 @@ Ref<AudioEffectInstance> AudioEffectRecord::instantiate() {
|
|||
ins.instantiate();
|
||||
ins->is_recording = false;
|
||||
|
||||
//Re-using the buffer size calculations from audio_effect_delay.cpp
|
||||
// Reusing the buffer size calculations from audio_effect_delay.cpp.
|
||||
float ring_buffer_max_size = IO_BUFFER_SIZE_MS;
|
||||
ring_buffer_max_size /= 1000.0; //convert to seconds
|
||||
ring_buffer_max_size *= AudioServer::get_singleton()->get_mix_rate();
|
||||
|
|
@ -149,7 +146,7 @@ Ref<AudioEffectInstance> AudioEffectRecord::instantiate() {
|
|||
|
||||
ensure_thread_stopped();
|
||||
bool is_currently_recording = false;
|
||||
if (current_instance != nullptr) {
|
||||
if (current_instance.is_valid()) {
|
||||
is_currently_recording = current_instance->is_recording;
|
||||
}
|
||||
if (is_currently_recording) {
|
||||
|
|
@ -161,28 +158,28 @@ Ref<AudioEffectInstance> AudioEffectRecord::instantiate() {
|
|||
}
|
||||
|
||||
void AudioEffectRecord::ensure_thread_stopped() {
|
||||
if (current_instance != nullptr) {
|
||||
if (current_instance.is_valid()) {
|
||||
current_instance->finish();
|
||||
}
|
||||
}
|
||||
|
||||
void AudioEffectRecord::set_recording_active(bool p_record) {
|
||||
if (p_record) {
|
||||
if (current_instance == nullptr) {
|
||||
if (current_instance.is_null()) {
|
||||
WARN_PRINT("Recording should not be set as active before Godot has initialized.");
|
||||
return;
|
||||
}
|
||||
ensure_thread_stopped();
|
||||
current_instance->init();
|
||||
} else {
|
||||
if (current_instance != nullptr) {
|
||||
if (current_instance.is_valid()) {
|
||||
current_instance->is_recording = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioEffectRecord::is_recording_active() const {
|
||||
if (current_instance == nullptr) {
|
||||
if (current_instance.is_null()) {
|
||||
return false;
|
||||
} else {
|
||||
return current_instance->is_recording;
|
||||
|
|
@ -241,12 +238,8 @@ Ref<AudioStreamWAV> AudioEffectRecord::get_recording() const {
|
|||
Vector<uint8_t> bleft;
|
||||
Vector<uint8_t> bright;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
ResourceImporterWAV::_compress_ima_adpcm(left, bleft);
|
||||
ResourceImporterWAV::_compress_ima_adpcm(right, bright);
|
||||
#else
|
||||
ERR_PRINT("AudioEffectRecord cannot do IMA ADPCM compression at runtime.");
|
||||
#endif
|
||||
AudioStreamWAV::_compress_ima_adpcm(left, bleft);
|
||||
AudioStreamWAV::_compress_ima_adpcm(right, bright);
|
||||
|
||||
int dl = bleft.size();
|
||||
dst_data.resize(dl * 2);
|
||||
|
|
@ -259,6 +252,12 @@ Ref<AudioStreamWAV> AudioEffectRecord::get_recording() const {
|
|||
w[i * 2 + 0] = rl[i];
|
||||
w[i * 2 + 1] = rr[i];
|
||||
}
|
||||
} else if (dst_format == AudioStreamWAV::FORMAT_QOA) {
|
||||
qoa_desc desc = {};
|
||||
desc.samples = current_instance->recording_data.size() / 2;
|
||||
desc.samplerate = AudioServer::get_singleton()->get_mix_rate();
|
||||
desc.channels = 2;
|
||||
AudioStreamWAV::_compress_qoa(current_instance->recording_data, dst_data, &desc);
|
||||
} else {
|
||||
ERR_PRINT("Format not implemented.");
|
||||
}
|
||||
|
|
@ -283,7 +282,7 @@ void AudioEffectRecord::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_format"), &AudioEffectRecord::get_format);
|
||||
ClassDB::bind_method(D_METHOD("get_recording"), &AudioEffectRecord::get_recording);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "format", PROPERTY_HINT_ENUM, "8-Bit,16-Bit,IMA-ADPCM"), "set_format", "get_format");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "format", PROPERTY_HINT_ENUM, "8-Bit,16-Bit,IMA ADPCM,Quite OK Audio"), "set_format", "get_format");
|
||||
}
|
||||
|
||||
AudioEffectRecord::AudioEffectRecord() {
|
||||
|
|
|
|||
|
|
@ -31,9 +31,6 @@
|
|||
#ifndef AUDIO_EFFECT_RECORD_H
|
||||
#define AUDIO_EFFECT_RECORD_H
|
||||
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/io/marshalls.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/os/thread.h"
|
||||
#include "scene/resources/audio_stream_wav.h"
|
||||
#include "servers/audio/audio_effect.h"
|
||||
|
|
|
|||
|
|
@ -145,8 +145,8 @@ void AudioEffectSpectrumAnalyzerInstance::process(const AudioFrame *p_src_frames
|
|||
}
|
||||
|
||||
//determine time of capture
|
||||
double remainer_sec = (temporal_fft_pos / mix_rate); //subtract remainder from mix time
|
||||
last_fft_time = time - uint64_t(remainer_sec * 1000000.0);
|
||||
double remainder_sec = (temporal_fft_pos / mix_rate); //subtract remainder from mix time
|
||||
last_fft_time = time - uint64_t(remainder_sec * 1000000.0);
|
||||
}
|
||||
|
||||
void AudioEffectSpectrumAnalyzerInstance::_bind_methods() {
|
||||
|
|
|
|||
|
|
@ -39,34 +39,34 @@ void AudioEffectStereoEnhanceInstance::process(const AudioFrame *p_src_frames, A
|
|||
unsigned int delay_frames = (base->time_pullout / 1000.0) * AudioServer::get_singleton()->get_mix_rate();
|
||||
|
||||
for (int i = 0; i < p_frame_count; i++) {
|
||||
float l = p_src_frames[i].left;
|
||||
float r = p_src_frames[i].right;
|
||||
float left = p_src_frames[i].left;
|
||||
float right = p_src_frames[i].right;
|
||||
|
||||
float center = (l + r) / 2.0f;
|
||||
float center = (left + right) / 2.0f;
|
||||
|
||||
l = (center + (l - center) * intensity);
|
||||
r = (center + (r - center) * intensity);
|
||||
left = (center + (left - center) * intensity);
|
||||
right = (center + (right - center) * intensity);
|
||||
|
||||
if (surround_mode) {
|
||||
float val = (l + r) / 2.0;
|
||||
float val = (left + right) / 2.0;
|
||||
|
||||
delay_ringbuff[ringbuff_pos & ringbuff_mask] = val;
|
||||
|
||||
float out = delay_ringbuff[(ringbuff_pos - delay_frames) & ringbuff_mask] * surround_amount;
|
||||
|
||||
l += out;
|
||||
r += -out;
|
||||
left += out;
|
||||
right += -out;
|
||||
} else {
|
||||
float val = r;
|
||||
float val = right;
|
||||
|
||||
delay_ringbuff[ringbuff_pos & ringbuff_mask] = val;
|
||||
|
||||
//r is delayed
|
||||
r = delay_ringbuff[(ringbuff_pos - delay_frames) & ringbuff_mask];
|
||||
// The right channel is delayed.
|
||||
right = delay_ringbuff[(ringbuff_pos - delay_frames) & ringbuff_mask];
|
||||
}
|
||||
|
||||
p_dst_frames[i].left = l;
|
||||
p_dst_frames[i].right = r;
|
||||
p_dst_frames[i].left = left;
|
||||
p_dst_frames[i].right = right;
|
||||
ringbuff_pos++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,15 @@ float AudioStreamGenerator::get_mix_rate() const {
|
|||
return mix_rate;
|
||||
}
|
||||
|
||||
void AudioStreamGenerator::set_mix_rate_mode(AudioStreamGenerator::AudioStreamGeneratorMixRate p_mix_rate_mode) {
|
||||
ERR_FAIL_INDEX(p_mix_rate_mode, AudioStreamGeneratorMixRate::MIX_RATE_MAX);
|
||||
mix_rate_mode = p_mix_rate_mode;
|
||||
}
|
||||
|
||||
AudioStreamGenerator::AudioStreamGeneratorMixRate AudioStreamGenerator::get_mix_rate_mode() const {
|
||||
return mix_rate_mode;
|
||||
}
|
||||
|
||||
void AudioStreamGenerator::set_buffer_length(float p_seconds) {
|
||||
buffer_len = p_seconds;
|
||||
}
|
||||
|
|
@ -46,11 +55,22 @@ float AudioStreamGenerator::get_buffer_length() const {
|
|||
return buffer_len;
|
||||
}
|
||||
|
||||
float AudioStreamGenerator::_get_target_rate() const {
|
||||
switch (mix_rate_mode) {
|
||||
case AudioStreamGeneratorMixRate::MIX_RATE_OUTPUT:
|
||||
return AudioServer::get_singleton()->get_mix_rate();
|
||||
case AudioStreamGeneratorMixRate::MIX_RATE_INPUT:
|
||||
return AudioServer::get_singleton()->get_input_mix_rate();
|
||||
default:
|
||||
return mix_rate;
|
||||
}
|
||||
}
|
||||
|
||||
Ref<AudioStreamPlayback> AudioStreamGenerator::instantiate_playback() {
|
||||
Ref<AudioStreamGeneratorPlayback> playback;
|
||||
playback.instantiate();
|
||||
playback->generator = this;
|
||||
int target_buffer_size = mix_rate * buffer_len;
|
||||
int target_buffer_size = _get_target_rate() * buffer_len;
|
||||
playback->buffer.resize(nearest_shift(target_buffer_size));
|
||||
playback->buffer.clear();
|
||||
return playback;
|
||||
|
|
@ -72,16 +92,20 @@ void AudioStreamGenerator::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_mix_rate", "hz"), &AudioStreamGenerator::set_mix_rate);
|
||||
ClassDB::bind_method(D_METHOD("get_mix_rate"), &AudioStreamGenerator::get_mix_rate);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_mix_rate_mode", "mode"), &AudioStreamGenerator::set_mix_rate_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_mix_rate_mode"), &AudioStreamGenerator::get_mix_rate_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_buffer_length", "seconds"), &AudioStreamGenerator::set_buffer_length);
|
||||
ClassDB::bind_method(D_METHOD("get_buffer_length"), &AudioStreamGenerator::get_buffer_length);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_rate_mode", PROPERTY_HINT_ENUM, "System Output Rate,System Input Rate,Custom Rate"), "set_mix_rate_mode", "get_mix_rate_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mix_rate", PROPERTY_HINT_RANGE, "20,192000,1,suffix:Hz"), "set_mix_rate", "get_mix_rate");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "buffer_length", PROPERTY_HINT_RANGE, "0.01,10,0.01,suffix:s"), "set_buffer_length", "get_buffer_length");
|
||||
}
|
||||
|
||||
AudioStreamGenerator::AudioStreamGenerator() {
|
||||
mix_rate = 44100;
|
||||
buffer_len = 0.5;
|
||||
BIND_ENUM_CONSTANT(MIX_RATE_OUTPUT);
|
||||
BIND_ENUM_CONSTANT(MIX_RATE_INPUT);
|
||||
BIND_ENUM_CONSTANT(MIX_RATE_CUSTOM);
|
||||
BIND_ENUM_CONSTANT(MIX_RATE_MAX);
|
||||
}
|
||||
|
||||
////////////////
|
||||
|
|
@ -162,12 +186,12 @@ int AudioStreamGeneratorPlayback::_mix_internal(AudioFrame *p_buffer, int p_fram
|
|||
skips++;
|
||||
}
|
||||
|
||||
mixed += p_frames / generator->get_mix_rate();
|
||||
mixed += p_frames / generator->_get_target_rate();
|
||||
return p_frames;
|
||||
}
|
||||
|
||||
float AudioStreamGeneratorPlayback::get_stream_sampling_rate() {
|
||||
return generator->get_mix_rate();
|
||||
return generator->_get_target_rate();
|
||||
}
|
||||
|
||||
void AudioStreamGeneratorPlayback::start(double p_from_pos) {
|
||||
|
|
|
|||
|
|
@ -37,16 +37,31 @@
|
|||
class AudioStreamGenerator : public AudioStream {
|
||||
GDCLASS(AudioStreamGenerator, AudioStream);
|
||||
|
||||
float mix_rate;
|
||||
float buffer_len;
|
||||
public:
|
||||
enum AudioStreamGeneratorMixRate {
|
||||
MIX_RATE_OUTPUT,
|
||||
MIX_RATE_INPUT,
|
||||
MIX_RATE_CUSTOM,
|
||||
MIX_RATE_MAX,
|
||||
};
|
||||
|
||||
private:
|
||||
AudioStreamGeneratorMixRate mix_rate_mode = MIX_RATE_CUSTOM;
|
||||
float mix_rate = 44100;
|
||||
float buffer_len = 0.5;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
float _get_target_rate() const;
|
||||
|
||||
void set_mix_rate(float p_mix_rate);
|
||||
float get_mix_rate() const;
|
||||
|
||||
void set_mix_rate_mode(AudioStreamGeneratorMixRate p_mix_rate_mode);
|
||||
AudioStreamGeneratorMixRate get_mix_rate_mode() const;
|
||||
|
||||
void set_buffer_length(float p_seconds);
|
||||
float get_buffer_length() const;
|
||||
|
||||
|
|
@ -55,7 +70,7 @@ public:
|
|||
|
||||
virtual double get_length() const override;
|
||||
virtual bool is_monophonic() const override;
|
||||
AudioStreamGenerator();
|
||||
AudioStreamGenerator() {}
|
||||
};
|
||||
|
||||
class AudioStreamGeneratorPlayback : public AudioStreamPlaybackResampled {
|
||||
|
|
@ -96,4 +111,6 @@ public:
|
|||
AudioStreamGeneratorPlayback();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(AudioStreamGenerator::AudioStreamGeneratorMixRate);
|
||||
|
||||
#endif // AUDIO_STREAM_GENERATOR_H
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
#include "eq_filter.h"
|
||||
|
||||
#include "core/error/error_macros.h"
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/math/math_defs.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#define EQ_FILTER_H
|
||||
|
||||
#include "core/templates/vector.h"
|
||||
#include "core/typedefs.h"
|
||||
|
||||
class EQ {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@
|
|||
|
||||
#include "reverb_filter.h"
|
||||
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/math/audio_frame.h"
|
||||
#include "core/os/memory.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@
|
|||
#ifndef REVERB_FILTER_H
|
||||
#define REVERB_FILTER_H
|
||||
|
||||
#include "core/math/audio_frame.h"
|
||||
#include "core/os/memory.h"
|
||||
#include "core/typedefs.h"
|
||||
|
||||
class Reverb {
|
||||
public:
|
||||
enum {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue