Log In  

Hello, i've playing with pico-8 for quite a long time and is great, i really like this piece of software

the issue: when i try to play two sounds at the same time using the sfx command, despite specifying different channels in the parameter, one sound cuts the other, for example:

sfx(0, 0, 0, 1) --plays only the first note from the first sfx page on channel 0
sfx(0, 1, 2, 1) --plays only the third note from the first sfx page on channel 1

the first sfx page:

(result: the sounds overlaps eachother, instead of mixing them despite being on different channels)

but if the second sound i'm trying to play comes from a different sfx page, the sounds mixes without any problem

sfx(0, 0, 0, 1) --plays only the first note from the first sfx page on channel 0
sfx(1, 1, 0, 1) --plays only the first note from the second sfx page on channel 1

the second sfx page:

(result: the two sounds are played at the same time, no overlap)

why is the channel parameter ignored in the first example? if is specified, it should play the note on the assigned channel and thus, mix the two sounds like in the second example, instead of overlaping them.

now, why i'm taking this approach? i'm trying to create a rhythm game, beatmania/djmax style, after sequencing the first two channels of a 2 minute song, is obvious that only one song with only one chart is going to be available to play.

instead, i'm trying to use the sfx pages as a keysound storage, and use tables to save the song info, and see if i can at least have 3 songs available with different charts and have a more precise bpm, since the game won't use much code/variables.

please let me know if this can be fixed or if it requires too much work, other approach i can use is with the peek/poke commands to patch the song in runtime and hijack the notes the user must press, this could work to add more charts but still would be only one song or have several songs with lots of repetitive note patterns.

Thanks in advance!

P#95083 2021-07-20 03:58 ( Edited 2021-07-21 04:38)

:: shy

Just tested this, and you're right! Playing the same sfx on multiple channels doesn't work, even if you set length and starting index to different values. It seems to stop it from playing on any other channel first. Here's a cartridge that demonstrates the bug a bit better:

Cart #multisfxbug-0 | 2021-07-20 | Code ▽ | Embed ▽ | No License

I can understand why this is happening (sometimes the same sound fires multiple times in one frame, and you don't want a huge amplitude boost when that happens, etc etc). But I think there's a good argument to be made here to play both copies, if sfx is called with a manual start index and length set.

For now, a quick workaround solution would be to use the P8SCII codes for audio ('\a'). If you read the manual for this, they can play any notes, instruments, effects, speed, length, and I think each one counts as a new sfx. Here's an example for your c1 note:

?"\asgl10i6c1",0,0 --play one note at speed 16: instrument 6, c1
P#95101 2021-07-20 20:42
:: ch32

thanks for the response, now that i see this '\a' code, it seems to be a better fit, i'm only missing playing on a specific channel, since i'm using the same "tracker" logic to assign the channel for each sound that will be played, this is to avoid unintended overlaps, maybe i will be able to virtually assign channels, but it would be better to have the sound system take care of that.

Thanks again!

P#95120 2021-07-21 04:53

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2021-09-23 08:43:40 | 0.011s | Q:18