Ocarina playdate music app toy OUT NOW!

Update this is OUT NOW!
https://lowtekgames.itch.io/ocarina-pd
Hi making another quick music app, this time an ocarina.
Iv got a collection of real ocarinas and want a digital 1 bit one in my pocket.

heres what i got so far
ocorina

can probubly only do a 4 hole coz u can only press 2 directional buttons at the same time,
if you hold it kinda at an angle so u can blow on the mic it kinda looks like ur aquardly holing an ocarina anyway whitch is quite cool.

Lbtn = 0
Dbtn = 0
Abtn = 0
Bbtn = 0

local holes = {Lbtn,Dbtn,Bbtn,Abtn}

local holesNow = (holes[1]..holes[2]..holes[3]..holes[4])

 if holesNow == (1111) then
	print("-1111")
 end
 if holesNow == (1101) then
	print("-1101")
 end
 if holesNow == (1100) then
	print("-1100")
 end
 if holesNow == (1000) then
	print("-1000")
 end
 if holesNow == (0000) then
	print("-0000")
 end

then i check if the butons being held down and change the Abtn to 1 if it is and 0 if not

this way of checking for patterns dosnt seem to work yet but il look more at it tomorrow

Another issue im facing is when i try ti import the import "CoreLibs/micinput"
i get a build error or it crashes on launch.
main.lua:6: No such file: CoreLibs/micinput
Any idea whats going on there?

Am i right in thinking i just need this from the sdk page?
playdate.sound.micinput.getLevel()
--Returns the current microphone input level, a value from 0.0 (quietest) to 1.0 (loudest).
then just check if playdate.sound.micinput.getLevel() > 0.6 to activate playing ?

3 Likes

Big thanks to "Drew-Lo" on the discord for showing me how to do mic input.
not much too it whitch is nice, dont need to import mic lib (seems like the mic being on makes the light on playdate go yellow, I assume so devs canspy on players, but not sure how it effects the battery)

--in init etc
playdate.sound.micinput.startListening()

--then in update
mic_input = playdate.sound.micinput.getLevel()
 --print(mic_input)

 if mic_input > 0.03 then
--do all button stuff in here
end

as for the actual way it works its similar to the gurdy app.
I play all the available notes on init but set the volume to 0 and do a bunch of ifelse statments to figure out whitch should be played and set the volume for that audio to 1 and the rest to 0

	if (Lbtn == 1) and (Dbtn == 1) and (Bbtn == 1) and (Abtn == 1)then
		--G1#
	F1s:setVolume(0)
	G1s:setVolume(1)
	A1s:setVolume(0)
	C1:setVolume(0)
	C1s:setVolume(0)
	D1:setVolume(0)
	D1s:setVolume(0)
	F2:setVolume(0)
	F2s:setVolume(0)
	G2:setVolume(0)
	G2s:setVolume(0)
	A2s:setVolume(0)
	elseif(Lbtn == 1) and (Dbtn == 1) and (Bbtn == 0) and (Abtn == 1)then
		--A1#
		F1s:setVolume(0)
		G1s:setVolume(0)
		A1s:setVolume(1)
		C1:setVolume(0)
		C1s:setVolume(0)
		D1:setVolume(0)
		D1s:setVolume(0)
		F2:setVolume(0)
		F2s:setVolume(0)
		G2:setVolume(0)
		G2s:setVolume(0)
		A2s:setVolume(0)
	elseif(Lbtn == 1) and (Dbtn == 1) and (Bbtn == 1) and (Abtn == 0)then
		--C

I recored a bunch of samples from my real ocorina
And here it is in action.

got a few bugs to work out and features to add before relese:
bugs:
-seems to stop working after a short time, graph looks fine on the profiler (wasnt looping the note tracks)

Features in :
-Tweek mic threshold for more noisy enviroments
-System to change skins but no skins yet

Features to add:
-Add skins(done)
-Add transpose(done)
-Add animated blow sprite when blowing

-- add top and bottom notes, some ocorinas have lower note u can get my leaning the windway
against your chin or nose on the low note so a acceleromiter and low note could be a thing
as well as the opposite to do a high note with tilt up, simulation a full 6 hole open ocarina (done)

--also mabie add a instructions and a pic of how to hold on the menu screen(done)

1 Like

Figured out the stoping working after a little bit, was thinkingt may be the length of each track and it was, stops after beingplayed for 6 seconds
F1s = playdate.sound.fileplayer.new('sounds/g1s')
F1s:setVolume(0)
F1s:play(0)
F1s:setRate(1)

the bit u need is the 0 after play to make it loop F1s:play(0) i learned this on the gurdy app and then forgot

Noticed a bug that mic dosnt come on after device gets put to sleep/ locked and unlocked again

Il just leave this here for me and others refrence in future:

function playdate.deviceDidUnlock()
print("Unlock")
playdate.sound.micinput.startListening()
end

docs just have this "playdate.deviceDidUnlock()" spent ages not know where to add it , juts needed function before it.

ocorina1menu1
added a menuImage,
I tried creating the image in init but dodont seem to work till i moved it to the will pause function
heres the code for future reference:
function playdate.gameWillPause()
local SystmMenuImageBG = gfx.image.new("images/systemMenuImage")
SystmMenuImageBGSprite = gfx.sprite.new(SystmMenuImageBG)
SystmMenuImageBGSprite:moveTo(200, 120)
--print("pause")
playdate.setMenuImage(SystmMenuImageBG,0)
end

function playdate.gameWillResume()
--print("unpause")
end

1 Like

Very cool. I would love to try it out.

out now on itch

2 Likes