Skip to content

Commit

Permalink
Fix indexes (TODO: Refactor indexes code)
Browse files Browse the repository at this point in the history
  • Loading branch information
garey committed Mar 13, 2023
1 parent 451fee5 commit 731456d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions scripting/voiceutils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ forward VU_OnStopSpeak(const index);
*
* @noreturn
*/
forward VU_OnDecompress(const index, const sampleRate, const samples[], n_samples);
forward VU_OnDecompress(const index, const receiver, const sampleRate, const samples[], n_samples);

native VU_IsDenoised(const index);
native VU_SetDenoise(const index, bool:active);
native VU_SetPitch(const index, Float:pitch);
// 0.0 - 1.0
native VU_SetVolume(const index, Float:volume);
native VU_SetVolume(const sender, const receiver, Float:volume);
6 changes: 3 additions & 3 deletions voice_utils/voice_utils/src/natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ void OnSoundDecompress(size_t clientIndex, size_t receiverIndex, uint16_t sample
if(receiverIndex == size_t(-1))
receiverIndex = 0;

if (g_player_volume[clientIndex][receiverIndex])
if (g_player_volume[clientIndex+1][receiverIndex])
{
size_t size = *sample_size;
int16_t* samples16 = (int16_t*)samples;
for (auto i = 0u; i < size; i++)
{
samples16[i] *= g_player_volume[clientIndex][receiverIndex];
samples16[i] *= g_player_volume[clientIndex+1][receiverIndex];

if (samples16[i] > std::numeric_limits<int16>::max()) { samples16[i] = std::numeric_limits<int16>::max(); }
if (samples16[i] < std::numeric_limits<int16>::min()) { samples16[i] = std::numeric_limits<int16>::min(); }
Expand Down Expand Up @@ -479,7 +479,7 @@ cell AMX_NATIVE_CALL SetVolume(Amx* amx, cell* params)
{
params[arg_receiver] = 0;
};
g_player_volume[params[arg_sender] - 1][params[arg_receiver]] = amx_ctof(params[arg_volume]);
g_player_volume[params[arg_sender]][params[arg_receiver]] = amx_ctof(params[arg_volume]);
return true;
}

Expand Down

0 comments on commit 731456d

Please sign in to comment.