iPhoneのゲームを作成することになったため、音声ファイル再生の方法を調べたのですが、数多くのフォーマットがあり、どの形式で利用するのがいいか迷ってしまいました。 そこで、各フォーマットとその特徴をメモっておこうと思います。 なお、下記の表は AppleのiOS Developer Libraryから引用したものです。 音声のデコード方式について音を鳴らすのに、ハードウエアデコードを使うか、ソフトウエアデコードを使うかは同時に鳴らせる音声ファイルの数に影響します。 同時に再生されている各サウンドはひとつの「チャンネル」を使用しますが、ハードウエアチャンネルは一つしかないため、AACまたはMP3がハードウエアチャンネルで再生されている場合は、その他のファイルの音声を同時に鳴らそうとすると、ソフトウエアデコードされることになります。(つまり、ソフトウエアデコードできなかったiOS3.0以前は
パフォーマンスの改善には、ボトルネックの検出が欠かせません。 どの処理に時間がかかっているのか判別するため、処理の経過時間を記録します。 stackoverflow*1では以下のような方法が提案されています。 NSDate *start = [NSDate date]; // do stuff... NSTimeInterval timeInterval = [start timeIntervalSinceNow]; これで経過時間を取得できます。 が、しかし。「1回だけ経過時間を取得する」なんてことは、あまりありません。 たとえば、「あるメソッド内で行われている処理の中で、一番重い処理を見つけたい」といったときには、メソッドの処理を5個くらいに分割してそれぞれの経過時間を取得し、大雑把なアタリをつける方が効率的です。 つまり、経過時間を取得する処理が複数回おこなわれます。 しかし、経過時
「iPhone 高精度タイマー」というキーワードで検索してみたところ、なぜか NSTimeInterval が出てきて「それは違うだろ!」と思ったので、今日は iPhone の高精度タイマーについて書いてみたいと思います(笑) ミリ秒よりずっと細かい、マイクロ秒とかナノ秒の話です。 iOS でナノ秒単位の細かい時間を取得するには mach_absolute_time 関数を利用します。mach_absolute_time 関数は mach/mach_time.h に定義されています。 #import <mach/mach_time.h> 単純に mach_absolute_time() を呼びだすとカーネルの絶対時間を取得することができます。例えば以下のようなコードを書くとループを100回まわして NOP 命令を実行した場合の時間を取得できます。 uint64_t start, e
Appleが提供しているプログラミングガイドは全部読んだほうがいいなーと思っています。 目下、興味のあるところから順次読み込み中。 今回は[PDF] Core Animationプログラミングガイドを読んだので、覚えておいたほうがいいところとかをピックアップし、自分なりの考察なんかを加えて書いています。 UIView/CALayerの基本構造 画面になにかを表示しようとした時、使うのはUIViewかそのサブクラスを使うのが通常です。 addSubview:メソッドなど使って階層構造を成して構築していきますね。 普通はUIViewを使えば問題ありませんが、描画のパフォーマンスやちょっとした細かい演出などをしたい場合はCALayerを利用します。 やはりどういう構造になって画面に表示されているか、を知るのは大事なことですね。 UIViewは通常、レンダリング周りを担当するCALayerクラスを
huin Job : Software Engineer(iOS, Android) Use : Objective-C, Swift, Java Like : Gadget, Apple, Photography, Art, Design, UI, UX More posts by huin. 日本のAppStoreでは未だ公開されていないfacebookの「Paper」ですが、 そのUIは実験的ながらも非常に高い完成度で個人的にはすごく好きなアプリです。 良いアプリがあれば "どうやって作っているのか" が気になるのがイチiOSエンジニアの性なんですが、facebook自体がPaperの裏側について説明した動画をしていて、非常に良い内容だったので紹介します。 なんのイベントなのかはよくわかってないのですが、 公開日は4/18なので比較的最近だと思います。 当然英語なので理解は浅いのです
UIImageの画像をリサイズ、回転、反転したい場合がある。こんなときにはQuartz 2D APIを使用する。Quartz 2D APIはCore Graphicsフレームワークの一部。 CTM(Current Transformation Matrix)を使う。主に以下の3つ。 CGContextTranslateCTM : 原点の平行移動 CGContextRotateCTM : 原点を中心として座標系を回転 CGContextScaleCTM : 原点を中心として座標系を拡大縮小 ①とりあえずそのまま描画 - (UIImage*)drawImage { UIImage *original_img = [UIImage imageNamed:@"frog"]; UIGraphicsBeginImageContext(self.view.bounds.size); [original_
I am new to Automatic Reference Counting with LLVM and Objective-C, and have a question about returning CGImageRefs from my Objective-C function. In the days of manual reference counting, it was possible to simply cast the CGImageRef to an id, autorelease it, then return the original CGImageRef. With ARC, I am aware that you can direct the ARC system to autorelease and return your retainable objec
I have a method that returns a CGImageRef object. It contains this call: CGImageRef posterFrame = [avAssetImage copyCGImageAtTime:time actualTime:nil error:&error]; ... return posterFrame; This situation, as I understand it, calls for an autorelease. But I have no idea how to do it. I've tried using CFCollectable(), but it doesn't work. Any ideas?
It has been quite a while since I wrote the last article in the Core Animation Games series. If you remember, in it I complained bitterly about the CA scrolling classes, and how none of them filled the ticket. To recapitulate, these are the 3 things I needed: A window into a coordinate system plane populated by “objects”… that smoothly moves through it by remapping how its borders map to that unde
AI, ML, and Data Science Programming Languages Web Development Languages DevOps Databases Computer Science Subjects Python Technologies Software Testing Cyber Security All Categories Back Artificial Intelligence Machine Learning ML With Python Data Science Statistics NLP Neural Networks TensorFlow PyTorch Matplotlib NumPy Pandas SciPy Big Data Analytics See all
There are two drawRect methods: - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); // do drawing here CGContextRestoreGState(context); } And - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); UIGraphicsPushContext(context); // do drawing here UIGraphicsPopContext(); } UIGraphicsPushContext / UIGraph
In a CALayer subclass I'm working on I have a custom property that I want to animate automatically, that is, assuming the property is called "myProperty", I want the following code: [myLayer setMyProperty:newValue]; To cause a smooth animation from the current value to "newValue". Using the approach of overriding actionForKey: and needsDisplayForKey: (see following code) I was able to get it to ru
よく、以下のようなコードでオフスクリーンコンテキストを作成し、 描画の後画像を得るサンプルを見ます。 コードが単純なためか、非常に広く使われていると思います。 UIGraphicsBeginImageContextWithOptions(CGSizeMake(1024, 1024), NO, 1.0); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextFillEllipseInRect(context, CGRectMake(0, 0, 1024, 1024)); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); ですが、これは本来やらなくていい処理をしていると思いませんか? という
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く