简体   繁体   中英

iPhone start Audio Recording by Voice

i already have a 'start voice recording" when the volume reach a special level. But it has one downside. When it starts recording it already missed a 1/2 second or so. When speaking a sentence it would miss the first word.

Any ideas (best with example).

Lets say I start first listening and get the peakpower, average, lowpass

 [recorder updateMeters];  ALPHA = 0.05;
peakPowerForChannel = pow(10, (0.05 * [recorder peakPowerForChannel:0]));
averagePowerForChannel = pow(10, (0.05 * [recorder averagePowerForChannel:0]));
lowPassResults = ALPHA * peakPowerForChannel + (1.0 - ALPHA) * lowPassResults;  
averagePassResults = ALPHA * averagePowerForChannel + (1.0 - ALPHA) * averagePassResults;   

than i look if its loud enough to record

 if (peakPowerForChannel > 0.08f) ) -> start recording

and if its less than a value it stops

  (peakPowerForChannel < 0.01f) -> stop record, start listening again

for now I found best is listening the peakpower, rather the average. but still its not fine. I also thought about to have a kind of tempory recording all time and when the peak is high enough I could start from now-2 seconds. Something like that, but here I dont know how to realize. So any practical suggestions are welcome.

thanks chris

Like you said, continually record a short 1/2s chunk, which expands indefinitely when the power level is reached and indefinite recording starts. When recording stops, it should include the missing 1/2s opening.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM