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


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

--

Legend:

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

    v1 v2  
    77ことを試してみます。 
    88 
    9 ===== データとサンプルコード ======= 
     9===== データとサンプルコード ===== 
    1010http://www.perfume-global.com/ からモーションキャプチャデータ(bvh)とサウンド(wav)データを 
    1111入手します。また、Processingのサンプルコードもダウンロードします。サンプルコードには、 
    1212processingからBVHファイルを読み込むためのライブラリが含まれています。BVHは標準ではProcessingで 
    1313読める様にはなっていないので、このライブラリは必須です。 
     14 
     15===== 同期再生のためのスケッチ ===== 
    1416 
    1517サウンドとキャプチャデータを同期再生させるために、ダウンロードしたサンプルのスケッチを以下の様に書き換えます。 
     
    8183  popMatrix(); 
    8284 } 
     85 
     86これで、アニメーションとサウンドが同期して再生されます。肝は、''int currentTime = player.position(); ''で再生音の時間的なポジションを入手して、 
     87アニメーション画像の変更をこの時間でもって指定する ''  bvh1.update(currentTime);''ところです。 
     88 
     89==== processing version 3(beta) 対応 ==== 
     90上記のProcessingはProcessingの現行バージョン(2)で動作することを確認しています。 
     91次期バージョンのProcessing 3ではサウンド関係のライブラリが入れ替わっており、Minimライブラリは標準ライブラリから外れています。 
     92代って sound ツールが導入されているようです。色々と試してみて、一応Processing 3でも同期再生ができましたので、参考までにスケッチを載せておきます。 
     93 
     94  import processing.sound.*; 
     95 
     96  SoundFile player; 
     97 
     98  BvhParser parserA = new BvhParser(); 
     99  PBvh bvh1, bvh2, bvh3; 
     100 
     101  public void setup() 
     102  { 
     103    size( 1280, 720, P3D ); 
     104    background( 0 ); 
     105    noStroke(); 
     106    frameRate( 40 );//not 30 but 40 
     107     
     108    bvh1 = new PBvh( loadStrings( "bvhfiles/aachan.bvh" ) ); 
     109    bvh2 = new PBvh( loadStrings( "bvhfiles/kashiyuka.bvh" ) ); 
     110    bvh3 = new PBvh( loadStrings( "bvhfiles/nocchi.bvh" ) ); 
     111 
     112    //minim = new Minim(this); 
     113    //player = minim.loadFile("Perfume_globalsite_sound.wav"); 
     114    player =new SoundFile(this,"Perfume_globalsite_sound.wav"); 
     115    //player.play(); 
     116 
     117    player.loop(); 
     118  } 
     119 
     120public void draw() 
     121{ 
     122  background( 0 ); 
     123   
     124  //camera 
     125  float _cos = cos(millis() / 5000.f); 
     126  float _sin = sin(millis() / 5000.f); 
     127  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); 
     128   
     129  //ground  
     130  fill( color( 255 )); 
     131  stroke(127); 
     132  line(width/2.0f, height/2.0f, -30, width/2.0f, height/2.0f, 30); 
     133  stroke(127); 
     134  line(width/2.0f-30, height/2.0f, 0, width/2.0f + 30, height/2.0f, 0); 
     135  stroke(255); 
     136  pushMatrix(); 
     137  translate( width/2, height/2-10, 0); 
     138  scale(-1, -1, -1); 
     139   
     140  //model 
     141  bvh1.update( millis() ); 
     142  bvh2.update( millis() ); 
     143  bvh3.update( millis() ); 
     144  bvh1.draw(); 
     145  bvh2.draw(); 
     146  bvh3.draw(); 
     147  popMatrix(); 
     148} 
     149 
     150void stop() 
     151{ 
     152  player.stop(); 
     153  //minim.stop(); 
     154 
     155  super.stop(); 
     156} 
     157