Package ipsk.audio.impl.j2audio
Class J2AudioController
- java.lang.Object
- 
- ipsk.audio.impl.j2audio.J2AudioController
 
- 
- All Implemented Interfaces:
- AudioController,- CaptureListener,- PlaybackListener
 
 public class J2AudioController extends java.lang.Object implements AudioController, CaptureListener, PlaybackListener The main class to manage multi-line audio recording and playback.- looks for matching audio mixers and lines
- opens the lines
- handles line-synchronized starting and stopping
 - Author:
- klausj
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface ipsk.audio.AudioControllerAudioController.CaptureStatus, AudioController.PlaybackStatus
 
- 
 - 
Field Summary- 
Fields inherited from interface ipsk.audio.AudioControllerAUDIO_END, DISABLE_CAPTURE, FULLDUPLEX, HOLD_OPEN, OPEN_ON_DEMAND, POS_UNKNOWN
 
- 
 - 
Constructor SummaryConstructors Constructor Description J2AudioController()Default constructor.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddAudioControllerListener(AudioControllerListener acl)Adds controller listener.voidclose()closes this sessionprotected voidcloseCapture()protected voidclosePlayback()voidconfigure()Configures a session.javax.sound.sampled.AudioFormatgetAudioFormat()get current selected audio formatAudioController.CaptureStatusgetCaptureStatus()Get status of capture engine.float[]getLevels()gets current normalized linear audio levels maximum level is 1.0 representing 0dB minimum level is 0 array has channels * numLines entrieslonggetMode()Returns mode flags.intgetNumLines()Get number of lines.javax.sound.sampled.AudioFormatgetPlaybackAudioFormat()Get audio format for playback.AudioSource[]getPlaybackAudioSources()Get playback audio sources.java.io.File[]getPlaybackFiles()Deprecated.Use getPlaybackURLs instead !longgetPlaybackFrameLength()Gets length of largest playback file in frames, -1 if not availablelonggetPlaybackFramePosition()Get playback position.longgetPlaybackStartFramePosition()Gets the start position.AudioController.PlaybackStatusgetPlaybackStatus()Get status of playback engine.longgetPlaybackStopFramePosition()Gets the stop position.java.lang.StringgetProperty(java.lang.String propertyName)Get an implementation specific property.java.lang.StringgetPropertyDescription(java.lang.String propertyName)Get a description of the property.java.lang.String[]getPropertyNames()Get an implementation specific property names.java.io.File[]getRecordingFiles()Get recording files.longgetRecordingFramePosition()Get recording position.java.io.OutputStream[]getRecordingOutputStreams()javax.sound.sampled.Mixer.InfogetSourceMixerInfo()Get current used source mixer (playback) info.javax.sound.sampled.Mixer.InfogetTargetMixerInfo()Get current used target mixer (recording) info.booleanisOverwrite()Gets overwrite flag.booleanisPlaybackRandomPositioningSupported()Get random positioning capability of the playback engine.static voidmain(java.lang.String[] args)Creates a controller.voidopen()Opens the session.voidpausePlayback()Pauses playback.voidplay()Plays the audio files(s).voidplayed(Playback pb)voidpreparePlayback()Prepares playback.voidprepareRecording()Prepares recording.booleanprepareRecording(boolean forceOverwrite)voidremoveAudioControllerListener(AudioControllerListener acl)Removes controller listener.voidsetAudioFormat(javax.sound.sampled.AudioFormat format)Use audio format audioFormat..voidsetMode(int mode)voidsetMode(long modeBits)voidsetNumLines(int numLines)Use numLines lines.voidsetOverwrite(boolean overwrite)Sets overwrite flag.voidsetPlaybackAudioSources(AudioSource[] audioSources)Set playback audio sources.voidsetPlaybackFiles(java.io.File[] files)Set playback files.longsetPlaybackFramePosition(long newPosition)Sets the new frame position of playback.voidsetPlaybackInputStreams(java.io.InputStream[] inputStreams)Sets playback Inputstreams to use.longsetPlaybackStartFramePosition(long startPosition)Sets the start position.longsetPlaybackStopFramePosition(long stopPosition)Sets the stop position.voidsetPlaybackURLs(java.net.URL[] urls)Set playback URL's.voidsetProperty(java.lang.String arg0, java.lang.String arg1)Set a property for a specific implementation.voidsetRecordingFiles(java.io.File[] files)Sets recording files to use.voidsetRecordingOutputStreams(java.io.OutputStream[] streams)Sets recording OutputStreams to use.voidsetSettings()Call the graphical user interface of the controller implementation to set the configuration.voidsetSourceMixer(javax.sound.sampled.Mixer mixer)Sets playback mixer.voidsetSourceMixer(javax.sound.sampled.Mixer.Info mixerInfo)Use the source mixer (playback) described by mixerInfo.voidsetSourceMixerName(java.lang.String string)Use the source mixer (playback) with the given name.voidsetTargetMixer(javax.sound.sampled.Mixer mixer)Sets recording mixer.voidsetTargetMixer(javax.sound.sampled.Mixer.Info mixerInfo)Use the target mixer (recording) described by mixerInfo.voidsetTargetMixerName(java.lang.String targetMixerName)Use the target mixer (recording) with the given name.voidstartCapture()Starts the capturing of data.voidstartDuplex()voidstartPlayback()Starts the playback.voidstartRecording()Starts recording to the given files.voidstop()voidstopCapture()Stops capturing.voidstopPlayback()Stops playback.voidstopRecording()Stops recording. the method blocks until all files are writtenvoidupdate(Capture src, CaptureStatus cs)voidupdate(Playback p, Playback.PlayerStatus ps)protected voidupdateListeners(AudioController.PlaybackStatus pe, AudioController.CaptureStatus ce)
 
