Log In  

Cart #12679 | 2015-08-15 | Code ▽ | Embed ▽ | No License

I wanted to experiment with modifying SFX data via a cart.


  • Compose and edit music
  • Copy and Paste selections within patterns and between patterns
  • Transpose selection by octaves
  • Save to cart

Known issues:

  • Modifying selections only works if the selection was made in a leftwards direction.
  • The music staff isn't actually accurate at all. It just uses one px per semitone.
  • Green play line isn't always accurate if you've changed the speed or pattern length, restarting playback fixes it.

SFX Data Layout for anyone interested:

Starting from 0x3200
Blocks of 68 bytes for each SFX pattern 64 bytes of sound data and then 4 bytes of metadata.

Each sound data chunk is made of a 16 bit value divided into
6 bits for the note, 3 bits for the instrument, 3 bits for the volume, 3 bits of the FX, 1 bit unused.


byte 65 is the speed
byte 66 is loop start
byte 67 is the loop end

P#12680 2015-08-15 10:29 ( Edited 2016-06-09 00:18)

Cool to see that you made this! I may have to pass it on to my musician friend.

P#12690 2015-08-15 14:44 ( Edited 2015-08-15 18:44)

Really nice work, this is looking great.

P#12691 2015-08-15 14:59 ( Edited 2015-08-15 18:59)

I love how this community goes from "hey that'd be cool to make" to "hey I made this thing we talked about the other day." Really slick work, and a very intuitive interface.

P#12701 2015-08-16 01:03 ( Edited 2015-08-16 05:03)

Okay, honest question here about the way speed works. I've got a boss fight where I want the music to increase in speed as he takes damage, but when you modify the speed of all tracks while the music is playing, the current measure runs for as long as the old speed. So if the delay is decreased and notes play faster, there's a silent pause for a bit until the next measure starts up. And if the delay is increased then the last few slower notes get cut off and the next measure starts early.

Is there another place in memory where the current pattern speed/delay is stored, probably calculated as the max of the four tracks speed * 32 notes? Can I access this so the current measure timing gets updated?

For now I'm checking the current note index via stat(20)==31, and only updating the track speeds on that last note so it has a very short silence or cutoff on the last note. But there has to be a better way!

P#12703 2015-08-16 02:51 ( Edited 2015-08-16 06:51)

@Shazang I know! what I really like about pico8 is how quick it is to go from an idea to a working prototype, to a useful thing.

@innomin good question! I'm not sure how that music stuff works, might need to ask zep.
good to know about stat(20) though!

P#12704 2015-08-16 03:03 ( Edited 2015-08-16 07:03)

Why yes, this game does need mouse input!

p8: http://codepad.org/OeRl6oIq

Here's the patch:

> mouse = {
>   init = function()
>     poke(0x5f2d, 1)
>   end,
>   -- return int:x, int:y, onscreen:bool
>   pos = function()
>     local x,y = stat(32)-1,stat(33)-1
>     return stat(32)-1,stat(33)-1
>   end,
>   -- return int:button [0..4]
>   -- 0 .. no button
>   -- 1 .. left
>   -- 2 .. right
>   -- 4 .. middle
>   button = function()
>     return stat(34)
>   end,
> }
<    handx,handy=0,0
>    mouse.init()
>    handx,handy=mouse.pos()
<    if btn(0) then handx-=(fast and 2 or 1) end
<    if btn(1) then handx+=(fast and 2 or 1) end
<    if btn(2) then handy-=(fast and 2 or 1) end
<    if btn(3) then handy+=(fast and 2 or 1) end
>    handx,handy = mouse.pos()
P#22476 2016-06-07 22:51 ( Edited 2016-06-08 06:18)

This music studio is wonderful (even if I'm more used to trackers), and the mouse patch is a nice addition!

P#22495 2016-06-08 03:16 ( Edited 2016-06-08 07:16)

Amazing, will definitely try using this instead of the sfx editor. I actually had a similar idea (something more akin to a MIDI sequencer) but this is way better than what I had in mind.

P#22508 2016-06-08 08:37 ( Edited 2016-06-08 12:37)

Interestingly the mouse click doesn't work in the web player on my Mac using Safari or Chrome? Though I can point with the mouse and press keys to click.

P#22537 2016-06-08 18:47 ( Edited 2016-06-08 22:47)

matt, i don't think there's any code to handle the button press in that patch, would need to add some extra logic.

P#22539 2016-06-08 20:18 ( Edited 2016-06-09 00:18)

[Please log in to post a comment]