Log In  
Follow
packbat
Follow

Mid-Atlantic USian. Fan of autobiographical games, unusual game experiences, and heavily stylized graphics. Queer, disabled, autistic.

[sfx]

This was an exercise I was doing in transcribing music from sheet music - in this case, the first Gymnopédies from Erik Satie's 3 Gymnopédies - and it actually turned out to contain a really interesting little technical challenge.

The thing about Gymnopédies 1 from a PICO-8 perspective is that there are simply too many voices in the harmony to contain in four channels. So, obviously, arpeggios.

...but also, Gymnopédies 1 is a very calm piece of music - tormented (one is instructed to play this "Lent et douloureux", or roughly "slow and painful" in English), but emotionally quiet. The plodding beat of the piece is the low bass note on the downbeat, not the middle chords between them, and launching directly at full volume into an arpeggio is far too dramatic and disruptive. So the question becomes: how do you simultaneously fade in and out an arpeggio while arpeggiating?

Which, I mean, custom SFX instruments, of course. But I actually accidentally played myself initially, because the first thing I always do looking at a piece of sheet music is ask, "how large can I make the subdivisions?", and the piece is entirely in quarter notes, so I made my subdivision a quarter note. And if each measure of 3/4 is three lines, then I can't use arpeggios in the music SFX because they overlap - I have to use arpeggios in the custom SFX instruments.

...and there are more distinct chords in the piece than I have custom SFX instrument slots. So I have to compromise. And I can't do much shaping of the notes, because I don't have any subdivisions within them. It functioned, but I was not happy.

This version makes each line an eighth note. Because each line is an eighth note, each block of two quarter notes where I want my arpeggios lands either on the border between two four-line blocks containing no other notes or in a four-line block by itself...

...and therefore I can build my arpeggios directly in PICO-8 and let custom SFX instruments handle the fade-in and fade-out. I have six custom SFX instruments and all the arps are, very nearly, the exact notes in the score.

And I can do more shaping of the other notes, because they cover twice as many lines.

There's more polish I could and probably should do of this - I have twenty-five empty SFX to work with - but I'm happy with it. It was a really good exercise.

P#102309 2021-12-10 17:14

So, using PICO-8 with a US QWERTY keyboard (Wikimedia Commons image link), there's a kind of virtual music-keyboard embedded in it when you're editing SFX, with the bottom row from Z to M being the white keys of the octave below the one selected and the top row from Q to P being the white keys of the octave and a third above, and the black keys being on the lines above their adjacent white keys. C1 = z, C#1 = s, D1 = x, and so on.

For people using PICO-8 with other keyboard layouts, in the default keybindings, is this physical arrangement the same, or are the key names the same instead? Or some other situation?

P#99495 2021-11-02 01:53

As of 0.2.3, if you want to export a music composition in the tracker at the PICO-8 command line, the length of export caps at 32768 music ticks, or about four minutes and thirty-two seconds. To export something longer requires doing it in real time, be that five, ten, or seventy minutes, which is a pain and is slow.

Other exporters - sprite sheet, web application, binary - have flags to change how the export works; would it be possible to do something similar with the music/SFX exporter? Number of patterns played (or number of repeats, for a looping SFX) would seem the most intuitive for the end user, and (unlike music ticks) would involve numbers of a reasonable size, but I'm not attached to any specific solution.

P#97300 2021-09-14 04:00

Weird tiny bug I've noticed in 0.2.2c on Windows 7: if, either when PICO-8 is booting or rebooting, I hit Ctrl+M to toggle mute before the commandline appears, the M appears at the commandline after boot.

P#94146 2021-06-27 17:04

[sfx]

In versions of PICO-8 prior to 0.2.2, and according to the manual:

SFX instruments are only retriggered when the pitch changes, or the previous note
has zero volume. This is useful for instruments that change more slowly over time.
For example: a bell that gradually fades out. To invert this behaviour, effect 3
(normally 'drop') can be used when triggering the note. All other effect values have
their usual meaning when triggering SFX instruments.

However, in version 0.2.2, these SFX also retrigger when they have exceeded their total length.

The SFX up top demonstrates this: in 0.2.1b,

  • SFX 03 plays a single 16-tick note three times, 128 ticks apart, and
  • SFX 04 plays eight 16-tick notes at equal 32-tick intervals;

but in 0.2.2c,

  • SFX 03 plays a 64-tick note, two 16-tick notes, and then two 16-tick notes, and
  • SFX 04 plays eight 16-tick notes at a syncopated rhythm, alternating 48 and 16 ticks.

This will break some pre-0.2.2 compositions.

p.s. Slight edit correction: the manual is also incorrect in the opposite direction, because custom SFX instruments do not retrigger if the previous note has zero volume but uses the same pitch and instrument.