- 
- 
- 
Method Detail- 
setNumLinespublic void setNumLines(int numLines) Description copied from interface:AudioControllerUse numLines lines. For each line a recording file will be created.- Specified by:
- setNumLinesin interface- AudioController
- Parameters:
- numLines- number of lines to use
 
 - 
setSourceMixerpublic void setSourceMixer(javax.sound.sampled.Mixer.Info mixerInfo) Description copied from interface:AudioControllerUse the source mixer (playback) described by mixerInfo.- Specified by:
- setSourceMixerin interface- AudioController
- Parameters:
- mixerInfo- the info (name) of the mixer
 
 - 
setModepublic void setMode(int mode) 
 - 
configurepublic void configure() throws AudioControllerExceptionDescription copied from interface:AudioControllerConfigures a session.- Specified by:
- configurein interface- AudioController
- Throws:
- AudioControllerException
 
 - 
openpublic void open() throws AudioControllerExceptionDescription copied from interface:AudioControllerOpens the session.- Specified by:
- openin interface- AudioController
- Throws:
- AudioControllerException
 
 - 
prepareRecordingpublic void prepareRecording() throws AudioControllerExceptionDescription copied from interface:AudioControllerPrepares recording.- Specified by:
- prepareRecordingin interface- AudioController
- Throws:
- AudioControllerException
 
 - 
prepareRecordingpublic boolean prepareRecording(boolean forceOverwrite) throws AudioControllerException- Throws:
- AudioControllerException
 
 - 
startRecordingpublic void startRecording() Description copied from interface:AudioControllerStarts recording to the given files.- Specified by:
- startRecordingin interface- AudioController
- See Also:
- AudioController.prepareRecording()
 
 - 
stopRecordingpublic void stopRecording() throws AudioControllerExceptionDescription copied from interface:AudioControllerStops recording. the method blocks until all files are written- Specified by:
- stopRecordingin interface- AudioController
- Throws:
- AudioControllerException
 
 - 
playedpublic void played(Playback pb) 
 - 
preparePlaybackpublic void preparePlayback() throws AudioControllerExceptionDescription copied from interface:AudioControllerPrepares playback.- Specified by:
- preparePlaybackin interface- AudioController
- Throws:
- AudioControllerException
 
 - 
getLevelspublic float[] getLevels() gets current normalized linear audio levels maximum level is 1.0 representing 0dB minimum level is 0 array has channels * numLines entries- Specified by:
- getLevelsin interface- AudioController
- Returns:
- current audio levels
 
 - 
closepublic void close() closes this session- Specified by:
- closein interface- AudioController
 
 - 
closePlaybackprotected void closePlayback() 
 - 
closeCaptureprotected void closeCapture() 
 - 
