Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

ch.laoe.audio
Class Audio  view Audio download Audio.java

java.lang.Object
  extended bych.laoe.audio.Audio
All Implemented Interfaces:
java.lang.Runnable

public class Audio
extends java.lang.Object
implements java.lang.Runnable

This file is part of LAoE. LAoE is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. LAoE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with LAoE; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Class: Audio Autor: olivier gäumann, neuchâtel (switzerland) JDK: 1.3 Desctription: encapsulates all public audio functions. If you find some strange comments, excuse our cat "moustique". He also likes my computer. History: Date: Description: Autor: 25.08.00 erster Entwurf oli4 14.10.00 neues Audio-Framework oli4 20.11.00 new stream-technic oli4 30.03.01 exit from thread on destroy oli4 20.09.01 forwind/rewind implemented oli4 20.03.02 looping mode for play and capture oli4


Nested Class Summary
static class Audio.FileTypeLaoe
           
 
Field Summary
private  java.lang.Thread audioThread
           
private  ch.laoe.audio.capture.ACapture capture
           
private  ch.laoe.clip.ALayer captureLayer
           
private  int captureOffset
           
private static int capturePacketSize
           
private  ch.laoe.clip.AClip clip
           
private  javax.sound.sampled.AudioFormat.Encoding encoding
           
private  java.io.File file
           
private  AFileOptions fileOptions
           
private  javax.sound.sampled.AudioFileFormat.Type fileType
           
static Audio.FileTypeLaoe fileTypeLaoe
           
private  ch.laoe.clip.ALayer flattenedLayer
           
private static int FORWIND
           
private  AudioListener listener
           
private  int loopEndPointer
           
private  boolean looping
           
private  int loopStartPointer
           
private  java.lang.Object monitor
           
private static int OFFWIND
           
private  int oldPeakLevelIndex
           
static int PAUSE
           
static int PLAY
           
private  ch.laoe.audio.play.APlay player
           
private  ch.laoe.clip.ALayer playLayer
           
private  int playOffset
           
private static int playPacketSize
           
private  int playPointer
           
protected  AudioPlotter plotter
           
static int REC
           
private static int REWIND
           
private  boolean running
           
private  int state
           
private  int stateBeforePause
          start pause.
static int STOP
           
private  int winding
           
 
Constructor Summary
Audio(ch.laoe.clip.AClip clip)
          constructor
 
Method Summary
 void changeSampleRate(float sr)
          changes the samplerate on the fly!
static AFileOptions createFileOptions(java.lang.String extension)
           
 void destroy()
          destroys the running tasks.
private  void doWait()
           
private  void fireAudioEvent()
           
 void forwind()
          forwind
static javax.sound.sampled.AudioFormat.Encoding[] getAllEncodings()
           
static javax.sound.sampled.AudioFileFormat.Type[] getAllFileTypes()
           
static java.lang.String getAudioSystemInfo()
          returns informations about the audio-system
static int getCaptureBlockSize()
           
 ch.laoe.clip.AClip getClip()
           
 javax.sound.sampled.AudioFormat.Encoding getEncoding()
           
 java.io.File getFile()
          get the current file
 AFileOptions getFileOptions()
           
 javax.sound.sampled.AudioFileFormat.Type getFileType()
           
 int getLoopEndPointer()
          get loop end pointer
 int getLoopStartPointer()
          get loop start pointer
 float getPeakLevel(int channelIndex)
           
static int getPlayBlockSize()
           
 int getPlayPointer()
          get play pointer
 AudioPlotter getPlotter()
          returns the plotter
 int getState()
           
 boolean isActive()
           
 boolean isLooping()
           
 void limitLoopPointers()
          rearrange loop-pointer to valid values
private  int limitPointerRange(int p)
           
 void noWinding()
          rewind
private  void onPlay()
           
private  void onRec()
           
private  void onWinding()
           
 void open(java.io.File f)
          open a soundfile, convert to a AClip.
 void pause()
           
 void play()
          start playing sound
private  void prepareLayer()
           
 void rec()
          start record sound
 void rewind()
          rewind
 void run()
          This method will be called by whoever wishes to run your class implementing Runnable.
 boolean save()
          save the current AClip in the current file.
 void saveAs(java.io.File f)
          ¨ äöööööööööööööööööööö save the current AClip in a new file
 void setAudioListener(AudioListener l)
          set unique audio-listener
static void setCaptureBlockSize(int s)
           
 void setEncoding(javax.sound.sampled.AudioFormat.Encoding e)
           
private  void setFile(java.io.File f)
          set the current file
 void setFileOptions(AFileOptions fileOptions)
           
 void setFileType(javax.sound.sampled.AudioFileFormat.Type ft)
           
 void setFileType(java.lang.String extension)
           
 void setLoopEndPointer(int p)
          set loop end pointer
 void setLooping(boolean l)
           
 void setLoopStartPointer(int p)
          set loop start pointer
static void setPlayBlockSize(int s)
           
 void setPlayPointer(int p)
          set play pointer
private  void sleep(int t)
           
 void stop()
          stop playing/looping/recording sound
private  void wakeup()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clip

private ch.laoe.clip.AClip clip

flattenedLayer

private ch.laoe.clip.ALayer flattenedLayer

fileType

private javax.sound.sampled.AudioFileFormat.Type fileType

fileTypeLaoe

public static Audio.FileTypeLaoe fileTypeLaoe

