Search code examples
iphoneipadaudiotoolboxremoteio

Issues in Use of performSelectorOnMainThread in every millisecond


I wanna show the amplitude of real time sound on a UIView by graph.

I set sound sample rate as 1000 in a second.

And, To Update Graph, I did like this. this is called in every millisecond.

[Audio performSelectorOnMainThread:@selector(updateGraph) withObject:nil waitUntilDone:NO];

and inside of updateGraph is like this.

- (void) updateGraph{
    [graphview setNeedsDisplay];
}

But it draws graph angularly.

http://achievstar.tistory.com/234 (I'm new in this site so i couldn't upload pictures)

(I guess) it is because of the "waitUntilDone:NO".

iphone 4S and also iPad2 couldn't catch up the rate of 1000.

I also tried "YES" for "waitUntilDone". It draws rightly,

http://achievstar.tistory.com/234 (see the below figure)

but also, the devices couldn't catch up with the rate of 1000,

so in this way, graphing speed was slow.

is there a way to fix the graph better?

I'm really stock here that i couldn't even find good solution any more.


Solution

  • I Just Got a Answer on my own!

    I was getting sound input in every millisecond,

    and within' it I also updated graph in every millisecond too.

    that means I updated every fixel of 480 in a millisecond.

    I thought i should update graph immediately when i get sound input,

    to show graph smoothly.

    But I was wrong. That was not necessary to update every fixel.

    Because It really takes a lot of process.

    So I changed the code to update UI not in every millisecond. and it works really well.