Not sure if this is simple but I'm stumped.
How do I delete a sample that's crated by the Mic using micinput?
Not sure if this is simple but I'm stumped.
How do I delete a sample that's crated by the Mic using micinput?
I'm guessing you're using the Lua function playdate.sound.micinput.recordToSample(sample, finishCallback)? In that case, the sample and its data will be freed when the garbage collector can reclaim it--that is, once there are no more references to it. So simply doing sample = nil will do the trick if you haven't assigned the sample to any other variables.
I should have been more clear. Heres my code:
function playdate.update()
gfx.setColor(gfx.kColorWhite)
gfx.clear()
if playdate.buttonJustPressed('A') then
if recording == false then
playdate.sound.micinput.startListening()
playdate.sound.micinput.recordToSample( buffer, function ( sample )
sample:save( 'playerSample'.. currentClip )
end)
recording = true
elseif recording then playdate.sound.micinput.stopListening() recording = false print ('stopped') end
end
if playdate.buttonJustPressed('b') then
table.insert(clips, math.max(table.unpack(clips))+1)
end
end
sample:save() seems to save to PlaydateSDK\Disk\Data\sound on my computer. Not sure where it saves on the playdate.
But can I delete it on the playdate?
playdate.datastore.delete([filename])
Thanks Matt,
It's working. Used
playdate.file.delete(path, [recursive])
Excellent! Thanks for reporting back