views:

290

answers:

0

Hi , i found this tutorial , and it's good , but doesn't work for me !

here is the code :

- (void)listenForBlow:(NSTimer *)timer {
    [recorder updateMeters];

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

    if (lowPassResults > 0.95)
        NSLog(@"Mic blow detected");
 //change the background color e.g !
}

in the console show me the nslog reseult like this (without any bowling !):

2010-04-11 23:32:27.935 MicBlow[2358:207] Mic blow detected
2010-04-11 23:32:27.965 MicBlow[2358:207] Mic blow detected
2010-04-11 23:32:27.995 MicBlow[2358:207] Mic blow detected
2010-04-11 23:32:28.026 MicBlow[2358:207] Mic blow detected
2010-04-11 23:32:28.055 MicBlow[2358:207] Mic blow detected
2010-04-11 23:32:28.086 MicBlow[2358:207] Mic blow detected
2010-04-11 23:32:28.115 MicBlow[2358:207] Mic blow detected
2010-04-11 23:32:28.145 MicBlow[2358:207] Mic blow detected
2010-04-11 23:32:28.175 MicBlow[2358:207] Mic blow detected
2010-04-11 23:32:28.205 MicBlow[2358:207] Mic blow detected
2010-04-11 23:32:28.236 MicBlow[2358:207] Mic blow detected

i change this value :

 if (lowPassResults < 0.95)

to

if (lowPassResults > 0.95)

so it seems work ! but doesn't chage anything , again if i put the background changing code the , my code change background but without any bowling !! what's the problem ?