<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code &#38; Me</title>
	<atom:link href="http://codeand.me/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeand.me</link>
	<description>Android &#38; iOS games and articles</description>
	<lastBuildDate>Sat, 15 Dec 2012 08:25:41 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Voice Fighter for Android</title>
		<link>http://codeand.me/a/voice-fighter-for-android/</link>
		<comments>http://codeand.me/a/voice-fighter-for-android/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 13:43:19 +0000</pubDate>
		<dc:creator>Me</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[andengine]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[voice control]]></category>

		<guid isPermaLink="false">http://codeand.me/?p=795</guid>
		<description><![CDATA[Voice Fighter for Android is Open Source! Check it out  [...]]]></description>
				<content:encoded><![CDATA[<p>Voice Fighter for Android is Open Source! Check it out on github !</p>
<p><a href="https://github.com/czyang/Voice-Fighter-Android" target="_blank">https://github.com/czyang/Voice-Fighter-Android</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codeand.me/a/voice-fighter-for-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>dennisRitchie Good Bye</title>
		<link>http://codeand.me/a/dennisritchie-good-bye/</link>
		<comments>http://codeand.me/a/dennisritchie-good-bye/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 15:09:08 +0000</pubDate>
		<dc:creator>Me</dc:creator>
				<category><![CDATA[life]]></category>
		<category><![CDATA[dennis ritchie]]></category>

		<guid isPermaLink="false">http://codeand.me/?p=788</guid>
		<description><![CDATA[free(dennisRitchie); dennisRitchie = null; &#160; &#038;nbsp [...]]]></description>
				<content:encoded><![CDATA[<p>free(dennisRitchie);</p>
<p>dennisRitchie = null;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://en.wikipedia.org/wiki/Dennis_Ritchie">http://en.wikipedia.org/wiki/Dennis_Ritchie</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codeand.me/a/dennisritchie-good-bye/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>到上海了</title>
		<link>http://codeand.me/a/shanghai_1/</link>
		<comments>http://codeand.me/a/shanghai_1/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 15:01:14 +0000</pubDate>
		<dc:creator>Me</dc:creator>
				<category><![CDATA[life]]></category>
		<category><![CDATA[上海]]></category>

		<guid isPermaLink="false">http://codeand.me/?p=773</guid>
		<description><![CDATA[2011.10.1 的外滩 &#160; &#160; &#160;]]></description>
				<content:encoded><![CDATA[<p>2011.10.1 的外滩</p>
<p><a href="http://codeand.me/wp-content/uploads/2011/10/201110018791.jpg"><img class="alignnone size-full wp-image-775" title="20111001879" src="http://codeand.me/wp-content/uploads/2011/10/201110018791.jpg" alt="" width="480" height="360" /></a></p>
<p><span id="more-773"></span></p>
<p>&nbsp;</p>
<p><a href="http://codeand.me/wp-content/uploads/2011/10/20111001883.jpg"><img class="alignnone size-full wp-image-776" title="20111001883" src="http://codeand.me/wp-content/uploads/2011/10/20111001883.jpg" alt="" width="480" height="360" /></a></p>
<p><a href="http://codeand.me/wp-content/uploads/2011/10/20111001885.jpg"><img class="alignnone size-full wp-image-777" title="20111001885" src="http://codeand.me/wp-content/uploads/2011/10/20111001885.jpg" alt="" width="480" height="360" /></a></p>
<p><a href="http://codeand.me/wp-content/uploads/2011/10/20111001893.jpg"><img class="alignnone size-full wp-image-778" title="20111001893" src="http://codeand.me/wp-content/uploads/2011/10/20111001893.jpg" alt="" width="461" height="346" /></a></p>
<p><a href="http://codeand.me/wp-content/uploads/2011/10/20111001894.jpg"><img class="alignnone size-full wp-image-779" title="20111001894" src="http://codeand.me/wp-content/uploads/2011/10/20111001894.jpg" alt="" width="461" height="346" /></a></p>
<p><a href="http://codeand.me/wp-content/uploads/2011/10/20111001897.jpg"><img class="alignnone size-full wp-image-780" title="20111001897" src="http://codeand.me/wp-content/uploads/2011/10/20111001897.jpg" alt="" width="480" height="360" /></a></p>
<p><a href="http://codeand.me/wp-content/uploads/2011/10/20111001900.jpg"><img class="alignnone size-full wp-image-781" title="20111001900" src="http://codeand.me/wp-content/uploads/2011/10/20111001900.jpg" alt="" width="461" height="346" /></a></p>
<p><a href="http://codeand.me/wp-content/uploads/2011/10/20111001901.jpg"><img class="alignnone size-full wp-image-782" title="20111001901" src="http://codeand.me/wp-content/uploads/2011/10/20111001901.jpg" alt="" width="461" height="346" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://codeand.me/a/shanghai_1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Attention Trainer Web Edtion</title>
		<link>http://codeand.me/a/attention_trainer_web_edtion/</link>
		<comments>http://codeand.me/a/attention_trainer_web_edtion/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 09:29:11 +0000</pubDate>
		<dc:creator>Me</dc:creator>
				<category><![CDATA[MyToy]]></category>
		<category><![CDATA[Attention Trainer]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[Toy]]></category>

		<guid isPermaLink="false">http://codeand.me/?p=757</guid>
		<description><![CDATA[Introduction: Do you feel hard to focus? This app can h [...]]]></description>
				<content:encoded><![CDATA[<p><strong>Introduction:</strong></p>
<p>Do you feel hard to focus? This app can help you train to focus, give you attention fitness. Make the plan and follow the training cycle, you can find it’s easy to focus! The training cycle is two phases the “attention time” and “break time”. In “attention time”, you need to focus on your work, in the break time you just take a few minutes to breaks. Through some training you will get a longer attention span.</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="424" height="580">
      <param name="movie" value="http://codeand.me/wp-content/uploads/2011/09/AttentionTrainer.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://codeand.me/wp-content/uploads/2011/09/AttentionTrainer.swf" width="424" height="580">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p><strong>Usage:</strong></p>
<p>This is just 3 steps to train your attention.</p>
<p>1.Make the plan, set the attention time and break time, start with 12 minutes as attention time and 2 minutes as break time are recommended.</p>
<p>2.In the training cycle, when the “Start” button is pressed, the training cycle begins, training cycle has 2 phases. The first phase is “attention time”. In “attention time”, you need to focus on your work, when the timer goes off you will get a notification. Training will enter the “break time” the second phase, in this phase you just take a few minutes break (depend on your plan, 2 minutes is recommended for all situation). When the second phase end, the training is back to first phase, you need to focus on your work again… the training cycle won’t stop until “cancel” button is pressed.</p>
<p>3.Through some training if you feel you can focus longer, you would change your plan, increase the “attention time” (increase 2 minutes in each time is recommended).</p>
<p>注意力教练-网页版</p>
<p>简介</p>
<p>你感觉很难集中注意力吗？这个应用能够帮助你训练你的注意力，使你更容易集中注意力。你只需要在程序里面制定你的训练计划，然后根据提示执行的你计划，你会发现很容易就能够锻炼你的专注力。只需要用这个方法坚持练习一段时间，你就能够得到更长的集中注意力的时间。这是一个简单又有效的软件，为什么不试一下呢? :)</p>
<p><span id="more-757"></span></p>
<p>训练注意力的过程只需要三步：</p>
<p>1. 在程序中制定一个简单的计划，计划包括“集中注意力时间”，“休息时间”（我们强烈推荐你从12分钟“集中注意力时间”和 2分钟“休息时间”开始进行练习）。设定完之后记得点击应用。这样就可以进入下一步。</p>
<p>2. 现在可以点击“开始”按钮来进入训练周期。训练周期分为两步，第一步是“集中注意力时间”，程序会显示“请集中注意力”，在这个步骤中你就集中注意力做你的事情（比如工作，写文档，读文章等等）。计时器会进行倒计时，如果集中注意力的时间结束后，程序会给你一个提示，这样就进入训练周期的第二步在这个步骤中“休息时间”，在这个步骤中，你就让自己放松一会,“休息时间”结束之后，你会得到一个提示，这样又回到了“集中注意力时间”，你又开始做你的工作。这个训练周期会这样一直重复下去直到“取消”按钮被按下。</p>
<p>3. 通过重复训练周期，你很快会发现你可以集中精力更长时间，这样你就可以更进一步，现在增加训练计划中的“集中注意力时间”（我们建议你每次增加2分钟），你可以维持休息时间不变，2分钟的休息时间是在所有情况下都适用的，也是被推荐的，别忘了设置结束后点击“应用”按钮。</p>
]]></content:encoded>
			<wfw:commentRss>http://codeand.me/a/attention_trainer_web_edtion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>如何相对安全的保存iPhone游戏的分数</title>
		<link>http://codeand.me/a/game_center_score_save/</link>
		<comments>http://codeand.me/a/game_center_score_save/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 14:48:33 +0000</pubDate>
		<dc:creator>Me</dc:creator>
				<category><![CDATA[Gab]]></category>
		<category><![CDATA[crypto]]></category>
		<category><![CDATA[Game Center]]></category>
		<category><![CDATA[highscore]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[加密]]></category>
		<category><![CDATA[最高分]]></category>

		<guid isPermaLink="false">http://codeand.me/?p=740</guid>
		<description><![CDATA[介绍一种保存游戏分数（高分）的方法，里面提供了相关的代码。这个方法可以相对安全的保存你的游戏分数，因为现在几乎 [...]]]></description>
				<content:encoded><![CDATA[<p>介绍一种保存游戏分数（高分）的方法，里面提供了相关的代码。这个方法可以相对安全的保存你的游戏分数，因为现在几乎所有移动平台的游戏都使用了OpenFeint，Game Center一类的社交游戏网络，其中使用最多的功能就是在线排行榜。我在我的两个iPhone游戏（<a href="http://itunes.apple.com/us/app/voice-fighter/id449643608?ls=1&amp;mt=8" target="_blank">Voice Fighter</a>, <a href="http://itunes.apple.com/cn/app/magic-tiles/id442161500?mt=8#" target="_blank">Magic Tiles</a>）中均使用了这个方法保存游戏的最高分数，防止游戏最高分数被越狱的用户通过修改游戏文件来作弊。但这个方法防不了那些通过截取网络数据包来改分数的手段。因为整个方法的核心就是加密分数然后保存在本地。</p>
<p>代码部分出自：<a href="http://www.cocos2d-iphone.org/forum" target="_blank">Cocos2d论坛</a></p>
<p>方法的过程是：</p>
<p>1.需要保存游戏分数时，有游戏分数H，把H的数据类型转换成字符串：S，在S后加上字符串M作为混淆字符串，现在就得到字符串X(X=S+M).</p>
<p>2.用MD5或者其他加密算法加密字符串X，得到一串密文，把这串密文和H保存在本地文件中.</p>
<p>3.用户程序需要获取H时（比如游戏启动时需要在界面中显示最高分），读取保存密文和H的文件，这样就可以获得H和加密后的密文，现在就对密文进行解密，得到一个数字，用这个数字和H进行对比，如果得到的数字不等于H就证明用户修改过分数，可以选择清零数据；结果相等则通过检查。</p>
<p><span id="more-740"></span></p>
<pre class="brush:py">#import &lt;CommonCrypto/CommonDigest.h&gt; 
//magicString既为前文的字符串M,可以任意修改这个字符串，不过要注意长度不要超过加密函数的上限
static NSString* magicString = @"passward$#@";
//MD5加密，也可以用其他加密方法，或者新写一个加密函数调用N次这个md5算法。
#pragma mark crypto
-(NSString*) md5:(NSString*) str {
    const char *cStr = [str UTF8String];
    unsigned char result[CC_MD5_DIGEST_LENGTH];
    CC_MD5( cStr, strlen(cStr), result );
    return [NSString stringWithFormat:
            @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
            result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7],
            result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15]
            ];
}</pre>
<pre class="brush:cpp">//这段代码应该在"saveHighScore"保存分数一类的函数中
//highscore既是H,需要加密保存的分数,magicString同上。
NSString *md5Input = [NSString stringWithFormat:@"%d%@", highscore, magicString];
//cryptoString是X,之后只需要保存X即可。
NSString *cryptoString = [self md5:md5Input];</pre>
<pre class="brush:cpp">//这段代码应该在readHighScore一类的函数里
//highscore是从文件中读取的之前保存的最高分
//cryptoString是从文件中读取的加密字符串
    NSString *md5Input = [NSString stringWithFormat:@"%d%@", highscore, magicString];
    NSString *cryptoString = [self md5:md5Input];
    if ([cryptoString isEqualToString:mima] == NO) {
        //用户手动修改了最高分数，归零最高分数
    }</pre>
<p>因为好多临时变量的功能其实是相同的，所以我用了相同的名字。</p>
<p>如果你在模拟器里面测试程序时不知到你保存了的文件保存在哪里。<a title="iOS Simulator File System on Your Mac" href="http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/125-Using_iOS_Simulator/ios_simulator_application.html" target="_blank">请点击</a> iOS Simulator File System on Your Mac</p>
]]></content:encoded>
			<wfw:commentRss>http://codeand.me/a/game_center_score_save/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>09年的实验室</title>
		<link>http://codeand.me/a/mpi-cluster/</link>
		<comments>http://codeand.me/a/mpi-cluster/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 08:45:21 +0000</pubDate>
		<dc:creator>Me</dc:creator>
				<category><![CDATA[life]]></category>
		<category><![CDATA[mpi]]></category>
		<category><![CDATA[实验室]]></category>
		<category><![CDATA[并行计算]]></category>
		<category><![CDATA[机群]]></category>

		<guid isPermaLink="false">http://codeand.me/?p=724</guid>
		<description><![CDATA[拍摄于2009年11月25日的照片，“智能信息处理实验室”的mpi并行计算机群，RainySummer和我弄的 [...]]]></description>
				<content:encoded><![CDATA[<p>拍摄于2009年11月25日的照片，“智能信息处理实验室”的mpi并行计算机群，<a title="码农。80后。男。天秤。理想主义者。懒。神经质。对电脑、游戏有一种 与生俱来的兴趣" href="http://xd547.com/" rel="friend" target="_blank">RainySummer</a>和我弄的，当然还有实验室的老师非常多的赞助与帮忙，交换机和网线都是老师自掏腰包垫钱买的。当时我们是这个实验室的学生。那些网线接头还是我一个个自己夹出来的。机器是学校机房淘汰了的旧电脑。实验室的老师同学围绕这个机群还写出了好几篇论文，现在估计已经不在用了。</p>
<p><img class="alignnone size-full wp-image-733" title="20091125232" src="http://codeand.me/wp-content/uploads/2011/08/20091125232.jpg" alt="" width="512" height="384" /></p>
<p><span id="more-724"></span></p>
<p><img class="alignnone size-full wp-image-734" title="c" src="http://codeand.me/wp-content/uploads/2011/08/c.jpg" alt="" width="512" height="384" /></p>
<p><a href="http://codeand.me/wp-content/uploads/2011/08/20091125231.jpg"><img class="alignnone size-full wp-image-732" title="20091125231" src="http://codeand.me/wp-content/uploads/2011/08/20091125231.jpg" alt="" width="512" height="384" /></a></p>
<p><img class="alignnone size-full wp-image-730" title="20091125229" src="http://codeand.me/wp-content/uploads/2011/08/20091125229.jpg" alt="" width="512" height="384" /></p>
<p><img class="alignnone size-full wp-image-726" title="20091125224" src="http://codeand.me/wp-content/uploads/2011/08/20091125224.jpg" alt="" width="512" height="384" /></p>
<p><img class="alignnone size-full wp-image-725" title="20091125223" src="http://codeand.me/wp-content/uploads/2011/08/20091125223.jpg" alt="" width="512" height="384" /></p>
]]></content:encoded>
			<wfw:commentRss>http://codeand.me/a/mpi-cluster/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Make a Voice Control Game on iPhone</title>
		<link>http://codeand.me/a/how-to-make-a-voice-control-game-on-iphone/</link>
		<comments>http://codeand.me/a/how-to-make-a-voice-control-game-on-iphone/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 16:38:15 +0000</pubDate>
		<dc:creator>Me</dc:creator>
				<category><![CDATA[iOS Coding]]></category>
		<category><![CDATA[develop]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[voice control]]></category>

		<guid isPermaLink="false">http://codeand.me/?p=684</guid>
		<description><![CDATA[Some of you might play several game using voice to cont [...]]]></description>
				<content:encoded><![CDATA[<p>Some of you might play several game using voice to control the game, say &#8220;ahhh&#8221; to move the role and shout &#8220;pah&#8221; to shoot something out&#8230;</p>
<p>If you hadn&#8217;t played a game like that, you must try my game: <a href="http://itunes.apple.com/us/app/voice-fighter/id449643608?ls=1&amp;mt=8" target="_blank">Voice Fighter</a></p>
<p>This article will teach you how to use the iPhone SDK to develop the voice control part of these kinds of game. You can use the code from this article to make your own game. But this article will not show you how to make the graphic part of the game. You can use <a href="http://www.cocos2d-iphone.org/" target="_blank">Cocos2d</a> or other game engine to make the rest of the game.</p>
<p>&#8220;Voice Control&#8221; in this point is not about the &#8220;speech recognition&#8221; but like the &#8220;voice operated switch&#8221;. These games receive the information from microphone and do some simple analysis，We will use AVAudioRecorder to receive the information. You must be aware that doing this work has a lot of ways, you can find more information in iphone SDK documents, as I know use AVAudioRecorder is the simplest way, so let&#8217;s start!</p>
<p><span id="more-684"></span></p>
<p>Here is the class(Objective-C) from my game <a href="http://itunes.apple.com/us/app/voice-fighter/id449643608?ls=1&amp;mt=8" target="_blank">Voice Fighter</a>:</p>
<p>AVMicInput.h</p>
<pre class="brush:py">//
//  AVMicInput.h
//  voicefighter
//
//  Created by Chengzhi Yang on 11-6-25.
//  http://codeand.me.
//  Copyright 2011 All rights reserved.
//
#import &lt;Foundation/Foundation.h&gt;
#import &lt;AVFoundation/AVFoundation.h&gt;
#import &lt;CoreAudio/CoreAudioTypes.h&gt;

@interface AVMicInput : NSObject {
    AVAudioRecorder *recorder;
    NSTimer *levelTimer;
}

-(float) micAveragePower;

@end</pre>
<p>AVMicInput.m</p>
<pre class="brush:py">//
//  AVMicInput.m
//  voicefighter
//
//  Created by Chengzhi Yang on 11-6-25.
//  http://codeand.me.
//  Copyright 2011 All rights reserved.
#import "AVMicInput.h"
@implementation AVMicInput
-(id) init
{
	if( (self=[super init]) ) {
        NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];

        NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
                                  [NSNumber numberWithFloat: 44100.0],                 AVSampleRateKey,
                                  [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
                                  [NSNumber numberWithInt: 1],                         AVNumberOfChannelsKey,
                                  [NSNumber numberWithInt: AVAudioQualityMin],         AVEncoderAudioQualityKey,
                                  nil];
        NSError *error;

        recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&amp;error];

        if (recorder) {
            [recorder prepareToRecord];
            recorder.meteringEnabled = YES;
            [recorder record];
        } else
            NSLog(@"%@",[error description]);
	}
	return self;
}

- (void) dealloc {
    [recorder dealloc];
    [super dealloc];
}

-(float) micAveragePower
{
    [recorder updateMeters];
    float avgPower = [recorder averagePowerForChannel:0];
    //NSLog(@"%f",avgPower);
    return avgPower;
}

@end</pre>
<p>You can add AVMicInput.h and  AVMicInput.m to your project without any change. This class will setup the AVAudioRecorder for you. You may notice the strings &#8220;/dev/null&#8221;. In Unix-like operating systems, &#8220;/dev/null&#8221; is a special file that discards all data written to it (but reports that the write operation succeeded) and provides no data to any process that reads from it <a href="http://en.wikipedia.org/wiki//dev/null" target="_blank">[1]</a>, iPhone OS is one of Unix-like operating systems. Other codes will explain in rest of this article.</p>
<p>Put the following code to your initializer to initialize the AVMicInput class:</p>
<pre class="brush:cpp">AVMicInput *avMicIn;
avMicIn = [[AVMicInput alloc] init];</pre>
<p>In your main loop or where you want to get the information from microphone add the following code:</p>
<pre class="brush:cpp">float micIn = [avMicIn micAveragePower];</pre>
<p>If the AVMicInput was correctly initialized, micAveragePower will return a float that is the immediate dB(<a href="http://en.wikipedia.org/wiki/Decibel" target="_blank">Decibel</a>) information(you can also understand the information into digital signal) from microphone, the range of the return value micIn is [-120, 0].  -120 is the absolutely quiet, 0 is the maximum value(if the voice is very loud, such as a shout, you could get 0). I make a list to help you understand the micIn:<br />
1. If your microphone was broken, iPhone or your Mac, you will always get -120 on your iphone or simulator.<br />
2. In most cases, a silent environment. The range of micIn is about -30 to -50, you can test by yourself.<br />
3. If you say &#8220;ahhh&#8221; or say something softly, the range of micIn is about -30 to -10.<br />
4. if you speak loudly or shout, the range of micIn is  -10 to 0.</p>
<p>In my game <a href="http://itunes.apple.com/us/app/voice-fighter/id449643608?ls=1&amp;mt=8" target="_blank">Voice Fighter</a>, through a lot of test and tweak, I used the below code to determine which state of value I got, is &#8220;ahhh&#8221; or &#8220;pah&#8221;(It&#8217;s not necessary to use these two incantation, &#8220;HA&#8221;, &#8220;PEW&#8221;, &#8220;BANG&#8221;, &#8220;KAMEHAMEHA&#8221;&#8230; is available)</p>
<pre class="brush:cpp">if ( micIn &gt; -6 ){
    //We got a "Pah"!
} else if ( micIn &gt;= -25 &amp;&amp; micIn &lt; -6  ) {
    //we got a "Ahhhhhh"
}</pre>
<p>You can tweak the threshold by your self.</p>
<p>Others you need know:<br />
1. For now time, most iOS device has a microphone. I&#8217;m write the <a href="http://itunes.apple.com/us/app/voice-fighter/id449643608?ls=1&amp;mt=8" target="_blank">Voice Fighter</a> use a ipod touch 4, but the older generation ipod may need a plug-in microphone to let you play with the microphone.</p>
<p>2. If you use Cocos2d to make your game or in your own engine you used the cocosDension to play the sound like this: [[SimpleAudioEngine sharedEngine] playEffect:@&#8221;1.aifc&#8221;]; You will noticed if you play a sound the AVAudioRecorder will stop work. For this situation, You can solve the problem by this method:<br />
(1). Add #import &#8220;CDAudioManager.h&#8221; to AppDelegate.m .<br />
(2). Add [CDAudioManager initAsynchronously:kAMM_PlayAndRecord]; to &#8211; (void) applicationDidFinishLaunching:(UIApplication*)application .<br />
And you can find more solution in <a href="http://www.cocos2d-iphone.org/forum/topic/3044#post-105754" target="_blank">here</a>. In that forum czyang is me :)</p>
<p>3. If you want to make a voice control game on Android platform please think twice. Theoretically make a voice control game on Android could use the same way, but I was made the Voice Fighter for Android(<a href="https://market.android.com/details?id=me.codeand.ahahpah_en" target="_blank">here</a>) in same way. The input of microphone was totally different! Thanks to separate hardware on android. Each type of android phone have different hardware, and information from microphone on these device may have a huge different. The Voice Fighter for Android just working normally on a bit type of android phone, so I got a lot of 1 star in market. For now I don&#8217;t have a solution about this problem.</p>
<p>Now you got all of the &#8220;voice control&#8221; things. You can use these code to make a voice control game by your self.</p>
<p>If you feel this article is good for you, don&#8217;t forget to buy a <a href="http://itunes.apple.com/us/app/voice-fighter/id449643608?ls=1&amp;mt=8" target="_blank">Voice Fighter</a> or tell your friends about this game for support me :)</p>
<p>BTW, Now I have a few promo code of voice fighter left. I will giveaway 5 of them. If you want to get one, please fill your email correctly and leave a reply follow this article with &#8220;Show me your code&#8221;. I will send the promo code to your email in 24 hours.</p>
]]></content:encoded>
			<wfw:commentRss>http://codeand.me/a/how-to-make-a-voice-control-game-on-iphone/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Voice Fighter (for iPhone)</title>
		<link>http://codeand.me/a/voice-fighter-iphone/</link>
		<comments>http://codeand.me/a/voice-fighter-iphone/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 10:06:47 +0000</pubDate>
		<dc:creator>Me</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[ah]]></category>
		<category><![CDATA[ahah]]></category>
		<category><![CDATA[ahhh]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[iphone game]]></category>
		<category><![CDATA[iPod touch]]></category>
		<category><![CDATA[itouch]]></category>
		<category><![CDATA[pah]]></category>
		<category><![CDATA[voice]]></category>
		<category><![CDATA[voice control]]></category>
		<category><![CDATA[voice control game]]></category>
		<category><![CDATA[voice fighter]]></category>

		<guid isPermaLink="false">http://codeand.me/?p=627</guid>
		<description><![CDATA[ $0.99 Play the game only by your VOICE !!! Voice Fight [...]]]></description>
				<content:encoded><![CDATA[<p><strong><a href="http://codeand.me/wp-content/uploads/2011/07/114.png"><img class="alignnone size-full wp-image-658" title="114" src="http://codeand.me/wp-content/uploads/2011/07/114.png" alt="" width="114" height="114" /></a><br />
</strong></p>
<p><span style="color: #00ccff;"><strong> <a href="http://itunes.apple.com/us/app/voice-fighter/id449643608?ls=1&amp;mt=8" target="_blank"><img class="alignnone size-full wp-image-594" title="iphonepaid" src="http://codeand.me/wp-content/uploads/2011/03/iphonepaid.png" alt="iTunes Link" width="117" height="39" /></a>$0.99</strong></span></p>
<p>Play the game only by your <strong>VOICE</strong> !!!</p>
<p>Voice Fighter is a new voice control shooting game!</p>
<p>How to:</p>
<p>1.Say &#8220;ah&#8221; to control your fighter.</p>
<p>2.Shout &#8220;Pah&#8221; to shoot.</p>
<p>3.Shout for two seconds to launch the <strong>ultimate bomb!!!</strong></p>
<p><span style="color: #ff0000;"><strong>MORE fun!  MORE crazier!</strong> </span></p>
<p>&nbsp;</p>
<p><span id="more-627"></span></p>
<p>Features:</p>
<p>1. Ultimate BOMB is a throat detonator!<br />
2. Play the game only by your VOICE.<br />
3. Play with your friends will get more fun!</p>
<p><img class="size-full wp-image-637 alignnone" title="Screenshot 2011.07.14 15.02.11" src="http://codeand.me/wp-content/uploads/2011/07/Screenshot-2011.07.14-15.02.11.png" alt="" width="346" height="230" /><img class="size-full wp-image-641 alignnone" title="Screenshot 2011.07.14 15.03.19" src="http://codeand.me/wp-content/uploads/2011/07/Screenshot-2011.07.14-15.03.19.png" alt="" width="346" height="230" /><img class="size-full wp-image-640 alignnone" title="Screenshot 2011.07.14 15.02.59" src="http://codeand.me/wp-content/uploads/2011/07/Screenshot-2011.07.14-15.02.59.png" alt="" width="346" height="230" /><img class="alignnone size-full wp-image-639" title="Screenshot 2011.07.14 15.02.42" src="http://codeand.me/wp-content/uploads/2011/07/Screenshot-2011.07.14-15.02.42.png" alt="" width="346" height="230" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://codeand.me/a/voice-fighter-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magic Tiles</title>
		<link>http://codeand.me/a/magic_tiles/</link>
		<comments>http://codeand.me/a/magic_tiles/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 13:49:32 +0000</pubDate>
		<dc:creator>Me</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[My iPhone APP]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[iOS game]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iphone game]]></category>
		<category><![CDATA[iPod touch]]></category>
		<category><![CDATA[magic tiles]]></category>
		<category><![CDATA[MagicTiles]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://codeand.me/?p=560</guid>
		<description><![CDATA[Magic Tiles for iPhone is available in App Store! Magic [...]]]></description>
				<content:encoded><![CDATA[<p><strong><span style="color: #00ccff;">Magic Tiles for iPhone is available in App Store!</span></strong></p>
<h1><img class="size-full wp-image-583 alignnone" title="Icon@2x" src="http://codeand.me/wp-content/uploads/2011/06/Icon@2x.png" alt="ICON" width="114" height="114" /> <span style="color: #ff0000;">Magic Tiles</span></h1>
<h1><a href="http://itunes.apple.com/cn/app/magic-tiles/id442161500?mt=8#" target="_blank"><img title="iphonepaid" src="http://codeand.me/wp-content/uploads/2011/03/iphonepaid.png" alt="iTunes Link" width="117" height="39" /></a><span style="color: #ff0000; font-size: 13px; line-height: 18px; font-weight: normal;">Just $0.99</span></h1>
<p><span style="color: #000000;">Caution! Somebody says that they are addicted to this game! :)</span></p>
<p>&nbsp;</p>
<p><span id="more-560"></span></p>
<p><span style="color: #000000;">_______________________________________ </span></p>
<p><span style="color: #000000;">How to play: </span></p>
<p><span style="color: #000000;">-In a limited time, keep taping a blank grid. Tiles having same colors will be eliminated if they are horizontally or vertically connected by the tapped grid, and you will get scores for the eliminations. </span><br />
<span style="color: #000000;">-If you taped a wrong grid, game time will decrease as penalty. </span><br />
<span style="color: #000000;">-If no more tiles can be eliminated, a new grids will be created. </span></p>
<p><span style="color: #000000;">_______________________________________ </span></p>
<p><span style="color: #000000;">Tips on Scoring: </span></p>
<p><span style="color: #000000;">-You have 120 seconds to play. </span><br />
<span style="color: #000000;">-1 score for each tile elimination. </span><br />
<span style="color: #000000;">-1 wrong tap results 8-second decrease in game time. </span></p>
<p><span style="color: #000000;">_______________________________________ </span></p>
<p><span style="color: #000000;">Features: </span></p>
<p><span style="color: #000000;">-Now support iPhone and iPod touch.</span></p>
<p>&nbsp;</p>
<h2><span style="color: #000000;">Screenshot</span></h2>
<p><span style="color: #000000;"><strong><img title="Main_menu" src="http://a1.mzstatic.com/us/r30/Purple/69/8a/99/mzl.fedcadvl.320x480-75.jpg" alt="" width="288" height="432" /> <img class="alignnone" title="help_screen" src="http://a4.mzstatic.com/us/r30/Purple/92/e3/ae/mzl.degkpnmo.320x480-75.jpg" alt="" width="288" height="432" /></strong></span></p>
<p><span style="color: #000000;"><strong><img class="alignnone" title="game play" src="http://a1.mzstatic.com/us/r30/Purple/02/3f/db/mzl.tqojccbw.320x480-75.jpg" alt="" width="288" height="432" /><img class="alignnone" title="game over" src="http://a3.mzstatic.com/us/r30/Purple/6a/f5/39/mzl.wwxqbnqe.320x480-75.jpg" alt="" width="288" height="432" /><br />
</strong></span></p>
]]></content:encoded>
			<wfw:commentRss>http://codeand.me/a/magic_tiles/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>我的Android收入情况</title>
		<link>http://codeand.me/a/%e6%88%91%e7%9a%84android%e6%94%b6%e5%85%a5%e6%83%85%e5%86%b5/</link>
		<comments>http://codeand.me/a/%e6%88%91%e7%9a%84android%e6%94%b6%e5%85%a5%e6%83%85%e5%86%b5/#comments</comments>
		<pubDate>Sat, 07 May 2011 03:28:24 +0000</pubDate>
		<dc:creator>Me</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[报告]]></category>
		<category><![CDATA[收入]]></category>

		<guid isPermaLink="false">http://codeand.me/?p=534</guid>
		<description><![CDATA[我开发Android程序已经5个多月了，一共4款应用。我放上我的收入的具体明细。 收入的情况： 我的所有应用都 [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://codeand.me/wp-content/uploads/2011/05/p_large_vtgO_68f9000893f35c44.jpg"><br />
</a>我开发Android程序已经5个多月了，一共4款应用。我放上我的收入的具体明细。</p>
<div>收入的情况：</div>
<div>我的所有应用都有两个版本，一个是英文版，一个是中文版。英文版的应用我都用admob广告，中文版的广告我用的是国内的有米广告。</div>
<div>有米广告的总展示次数：215,683  总点击数：3,609   总收入：756￥   平均点击率：1.67%  平均每次广告点击有0.02￥的收入。</div>
<div>admob广告总展示次数：170,671  总点击数：点击率0.66% 总收入 43.69$</div>
<div>英文版的展示次数比中文版少主要原因是英文版我还是没有找到什么推广方式。</div>
<div>啊啊啪（AhahPah）的中英文两个版本用户总共提交了37880个在线分数，用户必须用手机上网和成功玩完一局游戏后才能提交一次分数，一个手机多次提交的分数只记录最高分。从这点分析啊啊啪的中英文版本的下载量大概在  40000-50000之间。</div>
<div>我的想法：</div>
<div>看了两天相关的iPhone和Android的各种新闻资讯，感觉Android还是没有什么希望，我可能不会再集中精力继续开发android程序了除非找到什么合适的盈利方式。</div>
<div>这几天有米广告搞了个开发者扶持计划 <a href="http://www.youmi.net/page/activity/multimillion_project">http://www.youmi.net/page/activity/multimillion_project</a> 里面一个最主要的条件是，扶持的应用每天的活跃用户数量必须大于50000，我想问的是国内有几个Android应用能够大于这个数值？ 这个数值估计会是用广告请求量来衡量的。扶持计划的主要扶持办法就是让被扶持的开发者的收入每天有300￥不到的由扶持方补给你。我想说的是如果你的一个应用每天有50000活跃用户，你连300块的广告费都不能自己赚到的话，这种经济效益也实在让人不能接受了。 最近几天我的每天收入大概是在  15￥ ，昨天的<span style="font-family: 微软雅黑, helvetica, tahoma, arial, 宋体;">请求数量大概是 </span>4,295，点击数是76，点击率大概 1.7%。这样算来如果每天的请求量有40000的话，点击率还能保持1.7%的话，每天就有680的点击数，每次点击算0.02￥的话，每天就有</div>
<div>136￥如果这么高的请求量还能持续30天的话，那么一个月的收入就有4080。对于一个每天能有40000请求的程序，肯定是无法接受的一个收入。（ps.我的应用里面广告位置放在不容易点到的位置的话，平均点击率不会超过0.5%）</div>
<div>如果你觉得我的应用太有问题或者太垃圾的话。你也可以在gfan 和 hiapk论坛里面看一下那些大作的下载量，发布几个月的大作往往只有不超过5W的下载量，这个下载量是对于中国大陆的，包括几个论坛，几个应用商场。能为广告做贡献的用户又能有多少呢？</div>
<div><span style="font-family: 微软雅黑, helvetica, tahoma, arial, 宋体;">最近有条新闻说某分析机构做了一个报告，里面说Android Market的应用将会在今年8月份超过iPhone商店。但是从网络言论来看大部分人对此都很不屑，Android的应用再多对开发者来说并不会有任何好处。</span></div>
<div><span style="font-family: 微软雅黑, helvetica, tahoma, arial, 宋体;"><br />
</span></div>
<div><span style="font-family: 微软雅黑, helvetica, tahoma, arial, 宋体;">从网络言论来看包括TechCrunch一类的网站，对Android开发的前景并不看好。</span></div>
<div>现阶段的 Android平台，对于大多数个人开发者来说确实不是一个好的赚钱平台，在今后一段很长的时间内也绝对不是。</div>
]]></content:encoded>
			<wfw:commentRss>http://codeand.me/a/%e6%88%91%e7%9a%84android%e6%94%b6%e5%85%a5%e6%83%85%e5%86%b5/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