addAudioControllerListenerpublic void addAudioControllerListener(AudioControllerListener acl) Description copied from interface:AudioControllerAdds controller listener.- Specified by:
- addAudioControllerListenerin interface- AudioController
- Parameters:
- acl- controller listener
 
 - 
removeAudioControllerListenerpublic void removeAudioControllerListener(AudioControllerListener acl) Description copied from interface:AudioControllerRemoves controller listener.- Specified by:
- removeAudioControllerListenerin interface- AudioController
- Parameters:
- acl- controller listener
 
 - 
updateListenersprotected void updateListeners(AudioController.PlaybackStatus pe, AudioController.CaptureStatus ce) 
 - 
getAudioFormatpublic javax.sound.sampled.AudioFormat getAudioFormat() get current selected audio format- Specified by:
- getAudioFormatin interface- AudioController
- Returns:
- audio format
 
 - 
startPlaybackpublic void startPlayback() throws AudioControllerExceptionDescription copied from interface:AudioControllerStarts the playback.- Specified by:
- startPlaybackin interface- AudioController
- Throws:
- AudioControllerException
 
 - 
playpublic void play() throws AudioControllerExceptionPlays the audio files(s). (Blocking!) Blocks until the whole file is played.- Throws:
- AudioControllerException
 
 - 
pausePlaybackpublic void pausePlayback() Description copied from interface:AudioControllerPauses playback.- Specified by:
- pausePlaybackin interface- AudioController
 
 - 
stopPlaybackpublic void stopPlayback() Description copied from interface:AudioControllerStops playback.- Specified by:
- stopPlaybackin interface- AudioController
 
 - 
startCapturepublic void startCapture() Description copied from interface:AudioControllerStarts the capturing of data. Can be used to capture data from the line without writing to files- Specified by:
- startCapturein interface- AudioController
 
 - 
stopCapturepublic void stopCapture() Description copied from interface:AudioControllerStops capturing.- Specified by:
- stopCapturein interface- AudioController
 
 - 
stoppublic void stop() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
startDuplexpublic void startDuplex() throws AudioControllerException- Throws:
- AudioControllerException
 
 - 
getPlaybackFrameLengthpublic long getPlaybackFrameLength() Description copied from interface:AudioControllerGets length of largest playback file in frames, -1 if not available- Specified by:
- getPlaybackFrameLengthin interface- AudioController
- Returns:
- length of largest playback file in frames
 
 - 
getPlaybackFramePositionpublic long getPlaybackFramePosition() Description copied from interface:AudioControllerGet playback position.- Specified by:
- getPlaybackFramePositionin interface- AudioController
- Returns:
- current playback position in audio frames or POS_UNKNOWN (-1) if not supported
 
 - 
getRecordingFramePositionpublic long getRecordingFramePosition() Description copied from interface:AudioControllerGet recording position.- Specified by:
- getRecordingFramePositionin interface- AudioController
- Returns:
- current recording position in audio frames or -1 if not supported
 
 - 
setPlaybackFramePositionpublic long setPlaybackFramePosition(long newPosition) Description copied from interface:AudioControllerSets the new frame position of playback.- Specified by:
- setPlaybackFramePositionin interface- AudioController
- Parameters:
- newPosition- the requested position
- Returns:
- the actually set position or POS_UNKNOWN (-1) if not supported
 
 - 
setSettingspublic void setSettings() Description copied from interface:AudioControllerCall the graphical user interface of the controller implementation to set the configuration.- Specified by:
- setSettingsin interface- AudioController
 
 - 
getCaptureStatuspublic AudioController.CaptureStatus getCaptureStatus() Get status of capture engine.- Specified by:
- getCaptureStatusin interface- AudioController
- Returns:
- capture status
 
 - 
getPlaybackStatuspublic AudioController.PlaybackStatus getPlaybackStatus() Get status of playback engine.- Specified by:
- getPlaybackStatusin interface- AudioController
- Returns:
- playback status
 
 - 
getPlaybackFilespublic java.io.File[] getPlaybackFiles() Deprecated.Use getPlaybackURLs instead !Description copied from interface:AudioControllerGets playback files.the size of the array is equal the number of lines opened. - Specified by:
- getPlaybackFilesin interface- AudioController
- Returns:
- playback files array (returns alaways null !)
 
 - 
getRecordingFilespublic java.io.File[] getRecordingFiles() Get recording files.- Specified by:
- getRecordingFilesin interface- AudioController
- Returns:
- recording files array
 
 - 
