=== モーションキャプチャデータとサウンドの同期再生 === ARの表示にモーションキャプチャデータを使えればと言う話が出ました。 で、http://www.perfume-global.com/ で公開されているBVHデータを使えるか どうか試してみます。 まずは、公開されているキャプチャデータ(BVH)とサウンドを同期してProcessingで再生する ことを試してみます。 ===== データとサンプルコード ======= http://www.perfume-global.com/ からモーションキャプチャデータ(bvh)とサウンド(wav)データを 入手します。また、Processingのサンプルコードもダウンロードします。サンプルコードには、 processingからBVHファイルを読み込むためのライブラリが含まれています。BVHは標準ではProcessingで 読める様にはなっていないので、このライブラリは必須です。 サウンドとキャプチャデータを同期再生させるために、ダウンロードしたサンプルのスケッチを以下の様に書き換えます。 import ddf.minim.*; BvhParser parserA = new BvhParser(); PBvh bvh1, bvh2, bvh3; AudioPlayer player; Minim minim; public void setup() { size(1280, 720, P3D); background(0); noStroke(); frameRate(40); bvh1 = new PBvh(loadStrings("kashiyuka.bvh")); bvh2 = new PBvh(loadStrings("nocchi.bvh")); bvh3 = new PBvh(loadStrings("aachan.bvh")); minim = new Minim(this); player = minim.loadFile("Perfume_globalsite_sound.wav"); player.play(); player.loop(); } public void draw() { int currentTime = player.position(); background(color(255,255,128)); //camera float _cos = cos(currentTime / 5000.f); float _sin = sin(currentTime / 5000.f); camera(width/4.f + width/4.f * _cos +200, height/2.0f-100, 550 + 150 * _sin, width/2.0f, height/2.0f, -400, 0, 1, 0); //ground fill(color(0)); stroke(127); line(width/2.0f, height/2.0f, -30, width/2.0f, height/2.0f, 30); stroke(127); line(width/2.0f-30, height/2.0f, 0, width/2.0f + 30, height/2.0f, 0); stroke(255); pushMatrix(); translate(width/2, height/2-10, 0); rotateX(PI); sphereDetail(10); lights(); directionalLight(100, 100, 100, -1, -1, 0); //model bvh1.update(currentTime); bvh2.update(currentTime); bvh3.update(currentTime); bvh1.draw(); bvh2.draw(); bvh3.draw(); popMatrix(); }