Write playdate.sound.sampleplayer sound to file

I've been working on a game that can record a sound, and I want to save that sound to disk.

Is there a way to do this?

Thanks in advance!

playdate.sound.sample:save(filename) may be what you're looking for ?


It would be if I was working with a sound from disk, but I'm creating a sound from scratch using playdate.sound.micinput.recordToSample.

In what way does the your code not work as expected?

How does it differ from the below (untested code)

local secondsToRecord = 7
local buffer = playdate.sound.sample.new(secondsToRecord, playdate.sound.kFormat16bitMono)

function saveRecording(sample)

playdate.sound.micinput.recordToSample(buffer, saveRecording)
1 Like

Dang, I knew it was something stupid!

I was using sampleplayer instead of sample.