ios - Level Metering with AVAudioEngine -


i watched wwdc video (session 502 avaudioengine in practice) on avaudioengine , excited make app built on tech.

i haven't been able figure out how might level monitoring of microphone input, or mixer's output.

can help? clear, i'm talking monitoring current input signal (and displaying in ui), not input/output volume setting of channel/track.

i know can avaudiorecorder, not avaudionode avaudioengine requires.

try install tap on main mixer, make faster setting framelength, read samples , average, this:

self.mainmixer = [self.engine mainmixernode]; [self.mainmixer installtaponbus:0 buffersize:1024 format:[self.mainmixer outputformatforbus:0] block:^(avaudiopcmbuffer * _nonnull buffer, avaudiotime * _nonnull when) {     [buffer setframelength:1024];     uint32 innumberframes = buffer.framelength;      if(buffer.format.channelcount>0)     {         float32* samples = (float32*)buffer.floatchanneldata[0];         float32 avgvalue = 0;          vdsp_meamgv((float32*)samples, 1, &avgvalue, innumberframes);         self.averagepowerforchannel0 = (level_lowpass_trig*((avgvalue==0)?-100:20.0*log10f(avgvalue))) + ((1-level_lowpass_trig)*self.averagepowerforchannel0) ;         self.averagepowerforchannel1 = self.averagepowerforchannel0;     }      if(buffer.format.channelcount>1)     {         float32* samples = (float32*)buffer.floatchanneldata[1];         float32 avgvalue = 0;          vdsp_meamgv((float32*)samples, 1, &avgvalue, innumberframes);         self.averagepowerforchannel1 = (level_lowpass_trig*((avgvalue==0)?-100:20.0*log10f(avgvalue))) + ((1-level_lowpass_trig)*self.averagepowerforchannel1) ;     } }]; 

to peak values, use vdsp_maxmgv instead of vdsp_meamgv.


level_lowpass_trig simple filter valued between 0.0 1.0, if set 0.0 filter values , not data. if set 1.0 noise. higher value more variation in data. seems value between 0.10 0.30 applications.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -