Changes between Initial Version and Version 1 of misc/misc/processing/bvh_and_sound


Ignore:
Timestamp:
09/19/14 10:49:56 (10 years ago)
Author:
noboru.yamamoto
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • misc/misc/processing/bvh_and_sound

    v1 v1  
     1=== モーションキャプチャデータとサウンドの同期再生 ===  
     2 
     3ARの表示にモーションキャプチャデータを使えればと言う話が出ました。 
     4で、http://www.perfume-global.com/ で公開されているBVHデータを使えるか 
     5どうか試してみます。 
     6まずは、公開されているキャプチャデータ(BVH)とサウンドを同期してProcessingで再生する 
     7ことを試してみます。 
     8 
     9===== データとサンプルコード ======= 
     10http://www.perfume-global.com/ からモーションキャプチャデータ(bvh)とサウンド(wav)データを 
     11入手します。また、Processingのサンプルコードもダウンロードします。サンプルコードには、 
     12processingからBVHファイルを読み込むためのライブラリが含まれています。BVHは標準ではProcessingで 
     13読める様にはなっていないので、このライブラリは必須です。 
     14 
     15サウンドとキャプチャデータを同期再生させるために、ダウンロードしたサンプルのスケッチを以下の様に書き換えます。 
     16 
     17 import ddf.minim.*; 
     18 
     19 BvhParser parserA = new BvhParser(); 
     20 PBvh bvh1, bvh2, bvh3; 
     21 
     22 AudioPlayer player; 
     23 Minim minim; 
     24 
     25 public void setup() 
     26 { 
     27  size(1280, 720, P3D); 
     28  background(0); 
     29  noStroke(); 
     30  frameRate(40); 
     31 
     32  bvh1 = new PBvh(loadStrings("kashiyuka.bvh")); 
     33  bvh2 = new PBvh(loadStrings("nocchi.bvh")); 
     34  bvh3 = new PBvh(loadStrings("aachan.bvh")); 
     35   
     36  minim = new Minim(this); 
     37  player = minim.loadFile("Perfume_globalsite_sound.wav");  
     38   
     39  player.play(); 
     40  player.loop(); 
     41 } 
     42 
     43 public void draw() 
     44 { 
     45  int currentTime = player.position(); 
     46   
     47  background(color(255,255,128)); 
     48 
     49  //camera 
     50   
     51  float _cos = cos(currentTime / 5000.f); 
     52   
     53  float _sin = sin(currentTime / 5000.f); 
     54   
     55  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); 
     56 
     57  //ground  
     58   
     59  fill(color(0)); 
     60  stroke(127); 
     61  line(width/2.0f, height/2.0f, -30, width/2.0f, height/2.0f, 30); 
     62  stroke(127); 
     63  line(width/2.0f-30, height/2.0f, 0, width/2.0f + 30, height/2.0f, 0); 
     64  stroke(255); 
     65  pushMatrix(); 
     66  translate(width/2, height/2-10, 0); 
     67  rotateX(PI); 
     68  sphereDetail(10); 
     69  lights(); 
     70  directionalLight(100, 100, 100, -1, -1, 0); 
     71 
     72  //model 
     73 
     74  bvh1.update(currentTime); 
     75  bvh2.update(currentTime); 
     76  bvh3.update(currentTime); 
     77 
     78  bvh1.draw(); 
     79  bvh2.draw(); 
     80  bvh3.draw(); 
     81  popMatrix(); 
     82 }