Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Soundbuffer problem on iPad mini

edited September 2014 in Bugs Posts: 6

Hello,
I was coding a simple audio clock when I found a strange bug on my iPad Mini.
After calling the "sound" function a certain number of times the system plays all the samples together every subsequent call.

This simple program can reproduce the problem:
http://pastebin.com/UM7h7AJu

It plays a sample for every 'touch' event, if you swipe two fingers for few seconds the bug will be reproduced.

I also tryed to play with the "soundBufferSize" function with no success, same results.

I think there is something wrong with the audio buffer wrapper function in codea, is the "sound" function related to OpenAL library ?

Thank you in advice

Comments

  • dave1707dave1707 Mod
    Posts: 7,909

    @maurky I tried to load your code and run it, but no luck. The audiodata is causing problems, probably because it's so big. Can you recreate the problem with a smaller music version or with Codea's build in music.

  • Posts: 2,042

    If I have understand correctly, you are saying the bug is that multiple sounds play at once? This is normal.

    P.S. you are using classes wrong! You need to make an instance of a class, not just call the class. See below my changes:


    Say = class() function Say:init() self.stime=0 self.ary={} end function Say:play(id) if audiodata[id] ~= nil then print("Playing ",id) sound (soundbuffer( audiodata[id].data, FORMAT_MONO16, 22050)) end end function Say:update() if #self.ary == 0 then return end self.stime = self.stime - DeltaTime if self.stime <= 0 then local id = table.remove(self.ary, 1) if audiodata[id] ~= nil then self:play(id) self.stime = audiodata[id].len end end end function Say:talk(ary) if type(ary) == "table" then for _, data in pairs(ary) do table.insert(self.ary, data) end else table.insert(self.ary, ary) end end function setup() say1 = Say() say1:talk({'n4','n3','n2','n1','8bit_stab_1'}) end function draw() background(40, 40, 50) say1:update() end function touched () local id = math.random(4) say1:play("n"..id) end
  • The bug is: when I touch the screen (with one finger, without moving) I hear all the numbers samples playing together.

    This bug happen on iPad Mini only, i tested it on iPad 1, 2 also and it is not reproducible.

    The faster way to reproduce the bug is lauching the project on Air Code, swipe on screen for one second and press ⌘R or Ctrl+R to restart.

    Another way to reproduce is:
    1) launch program
    2) put 3 fingers on screen
    3) swipe the fingers fast for 3/5 seconds and release

    Now, if you are on iPad Mini and touch the screen you can hear all the numbers playing together with a single call (sound call)

    Any ideas?

    ps.: Thank you for code fix!

  • Posts: 2,042

    this is normal behavior (I believe) the reason it isn't happening at the beginning is your talk function plays them in order.

  • We finally got a clue.
    I've tested the program inside the xcode, and I found this error repeated:

    2014-09-05 12:10:38.441 AClock[2626:60b] OAL Error: +[ALWrapper deleteBuffers:numBuffers:]: Invalid Operation (error code 0x0000a004)
    2014-09-05 12:10:38.442 AClock[2626:60b] OAL Warning: -[OALAudioSession onAudioError:]: Received audio error notification. Resetting audio session.
    2014-09-05 12:10:38.534 AClock[2626:60b] OAL Error: -[OALAudioSession setAudioSessionActive:]: Could not deactivate audio session: Error Domain=NSOSStatusErrorDomain Code=560030580 "The operation couldn’t be completed. (OSStatus error 560030580.)"
    

    It looks like is OpenAL error, tested on my iPad mini (iPad4,4)

    Do you think i should open ticket on issue traker?

  • Posts: 2,042

    Sure, if you find an issue, put it on the tracker so Simeon can see it and fix it.

  • @wrmichael: It seems I reach your same bug on the xcode console, I've put it on the tracker, I hope it can help you too:
    https://bitbucket.org/TwoLivesLeft/core/issue/320/soundbuffer-openal-problem-on-ipad-mini

    @zoyt: Sorry for bumping old threads.

  • Posts: 2,820

    Haha. I'm not that picky. It's just that, in the moderators and my opinions, we prefer threads older than a month not to be bumped.
    Thanks!

  • @zoyt: Lol, I know, but was fun :)

Sign In or Register to comment.