2014年3月3日月曜日

タッチ位置と画像の位置を合わせる

 UITapGestureRecognizer* pan = (UITapGestureRecognizer*) sender;
    CGPoint location = [pan locationInView:self.view];
    NSLog(@"pan x=%f, y=%f", location.x, location.y);
    started =true;
    areaValue = [[AreaValue alloc] init];
    areaValue->x = location.x/self.view.frame.size.width*480;

    areaValue->y = location.y/self.view.frame.size.height*640;

2014年2月27日木曜日

iosアプリのアイコン必要画像一覧

・アプリアイコン
iTunesArtwork@2x.png  1024×1024 px
iTunesArtwork.png    512×512
appicon-xxxhdpi.png    196×196
appicon-xxhdpi.png     176×176
appicon-76@2x.png     152×152
appicon-72@2x.png     144×144
appicon@2x.png       120×120
appicon-114.png       114×114
appicon-76.png        76×76
appicon-72.png        72×72
appicon.png         57×57
 
・スプラッシュスクリーン
Default-Landscape@2x.png   2048(横)x1536(縦)
Default-Portrait@2x.png    1536×2048
Default-Landscape.png    1024×768
Default-Portrait.png      768×1024
Default-568h@2x.png     640×1136
Default@2x.png       640×960 
Default.png         320×480
 
・ナビゲーションバー背景画像
navbar@2x.png      640×88
navbar.png        320×44
navbar-ipad@2x.png    1536×88
navbar-ipad.png      768×44

スレッドの作り方

unsigned thID;
HANDLE hTh;
hTh = (HANDLE)_beginthreadex(NULL, 0, scanPaperThread, NULL, 0, &thID);

if (hTh != NULL) {
  CloseHandle(hTh);
  printf("ハンドルクローズしました\n");
}

unsigned __stdcall scanPaperThread(void *lpx)
{

かえるの歌

18,17,16,15,16,17,18,16,15,14,13,14,15,16,18,18,18,18,18,17,16,15,16,17,18

きらきら星

18,18,14,14,13,13,14,14,15,15,16,16,17,17,18,18,14,14,15,15,16,16,17,17,14,14,15,15,16,16,17,17,18,18,14,14,13,13,14,14,15,15,16,16,17,17,18,18

Excelマクロ

Function test(hoge As String)
    If hoge = "ど" Then
        test = 18
    ElseIf hoge = "れ" Then
        test = 17
    ElseIf hoge = "み" Then
        test = 16
    ElseIf hoge = "ふぁ" Then
        test = 15
    ElseIf hoge = "そ" Then
        test = 14
    ElseIf hoge = "ら" Then
        test = 13
    ElseIf hoge = "し" Then
        test = 12
    End If
End Function


sin波

AudioOutputUnitStop(aU);
-(void)playSound{
    
    //Sampling rate
    _sampleRate = 44100.0f;
    
    //Bit rate
    bitRate = 8// 8bit
    

    //AudioComponentDescription
    AudioComponentDescription aCD;
    aCD.componentType = kAudioUnitType_Output;
    aCD.componentSubType = kAudioUnitSubType_RemoteIO;
    aCD.componentManufacturer = kAudioUnitManufacturer_Apple;
    aCD.componentFlags = 0;
    aCD.componentFlagsMask = 0;
    
    //AudioComponent
    AudioComponent aC = AudioComponentFindNext(NULL, &aCD);
    AudioComponentInstanceNew(aC, &aU);
    AudioUnitInitialize(aU);
    
    //コールバック
    AURenderCallbackStruct callbackStruct;
    callbackStruct.inputProc = renderer;
    callbackStruct.inputProcRefCon = (__bridge void*)self;
    AudioUnitSetProperty(aU,
                         kAudioUnitProperty_SetRenderCallback,
                         kAudioUnitScope_Input,
                         0,
                         &callbackStruct,
                         sizeof(AURenderCallbackStruct));
    
    //AudioStreamBasicDescription
    AudioStreamBasicDescription aSBD;
    aSBD.mSampleRate = _sampleRate;
    aSBD.mFormatID = kAudioFormatLinearPCM;
    aSBD.mFormatFlags = kAudioFormatFlagsAudioUnitCanonical;
    aSBD.mChannelsPerFrame = 2;
    aSBD.mBytesPerPacket = sizeof(AudioUnitSampleType);
    aSBD.mBytesPerFrame = sizeof(AudioUnitSampleType);
    aSBD.mFramesPerPacket = 1;
    aSBD.mBitsPerChannel = bitRate * sizeof(AudioUnitSampleType);
    aSBD.mReserved = 0;
    
    //AudioUnit
    AudioUnitSetProperty(aU,
                         kAudioUnitProperty_StreamFormat,
                         kAudioUnitScope_Input,
                         0,
                         &aSBD,
                         sizeof(aSBD));
    

    
    //再生
    AudioOutputUnitStart(aU);

    
}

static OSStatus renderer(void *inRef,
                         AudioUnitRenderActionFlags *ioActionFlags,
                         const AudioTimeStamp* inTimeStamp,
                         UInt32 inBusNumber,
                         UInt32 inNumberFrames,
                         AudioBufferList *ioData) {
    
    //キャスト
    ViewController* def = (__bridge ViewController*)inRef;
    
    //サイン波
    float freq = def.frequency*2.0*M_PI/def.sampleRate;
    
    //値を書き込むポインタ
    AudioUnitSampleType *outL = ioData->mBuffers[0].mData;
    AudioUnitSampleType *outR = ioData->mBuffers[1].mData;
    
    for (int i = 0; i < inNumberFrames; i++) {
        // 周波数を計算
        float wave = sin(def.phase);
        AudioUnitSampleType sample = wave * (1 << kAudioUnitSampleFractionBits);
        *outL++ = sample;
        *outR++ = sample;
        def.phase += freq;
    }
    
    return noErr;
    

};