fileOptions

private AFileOptions fileOptions

encoding

private javax.sound.sampled.AudioFormat.Encoding encoding

file

private java.io.File file

audioThread

private java.lang.Thread audioThread

running

private boolean running

monitor

private java.lang.Object monitor

looping

private boolean looping

STOP

public static final int STOP
See Also:
Constant Field Values

PLAY

public static final int PLAY
See Also:
Constant Field Values

PAUSE

public static final int PAUSE
See Also:
Constant Field Values

REC

public static final int REC
See Also:
Constant Field Values

state

private int state

player

private ch.laoe.audio.play.APlay player

playOffset

private int playOffset

playLayer

private ch.laoe.clip.ALayer playLayer

playPacketSize

private static int playPacketSize

winding

private int winding

FORWIND

private static final int FORWIND
See Also:
Constant Field Values

REWIND

private static final int REWIND
See Also:
Constant Field Values

OFFWIND

private static final int OFFWIND
See Also:
Constant Field Values

capture

private ch.laoe.audio.capture.ACapture capture

captureOffset

private int captureOffset

captureLayer

private ch.laoe.clip.ALayer captureLayer

capturePacketSize

private static int capturePacketSize

stateBeforePause

private int stateBeforePause
start pause. Pause is terminated by playing or looping further.


listener

private AudioListener listener

oldPeakLevelIndex

private int oldPeakLevelIndex

playPointer

private int playPointer

loopStartPointer

private int loopStartPointer

loopEndPointer

private int loopEndPointer

plotter

protected AudioPlotter plotter
Constructor Detail

Audio

public Audio(ch.laoe.clip.AClip clip)
constructor

Method Detail

getClip

public ch.laoe.clip.AClip getClip()

prepareLayer

private void prepareLayer()

getFileType

public javax.sound.sampled.AudioFileFormat.Type getFileType()

setFileType

public void setFileType(javax.sound.sampled.AudioFileFormat.Type ft)

setFileType

public void setFileType(java.lang.String extension)

getAllFileTypes

public static javax.sound.sampled.AudioFileFormat.Type[] getAllFileTypes()

createFileOptions

public static AFileOptions createFileOptions(java.lang.String extension)

setFileOptions

public void setFileOptions(AFileOptions fileOptions)

getFileOptions

public AFileOptions getFileOptions()

getAudioSystemInfo

public static java.lang.String getAudioSystemInfo()
returns informations about the audio-system


getEncoding

public javax.sound.sampled.AudioFormat.Encoding getEncoding()

setEncoding

public void setEncoding(javax.sound.sampled.AudioFormat.Encoding e)

getAllEncodings

public static javax.sound.sampled.AudioFormat.Encoding[] getAllEncodings()

open

public void open(java.io.File f)
          throws AudioException
open a soundfile, convert to a AClip.


save

public boolean save()
             throws AudioException
save the current AClip in the current file. If no current file is defined, it returns false, else true.


saveAs

public void saveAs(java.io.File f)
            throws AudioException
¨ äöööööööööööööööööööö save the current AClip in a new file


setFile

private void setFile(java.io.File f)
set the current file


getFile

public java.io.File getFile()
get the current file


run

public void run()
Description copied from interface: java.lang.Runnable
This method will be called by whoever wishes to run your class implementing Runnable. Note that there are no restrictions on what you are allowed to do in the run method, except that you cannot throw a checked exception.

Specified by:
run in interface java.lang.Runnable

sleep

private void sleep(int t)

destroy

public void destroy()
destroys the running tasks. call when not using anymore.


doWait

private void doWait()

wakeup

private void wakeup()

setLooping

public void setLooping(boolean l)

isLooping

public boolean isLooping()

setPlayBlockSize

public static void setPlayBlockSize(int s)

getPlayBlockSize

public static int getPlayBlockSize()

play

public void play()
          throws AudioException
start playing sound


onPlay

private void onPlay()

changeSampleRate

public void changeSampleRate(float sr)
changes the samplerate on the fly!


forwind

public void forwind()
forwind


rewind

public void rewind()
rewind


noWinding

public void noWinding()
rewind


onWinding

private void onWinding()

stop

public void stop()
stop playing/looping/recording sound


setCaptureBlockSize

public static void setCaptureBlockSize(int s)

getCaptureBlockSize

public static int getCaptureBlockSize()

rec

public void rec()
         throws AudioException
start record sound


onRec

private void onRec()

pause

public void pause()

isActive

public boolean isActive()

getState

public int getState()

setAudioListener

public void setAudioListener(AudioListener l)
set unique audio-listener


fireAudioEvent

private void fireAudioEvent()

getPeakLevel

public float getPeakLevel(int channelIndex)

limitPointerRange

private int limitPointerRange(int p)

setPlayPointer

public void setPlayPointer(int p)
set play pointer


getPlayPointer

public int getPlayPointer()
get play pointer


setLoopStartPointer

public void setLoopStartPointer(int p)
set loop start pointer


getLoopStartPointer

public int getLoopStartPointer()
get loop start pointer


setLoopEndPointer

public void setLoopEndPointer(int p)
set loop end pointer


getLoopEndPointer

public int getLoopEndPointer()
get loop end pointer


limitLoopPointers

public void limitLoopPointers()
rearrange loop-pointer to valid values


getPlotter

public AudioPlotter getPlotter()
returns the plotter