summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/audio/audio_player.cpp50
-rw-r--r--scene/audio/audio_player.h1
-rw-r--r--scene/gui/text_edit.cpp8
-rw-r--r--scene/gui/text_edit.h1
-rw-r--r--scene/resources/audio_stream_sample.cpp32
-rw-r--r--scene/resources/environment.cpp3
6 files changed, 68 insertions, 27 deletions
diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp
index 058b162e83..08b01c6a4c 100644
--- a/scene/audio/audio_player.cpp
+++ b/scene/audio/audio_player.cpp
@@ -31,20 +31,7 @@
#include "engine.h"
-void AudioStreamPlayer::_mix_audio() {
-
- if (!stream_playback.is_valid()) {
- return;
- }
-
- if (!active) {
- return;
- }
-
- if (setseek >= 0.0) {
- stream_playback->start(setseek);
- setseek = -1.0; //reset seek
- }
+void AudioStreamPlayer::_mix_internal(bool p_fadeout) {
int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus);
@@ -52,19 +39,24 @@ void AudioStreamPlayer::_mix_audio() {
AudioFrame *buffer = mix_buffer.ptr();
int buffer_size = mix_buffer.size();
+ if (p_fadeout) {
+ buffer_size = MIN(buffer_size, 16); //short fadeout ramp
+ }
+
//mix
stream_playback->mix(buffer, 1.0, buffer_size);
//multiply volume interpolating to avoid clicks if this changes
+ float target_volume = p_fadeout ? -80.0 : volume_db;
float vol = Math::db2linear(mix_volume_db);
- float vol_inc = (Math::db2linear(volume_db) - vol) / float(buffer_size);
+ float vol_inc = (Math::db2linear(target_volume) - vol) / float(buffer_size);
for (int i = 0; i < buffer_size; i++) {
buffer[i] *= vol;
vol += vol_inc;
}
//set volume for next mix
- mix_volume_db = volume_db;
+ mix_volume_db = target_volume;
AudioFrame *targets[4] = { NULL, NULL, NULL, NULL };
@@ -95,6 +87,30 @@ void AudioStreamPlayer::_mix_audio() {
}
}
+void AudioStreamPlayer::_mix_audio() {
+
+ if (!stream_playback.is_valid()) {
+ return;
+ }
+
+ if (!active) {
+ return;
+ }
+
+ if (setseek >= 0.0) {
+ if (stream_playback->is_playing()) {
+
+ //fade out to avoid pops
+ _mix_internal(true);
+ }
+ stream_playback->start(setseek);
+ setseek = -1.0; //reset seek
+ mix_volume_db = volume_db; //reset ramp
+ }
+
+ _mix_internal(false);
+}
+
void AudioStreamPlayer::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
@@ -163,7 +179,7 @@ float AudioStreamPlayer::get_volume_db() const {
void AudioStreamPlayer::play(float p_from_pos) {
if (stream_playback.is_valid()) {
- mix_volume_db = volume_db; //reset volume ramp
+ //mix_volume_db = volume_db; do not reset volume ramp here, can cause clicks
setseek = p_from_pos;
active = true;
set_process_internal(true);
diff --git a/scene/audio/audio_player.h b/scene/audio/audio_player.h
index 4bfc44730d..6e9d623433 100644
--- a/scene/audio/audio_player.h
+++ b/scene/audio/audio_player.h
@@ -59,6 +59,7 @@ private:
MixTarget mix_target;
+ void _mix_internal(bool p_fadeout);
void _mix_audio();
static void _mix_audios(void *self) { reinterpret_cast<AudioStreamPlayer *>(self)->_mix_audio(); }
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index f4876668f6..a568b6fab0 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -3668,6 +3668,11 @@ void TextEdit::set_readonly(bool p_readonly) {
readonly = p_readonly;
}
+bool TextEdit::is_readonly() const {
+
+ return readonly;
+}
+
void TextEdit::set_wrap(bool p_wrap) {
wrap = p_wrap;
@@ -4914,6 +4919,8 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode);
ClassDB::bind_method(D_METHOD("set_readonly", "enable"), &TextEdit::set_readonly);
+ ClassDB::bind_method(D_METHOD("is_readonly"), &TextEdit::is_readonly);
+
ClassDB::bind_method(D_METHOD("set_wrap", "enable"), &TextEdit::set_wrap);
ClassDB::bind_method(D_METHOD("set_max_chars", "amount"), &TextEdit::set_max_chars);
ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &TextEdit::set_context_menu_enabled);
@@ -4964,6 +4971,7 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("menu_option", "option"), &TextEdit::menu_option);
ClassDB::bind_method(D_METHOD("get_menu"), &TextEdit::get_menu);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "readonly"), "set_readonly", "is_readonly");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_current_line"), "set_highlight_current_line", "is_highlight_current_line_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), "set_syntax_coloring", "is_syntax_coloring_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled");
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 094474b264..b90571e0ab 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -448,6 +448,7 @@ public:
bool cursor_is_block_mode() const;
void set_readonly(bool p_readonly);
+ bool is_readonly() const;
void set_max_chars(int p_max_chars);
void set_wrap(bool p_wrap);
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index fdc3b79db6..f81f460521 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -31,17 +31,23 @@
void AudioStreamPlaybackSample::start(float p_from_pos) {
- for (int i = 0; i < 2; i++) {
- ima_adpcm[i].step_index = 0;
- ima_adpcm[i].predictor = 0;
- ima_adpcm[i].loop_step_index = 0;
- ima_adpcm[i].loop_predictor = 0;
- ima_adpcm[i].last_nibble = -1;
- ima_adpcm[i].loop_pos = 0x7FFFFFFF;
- ima_adpcm[i].window_ofs = 0;
+ if (base->format == AudioStreamSample::FORMAT_IMA_ADPCM) {
+ //no seeking in IMA_ADPCM
+ for (int i = 0; i < 2; i++) {
+ ima_adpcm[i].step_index = 0;
+ ima_adpcm[i].predictor = 0;
+ ima_adpcm[i].loop_step_index = 0;
+ ima_adpcm[i].loop_predictor = 0;
+ ima_adpcm[i].last_nibble = -1;
+ ima_adpcm[i].loop_pos = 0x7FFFFFFF;
+ ima_adpcm[i].window_ofs = 0;
+ }
+
+ offset = 0;
+ } else {
+ seek(p_from_pos);
}
- seek(p_from_pos);
sign = 1;
active = true;
}
@@ -373,6 +379,14 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in
dst_buff += target;
}
+
+ if (todo) {
+ //bit was missing from mix
+ int todo_ofs = p_frames - todo;
+ for (int i = todo_ofs; i < p_frames; i++) {
+ p_buffer[i] = AudioFrame(0, 0);
+ }
+ }
}
float AudioStreamPlaybackSample::get_length() const {
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index 232f690074..fe59450f2e 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -1184,7 +1184,8 @@ Environment::Environment() {
bg_energy = 1.0;
bg_canvas_max_layer = 0;
ambient_energy = 1.0;
- ambient_sky_contribution = 1.0;
+ //ambient_sky_contribution = 1.0;
+ set_ambient_light_sky_contribution(1.0);
tone_mapper = TONE_MAPPER_LINEAR;
tonemap_exposure = 1.0;