VisClient/org/hfbk/vis/visnode/VisAudio.java

Go to the documentation of this file.
00001 package org.hfbk.vis.visnode;
00002 
00003 import org.dronus.graph.Node;
00004 import org.hfbk.vid.VideoFetcher;
00005 import org.lwjgl.opengl.GL11;
00006 import org.lwjgl.util.vector.Vector3f;
00007 
00008 
00015 public class VisAudio extends Sound {
00016         
00017         
00018         VideoFetcher fetcher;
00019         String url;
00023         boolean playing=true;
00024         
00025         
00026         
00027         
00028         final int SAMPLE_STEP=150;
00029         short[] samples;
00030         
00031         int ringpos=0;
00032         final int RING_LENGTH=100;
00033         // a ring buffer for past sample storage
00034         final short[] ring=new short[RING_LENGTH];
00035         
00036         public VisAudio(Node n, Vector3f pos) {
00037                 super("");
00038                 this.position=pos;
00039                 // 
00040                 fetcher=new VideoFetcher(n.text);
00041         }
00042 
00043         void renderSelf() {
00044                 super.renderSelf();
00045                 
00046                 if (source==0 && fetcher.streamer!=null){
00047                         fetcher.streamer.start();
00048                         source=fetcher.streamer.getAudioSource();
00049                 }
00050                 GL11.glDisable(GL11.GL_TEXTURE_2D);
00051                 GL11.glColor3f(1,1,1);
00052                 
00053                 
00054         /*      if (samples!=null){
00055                         int samplepos=(int)(AL10.alGetSourcef(source,AL11.AL_SAMPLE_OFFSET)/SAMPLE_STEP);
00056                         
00057                         if (samplepos<samples.length)                           
00058                                 ring[ringpos]=samples[samplepos];
00059                         else
00060                                 ring[ringpos]=0;
00061                 */      
00062                         for (int i=1; i<100; i++){
00063                                 float y;
00064                                 
00065                                 y=ring[(ringpos-i+RING_LENGTH)%RING_LENGTH]*.0001f;
00066                                  
00067                                 float r=i/5f;
00068                                 
00069                         //      if (Math.abs(y)>.01){
00070                                 //      GL11.glColor4f(1,1,1,  1-i/130f);
00071                                         GL11.glBegin(GL11.GL_LINE_LOOP);
00072                                                 for (float a=0; a<2*Math.PI; a+=.1f)
00073                                                         GL11.glVertex3f((float)Math.sin(a)*r, y, (float)Math.cos(a)*r);
00074                                         GL11.glEnd();
00075                         //      }
00076                         }
00077         //      }
00078                 ringpos++; ringpos%=RING_LENGTH;
00079         }
00080 }

Generated on Tue Apr 7 17:57:21 2009 for visclient by  doxygen 1.5.1