Skip to content

Commit

Permalink
feat: make filters stereo & add channel arg to volume effect
Browse files Browse the repository at this point in the history
  • Loading branch information
vadzz-dev committed Nov 26, 2023
1 parent a468854 commit ef57f11
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/IAudioFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class IAudioFilter {
virtual ~IAudioFilter() = default;

[[nodiscard]] virtual uint32_t ApplyRotateEffect(float fRate, int priority) const = 0;
[[nodiscard]] virtual uint32_t ApplyVolumeEffect(float fVolume, int priority) const = 0;
[[nodiscard]] virtual uint32_t ApplyVolumeEffect(float fVolume, int priority, int channel) const = 0;
[[nodiscard]] virtual uint32_t ApplyPeakeqEffect(int lBand, float fBandwidth, float fQ, float fCenter, float fGain, int priority) const = 0;
[[nodiscard]] virtual uint32_t ApplyDampEffect(float fTarget, float fQuiet, float fRate, float fGain, float fDelay, int priority) const = 0;
[[nodiscard]] virtual uint32_t ApplyAutowahEffect(float fDryMix, float fWetMix, float fFeedback, float fRate, float fRange, float fFreq, int priority) const = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/alt-voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ AltVoiceError AV_CreateOpusEncoder(IOpusEncoder** opusEncoder, int bitRate);
AltVoiceError AV_CreateOpusDecoder(IOpusDecoder** opusDecoder);
void AV_DestroyOpusEncoder(const IOpusEncoder* opusEncoder);
void AV_DestroyOpusDecoder(const IOpusDecoder* opusDecoder);
AltVoiceError AV_CreateAudioFilter(IAudioFilter** audioFilter);
AltVoiceError AV_CreateAudioFilter(IAudioFilter** audioFilter, int channels);
void AV_DestroyAudioFilter(const IAudioFilter* audioFilter);
2 changes: 1 addition & 1 deletion localpkg/packages/l/libopus/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package("libopus")
"https://gitlab.xiph.org/xiph/opus.git")

add_versions("1.3.1", "65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d")
add_patches("1.3.1", path.join(os.scriptdir(), "patches", "1.3.1", "cmake.patch"), "603c746006d3f1f44700bc55fd46c2b466c5002b3612055af0216463a115c42f")
add_patches("1.3.1", path.join(os.scriptdir(), "patches", "1.3.1", "cmake.patch"), "c928fecab1eead857216c8eb459d62209eb16d205f62d562da72a4ccc0b5e804")
add_configs("avxSupported", { description = "AVX_SUPPORTED", default = true, type = "boolean" })
add_configs("opusx86MayHaveAvx", { description = "OPUS_X86_MAY_HAVE_AVX", default = true, type = "boolean" })

Expand Down
4 changes: 2 additions & 2 deletions src/CAudioFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ uint32_t CAudioFilter::ApplyRotateEffect(float fRate, int priority) const
return effectHandle;
}

uint32_t CAudioFilter::ApplyVolumeEffect(float fVolume, int priority) const
uint32_t CAudioFilter::ApplyVolumeEffect(float fVolume, int priority, int channel) const
{
BASS_BFX_VOLUME effectData;
effectData.fVolume = fVolume;
effectData.lChannel = BASS_BFX_CHANALL;
effectData.lChannel = channel;

const HFX effectHandle = BASS_ChannelSetFX(Stream, BASS_FX_BFX_VOLUME, priority);
BASS_FXSetParameters(effectHandle, &effectData);
Expand Down
2 changes: 1 addition & 1 deletion src/CAudioFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CAudioFilter: public IAudioFilter
~CAudioFilter() override;

[[nodiscard]] uint32_t ApplyRotateEffect(float fRate, int priority) const override;
[[nodiscard]] uint32_t ApplyVolumeEffect(float fVolume, int priority) const override;
[[nodiscard]] uint32_t ApplyVolumeEffect(float fVolume, int priority, int channel) const override;
[[nodiscard]] uint32_t ApplyPeakeqEffect(int lBand, float fBandwidth, float fQ, float fCenter, float fGain, int priority) const override;
[[nodiscard]] uint32_t ApplyDampEffect(float fTarget, float fQuiet, float fRate, float fGain, float fDelay, int priority) const override;
[[nodiscard]] uint32_t ApplyAutowahEffect(float fDryMix, float fWetMix, float fFeedback, float fRate, float fRange, float fFreq, int priority) const override;
Expand Down
4 changes: 2 additions & 2 deletions src/alt-voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ AltVoiceError AV_CreateOpusDecoder(IOpusDecoder** opusDecoder)
}
}

AltVoiceError AV_CreateAudioFilter(IAudioFilter** audioFilter)
AltVoiceError AV_CreateAudioFilter(IAudioFilter** audioFilter, int channels)
{
try
{
IAudioFilter* filter = new CAudioFilter(SAMPLE_RATE, AUDIO_CHANNELS, BASS_STREAM_DECODE);
IAudioFilter* filter = new CAudioFilter(SAMPLE_RATE, channels, BASS_STREAM_DECODE);
*audioFilter = filter;
return AltVoiceError::Ok;
}
Expand Down

0 comments on commit ef57f11

Please sign in to comment.