Path: blob/master/servers/audio/effects/audio_effect_delay.h
10278 views
/**************************************************************************/1/* audio_effect_delay.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "servers/audio/audio_effect.h"3334class AudioEffectDelay;3536class AudioEffectDelayInstance : public AudioEffectInstance {37GDCLASS(AudioEffectDelayInstance, AudioEffectInstance);3839friend class AudioEffectDelay;40Ref<AudioEffectDelay> base;4142Vector<AudioFrame> ring_buffer;4344unsigned int ring_buffer_pos;45unsigned int ring_buffer_mask;4647/* feedback buffer */48Vector<AudioFrame> feedback_buffer;4950unsigned int feedback_buffer_pos;5152AudioFrame h;53void _process_chunk(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count);5455public:56virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) override;57};5859class AudioEffectDelay : public AudioEffect {60GDCLASS(AudioEffectDelay, AudioEffect);6162friend class AudioEffectDelayInstance;63enum {64MAX_DELAY_MS = 3000,65MAX_TAPS = 266};6768float dry = 1.0f;6970bool tap_1_active = true;71float tap_1_delay_ms = 250.0f;72float tap_1_level = -6.0f;73float tap_1_pan = 0.2f;7475bool tap_2_active = true;76float tap_2_delay_ms = 500.0f;77float tap_2_level = -12.0f;78float tap_2_pan = -0.4f;7980bool feedback_active = false;81float feedback_delay_ms = 340.0f;82float feedback_level = -6.0f;83float feedback_lowpass = 16000.0f;8485protected:86static void _bind_methods();8788public:89void set_dry(float p_dry);90float get_dry();9192void set_tap1_active(bool p_active);93bool is_tap1_active() const;9495void set_tap1_delay_ms(float p_delay_ms);96float get_tap1_delay_ms() const;9798void set_tap1_level_db(float p_level_db);99float get_tap1_level_db() const;100101void set_tap1_pan(float p_pan);102float get_tap1_pan() const;103104void set_tap2_active(bool p_active);105bool is_tap2_active() const;106107void set_tap2_delay_ms(float p_delay_ms);108float get_tap2_delay_ms() const;109110void set_tap2_level_db(float p_level_db);111float get_tap2_level_db() const;112113void set_tap2_pan(float p_pan);114float get_tap2_pan() const;115116void set_feedback_active(bool p_active);117bool is_feedback_active() const;118119void set_feedback_delay_ms(float p_delay_ms);120float get_feedback_delay_ms() const;121122void set_feedback_level_db(float p_level_db);123float get_feedback_level_db() const;124125void set_feedback_lowpass(float p_lowpass);126float get_feedback_lowpass() const;127128Ref<AudioEffectInstance> instantiate() override;129130AudioEffectDelay() {}131};132133134