Log In  

You know what would be handy?

sfx n [channel [offset] [end]]

where [end] is the last note to be played. I'm in a spot right now where I'm needing extra space for music, and it would be very useful if I could cram more than one sound effect into a single slot.

P#38037 2017-03-04 14:22 ( Edited 2017-05-08 17:11)

More control over music in general would be great. I wanted to do something for a game I did where I had two tracks and swap between them dynamically without missing a beat but there's no real way to do it with the current API. Or at least no way to do it in the amount of time I had for the game jam.

P#38094 2017-03-08 03:10 ( Edited 2017-03-08 08:10)

hrm.. that is a nice idea. Apart from space saving, it would also allow things like varying sound effects like explosions by playing them from random offsets.

Unfortunately I can't break the API right now (PocketCHIP PICO-8 needs to work out of the box with BBS carts), but am wish-listing things like this for a potential API-breaking update in the future.

Judging by your gifs on twitter, there aren't many tokens to spare either, but the best alternative I could suggest is to memcpy sound data into an SFX each time you want to play. Here's a demo that stuffs 8 8-note sounds into 2 SFX:

Cart #38114 | 2017-03-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

It costs 5 tokens to copy the SFX data into user memory space during _init():

-- copy the first 2 SFX to 0x4300. (Each one is 68 bytes)

And 26 tokens to play them:

function tinysfx(i)
 -- clear the sfx to play
 -- copy 8 notes from the desired sfx
 band(i,0xfc)+ -- skip spd etc

Each SFX starting at 0x3200 is 68 bytes long: 32*2 for notes and 4 bytes for SPD & LOOP. The band() is to jump over the 4 byte gaps. If you already have note data stored somewhere in the cart data as one continuous block, you could skip the initial memcpy() and do it in 14 tokens total:

function tsfx(i)
P#38115 2017-03-09 01:50 ( Edited 2017-03-09 06:56)

While we are already on that topic. I would love to be able, to directly move values into the audio-buffer.

To make techniques like that possible:

For now I'll try to poke stuff around like you showed in this example.

P#40173 2017-05-04 08:31 ( Edited 2017-05-04 12:31)

Hm.. one neat detail could be, that the code must be evaluated in audio-frequency speed. That would make some "special facility" necessary. Something like a "shader for sound". =)

P#40174 2017-05-04 08:51 ( Edited 2017-05-04 12:51)

an optional frequency offset would go a long way towards sound effect variety!
for now I'll be trying with peeks and pokes...

P#40325 2017-05-08 13:11 ( Edited 2017-05-08 17:11)

[Please log in to post a comment]