So I will have these notes spawning, and all is fine unless i hold a pitch that i sing. So if i hold the pitch, the notes literally will pause until i stop. Why is this, and how can i fix it!?
[lua]local white = display.newRect(0, 0, 480, 320)
local back = display.newImage(“newclef.png”, 0, 0)
back:scale(“1”,“1”)
_G.score = 0
hit = 0
txt = display.newText(score, 200, 10, system.DefaultFont, 25)
txt:setTextColor(“193”,“42”,“221”)
local r = media.newRecording()
r:startTuner()
r:startRecording()
notesnum = 0
first = true
local line = display.newLine(150, 66, 150, 270)
line:setColor(255, 0, 0)
display.setStatusBar( display.HiddenStatusBar )
notes = {
{note=“d”, freq=“146”, top=“293”, more=“587”, posy=“221”, rot=false, sound=“media/d.wav”},
{note=“e”, freq=“164”, top=“329”, more=“659”, posy=“200”, rot=false, sound =“media/e.wav”},
{note=“f”, freq=“174”, top=“349”, more=“698”, posy=“175”, rot=false, sound=“media/f.wav”},
{note=“g”, freq=“196”, top=“392”, more=“783”, posy=“153”, rot=false, sound=“media/g.wav”},
{note=“a”, freq=“220”, top=“440”, more=“55”, posy=“124”, rot=false, sound=“media/a.wav”},
{note=“b”, freq=“246”, top=“493”, more=“61”, posy=“230”, rot=true, sound=“media/b.wav”},
{note=“c”, freq=“261”, top=“523”, more=“65”, posy=“211”, rot=true, sound=“media/c.wav”},
{note=“d2”, freq=“293”, top=“587”, more=“146”, posy=“185”, rot=true , sound=“media/d.wav”},
{note=“e2”, freq=“329”, top=“659”, more=“164”, posy=“159”, rot=true , sound=“media/e.wav”},
{note=“f2”, freq=“349”, top=“698”, more=“174”,posy=“130”, rot=true, sound=“media/f.wav”},
{note=“g2”, freq=“392”, top=“783”, more=“196”,posy=“110”, rot=true, sound=“media/g.wav”}
}
dec = “3”
i = notes[1]
function note(index)
notesnum = notesnum + 1
local note = display.newImage(“newnote.png”)
localGroup:insert(note)
function noteDelete()
note:removeSelf()
notesnum = notesnum - 1
end
if notes[index].rot == true then
note:rotate(“180”)
end
note.x=“500”
note.y= notes[index].posy
freq1 = notes[index].freq
top1 = notes[index].top
more1 = notes[index].more
function check(event)
f = r:getTunerFrequency()
if f < freq1 + 20 and f > freq1 - 20 or f < top1 + 20 and f > top1 - 20 or f < more1 + 10 and f > more1 - 10 then
x = nil
hit = 0
noteDelete()
_G.score = _G.score + 1
txt.text = score
end
return true
end
Runtime:addEventListener(“enterFrame”, check)
local function move()
if note then
note.x = note.x - 4.5
if note.x < 140 then
timer.cancel(time1)
note:removeSelf()
timer.cancel(time)
director:changeScene(“over”, “moveFromBottom”)
end
end
end
time1 = timer.performWithDelay(20, move, -1)
return note
end
local noteTable = {}
newNote = function(e)
noteTable[#notes + 1] = note(e)
end
local function newnot()
nex = math.random(1,11)
if first == true then
local note_sound = audio.loadSound( notes[nex].sound)
audio.play(note_sound);
end
if last then
if nex == last and nex ~= 11 then
nex = nex + 1
end
end
local function resume()
timer.resume( time )
newNote(nex)
print(“resuming”)
end
if first == true then
timer.pause( time )
print(“paused”)
timer.performWithDelay(“2000”, resume)
first = false
else
newNote(nex)
end
last = nex
end
time = timer.performWithDelay(3000, newnot, -1)[/lua]
Thank you! [import]uid: 59735 topic_id: 20936 reply_id: 320936[/import]