Package com.sun.j3d.audioengines.javasound

Source Code of com.sun.j3d.audioengines.javasound.JSClip

/*     */ package com.sun.j3d.audioengines.javasound;
/*     */
/*     */ import javax.sound.sampled.AudioInputStream;
/*     */ import javax.sound.sampled.AudioSystem;
/*     */ import javax.sound.sampled.Clip;
/*     */ import javax.sound.sampled.DataLine;
/*     */ import javax.sound.sampled.DataLine.Info;
/*     */ import javax.sound.sampled.LineEvent;
/*     */ import javax.sound.sampled.LineEvent.Type;
/*     */
/*     */ class JSClip extends JSChannel
/*     */ {
/*     */   Clip line;
/*  36 */   Clip otherChannel = null;
/*     */
/*  40 */   Clip reverbChannel = null;
/*     */
/*     */   DataLine initDataLine(AudioInputStream ais)
/*     */   {
/*     */     try
/*     */     {
/*  62 */       this.audioFormat = ais.getFormat();
/*     */
/*  74 */       DataLine.Info info = new DataLine.Info(Clip.class, this.audioFormat);
/*     */
/*  76 */       this.line = ((Clip)AudioSystem.getLine(info));
/*     */
/*  89 */       this.line.open(ais);
/*     */
/*  96 */       this.line.start();
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 105 */       return null;
/*     */     }
/* 107 */     return this.line;
/*     */   }
/*     */
/*     */   boolean startSamples(int loopCount, float leftGain, float rightGain, int leftDelay, int rightDelay)
/*     */   {
/* 138 */     if ((this.otherChannel == null) || (this.reverbChannel == null)) {
/* 139 */       startSample(loopCount, leftGain, leftDelay);
/*     */     }
/*     */
/* 145 */     if (this.ais == null)
/*     */     {
/* 150 */       return false;
/*     */     }
/*     */
/* 154 */     Clip leftLine = this.line;
/* 155 */     Clip rightLine = this.otherChannel;
/*     */
/* 170 */     double ZERO_EPS = 0.0039D;
/* 171 */     double leftVolume = leftGain;
/* 172 */     double rightVolume = rightGain;
/*     */
/* 177 */     this.startTime = System.currentTimeMillis();
/*     */     try
/*     */     {
/* 200 */       this.line.loop(loopCount);
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 208 */       this.startTime = 0L;
/* 209 */       return false;
/*     */     }
/*     */
/* 214 */     return true;
/*     */   }
/*     */
/*     */   boolean startSample(int loopCount, float gain, int delay)
/*     */   {
/* 235 */     boolean returnVal = startSamples(loopCount, gain, gain, 0, 0);
/* 236 */     return returnVal;
/*     */   }
/*     */
/*     */   int stopSample()
/*     */   {
/* 243 */     this.line.close();
/* 244 */     this.startTime = 0L;
/* 245 */     return 0;
/*     */   }
/*     */
/*     */   int stopSamples()
/*     */   {
/* 254 */     this.line.close();
/* 255 */     this.startTime = 0L;
/* 256 */     return 0;
/*     */   }
/*     */
/*     */   public void update(LineEvent event)
/*     */   {
/* 263 */     if (event.getType().equals(LineEvent.Type.STOP)) {
/* 264 */       this.line.close();
/*     */     }
/* 266 */     else if (!event.getType().equals(LineEvent.Type.CLOSE));
/*     */   }
/*     */ }

/* Location:           Z:\System\Library\Java\Extensions\j3daudio.jar
* Qualified Name:     com.sun.j3d.audioengines.javasound.JSClip
* JD-Core Version:    0.6.2
*/
TOP

Related Classes of com.sun.j3d.audioengines.javasound.JSClip

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.