diff options
Diffstat (limited to 'servers')
29 files changed, 152 insertions, 77 deletions
diff --git a/servers/audio/audio_effect.h b/servers/audio/audio_effect.h index 1274e06740..8ae716db20 100644 --- a/servers/audio/audio_effect.h +++ b/servers/audio/audio_effect.h @@ -35,7 +35,7 @@ #include "core/resource.h" class AudioEffectInstance : public Reference { - GDCLASS(AudioEffectInstance, Reference) + GDCLASS(AudioEffectInstance, Reference); public: virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) = 0; @@ -43,7 +43,8 @@ public: }; class AudioEffect : public Resource { - GDCLASS(AudioEffect, Resource) + GDCLASS(AudioEffect, Resource); + public: virtual Ref<AudioEffectInstance> instance() = 0; AudioEffect(); diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h index ab4ef5f91b..8f023c0401 100644 --- a/servers/audio/audio_stream.h +++ b/servers/audio/audio_stream.h @@ -38,7 +38,7 @@ class AudioStreamPlayback : public Reference { - GDCLASS(AudioStreamPlayback, Reference) + GDCLASS(AudioStreamPlayback, Reference); public: virtual void start(float p_from_pos = 0.0) = 0; @@ -55,7 +55,7 @@ public: class AudioStreamPlaybackResampled : public AudioStreamPlayback { - GDCLASS(AudioStreamPlaybackResampled, AudioStreamPlayback) + GDCLASS(AudioStreamPlaybackResampled, AudioStreamPlayback); enum { FP_BITS = 16, //fixed point used for resampling @@ -81,7 +81,7 @@ public: class AudioStream : public Resource { - GDCLASS(AudioStream, Resource) + GDCLASS(AudioStream, Resource); OBJ_SAVE_TYPE(AudioStream) //children are all saved as AudioStream, so they can be exchanged protected: @@ -100,7 +100,7 @@ class AudioStreamPlaybackMicrophone; class AudioStreamMicrophone : public AudioStream { - GDCLASS(AudioStreamMicrophone, AudioStream) + GDCLASS(AudioStreamMicrophone, AudioStream); friend class AudioStreamPlaybackMicrophone; Set<AudioStreamPlaybackMicrophone *> playbacks; @@ -119,7 +119,7 @@ public: class AudioStreamPlaybackMicrophone : public AudioStreamPlaybackResampled { - GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlayback) + GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlayback); friend class AudioStreamMicrophone; bool active; @@ -153,7 +153,7 @@ class AudioStreamPlaybackRandomPitch; class AudioStreamRandomPitch : public AudioStream { - GDCLASS(AudioStreamRandomPitch, AudioStream) + GDCLASS(AudioStreamRandomPitch, AudioStream); friend class AudioStreamPlaybackRandomPitch; Set<AudioStreamPlaybackRandomPitch *> playbacks; @@ -180,7 +180,7 @@ public: class AudioStreamPlaybackRandomPitch : public AudioStreamPlayback { - GDCLASS(AudioStreamPlaybackRandomPitch, AudioStreamPlayback) + GDCLASS(AudioStreamPlaybackRandomPitch, AudioStreamPlayback); friend class AudioStreamRandomPitch; Ref<AudioStreamRandomPitch> random_pitch; diff --git a/servers/audio/effects/audio_effect_amplify.h b/servers/audio/effects/audio_effect_amplify.h index b6e2a1d4d8..4a98196d94 100644 --- a/servers/audio/effects/audio_effect_amplify.h +++ b/servers/audio/effects/audio_effect_amplify.h @@ -36,7 +36,7 @@ class AudioEffectAmplify; class AudioEffectAmplifyInstance : public AudioEffectInstance { - GDCLASS(AudioEffectAmplifyInstance, AudioEffectInstance) + GDCLASS(AudioEffectAmplifyInstance, AudioEffectInstance); friend class AudioEffectAmplify; Ref<AudioEffectAmplify> base; @@ -47,7 +47,7 @@ public: }; class AudioEffectAmplify : public AudioEffect { - GDCLASS(AudioEffectAmplify, AudioEffect) + GDCLASS(AudioEffectAmplify, AudioEffect); friend class AudioEffectAmplifyInstance; float volume_db; diff --git a/servers/audio/effects/audio_effect_chorus.h b/servers/audio/effects/audio_effect_chorus.h index 9cad2906ff..417cc0c035 100644 --- a/servers/audio/effects/audio_effect_chorus.h +++ b/servers/audio/effects/audio_effect_chorus.h @@ -36,7 +36,7 @@ class AudioEffectChorus; class AudioEffectChorusInstance : public AudioEffectInstance { - GDCLASS(AudioEffectChorusInstance, AudioEffectInstance) + GDCLASS(AudioEffectChorusInstance, AudioEffectInstance); friend class AudioEffectChorus; Ref<AudioEffectChorus> base; @@ -54,7 +54,7 @@ public: }; class AudioEffectChorus : public AudioEffect { - GDCLASS(AudioEffectChorus, AudioEffect) + GDCLASS(AudioEffectChorus, AudioEffect); friend class AudioEffectChorusInstance; diff --git a/servers/audio/effects/audio_effect_compressor.h b/servers/audio/effects/audio_effect_compressor.h index 3ea3a58cb2..0fe956f60b 100644 --- a/servers/audio/effects/audio_effect_compressor.h +++ b/servers/audio/effects/audio_effect_compressor.h @@ -36,7 +36,7 @@ class AudioEffectCompressor; class AudioEffectCompressorInstance : public AudioEffectInstance { - GDCLASS(AudioEffectCompressorInstance, AudioEffectInstance) + GDCLASS(AudioEffectCompressorInstance, AudioEffectInstance); friend class AudioEffectCompressor; Ref<AudioEffectCompressor> base; @@ -49,7 +49,7 @@ public: }; class AudioEffectCompressor : public AudioEffect { - GDCLASS(AudioEffectCompressor, AudioEffect) + GDCLASS(AudioEffectCompressor, AudioEffect); friend class AudioEffectCompressorInstance; float threshold; diff --git a/servers/audio/effects/audio_effect_delay.h b/servers/audio/effects/audio_effect_delay.h index 131b8714a0..ee778c70dc 100644 --- a/servers/audio/effects/audio_effect_delay.h +++ b/servers/audio/effects/audio_effect_delay.h @@ -36,7 +36,7 @@ class AudioEffectDelay; class AudioEffectDelayInstance : public AudioEffectInstance { - GDCLASS(AudioEffectDelayInstance, AudioEffectInstance) + GDCLASS(AudioEffectDelayInstance, AudioEffectInstance); friend class AudioEffectDelay; Ref<AudioEffectDelay> base; @@ -58,7 +58,7 @@ public: }; class AudioEffectDelay : public AudioEffect { - GDCLASS(AudioEffectDelay, AudioEffect) + GDCLASS(AudioEffectDelay, AudioEffect); friend class AudioEffectDelayInstance; enum { diff --git a/servers/audio/effects/audio_effect_distortion.h b/servers/audio/effects/audio_effect_distortion.h index 2cbffc81a1..0b5ad0ec9e 100644 --- a/servers/audio/effects/audio_effect_distortion.h +++ b/servers/audio/effects/audio_effect_distortion.h @@ -36,7 +36,7 @@ class AudioEffectDistortion; class AudioEffectDistortionInstance : public AudioEffectInstance { - GDCLASS(AudioEffectDistortionInstance, AudioEffectInstance) + GDCLASS(AudioEffectDistortionInstance, AudioEffectInstance); friend class AudioEffectDistortion; Ref<AudioEffectDistortion> base; float h[2]; @@ -46,7 +46,8 @@ public: }; class AudioEffectDistortion : public AudioEffect { - GDCLASS(AudioEffectDistortion, AudioEffect) + GDCLASS(AudioEffectDistortion, AudioEffect); + public: enum Mode { MODE_CLIP, diff --git a/servers/audio/effects/audio_effect_eq.h b/servers/audio/effects/audio_effect_eq.h index c9735b9073..dc75e566e7 100644 --- a/servers/audio/effects/audio_effect_eq.h +++ b/servers/audio/effects/audio_effect_eq.h @@ -37,7 +37,7 @@ class AudioEffectEQ; class AudioEffectEQInstance : public AudioEffectInstance { - GDCLASS(AudioEffectEQInstance, AudioEffectInstance) + GDCLASS(AudioEffectEQInstance, AudioEffectInstance); friend class AudioEffectEQ; Ref<AudioEffectEQ> base; @@ -49,7 +49,7 @@ public: }; class AudioEffectEQ : public AudioEffect { - GDCLASS(AudioEffectEQ, AudioEffect) + GDCLASS(AudioEffectEQ, AudioEffect); friend class AudioEffectEQInstance; @@ -75,21 +75,24 @@ public: }; class AudioEffectEQ6 : public AudioEffectEQ { - GDCLASS(AudioEffectEQ6, AudioEffectEQ) + GDCLASS(AudioEffectEQ6, AudioEffectEQ); + public: AudioEffectEQ6() : AudioEffectEQ(EQ::PRESET_6_BANDS) {} }; class AudioEffectEQ10 : public AudioEffectEQ { - GDCLASS(AudioEffectEQ10, AudioEffectEQ) + GDCLASS(AudioEffectEQ10, AudioEffectEQ); + public: AudioEffectEQ10() : AudioEffectEQ(EQ::PRESET_10_BANDS) {} }; class AudioEffectEQ21 : public AudioEffectEQ { - GDCLASS(AudioEffectEQ21, AudioEffectEQ) + GDCLASS(AudioEffectEQ21, AudioEffectEQ); + public: AudioEffectEQ21() : AudioEffectEQ(EQ::PRESET_21_BANDS) {} diff --git a/servers/audio/effects/audio_effect_filter.h b/servers/audio/effects/audio_effect_filter.h index fd9a4bcf07..bb0d451522 100644 --- a/servers/audio/effects/audio_effect_filter.h +++ b/servers/audio/effects/audio_effect_filter.h @@ -37,7 +37,7 @@ class AudioEffectFilter; class AudioEffectFilterInstance : public AudioEffectInstance { - GDCLASS(AudioEffectFilterInstance, AudioEffectInstance) + GDCLASS(AudioEffectFilterInstance, AudioEffectInstance); friend class AudioEffectFilter; Ref<AudioEffectFilter> base; @@ -55,7 +55,8 @@ public: }; class AudioEffectFilter : public AudioEffect { - GDCLASS(AudioEffectFilter, AudioEffect) + GDCLASS(AudioEffectFilter, AudioEffect); + public: enum FilterDB { FILTER_6DB, @@ -95,7 +96,7 @@ public: VARIANT_ENUM_CAST(AudioEffectFilter::FilterDB) class AudioEffectLowPassFilter : public AudioEffectFilter { - GDCLASS(AudioEffectLowPassFilter, AudioEffectFilter) + GDCLASS(AudioEffectLowPassFilter, AudioEffectFilter); void _validate_property(PropertyInfo &property) const { if (property.name == "gain") property.usage = 0; @@ -107,7 +108,7 @@ public: }; class AudioEffectHighPassFilter : public AudioEffectFilter { - GDCLASS(AudioEffectHighPassFilter, AudioEffectFilter) + GDCLASS(AudioEffectHighPassFilter, AudioEffectFilter); void _validate_property(PropertyInfo &property) const { if (property.name == "gain") property.usage = 0; } @@ -118,7 +119,7 @@ public: }; class AudioEffectBandPassFilter : public AudioEffectFilter { - GDCLASS(AudioEffectBandPassFilter, AudioEffectFilter) + GDCLASS(AudioEffectBandPassFilter, AudioEffectFilter); void _validate_property(PropertyInfo &property) const { if (property.name == "gain") property.usage = 0; } @@ -129,28 +130,32 @@ public: }; class AudioEffectNotchFilter : public AudioEffectFilter { - GDCLASS(AudioEffectNotchFilter, AudioEffectFilter) + GDCLASS(AudioEffectNotchFilter, AudioEffectFilter); + public: AudioEffectNotchFilter() : AudioEffectFilter(AudioFilterSW::NOTCH) {} }; class AudioEffectBandLimitFilter : public AudioEffectFilter { - GDCLASS(AudioEffectBandLimitFilter, AudioEffectFilter) + GDCLASS(AudioEffectBandLimitFilter, AudioEffectFilter); + public: AudioEffectBandLimitFilter() : AudioEffectFilter(AudioFilterSW::BANDLIMIT) {} }; class AudioEffectLowShelfFilter : public AudioEffectFilter { - GDCLASS(AudioEffectLowShelfFilter, AudioEffectFilter) + GDCLASS(AudioEffectLowShelfFilter, AudioEffectFilter); + public: AudioEffectLowShelfFilter() : AudioEffectFilter(AudioFilterSW::LOWSHELF) {} }; class AudioEffectHighShelfFilter : public AudioEffectFilter { - GDCLASS(AudioEffectHighShelfFilter, AudioEffectFilter) + GDCLASS(AudioEffectHighShelfFilter, AudioEffectFilter); + public: AudioEffectHighShelfFilter() : AudioEffectFilter(AudioFilterSW::HIGHSHELF) {} diff --git a/servers/audio/effects/audio_effect_limiter.h b/servers/audio/effects/audio_effect_limiter.h index d629166f42..bf7167e3f4 100644 --- a/servers/audio/effects/audio_effect_limiter.h +++ b/servers/audio/effects/audio_effect_limiter.h @@ -36,7 +36,7 @@ class AudioEffectLimiter; class AudioEffectLimiterInstance : public AudioEffectInstance { - GDCLASS(AudioEffectLimiterInstance, AudioEffectInstance) + GDCLASS(AudioEffectLimiterInstance, AudioEffectInstance); friend class AudioEffectLimiter; Ref<AudioEffectLimiter> base; @@ -47,7 +47,7 @@ public: }; class AudioEffectLimiter : public AudioEffect { - GDCLASS(AudioEffectLimiter, AudioEffect) + GDCLASS(AudioEffectLimiter, AudioEffect); friend class AudioEffectLimiterInstance; float threshold; diff --git a/servers/audio/effects/audio_effect_panner.h b/servers/audio/effects/audio_effect_panner.h index 4256d05a2f..7bd5a09fc6 100644 --- a/servers/audio/effects/audio_effect_panner.h +++ b/servers/audio/effects/audio_effect_panner.h @@ -36,7 +36,7 @@ class AudioEffectPanner; class AudioEffectPannerInstance : public AudioEffectInstance { - GDCLASS(AudioEffectPannerInstance, AudioEffectInstance) + GDCLASS(AudioEffectPannerInstance, AudioEffectInstance); friend class AudioEffectPanner; Ref<AudioEffectPanner> base; @@ -45,7 +45,7 @@ public: }; class AudioEffectPanner : public AudioEffect { - GDCLASS(AudioEffectPanner, AudioEffect) + GDCLASS(AudioEffectPanner, AudioEffect); friend class AudioEffectPannerInstance; float pan; diff --git a/servers/audio/effects/audio_effect_phaser.h b/servers/audio/effects/audio_effect_phaser.h index 264e792be5..b76d6bb29c 100644 --- a/servers/audio/effects/audio_effect_phaser.h +++ b/servers/audio/effects/audio_effect_phaser.h @@ -36,7 +36,7 @@ class AudioEffectPhaser; class AudioEffectPhaserInstance : public AudioEffectInstance { - GDCLASS(AudioEffectPhaserInstance, AudioEffectInstance) + GDCLASS(AudioEffectPhaserInstance, AudioEffectInstance); friend class AudioEffectPhaser; Ref<AudioEffectPhaser> base; @@ -70,7 +70,7 @@ public: }; class AudioEffectPhaser : public AudioEffect { - GDCLASS(AudioEffectPhaser, AudioEffect) + GDCLASS(AudioEffectPhaser, AudioEffect); friend class AudioEffectPhaserInstance; float range_min; diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp index ca2a88f858..c250f2e2bd 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.cpp +++ b/servers/audio/effects/audio_effect_pitch_shift.cpp @@ -293,14 +293,16 @@ void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames, Audi float *out_l = (float *)p_dst_frames; float *out_r = out_l + 1; - shift_l.PitchShift(base->pitch_scale, p_frame_count, 2048, 4, sample_rate, in_l, out_l, 2); - shift_r.PitchShift(base->pitch_scale, p_frame_count, 2048, 4, sample_rate, in_r, out_r, 2); + shift_l.PitchShift(base->pitch_scale, p_frame_count, fft_size, base->oversampling, sample_rate, in_l, out_l, 2); + shift_r.PitchShift(base->pitch_scale, p_frame_count, fft_size, base->oversampling, sample_rate, in_r, out_r, 2); } Ref<AudioEffectInstance> AudioEffectPitchShift::instance() { Ref<AudioEffectPitchShiftInstance> ins; ins.instance(); ins->base = Ref<AudioEffectPitchShift>(this); + static const int fft_sizes[FFT_SIZE_MAX] = { 256, 512, 1024, 2048, 4096 }; + ins->fft_size = fft_sizes[fft_size]; return ins; } @@ -315,14 +317,50 @@ float AudioEffectPitchShift::get_pitch_scale() const { return pitch_scale; } +void AudioEffectPitchShift::set_oversampling(int p_oversampling) { + ERR_FAIL_COND(p_oversampling < 4); + oversampling = p_oversampling; +} + +int AudioEffectPitchShift::get_oversampling() const { + + return oversampling; +} + +void AudioEffectPitchShift::set_fft_size(FFT_Size p_fft_size) { + ERR_FAIL_INDEX(p_fft_size, FFT_SIZE_MAX); + fft_size = p_fft_size; +} + +AudioEffectPitchShift::FFT_Size AudioEffectPitchShift::get_fft_size() const { + return fft_size; +} + void AudioEffectPitchShift::_bind_methods() { ClassDB::bind_method(D_METHOD("set_pitch_scale", "rate"), &AudioEffectPitchShift::set_pitch_scale); ClassDB::bind_method(D_METHOD("get_pitch_scale"), &AudioEffectPitchShift::get_pitch_scale); + ClassDB::bind_method(D_METHOD("set_oversampling", "amount"), &AudioEffectPitchShift::set_oversampling); + ClassDB::bind_method(D_METHOD("get_oversampling"), &AudioEffectPitchShift::get_oversampling); + + ClassDB::bind_method(D_METHOD("set_fft_size", "size"), &AudioEffectPitchShift::set_fft_size); + ClassDB::bind_method(D_METHOD("get_fft_size"), &AudioEffectPitchShift::get_fft_size); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "pitch_scale", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_pitch_scale", "get_pitch_scale"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "oversampling", PROPERTY_HINT_RANGE, "4,32,1"), "set_oversampling", "get_oversampling"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "fft_size", PROPERTY_HINT_ENUM, "256,512,1024,2048,4096"), "set_fft_size", "get_fft_size"); + + BIND_ENUM_CONSTANT(FFT_SIZE_256); + BIND_ENUM_CONSTANT(FFT_SIZE_512); + BIND_ENUM_CONSTANT(FFT_SIZE_1024); + BIND_ENUM_CONSTANT(FFT_SIZE_2048); + BIND_ENUM_CONSTANT(FFT_SIZE_4096); + BIND_ENUM_CONSTANT(FFT_SIZE_MAX); } AudioEffectPitchShift::AudioEffectPitchShift() { pitch_scale = 1.0; + oversampling = 4; + fft_size = FFT_SIZE_2048; } diff --git a/servers/audio/effects/audio_effect_pitch_shift.h b/servers/audio/effects/audio_effect_pitch_shift.h index febc20e9d5..2028496ebf 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.h +++ b/servers/audio/effects/audio_effect_pitch_shift.h @@ -72,10 +72,11 @@ public: class AudioEffectPitchShift; class AudioEffectPitchShiftInstance : public AudioEffectInstance { - GDCLASS(AudioEffectPitchShiftInstance, AudioEffectInstance) + GDCLASS(AudioEffectPitchShiftInstance, AudioEffectInstance); friend class AudioEffectPitchShift; Ref<AudioEffectPitchShift> base; + int fft_size; SMBPitchShift shift_l; SMBPitchShift shift_r; @@ -84,12 +85,23 @@ public: }; class AudioEffectPitchShift : public AudioEffect { - GDCLASS(AudioEffectPitchShift, AudioEffect) + GDCLASS(AudioEffectPitchShift, AudioEffect); +public: friend class AudioEffectPitchShiftInstance; + enum FFT_Size { + FFT_SIZE_256, + FFT_SIZE_512, + FFT_SIZE_1024, + FFT_SIZE_2048, + FFT_SIZE_4096, + FFT_SIZE_MAX + }; + float pitch_scale; - int window_size; + int oversampling; + FFT_Size fft_size; float wet; float dry; bool filter; @@ -103,7 +115,15 @@ public: void set_pitch_scale(float p_pitch_scale); float get_pitch_scale() const; + void set_oversampling(int p_oversampling); + int get_oversampling() const; + + void set_fft_size(FFT_Size); + FFT_Size get_fft_size() const; + AudioEffectPitchShift(); }; +VARIANT_ENUM_CAST(AudioEffectPitchShift::FFT_Size); + #endif // AUDIO_EFFECT_PITCH_SHIFT_H diff --git a/servers/audio/effects/audio_effect_record.h b/servers/audio/effects/audio_effect_record.h index 528c7dbd7c..d9bf39eb5f 100644 --- a/servers/audio/effects/audio_effect_record.h +++ b/servers/audio/effects/audio_effect_record.h @@ -43,7 +43,7 @@ class AudioEffectRecord; class AudioEffectRecordInstance : public AudioEffectInstance { - GDCLASS(AudioEffectRecordInstance, AudioEffectInstance) + GDCLASS(AudioEffectRecordInstance, AudioEffectInstance); friend class AudioEffectRecord; Ref<AudioEffectRecord> base; @@ -77,7 +77,7 @@ public: }; class AudioEffectRecord : public AudioEffect { - GDCLASS(AudioEffectRecord, AudioEffect) + GDCLASS(AudioEffectRecord, AudioEffect); friend class AudioEffectRecordInstance; diff --git a/servers/audio/effects/audio_effect_reverb.h b/servers/audio/effects/audio_effect_reverb.h index ed76050f24..31a796bf98 100644 --- a/servers/audio/effects/audio_effect_reverb.h +++ b/servers/audio/effects/audio_effect_reverb.h @@ -37,7 +37,7 @@ class AudioEffectReverb; class AudioEffectReverbInstance : public AudioEffectInstance { - GDCLASS(AudioEffectReverbInstance, AudioEffectInstance) + GDCLASS(AudioEffectReverbInstance, AudioEffectInstance); Ref<AudioEffectReverb> base; @@ -54,7 +54,7 @@ public: }; class AudioEffectReverb : public AudioEffect { - GDCLASS(AudioEffectReverb, AudioEffect) + GDCLASS(AudioEffectReverb, AudioEffect); friend class AudioEffectReverbInstance; diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp index f5ac0afefa..305f9046c3 100644 --- a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp +++ b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp @@ -111,9 +111,10 @@ void AudioEffectSpectrumAnalyzerInstance::process(const AudioFrame *p_src_frames float *fftw = temporal_fft.ptrw(); for (int i = 0; i < to_fill; i++) { //left and right buffers - fftw[(i + temporal_fft_pos) * 2] = p_src_frames[i].l; + float window = -0.5 * Math::cos(2.0 * Math_PI * (double)i / (double)to_fill) + 0.5; + fftw[(i + temporal_fft_pos) * 2] = window * p_src_frames[i].l; fftw[(i + temporal_fft_pos) * 2 + 1] = 0; - fftw[(i + temporal_fft_pos + fft_size * 2) * 2] = p_src_frames[i].r; + fftw[(i + temporal_fft_pos + fft_size * 2) * 2] = window * p_src_frames[i].r; fftw[(i + temporal_fft_pos + fft_size * 2) * 2 + 1] = 0; } diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.h b/servers/audio/effects/audio_effect_spectrum_analyzer.h index 4f4c3c8a58..27eb88d29f 100644 --- a/servers/audio/effects/audio_effect_spectrum_analyzer.h +++ b/servers/audio/effects/audio_effect_spectrum_analyzer.h @@ -36,7 +36,7 @@ class AudioEffectSpectrumAnalyzer; class AudioEffectSpectrumAnalyzerInstance : public AudioEffectInstance { - GDCLASS(AudioEffectSpectrumAnalyzerInstance, AudioEffectInstance) + GDCLASS(AudioEffectSpectrumAnalyzerInstance, AudioEffectInstance); public: enum MagnitudeMode { @@ -68,7 +68,8 @@ public: VARIANT_ENUM_CAST(AudioEffectSpectrumAnalyzerInstance::MagnitudeMode) class AudioEffectSpectrumAnalyzer : public AudioEffect { - GDCLASS(AudioEffectSpectrumAnalyzer, AudioEffect) + GDCLASS(AudioEffectSpectrumAnalyzer, AudioEffect); + public: enum FFT_Size { FFT_SIZE_256, diff --git a/servers/audio/effects/audio_effect_stereo_enhance.h b/servers/audio/effects/audio_effect_stereo_enhance.h index 787c351a03..44b7d3eb5c 100644 --- a/servers/audio/effects/audio_effect_stereo_enhance.h +++ b/servers/audio/effects/audio_effect_stereo_enhance.h @@ -36,7 +36,7 @@ class AudioEffectStereoEnhance; class AudioEffectStereoEnhanceInstance : public AudioEffectInstance { - GDCLASS(AudioEffectStereoEnhanceInstance, AudioEffectInstance) + GDCLASS(AudioEffectStereoEnhanceInstance, AudioEffectInstance); friend class AudioEffectStereoEnhance; Ref<AudioEffectStereoEnhance> base; @@ -56,7 +56,7 @@ public: }; class AudioEffectStereoEnhance : public AudioEffect { - GDCLASS(AudioEffectStereoEnhance, AudioEffect) + GDCLASS(AudioEffectStereoEnhance, AudioEffect); friend class AudioEffectStereoEnhanceInstance; float volume_db; diff --git a/servers/audio/effects/audio_stream_generator.h b/servers/audio/effects/audio_stream_generator.h index c3490ddaa5..33839d3db8 100644 --- a/servers/audio/effects/audio_stream_generator.h +++ b/servers/audio/effects/audio_stream_generator.h @@ -35,7 +35,7 @@ #include "servers/audio/audio_stream.h" class AudioStreamGenerator : public AudioStream { - GDCLASS(AudioStreamGenerator, AudioStream) + GDCLASS(AudioStreamGenerator, AudioStream); float mix_rate; float buffer_len; @@ -59,7 +59,7 @@ public: class AudioStreamGeneratorPlayback : public AudioStreamPlaybackResampled { - GDCLASS(AudioStreamGeneratorPlayback, AudioStreamPlaybackResampled) + GDCLASS(AudioStreamGeneratorPlayback, AudioStreamPlaybackResampled); friend class AudioStreamGenerator; RingBuffer<AudioFrame> buffer; int skips; diff --git a/servers/audio_server.h b/servers/audio_server.h index 8c0ffd5a6b..942fe7bc87 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -147,7 +147,8 @@ class AudioBusLayout; class AudioServer : public Object { - GDCLASS(AudioServer, Object) + GDCLASS(AudioServer, Object); + public: //re-expose this here, as AudioDriver is not exposed to script enum SpeakerMode { @@ -390,7 +391,7 @@ VARIANT_ENUM_CAST(AudioServer::SpeakerMode) class AudioBusLayout : public Resource { - GDCLASS(AudioBusLayout, Resource) + GDCLASS(AudioBusLayout, Resource); friend class AudioServer; diff --git a/servers/camera/camera_feed.cpp b/servers/camera/camera_feed.cpp index 31b8b2874f..094c83cd7c 100644 --- a/servers/camera/camera_feed.cpp +++ b/servers/camera/camera_feed.cpp @@ -60,8 +60,8 @@ void CameraFeed::_bind_methods() { BIND_ENUM_CONSTANT(FEED_NOIMAGE); BIND_ENUM_CONSTANT(FEED_RGB); - BIND_ENUM_CONSTANT(FEED_YCbCr); - BIND_ENUM_CONSTANT(FEED_YCbCr_Sep); + BIND_ENUM_CONSTANT(FEED_YCBCR); + BIND_ENUM_CONSTANT(FEED_YCBCR_SEP); BIND_ENUM_CONSTANT(FEED_UNSPECIFIED); BIND_ENUM_CONSTANT(FEED_FRONT); @@ -145,7 +145,7 @@ CameraFeed::CameraFeed() { // create a texture object VisualServer *vs = VisualServer::get_singleton(); texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA - texture[CameraServer::FEED_CbCr_IMAGE] = vs->texture_create(); + texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create(); } CameraFeed::CameraFeed(String p_name, FeedPosition p_position) { @@ -162,14 +162,14 @@ CameraFeed::CameraFeed(String p_name, FeedPosition p_position) { // create a texture object VisualServer *vs = VisualServer::get_singleton(); texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA - texture[CameraServer::FEED_CbCr_IMAGE] = vs->texture_create(); + texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create(); } CameraFeed::~CameraFeed() { // Free our textures VisualServer *vs = VisualServer::get_singleton(); vs->free(texture[CameraServer::FEED_Y_IMAGE]); - vs->free(texture[CameraServer::FEED_CbCr_IMAGE]); + vs->free(texture[CameraServer::FEED_CBCR_IMAGE]); } void CameraFeed::set_RGB_img(Ref<Image> p_rgb_img) { @@ -208,7 +208,7 @@ void CameraFeed::set_YCbCr_img(Ref<Image> p_ycbcr_img) { } vs->texture_set_data(texture[CameraServer::FEED_RGBA_IMAGE], p_ycbcr_img); - datatype = CameraFeed::FEED_YCbCr; + datatype = CameraFeed::FEED_YCBCR; } } @@ -233,12 +233,12 @@ void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) { vs->texture_allocate(texture[CameraServer::FEED_Y_IMAGE], new_y_width, new_y_height, 0, Image::FORMAT_R8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING); ///@TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion - vs->texture_allocate(texture[CameraServer::FEED_CbCr_IMAGE], new_cbcr_width, new_cbcr_height, 0, Image::FORMAT_RG8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING); + vs->texture_allocate(texture[CameraServer::FEED_CBCR_IMAGE], new_cbcr_width, new_cbcr_height, 0, Image::FORMAT_RG8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING); } vs->texture_set_data(texture[CameraServer::FEED_Y_IMAGE], p_y_img); - vs->texture_set_data(texture[CameraServer::FEED_CbCr_IMAGE], p_cbcr_img); - datatype = CameraFeed::FEED_YCbCr_Sep; + vs->texture_set_data(texture[CameraServer::FEED_CBCR_IMAGE], p_cbcr_img); + datatype = CameraFeed::FEED_YCBCR_SEP; } } diff --git a/servers/camera/camera_feed.h b/servers/camera/camera_feed.h index 90c076071c..0c53ff9309 100644 --- a/servers/camera/camera_feed.h +++ b/servers/camera/camera_feed.h @@ -50,8 +50,8 @@ public: enum FeedDataType { FEED_NOIMAGE, // we don't have an image yet FEED_RGB, // our texture will contain a normal RGB texture that can be used directly - FEED_YCbCr, // our texture will contain a YCbCr texture that needs to be converted to RGB before output - FEED_YCbCr_Sep // our camera is split into two textures, first plane contains Y data, second plane contains CbCr data + FEED_YCBCR, // our texture will contain a YCbCr texture that needs to be converted to RGB before output + FEED_YCBCR_SEP // our camera is split into two textures, first plane contains Y data, second plane contains CbCr data }; enum FeedPosition { diff --git a/servers/camera_server.cpp b/servers/camera_server.cpp index 8d2ae37001..0f93221072 100644 --- a/servers/camera_server.cpp +++ b/servers/camera_server.cpp @@ -47,9 +47,9 @@ void CameraServer::_bind_methods() { ADD_SIGNAL(MethodInfo("camera_feed_removed", PropertyInfo(Variant::INT, "id"))); BIND_ENUM_CONSTANT(FEED_RGBA_IMAGE); - BIND_ENUM_CONSTANT(FEED_YCbCr_IMAGE); + BIND_ENUM_CONSTANT(FEED_YCBCR_IMAGE); BIND_ENUM_CONSTANT(FEED_Y_IMAGE); - BIND_ENUM_CONSTANT(FEED_CbCr_IMAGE); + BIND_ENUM_CONSTANT(FEED_CBCR_IMAGE); }; CameraServer *CameraServer::singleton = NULL; diff --git a/servers/camera_server.h b/servers/camera_server.h index d204142c7d..5a62af3d60 100644 --- a/servers/camera_server.h +++ b/servers/camera_server.h @@ -53,9 +53,9 @@ class CameraServer : public Object { public: enum FeedImage { FEED_RGBA_IMAGE = 0, - FEED_YCbCr_IMAGE = 0, + FEED_YCBCR_IMAGE = 0, FEED_Y_IMAGE = 0, - FEED_CbCr_IMAGE = 1, + FEED_CBCR_IMAGE = 1, FEED_IMAGES = 2 }; diff --git a/servers/physics/area_sw.cpp b/servers/physics/area_sw.cpp index 9d68869bc2..ad3e40916d 100644 --- a/servers/physics/area_sw.cpp +++ b/servers/physics/area_sw.cpp @@ -250,7 +250,7 @@ AreaSW::AreaSW() : gravity_is_point = false; gravity_distance_scale = 0; point_attenuation = 1; - angular_damp = 1.0; + angular_damp = 0.1; linear_damp = 0.1; priority = 0; set_ray_pickable(false); diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index b4c3670a7b..172a2a3429 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -346,8 +346,7 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_varian //biased_angular_velocity=Vector3(); set_active(false); } else { - if (mode != PhysicsServer::BODY_MODE_STATIC) - set_active(true); + set_active(true); } } break; case PhysicsServer::BODY_STATE_CAN_SLEEP: { diff --git a/servers/physics/gjk_epa.cpp b/servers/physics/gjk_epa.cpp index ae512183fd..1d5ca42838 100644 --- a/servers/physics/gjk_epa.cpp +++ b/servers/physics/gjk_epa.cpp @@ -722,7 +722,10 @@ struct GJK append(m_stock,face); return(0); } - m_status=m_stock.root?eStatus::OutOfVertices:eStatus::OutOfFaces; + // -- GODOT start -- + //m_status=m_stock.root?eStatus::OutOfVertices:eStatus::OutOfFaces; + m_status=eStatus::OutOfFaces; + // -- GODOT end -- return(0); } sFace* findbest() diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index bc6010117c..75910ff1c0 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -137,6 +137,8 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4); shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2); shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3); shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT"] = constt(ShaderLanguage::TYPE_VEC3); shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC3); |