P#93989 2021-06-24 19:58 ( Edited 2021-06-24 20:12)

This is the most minor thing ever, but the manual currently says under stat x

20..23  Note number (0..31) on channel 0..3

...but if the LEN of the SFX or LOOP endpoint of the SFX is greater than 32 and the SFX plays that long, then stat(20..23) will display numbers greater than 32 just fine.

I don't know if this is worth fixing, but something like "(normally 0..31)" would be technically accurate and still probably convey the desired information.

P#92483 2021-05-24 02:07

[sfx]

For reasons, I loaded up the IMSLP page for Bach's first cello suite yesterday and downloaded one of the scores - Shin-Itchiro Yokoyama's, I think it was - to transcribe into PICO-8.

I don't know if anyone on here has a dire need for more PICO-8 J.S. Bach beyond Gruber's arrangements of Bach's 2-Part Inventions from a couple years ago, but it was pretty rewarding to do and I like the results.

P#87805 2021-02-17 17:01

So, I wanted to do a quick experiment to see what happened if you played a note on a custom SFX instrument with reverb - would the reverb continue past the line where the note is played? would it cut off? Either would definitely be cool.

So I made a test cart:

Cart #dezapemiyi-0 | 2021-02-15 | Code ▽ | Embed ▽ | No License

...and did an export command from the command line to save a .wav of SFX 1 to open in Audacity, and PICO-8 immediately crashed.

It looks like it's an issue with SFX that contain custom SFX instruments, from my very quick testing.

P#87706 2021-02-15 23:06

As we've been messing around with doing various things in PICO-8, we've realized that there are a fair few operations involving moving blocks of bytes around in base RAM - animating sprites by switching sprites with each other on the spritesheet, storing the current draw state or random number seed during an operation so it can be restored afterwards, etc. and so on - where hardcoding memory addresses for temporary storage could lead to one operation clobbering data for another.

We don't know a lot about computer science, but it feels like the proper way to handle this is either using a peek to grab the data as a variable in Lua RAM and poke()ing it back afterwards or with a call stack somewhere in the user data RAM that functions can push data onto and pull data from. If a call stack actually is a good tool to have for this, it seems like a good function to implement as a library routine.

When we were thinking about it a while ago, we came up with:

-- stack handling in 55 tokens
-- incl. 25 tokens of overflow/
-- underflow handling

do
    local pointer=0x5e00
    -- i.e. just after user data

    function push(addr,len)
        pointer -= len
        if pointer < 0x4300 then
            stop("call stack overflow from "..addr)
        end
        memcpy(pointer,addr,len)
    end
    function pop(addr,len)
        if pointer+len > 0x5e00 then
            stop("call stack underflow to "..tostr(addr,true))
        end
        memcpy(addr,pointer,len)
        pointer += len
    end
end

...but I wanna kick it out onto the forums for people better at optimizing PICO-8 code to review and comment on.

P#84842 2020-11-29 18:49

*edit 2: 0.2.3 has a built-in way to do this with tostr

edit: see downthread for a better function

I was thinking about high scores in PICO-8 a while ago and it occurred to me that they'd make more sense as unsigned 32 bit integers than 16b.16b fixed point decimals. The easy part in that case is adding points - simply increment in units of 0x0.0001 instead of units of 1 - but if it's a high score, I'd also like to be able to display it.

Thus:

function tostr_u32(n)
    -- return n as a 32-bit uint
    -- 92 tokens, ~1/780 of a 30 FPS CPU per call
    -- " " as thousands divider

    -- calculate ones
    -- (0x.03e8 = 1000 * 0x0.0001)
    local s=tostr(shl(n%0x.03e8,16))
    if n>0 then
        n/=1000
    else
        -- if not-actually-a-sign-bit is set
        -- have to be a little tricksy

        -- splitting in half
        --  n&0x0.ffff lower
        --  lshr(n,16) upper
        -- upper half unit = 65 536
        -- so within thousands:
        local m=536*lshr(n,16)
        m+=n&0x0.ffff
        -- originally used
--      local m=536*lshr(n,16)+n&0x0.ffff
        -- but that returned wrong results
        s=tostr(shl(m%0x.03e8,16))
        -- and doing the division by
        -- 1000 in two steps:
        n=lshr(n,1)
        n/=500
    end

    while n~=0 do
        while #s%4~=3 do
            -- pad with zeros
            s="0"..s
        end
        s=tostr(shl(n%0x.03e8,16))
            .." "..s
        n/=1000
    end

    return s
end

I'm sure this could be minimized further and/or optimized further and/or made more general, but I'd be willing to use it as is so I figured I'd share.

