mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-11-22 00:42:16 -05:00
Fix sound
This commit is contained in:
parent
98d8c47f59
commit
d06ce1c684
4
game.h
4
game.h
@ -101,8 +101,8 @@ static inline void SFG_setPixel(uint16_t x, uint16_t y, uint8_t colorIndex);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Play given sound effect (SFX). This function may or may not use the sound
|
Play given sound effect (SFX). This function may or may not use the sound
|
||||||
samples provided in sounds.h, and it may or may not ignore the volume
|
samples provided in sounds.h, and it may or may not ignore the (logarithmic)
|
||||||
parameter (which is 0 to 255). Depending on the platform the function can play
|
volume parameter (0 to 255). Depending on the platform the function can play
|
||||||
completely different samples or even e.g. just beeps. If the platform can't
|
completely different samples or even e.g. just beeps. If the platform can't
|
||||||
play sounds, this function implementation can simply be left empty. This
|
play sounds, this function implementation can simply be left empty. This
|
||||||
function doesn't have to implement safety measures, the back end takes cares
|
function doesn't have to implement safety measures, the back end takes cares
|
||||||
|
14
main_sdl.c
14
main_sdl.c
@ -245,6 +245,19 @@ void SFG_playSound(uint8_t soundIndex, uint8_t volume)
|
|||||||
{
|
{
|
||||||
uint16_t pos = audioPos;
|
uint16_t pos = audioPos;
|
||||||
|
|
||||||
|
uint8_t volumeShift = 15 - volume / 16;
|
||||||
|
|
||||||
|
uint16_t baseLevel = AUDIO_ZERO - (0x8000 >> volumeShift);
|
||||||
|
|
||||||
|
for (int i = 0; i < SFG_SFX_SAMPLE_COUNT; ++i)
|
||||||
|
{
|
||||||
|
audioBuff[pos] = mixSamples(audioBuff[pos],baseLevel +
|
||||||
|
((SFG_GET_SFX_SAMPLE(soundIndex,i) << 8) >> volumeShift));
|
||||||
|
|
||||||
|
pos = (pos < SFG_SFX_SAMPLE_COUNT - 1) ? (pos + 1) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
int8_t volumeShift = volume / 16 - 7; // -7 to 8
|
int8_t volumeShift = volume / 16 - 7; // -7 to 8
|
||||||
|
|
||||||
uint16_t baseLevel = AUDIO_ZERO - (0x0001 << (volumeShift + 7));
|
uint16_t baseLevel = AUDIO_ZERO - (0x0001 << (volumeShift + 7));
|
||||||
@ -258,6 +271,7 @@ void SFG_playSound(uint8_t soundIndex, uint8_t volume)
|
|||||||
|
|
||||||
pos = (pos < SFG_SFX_SAMPLE_COUNT - 1) ? (pos + 1) : 0;
|
pos = (pos < SFG_SFX_SAMPLE_COUNT - 1) ? (pos + 1) : 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
Loading…
Reference in New Issue
Block a user