setPlaybackFilespublic void setPlaybackFiles(java.io.File[] files) Set playback files.- Specified by:
- setPlaybackFilesin interface- AudioController
- Parameters:
- files-
 
 - 
setPlaybackURLspublic void setPlaybackURLs(java.net.URL[] urls) Set playback URL's.- Specified by:
- setPlaybackURLsin interface- AudioController
- Parameters:
- urls-
 
 - 
setPlaybackAudioSourcespublic void setPlaybackAudioSources(AudioSource[] audioSources) Set playback audio sources.- Specified by:
- setPlaybackAudioSourcesin interface- AudioController
- Parameters:
- audioSources- sources for playback
 
 - 
getPlaybackAudioSourcespublic AudioSource[] getPlaybackAudioSources() Get playback audio sources.- Returns:
- playback audio sources
 
 - 
setPlaybackInputStreamspublic void setPlaybackInputStreams(java.io.InputStream[] inputStreams) Description copied from interface:AudioControllerSets playback Inputstreams to use.the size of the array must equal the number of lines opened. - Specified by:
- setPlaybackInputStreamsin interface- AudioController
- Parameters:
- inputStreams- the inputstream array to play
 
 - 
setRecordingFilespublic void setRecordingFiles(java.io.File[] files) Description copied from interface:AudioControllerSets recording files to use.the size of the array must equal the number of lines opened. - Specified by:
- setRecordingFilesin interface- AudioController
- Parameters:
- files-
 
 - 
setRecordingOutputStreamspublic void setRecordingOutputStreams(java.io.OutputStream[] streams) Description copied from interface:AudioControllerSets recording OutputStreams to use.the size of the array must equal the number of lines opened. - Specified by:
- setRecordingOutputStreamsin interface- AudioController
- Parameters:
- streams- recording OutputStreams
 
 - 
getRecordingOutputStreamspublic java.io.OutputStream[] getRecordingOutputStreams() 
 - 
setAudioFormatpublic void setAudioFormat(javax.sound.sampled.AudioFormat format) Description copied from interface:AudioControllerUse audio format audioFormat..- Specified by:
- setAudioFormatin interface- AudioController
- Parameters:
- format-
 
 - 
isPlaybackRandomPositioningSupportedpublic boolean isPlaybackRandomPositioningSupported() Description copied from interface:AudioControllerGet random positioning capability of the playback engine.- Specified by:
- isPlaybackRandomPositioningSupportedin interface- AudioController
- Returns:
- random positioning capability
 
 - 
setSourceMixerpublic void setSourceMixer(javax.sound.sampled.Mixer mixer) Sets playback mixer.- Parameters:
- mixer-
 
 - 
setTargetMixerpublic void setTargetMixer(javax.sound.sampled.Mixer mixer) Sets recording mixer.- Parameters:
- mixer-
 
 - 
setTargetMixerNamepublic void setTargetMixerName(java.lang.String targetMixerName) Description copied from interface:AudioControllerUse the target mixer (recording) with the given name.- Specified by:
- setTargetMixerNamein interface- AudioController
- Parameters:
- targetMixerName- the name of the target mixer
 
 - 
getModepublic long getMode() Returns mode flags.- Specified by:
- getModein interface- AudioController
- Returns:
- mode
 
 - 
mainpublic static void main(java.lang.String[] args) Creates a controller. Usage: java J2AudioController [-f][-i][-r][-p] [recordfile] Example:java J2AudioController rrecords to Untitled.wav 44100kHz,16bit, stereo
 - 
setOverwritepublic void setOverwrite(boolean overwrite) Description copied from interface:AudioControllerSets overwrite flag. If the overwrite flag is set, existing recording files are overwritten without any exception or warning.- Specified by:
- setOverwritein interface- AudioController
- Parameters:
- overwrite- overwrite flag
 
 - 
isOverwritepublic boolean isOverwrite() Description copied from interface:AudioControllerGets overwrite flag. If the overwrite flag is set, existing recording files are overwritten without any exception or warning.- Specified by:
- isOverwritein interface- AudioController
- Returns:
- overwrite flag
 
 - 
