Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make audio meter level with avaudiorecorder

Tags:

iphone

I am trying to create a audio meter level while I am recording the user voice using avaudiorecorder. Can someone help me in that regard?

like image 452
pankaj Avatar asked Mar 22 '11 07:03

pankaj


1 Answers

Swift code based on Tom's answer:

 NSOperationQueue().addOperationWithBlock({[weak self] in
        repeat {
            self?.audioRecorder.updateMeters()
            self?.averagePower = self?.audioRecorder.averagePowerForChannel(0)
            self?.peakPower = self?.audioRecorder.peakPowerForChannel(0)

            self?.performSelectorOnMainThread(#selector(DictaphoneViewController.updateMeter), withObject: self, waitUntilDone: false)
            NSThread.sleepForTimeInterval(0.05)//20 FPS
        }
            while (someCondition)
        })

Do the meter UI stuff inside func updateMeter(){//UI stuff here}

like image 155
Despotovic Avatar answered Oct 20 '22 09:10

Despotovic