Update audio example
This commit is contained in:
parent
59f83aec12
commit
dba6148554
1 changed files with 23 additions and 1 deletions
|
|
@ -7,13 +7,17 @@
|
|||
#include <psemek/audio/effect/volume.hpp>
|
||||
#include <psemek/audio/effect/fade_in.hpp>
|
||||
#include <psemek/audio/effect/fade_out.hpp>
|
||||
#include <psemek/audio/effect/compressor.hpp>
|
||||
#include <psemek/audio/duplicate.hpp>
|
||||
#include <psemek/audio/stereo.hpp>
|
||||
#include <psemek/audio/mixer.hpp>
|
||||
#include <psemek/app/app.hpp>
|
||||
#include <psemek/app/main.hpp>
|
||||
#include <psemek/gfx/painter.hpp>
|
||||
#include <psemek/util/clock.hpp>
|
||||
#include <psemek/util/to_string.hpp>
|
||||
#include <psemek/geom/constants.hpp>
|
||||
#include <psemek/geom/camera.hpp>
|
||||
|
||||
#include <map>
|
||||
|
||||
|
|
@ -64,7 +68,7 @@ struct audio_app
|
|||
{
|
||||
mixer_ = audio::make_mixer();
|
||||
volume_control_ = audio::volume_stereo(mixer_, 0.5f, 0.5f, 0.1f);
|
||||
engine_.output()->stream(volume_control_);
|
||||
engine_.output()->stream(audio::compressor(volume_control_, audio::from_db(-2.f), 0.95f, 0.002f, 1.f));
|
||||
}
|
||||
|
||||
void on_key_down(SDL_Keycode key) override
|
||||
|
|
@ -101,6 +105,22 @@ struct audio_app
|
|||
volume_control_->gain_right(0.5f - 0.5f * volume);
|
||||
}
|
||||
|
||||
void present() override
|
||||
{
|
||||
gl::ClearColor(0.8f, 0.8f, 1.f, 1.f);
|
||||
gl::Clear(gl::COLOR_BUFFER_BIT);
|
||||
|
||||
{
|
||||
gfx::painter::text_options opts;
|
||||
opts.x = gfx::painter::x_align::left;
|
||||
opts.y = gfx::painter::y_align::top;
|
||||
opts.scale = 2.f;
|
||||
opts.c = {0, 0, 0, 255};
|
||||
}
|
||||
|
||||
painter_.render(geom::window_camera{width(), height()}.transform());
|
||||
}
|
||||
|
||||
private:
|
||||
audio::engine engine_;
|
||||
audio::mixer_ptr mixer_;
|
||||
|
|
@ -108,6 +128,8 @@ private:
|
|||
std::map<SDL_Keycode, audio::channel_ptr> channels_;
|
||||
|
||||
util::clock<> clock_;
|
||||
|
||||
gfx::painter painter_;
|
||||
};
|
||||
|
||||
int main()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue