Skip to content

Commit

Permalink
Do all audio mixing in the AudioServer
Browse files Browse the repository at this point in the history
  • Loading branch information
ellenhp committed Aug 27, 2021
1 parent 53843ba commit 3598d30
Show file tree
Hide file tree
Showing 10 changed files with 1,009 additions and 887 deletions.
326 changes: 114 additions & 212 deletions scene/2d/audio_stream_player_2d.cpp

Large diffs are not rendered by default.

26 changes: 9 additions & 17 deletions scene/2d/audio_stream_player_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,30 @@ class AudioStreamPlayer2D : public Node2D {
Viewport *viewport = nullptr; //pointer only used for reference to previous mix
};

Output outputs[MAX_OUTPUTS];
SafeNumeric<int> output_count;
SafeFlag output_ready;

//these are used by audio thread to have a reference of previous volumes (for ramping volume and avoiding clicks)
Output prev_outputs[MAX_OUTPUTS];
int prev_output_count = 0;

Ref<AudioStreamPlayback> stream_playback;
Ref<AudioStream> stream;
Vector<AudioFrame> mix_buffer;

SafeNumeric<float> setseek{ -1.0 };
SafeFlag active;
SafeNumeric<float> setplay{ -1.0 };

Vector<AudioFrame> volume_vector;

uint64_t last_mix_count = -1;

float volume_db = 0.0;
float pitch_scale = 1.0;
bool autoplay = false;
bool stream_paused = false;
bool stream_paused_fade_in = false;
bool stream_paused_fade_out = false;
StringName bus;

void _mix_audio();
static void _mix_audios(void *self) { reinterpret_cast<AudioStreamPlayer2D *>(self)->_mix_audio(); }
StringName default_bus = "Master";

void _set_playing(bool p_enable);
bool _is_active() const;

StringName _get_actual_bus();
void _update_panning();
void _bus_layout_changed();

static void _listener_changed_cb(void *self) { reinterpret_cast<AudioStreamPlayer2D *>(self)->_update_panning(); }

uint32_t area_mask = 1;

float max_distance = 2000.0;
Expand Down
Loading

0 comments on commit 3598d30

Please sign in to comment.