Mercurial > jmeCapture
view src/com/aurellem/capture/Capture.java @ 33:c4bfbf5d090e
starting to get something that can percieve sound
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 30 Oct 2011 13:57:16 -0700 |
parents | 5f616cc420dd |
children | 784a3f4e6202 |
line wrap: on
line source
1 package com.aurellem.capture;3 import java.io.File;4 import java.io.IOException;5 import java.util.concurrent.Callable;7 import com.aurellem.capture.audio.MultiListener;8 import com.aurellem.capture.audio.WaveFileWriter;9 import com.aurellem.capture.video.AVIVideoRecorder;10 import com.aurellem.capture.video.AbstractVideoRecorder;11 import com.aurellem.capture.video.XuggleVideoRecorder;12 import com.jme3.app.Application;13 import com.jme3.audio.AudioRenderer;14 import com.jme3.renderer.ViewPort;15 import com.jme3.scene.Spatial;16 import com.jme3.system.AppSettings;18 public class Capture {20 public static void captureVideo(final Application app, final File file) throws IOException{22 final AbstractVideoRecorder videoRecorder;23 // The XuggleVideoRecorder is better than the AVIVideoRecorder in every way24 // except for ease of installation. The excellent work by Werner Randelshofer25 // is used as a fallback option. Please visit http://www.xuggle.com/ to learn26 // how to set up the XuggleVideoRecorder.28 if (file.getCanonicalPath().endsWith(".avi")){29 videoRecorder = new AVIVideoRecorder(file);}30 else { videoRecorder = new XuggleVideoRecorder(file);}32 Callable<Object> thunk = new Callable<Object>(){33 public Object call(){35 ViewPort viewPort =36 app.getRenderManager()37 .createPostView("aurellem record", app.getCamera());39 viewPort.setClearFlags(false, false, false);41 // get GUI node stuff42 for (Spatial s : app.getGuiViewPort().getScenes()){43 viewPort.attachScene(s);44 }46 app.getStateManager().attach(videoRecorder);47 viewPort.addProcessor(videoRecorder);48 return null;49 }50 };51 app.enqueue(thunk);52 }55 public static void captureAudio(final Application app, final File file) throws IOException{56 AppSettings settings = new AppSettings(true);57 settings.setAudioRenderer("Send");58 app.setSettings(settings);59 final WaveFileWriter writer = new WaveFileWriter(file);61 Callable<Object> thunk = new Callable<Object>(){62 public Object call(){63 AudioRenderer ar = app.getAudioRenderer();64 if (ar instanceof MultiListener){65 MultiListener ml = (MultiListener)ar;66 ml.registerSoundProcessor(writer);67 }68 return null;69 }70 };72 app.enqueue(thunk);73 }75 }