Closed rkevin-arch closed 3 years ago
ALFilters and ALEffects both work on SE. If you mean custom filters, it's difficult to do since a custom filter only applies until the sound stops. I'd have to think of a different way to implement it.
Ok, that's fine.
Can I merge this?
THIS IS A DRAFT PR. DO NOT MERGE YET.
This PR adds audio crossfading, custom audio filters, OpenAL filters and effects. All of the following would work on BGM, BGS and ME (not SE) unless stated otherwise.
It adds the following APIs to the
Audio
module:Audio.bgm_crossfade(filename, time = 2, volume = 100, pitch = 100, pos = -1)
: acts the same way asAudio.bgm_play
, but it crossfades between the currently playing track and the new one overtime
seconds.Audio.bgm_add_filter
: Adds a custom filter to the currently playing audio. Currently only one type of filter (Rectifier
) is supported. UseAudio.bgm_clear_filter
to clear all custom filters.Audio.bgm_add_filter("Rectifier", intensity)
. The intensity is between 0 and 1 and behaves the same way as Audacity's rectifier distortion.Audio.bgm_set_al_filter
: Sets an OpenAL filter to the currently playing audio. There are 3 types, lowpass, highpass and bandpass. I'm not actually sure what this does, I can hear no difference, but OpenAL exposes it. UseAudio.bgm_clear_al_filter
to clear it.Audio.bgm_set_al_filter(0, gain, gainhf)
to create a lowpass filter.Audio.bgm_set_al_filter(1, gain, gainlf)
to create a highpass filter.Audio.bgm_set_al_filter(2, gain, gainlf, gainhf)
to create a bandpass filter.Audio.bgm_set_al_effect(effect)
: Sets an OpenAL effect to the currently running audio. For how to construct an effect object, look below. UseAudio.bgm_clear_al_effect
to clear it.The
ALEffect
ruby module has been added, and you can create different types of AL effects using it. For example, to construct a EAXReverb effect and set thedensity
attribute, do:For a list of all possible effects and their attributes, check out
binding-mri/aleffect-binding.cpp
for now. For a list of what the attributes mean, consult the OpenAL Effects Extension Guide (you can ask for a copy in the ModShot discord).There's also a list of presets for EAXReverb type effects. Check
binding-mri/aleffect-binding.cpp
for a list of them. To load a preset (such as thedizzy
preset), do the following:The following enhancements are added:
Audio.bgm_play
with thepos
parameter set, you can start playing from that location even if you are currently playing the same file.pos
to 0 will start playing from the beginning.fadeInOnOffset
parameter tobgm_play
(likeAudio.bgm_play(filename, volume = 100, pitch = 100, pos = -1, fadeInOnOffset = true
). By default, if you set the pos parameter to a nonnegative number, the audio will fade in over 1 second. Set this to false if you don't want this behavior.Other things that sneaked into this PR:
Audio.bgm_playing?
introduced in #12.This PR has a lot of non trivial changes. We should probably test this for a while and see if it causes any issues before actually merging it. Please run ModShot with the
ALSOFT_LOGLEVEL=3
environment variable and log any OpenAL errors that may occur.See also: #19.