setPlaybackStartFramePositionpublic long setPlaybackStartFramePosition(long startPosition) Description copied from interface:AudioControllerSets the start position. Used to play only a segment of an audio file.- Specified by:
- setPlaybackStartFramePositionin interface- AudioController
- Parameters:
- startPosition- position in audio frames from where to start
- Returns:
- the actually set start position
 
 - 
getPlaybackStartFramePositionpublic long getPlaybackStartFramePosition() Description copied from interface:AudioControllerGets the start position.- Specified by:
- getPlaybackStartFramePositionin interface- AudioController
- Returns:
- start position
 
 - 
setPlaybackStopFramePositionpublic long setPlaybackStopFramePosition(long stopPosition) Description copied from interface:AudioControllerSets the stop position. Used to play only a segment of an audio file. To play the whole audio file set the position to AUDIO_END (-1).- Specified by:
- setPlaybackStopFramePositionin interface- AudioController
- Parameters:
- stopPosition- position in audio frames to stop
- Returns:
- the actually set stop position
 
 - 
getPlaybackStopFramePositionpublic long getPlaybackStopFramePosition() Description copied from interface:AudioControllerGets the stop position.- Specified by:
- getPlaybackStopFramePositionin interface- AudioController
- Returns:
- stop position
 
 - 
updatepublic void update(Playback p, Playback.PlayerStatus ps) - Specified by:
- updatein interface- PlaybackListener
 
 - 
getNumLinespublic int getNumLines() Description copied from interface:AudioControllerGet number of lines.- Specified by:
- getNumLinesin interface- AudioController
- Returns:
- number of lines to use
 
 - 
getSourceMixerInfopublic javax.sound.sampled.Mixer.Info getSourceMixerInfo() Description copied from interface:AudioControllerGet current used source mixer (playback) info.- Specified by:
- getSourceMixerInfoin interface- AudioController
- Returns:
- mixerInfo the info of the source mixer
 
 - 
setTargetMixerpublic void setTargetMixer(javax.sound.sampled.Mixer.Info mixerInfo) Description copied from interface:AudioControllerUse the target mixer (recording) described by mixerInfo.- Specified by:
- setTargetMixerin interface- AudioController
- Parameters:
- mixerInfo- the info of the target mixer
 
 - 
getTargetMixerInfopublic javax.sound.sampled.Mixer.Info getTargetMixerInfo() Description copied from interface:AudioControllerGet current used target mixer (recording) info.- Specified by:
- getTargetMixerInfoin interface- AudioController
- Returns:
- mixerInfo the info (name) of the target mixer
 
 - 
setModepublic void setMode(long modeBits) - Specified by:
- setModein interface- AudioController
 
 - 
updatepublic void update(Capture src, CaptureStatus cs) - Specified by:
- updatein interface- CaptureListener
 
 - 
getPlaybackAudioFormatpublic javax.sound.sampled.AudioFormat getPlaybackAudioFormat() Description copied from interface:AudioControllerGet audio format for playback. The controller sets the audio format according to the set playback files. So it can differ from the chosen foprmat.- Specified by:
- getPlaybackAudioFormatin interface- AudioController
- Returns:
- audio format
 
 - 
getPropertyNamespublic java.lang.String[] getPropertyNames() Description copied from interface:AudioControllerGet an implementation specific property names.- Specified by:
- getPropertyNamesin interface- AudioController
- Returns:
- property names
 
 - 
getPropertyDescriptionpublic java.lang.String getPropertyDescription(java.lang.String propertyName) Description copied from interface:AudioControllerGet a description of the property.- Specified by:
- getPropertyDescriptionin interface- AudioController
- Returns:
- description
 
 - 
setPropertypublic void setProperty(java.lang.String arg0, java.lang.String arg1)Description copied from interface:AudioControllerSet a property for a specific implementation.- Specified by:
- setPropertyin interface- AudioController
 
 - 
getPropertypublic java.lang.String getProperty(java.lang.String propertyName) Description copied from interface:AudioControllerGet an implementation specific property.- Specified by:
- getPropertyin interface- AudioController
- Returns:
- value of the property or null if there is no such property
 
 - 
setSourceMixerNamepublic void setSourceMixerName(java.lang.String string) Description copied from interface:AudioControllerUse the source mixer (playback) with the given name.- Specified by:
- setSourceMixerNamein interface- AudioController
- Parameters:
- string-
 
 
- 
 
-