Written in RubyMotion. Based on the level meters in Apple's Speak Here example app.
@meter = AudioMeterView.alloc.initWithFrame frame
view.addSubview(@meter)
@meter.input = @audioRecorder
AudioMeterView
takes as input
an AVAudioRecorder
or any other object that responds to
updateMeters
and either
averagePowerForChannel(channel)
peakPowerForChannel(channel)
or
averagePower
peakPower
The latter methods are used if they exist. Otherwise the former methods are called, with a channel of 0 unless you explicitly set the AudioMeterView
's channel
attribute.
The meter begins displaying when you set the AudioMeterView
's input
to an appropriate object. When you set input
to nil
, the meter lights gradually fall to zero.