Importing Pulp songs and an issue with the Synth

Is there an easy way to import the songs generated in Pulp and leverage it inside a Lua codebase?

Also, I tried doing something like this, but it only plays the first and last sound. Any idea why?

    soundEngine:playNote("B4", 1, 0.125)
    soundEngine:playNote("Bb3", 1, 0.125, playdate.sound.getCurrentTime() + 0.125)

    soundEngine:playNote("Ab3", 1, 0.125, playdate.sound.getCurrentTime() + 0.375)
    soundEngine:playNote("G", 1, 0.125, playdate.sound.getCurrentTime() + 0.5)
    soundEngine:playNote("Gb3", 1, 0.125, playdate.sound.getCurrentTime() + 0.625)
    soundEngine:playNote("F2", 1, 0.125, playdate.sound.getCurrentTime() + 0.75)
3 Likes

Is there an easy way to import the songs generated in Pulp and leverage it inside a Lua codebase?

Yup, download the Audio Runtime Bundle (available in the list of assets at the bottom of the Game mode in the editor). It includes documentation on how to use.

Also, I tried doing something like this, but it only plays the first and last sound. Any idea why?

You can only have one note queued at a time. So it plays the first note immediately and then queues the second which is replaced as it queues the third, and so on right up to the last note. The SDK documentation will be updated to mention this.

Encountered this exact issue... only the first and last notes enqueued. thanks for the clarification on it! :slight_smile:

I'll make a note in the docs! For sequencing notes in time you'll want to use playdate.sound.sequence.

Isn't that only for MIDi files though? I just set up a bunch of timers with callbacks at the right time delta from when i start it (little tunes that play when events happen in the game... so it's not too unwieldily... but i do hear timing glitches sometimes, which i kinda expected from going this route...

I just have a list of notes and timestamps when they play... I'd rather not spin up a whole MIDI file for each one...

You can build a sequence in code, too!

snd = playdate.sound

t = snd.track.new()
t:setInstrument(snd.synth.new(snd.kWaveSawtooth))
t:addNote(1,"C3",4)
t:addNote(5,"E3",4)
t:addNote(9,"G3",4)
t:addNote(13,"C4",4)

s = snd.sequence.new()
s:addTrack(t)
s:play()
2 Likes

AAH! Sweet! I think i' know what I'm working on this evening. :smiley:

1 Like