P#82745 2020-10-09 19:53 ( Edited 2021-09-10 12:40)

Cart #packbat_taptempo-1 | 2020-08-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

This one is super basic and was originally just going to be a utility within a bigger project, but it turned out so useful by itself that I wanted to share it. I'm sure not everyone has this problem, but I've found that changing the tempo after the SFX is written usually doesn't feel right - the piece ends up being built to make sense at the tempo it was created at.

To use the tap tempo tool, you decide what kind of rhythm you want to use, pick beats to tap on, figure out how many SFX lines between each beat you're tapping on, set that number appropriately, and tap it out.

(A couple examples: if I'm tapping quarter notes that I'll later subdivide into sixteenth notes, I leave it on 4 and tap every quarter note; if I'm planning to use a tresillo rhythm, 3+3+2, I set it to eight lines, tap the first beat of each group on the [x] button, and tap the other beats on the table.)

Then, when you're done tapping, you can hit [o] (z or c on keyboard, usually) to stop, reboot PICO-8, and punch in the calculated SPD to start composing with it.

If the tempo is jumping around weirdly while you're tapping, there might be some taps counting as multiple (I think the electrical engineering term is "bouncing"); increasing the "ignore gaps under" threshold will probably help stabilize it. (2 worked fine for me with PICO-8 standalone, but I found myself turning it up to 5 when I was testing it on the web just now.)

Hope it works for folks!

Edit: Figured out that I introduced a bug right before uploading - should work better now.

P#79921 2020-07-25 15:06 ( Edited 2020-08-05 15:43)

I was testing out various PICO-8 cartridges in the new version, including my own Rain Gif cart, and I discovered that when I chose the built-in "Save Gif" option, it would report that a GIF was saved to the desktop:

...but no file would appear.

On further testing, I discovered that on manually saving an image, it throws an error:

I'm not sure why this would happen - I've already checked whitelisting PICO-8 in my virus checker and that changes nothing. (And besides, I can save files and use the audio exporter just fine.) I'm running Windows 7 (yes, I know...) and installed PICO-8 yesterday using the installer download.

P#78963 2020-07-06 01:31

[sfx]

Something I noticed today while experimenting with PICO-8 sound effects: in 0.2.0i, if a silent (volume=0) row immediately before a non-silent row with an SFX instrument has the same SFX instrument as its instrument (e.g. if the user shift-clicked the SFX instrument to set the entire SFX to that instrument), even though the UI shows no difference, the program sometimes plays the SFX differently. (It looks like the effect lasts as long as the nominal length of the SFX instrument - 32 times its SPD.)

I assume this is a bug in how SFX instruments are implemented; if it's not, it strikes me as a bug in how the information is displayed.

P#77796 2020-06-08 16:28

In previous versions of PICO-8, pressing the Backspace key would consistently delete the note on the line immediately above the cursor.

In 0.2.0i, it doesn't seem to consistently do that:

On at least one occasion not captured here, Backspace deleted the effect that had just been added, rather than any notes.

This unpredictability makes it frustrating to work, because I don't know what my inputs will do.

P#76394 2020-05-11 20:57

[sfx]

For fairly whimsical reasons, I decided to write a four-part crab canon in PICO-8. Tenor and soprano channels play the melody forwards, bass and alto channels play the melody backwards.

If anyone wants to use it for anything, feel free to ask - but given that it uses all 64 SFX slots and all four sound channels for eighty seconds of music, I don't expect it to be useful to anyone in particular. It was fun to break out some of the partwriting skills from community college music theory classes again, though.

P#76249 2020-05-09 18:07

Cart #packbat_parametric_demo-0 | 2020-03-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Pretty straightforward: uses the feature of line() that it will draw from the end of the previous line to connect the dots around a curve defined parametrically (i.e. x,y both written as functions of t). Uses whatever the current pen color set by color() is.

Tried to build in some basic politeness features - it resets the draw state when it's done, it sets the sign on deltat to make sure that it points from t0 towards t1, it chooses a default value if deltat is given as 0 or not given, and it will always draw a line that starts at t0 and ends at t1 whether or not deltat is an integer factor of (t1-t0). With all of those implemented, it works out to 82 tokens; cutting all of those out drops it to 33 tokens. Haven't given this a bulletproof QA treatment but it passed some basic checks.

Demo uses the parametric representation of the standard ellipse off Wikipedia.

P#73616 2020-03-02 17:39

I realize it's not applicable for all games, but would it be feasible to implement screen reader support for PICO-8? I don't know a lot about WAI-ARIA for web or anything about accessibility of standalone applications, so I don't know how such a thing is to be done, but we already have printh() commands sending data to the "@clip"board - adding something like "@tts" (text to speech) seems PICO-8-ish.

PICO-8 already does a lot of accessibility-positive things - the color palette includes a lot of nicely contrasting brightnesses and hues, the controls can already be remapped freely, carts can implement optional mouse and keyboard input - and setting up for speech reader integration would give programmers another way to make their carts playable by everyone.

P#73131 2020-02-15 20:29

Cart #gipuwesuno-0 | 2020-02-12 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

We were fiddling with another project and realized that, because we were using sspr() to resize images, we didn't actually know where all the pixels were - and we wanted to know, because we wanted to cast a shadow that was the colors of what was below but in shadow. And we realized that PICO-8 lets you look at the screen in the code, and then the concept of green screen popped into our head, and then we got to work.

It's not minimized and it's not optimized - if you tell it to chromakey the whole screen, it'll chew through the entire CPU budget with change (ask us how we know!) - but I think it's readable enough that people can hack on it. We haven't tested it extensively, but we made sure it respected the current clipping rectangle and restored it before it exited, because that seemed like the correct thing to do.

function chromakey(drawfunc,x,y,w,h,c)
    -- replaces pixels of c in rectangle x,y,w,h with output of drawfunc
    -- c defaults to 3
    if type(c) == "nil" then
        c = 3
    end
    -- load prior clip state
    local clip_x0=peek(0x5f20)
    local clip_y0=peek(0x5f21)
    local clip_x1=peek(0x5f22)
    local clip_y1=peek(0x5f23)

    -- squeeze chromakey rectangle into clipping region
    x = max(x,clip_x0)
    y = max(y,clip_y0)
    w = min(w,clip_x1-x)
    h = min(h,clip_y1-y)

    clip()
    for xs = x,x+w-1 do
        local ys = y
        local y0 = y
        local chroma = false
        while ys < y+h do
            if not chroma and pget(xs,ys) == c then
                -- start detecting
                chroma = true
                y0 = ys
            end
            if chroma and pget(xs,ys) ~= c then
                -- stop detecting and draw rectangle
                clip(xs,y0,1,ys-y0)
                drawfunc()
                chroma = false
                clip()
            end
            ys += 1
        end
        if chroma then
            -- c extended to bottom of column
            clip(xs,y0,1,y+h-y0)
            drawfunc()
            clip()
        end
    end

    -- reset clipping region
    clip(clip_x0,clip_y0,clip_x1-clip_x0,clip_y1-clip_y0)
end
P#73022 2020-02-12 16:36

I noticed after I updated the cart on my Screen and Draw Palettes Demo thread that the post got bumped in the forum thread list with the message "[last person to post] replied 9 hours ago", when (a) they replied two months ago and (b) I updated the cart on the original post 9 hours ago.

(Yeah, that was really really belated. I was kind of embarrassed about the initial mistake.)

I'm not sure what's going on behind the scenes to display these timestamps but something like "Packbat updated a cartridge 9 hours ago" would be more accurate.

P#72035 2020-01-17 00:19

Cart #packbat_rain_gif-7 | 2020-04-25 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
6

No big story here - I'm a big fan of the bot rain.gif and wanted to make something in PICO-8 that would produce similar images. Is configured to loop seamlessly for 8-second gifs (PICO-8's default), but the parameter should be obvious and easy to change. Rain noise is implemented in a fairly basic form (the point of the cart is generating GIFs, not a full simulation) and disabled by default.

Currently has 16 palettes, all chosen to have reasonably good contrast ratio - should be clear how to edit those as well.


Edit 2019-12-15: Replaced green palettes, tweaked drop rendering, added more drop pattern randomization, added controls:

←/→ = change palette

[x]/[o] = reroll drops

The number that displays on the left is proportional to how many raindrops there are, the number that displays on the right is the palette index.

Edit 2020-01-18: Added some basic rain sounds with modes for light, medium, and heavy rain - option is stored in cart data and can be accessed via the menu when you first load or through the pause menu. Should be moderately quiet.

(9:29 p.m. UTC-05:00: Did a small tweak to the first-load menu to indicate how to change the setting.)

Edit 2020-01-22: Added granular volume control. ↑/↓ to adjust.

Edit 2020-04-06: Added pause menu items to (a) reroll both palette and rain pattern together and (b) automatically wait the loop length and save a GIF that will loop correctly.

Edit 2020-04-25: New graphical effect - raindrops now vary in length and in contrast with sky, which produces a bit of an illusion of depth.

P#70455 2019-12-01 17:11 ( Edited 2020-04-25 18:32)

View Older Posts
Follow Lexaloffle:        
Generated 2022-01-22 23:32:31 | 0.140s | Q:49