mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 14:12:51 +00:00
-Volume sliders, mute, solo and fx bypass are functional, closes #9021
-Fixed tree reselect, makes reselecting an audio bux FX work
This commit is contained in:
parent
b044e7d30d
commit
cbcf40bd31
@ -705,8 +705,8 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses) {
|
||||
effects->set_drag_forwarding(this);
|
||||
effects->connect("item_rmb_selected", this, "_effect_rmb");
|
||||
effects->set_allow_rmb_select(true);
|
||||
effects->set_single_select_cell_editing_only_when_already_selected(true);
|
||||
effects->set_focus_mode(FOCUS_CLICK);
|
||||
effects->set_allow_reselect(true);
|
||||
|
||||
send = memnew(OptionButton);
|
||||
send->set_clip_text(true);
|
||||
|
@ -580,7 +580,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
|
||||
tree = memnew(Tree);
|
||||
tree->set_hide_root(true);
|
||||
tree->set_select_mode(Tree::SELECT_MULTI);
|
||||
tree->set_single_select_cell_editing_only_when_already_selected(true);
|
||||
tree->set_allow_reselect(true);
|
||||
|
||||
tree->set_drag_forwarding(this);
|
||||
|
||||
|
@ -747,7 +747,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
|
||||
animations->set_hide_root(true);
|
||||
animations->connect("cell_selected", this, "_animation_select");
|
||||
animations->connect("item_edited", this, "_animation_name_edited");
|
||||
animations->set_single_select_cell_editing_only_when_already_selected(true);
|
||||
animations->set_allow_reselect(true);
|
||||
|
||||
anim_speed = memnew(SpinBox);
|
||||
vbc_animlist->add_margin_child(TTR("Speed (FPS):"), anim_speed);
|
||||
|
@ -3234,7 +3234,7 @@ VisualScriptEditor::VisualScriptEditor() {
|
||||
members->connect("button_pressed", this, "_member_button");
|
||||
members->connect("item_edited", this, "_member_edited");
|
||||
members->connect("cell_selected", this, "_member_selected", varray(), CONNECT_DEFERRED);
|
||||
members->set_single_select_cell_editing_only_when_already_selected(true);
|
||||
members->set_allow_reselect(true);
|
||||
members->set_hide_folding(true);
|
||||
members->set_drag_forwarding(this);
|
||||
|
||||
|
@ -1455,7 +1455,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
|
||||
|
||||
if (select_mode == SELECT_ROW) {
|
||||
|
||||
if (p_selected == p_current && !c.selected) {
|
||||
if (p_selected == p_current && (!c.selected || allow_reselect)) {
|
||||
c.selected = true;
|
||||
selected_item = p_selected;
|
||||
selected_col = 0;
|
||||
@ -1478,7 +1478,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
|
||||
|
||||
if (!r_in_range && &selected_cell == &c) {
|
||||
|
||||
if (!selected_cell.selected || force_select_on_already_selected) {
|
||||
if (!selected_cell.selected || allow_reselect) {
|
||||
|
||||
selected_cell.selected = true;
|
||||
|
||||
@ -1743,7 +1743,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
|
||||
|
||||
/* editing */
|
||||
|
||||
bool bring_up_editor = force_select_on_already_selected ? (c.selected && already_selected) : c.selected;
|
||||
bool bring_up_editor = allow_reselect ? (c.selected && already_selected) : c.selected;
|
||||
String editor_text = c.text;
|
||||
|
||||
switch (c.mode) {
|
||||
@ -3557,16 +3557,6 @@ int Tree::get_drop_mode_flags() const {
|
||||
return drop_mode_flags;
|
||||
}
|
||||
|
||||
void Tree::set_single_select_cell_editing_only_when_already_selected(bool p_enable) {
|
||||
|
||||
force_select_on_already_selected = p_enable;
|
||||
}
|
||||
|
||||
bool Tree::get_single_select_cell_editing_only_when_already_selected() const {
|
||||
|
||||
return force_select_on_already_selected;
|
||||
}
|
||||
|
||||
void Tree::set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable) {
|
||||
|
||||
force_edit_checkbox_only_on_checkbox = p_enable;
|
||||
@ -3587,6 +3577,15 @@ bool Tree::get_allow_rmb_select() const {
|
||||
return allow_rmb_select;
|
||||
}
|
||||
|
||||
void Tree::set_allow_reselect(bool p_allow) {
|
||||
allow_reselect = p_allow;
|
||||
}
|
||||
|
||||
bool Tree::get_allow_reselect() const {
|
||||
|
||||
return allow_reselect;
|
||||
}
|
||||
|
||||
void Tree::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_range_click_timeout"), &Tree::_range_click_timeout);
|
||||
@ -3640,8 +3639,8 @@ void Tree::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_allow_rmb_select", "allow"), &Tree::set_allow_rmb_select);
|
||||
ClassDB::bind_method(D_METHOD("get_allow_rmb_select"), &Tree::get_allow_rmb_select);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_single_select_cell_editing_only_when_already_selected", "enable"), &Tree::set_single_select_cell_editing_only_when_already_selected);
|
||||
ClassDB::bind_method(D_METHOD("get_single_select_cell_editing_only_when_already_selected"), &Tree::get_single_select_cell_editing_only_when_already_selected);
|
||||
ClassDB::bind_method(D_METHOD("set_allow_reselect", "allow"), &Tree::set_allow_reselect);
|
||||
ClassDB::bind_method(D_METHOD("get_allow_reselect"), &Tree::get_allow_reselect);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("item_selected"));
|
||||
ADD_SIGNAL(MethodInfo("cell_selected"));
|
||||
@ -3751,7 +3750,6 @@ Tree::Tree() {
|
||||
drop_mode_over = NULL;
|
||||
drop_mode_section = 0;
|
||||
single_select_defer = NULL;
|
||||
force_select_on_already_selected = false;
|
||||
|
||||
allow_rmb_select = false;
|
||||
force_edit_checkbox_only_on_checkbox = false;
|
||||
@ -3760,6 +3758,8 @@ Tree::Tree() {
|
||||
|
||||
cache.hover_item = NULL;
|
||||
cache.hover_cell = -1;
|
||||
|
||||
allow_reselect = false;
|
||||
}
|
||||
|
||||
Tree::~Tree() {
|
||||
|
@ -490,7 +490,8 @@ private:
|
||||
bool allow_rmb_select;
|
||||
bool scrolling;
|
||||
|
||||
bool force_select_on_already_selected;
|
||||
bool allow_reselect;
|
||||
|
||||
bool force_edit_checkbox_only_on_checkbox;
|
||||
|
||||
bool hide_folding;
|
||||
@ -566,15 +567,15 @@ public:
|
||||
void set_drop_mode_flags(int p_flags);
|
||||
int get_drop_mode_flags() const;
|
||||
|
||||
void set_single_select_cell_editing_only_when_already_selected(bool p_enable);
|
||||
bool get_single_select_cell_editing_only_when_already_selected() const;
|
||||
|
||||
void set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable);
|
||||
bool get_edit_checkbox_cell_only_when_checkbox_is_pressed() const;
|
||||
|
||||
void set_allow_rmb_select(bool p_allow);
|
||||
bool get_allow_rmb_select() const;
|
||||
|
||||
void set_allow_reselect(bool p_allow);
|
||||
bool get_allow_reselect() const;
|
||||
|
||||
void set_value_evaluator(ValueEvaluator *p_evaluator);
|
||||
|
||||
Tree();
|
||||
|
@ -159,6 +159,8 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
|
||||
|
||||
void AudioServer::_mix_step() {
|
||||
|
||||
bool solo_mode = false;
|
||||
|
||||
for (int i = 0; i < buses.size(); i++) {
|
||||
Bus *bus = buses[i];
|
||||
bus->index_cache = i; //might be moved around by editor, so..
|
||||
@ -166,6 +168,33 @@ void AudioServer::_mix_step() {
|
||||
|
||||
bus->channels[k].used = false;
|
||||
}
|
||||
|
||||
if (bus->solo) {
|
||||
//solo chain
|
||||
solo_mode = true;
|
||||
bus->soloed = true;
|
||||
do {
|
||||
|
||||
if (bus != buses[0]) {
|
||||
//everything has a send save for master bus
|
||||
if (!bus_map.has(bus->send)) {
|
||||
bus = buses[0]; //send to master
|
||||
} else {
|
||||
bus = bus_map[bus->send];
|
||||
if (bus->index_cache >= bus->index_cache) { //invalid, send to master
|
||||
bus = buses[0];
|
||||
}
|
||||
}
|
||||
|
||||
bus->soloed = true;
|
||||
} else {
|
||||
bus = NULL;
|
||||
}
|
||||
|
||||
} while (bus);
|
||||
} else {
|
||||
bus->soloed = false;
|
||||
}
|
||||
}
|
||||
|
||||
//make callbacks for mixing the audio
|
||||
@ -192,24 +221,26 @@ void AudioServer::_mix_step() {
|
||||
}
|
||||
|
||||
//process effects
|
||||
for (int j = 0; j < bus->effects.size(); j++) {
|
||||
if (!bus->bypass) {
|
||||
for (int j = 0; j < bus->effects.size(); j++) {
|
||||
|
||||
if (!bus->effects[j].enabled)
|
||||
continue;
|
||||
|
||||
for (int k = 0; k < bus->channels.size(); k++) {
|
||||
|
||||
if (!bus->channels[k].active)
|
||||
if (!bus->effects[j].enabled)
|
||||
continue;
|
||||
bus->channels[k].effect_instances[j]->process(bus->channels[k].buffer.ptr(), temp_buffer[k].ptr(), buffer_size);
|
||||
}
|
||||
|
||||
//swap buffers, so internal buffer always has the right data
|
||||
for (int k = 0; k < bus->channels.size(); k++) {
|
||||
for (int k = 0; k < bus->channels.size(); k++) {
|
||||
|
||||
if (!buses[i]->channels[k].active)
|
||||
continue;
|
||||
SWAP(bus->channels[k].buffer, temp_buffer[k]);
|
||||
if (!bus->channels[k].active)
|
||||
continue;
|
||||
bus->channels[k].effect_instances[j]->process(bus->channels[k].buffer.ptr(), temp_buffer[k].ptr(), buffer_size);
|
||||
}
|
||||
|
||||
//swap buffers, so internal buffer always has the right data
|
||||
for (int k = 0; k < bus->channels.size(); k++) {
|
||||
|
||||
if (!buses[i]->channels[k].active)
|
||||
continue;
|
||||
SWAP(bus->channels[k].buffer, temp_buffer[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,7 +268,24 @@ void AudioServer::_mix_step() {
|
||||
AudioFrame *buf = bus->channels[k].buffer.ptr();
|
||||
|
||||
AudioFrame peak = AudioFrame(0, 0);
|
||||
|
||||
float volume = Math::db2linear(bus->volume_db);
|
||||
|
||||
if (solo_mode) {
|
||||
if (!bus->soloed) {
|
||||
volume = 0.0;
|
||||
}
|
||||
} else {
|
||||
if (bus->mute) {
|
||||
volume = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
//apply volume and compute peak
|
||||
for (uint32_t j = 0; j < buffer_size; j++) {
|
||||
|
||||
buf[j] *= volume;
|
||||
|
||||
float l = ABS(buf[j].l);
|
||||
if (l > peak.l) {
|
||||
peak.l = l;
|
||||
|
@ -125,6 +125,8 @@ private:
|
||||
bool mute;
|
||||
bool bypass;
|
||||
|
||||
bool soloed;
|
||||
|
||||
//Each channel is a stereo pair.
|
||||
struct Channel {
|
||||
bool used;
|
||||
|
Loading…
Reference in New Issue
Block a user