SND_startPlay_4PCM_ENV docs say that if a sample is already playing on that channel, it is stopped and the new one started.
This doesn't happen. Both samples keep playing.
SND_startPlay_4PCM_ENV bug, starting a new song, both play
Moderator: Stef
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: SND_startPlay_4PCM_ENV bug, starting a new song, both play
No way to get 2 samples playing on the same channel :p
I guess you used it wrongly, can you provide the source code ?
I guess you used it wrongly, can you provide the source code ?
Re: SND_startPlay_4PCM_ENV bug, starting a new song, both play
Not complete source, but the important bits.
// Called on the title screen
SND_startPlay_4PCM_ENV(title_music, sizeof(title_music), 0, 1);
// Called in-game
SND_startPlay_4PCM_ENV(game_music, sizeof(game_music), 0, 1);
As you see, both are on channel 0 and looping. Imagine my surprise when both songs continued to play in-game.
// Called on the title screen
SND_startPlay_4PCM_ENV(title_music, sizeof(title_music), 0, 1);
// Called in-game
SND_startPlay_4PCM_ENV(game_music, sizeof(game_music), 0, 1);
As you see, both are on channel 0 and looping. Imagine my surprise when both songs continued to play in-game.
Re: SND_startPlay_4PCM_ENV bug, starting a new song, both play
And I see this is the guilty source in sound.c:
SOUND_PCM_CH_AUTO is 0, the same as channel 0.
Code: Select all
void SND_startPlay_4PCM_ENV(const u8 *sample, const u32 len, const u16 channel, const u8 loop)
...
// auto channel ?
if (channel == SOUND_PCM_CH_AUTO)
{
// scan for first free channel
ch = 0;
while ((ch < 4) && (status & (Z80_DRV_STAT_PLAYING << ch))) ch++;
// if all channel busy we use the first
if (ch == 4) ch = 0;
}
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: SND_startPlay_4PCM_ENV bug, starting a new song, both play
Outch ! that hurts ! What a stupid bug, i should have put auto to -1 of 0xFF..
Ok ^^ I will fix that quickly, thanks for reporting !
Ok ^^ I will fix that quickly, thanks for reporting !