Package ipsk.audio.impl.j2audio2
Class J2AudioController2
- java.lang.Object
-
- ipsk.audio.impl.j2audio2.J2AudioController2
-
- All Implemented Interfaces:
AudioController2,CaptureListener,PlayerListener,UpdateListener<PlayerEvent>,java.util.EventListener
public class J2AudioController2 extends java.lang.Object implements AudioController2, PlayerListener, CaptureListener
Audiocontroller implementation.- Author:
- K.Jaensch, klausj@phonetik.uni-muenchen.de
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ipsk.audio.AudioController2
AudioController2.AudioController2Listener, AudioController2.AudioControllerEvent, AudioController2.DeviceType
-
-
Constructor Summary
Constructors Constructor Description J2AudioController2()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAudioController2Listener(AudioController2.AudioController2Listener acl)Adds controller listener.voidcloseCapture()Closes the capture line.voidclosePlayback()Closes the playback line.DeviceInfoconvertLegacyDeviceName(java.lang.String deviceName)javax.sound.sampled.AudioFileFormatgetAudioFileFormat()Get audio format.longgetCaptureFramePosition()Get recording position.LevelInfo[]getCaptureLevelInfos()Gets levels of all channels. maximum level is 1.0 representing 0dB
minimum level is 0
array has channels * numLines entriesjavax.sound.sampled.Mixer.Info[]getCaptureMixerInfos()Get infos of available capture mixers.java.util.List<DeviceProviderInfo>getDeviceProviderInfos()Get available device providers.DeviceProvidergetInstance(DeviceProviderInfo providerInfo)java.lang.LonggetMaxRecordingFrameLength()Get max recording length.javax.sound.sampled.AudioFormatgetPlaybackAudioFormat()Get audio format for playback.java.io.FilegetPlaybackFile()Gets playback files.longgetPlaybackFrameLength()Gets length of largest playback file in frames, -1 if not availablelonggetPlaybackFramePosition()Get playback position.LevelInfo[]getPlaybackLevelInfos()javax.sound.sampled.Mixer.Info[]getPlaybackMixerInfos()Get infos of available playback mixers.longgetPlaybackStartFramePosition()Gets the start position.longgetPlaybackStopFramePosition()Gets the stop position.floatgetPreferredCaptureLineBufferSizeMilliSeconds()Get preferred capture line buffer size.floatgetPreferredPlaybackLineBufferSizeMilliSeconds()Get preferred playback line buffer size.PrimaryRecordTargetgetPrimaryRecordTarget()Get the primary recording target.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.FilegetRecordingFile()Gets recording files.java.io.FilegetRecordingSessionInfoFile()Get the current used session info file.booleanisCaptureOpen()Check if capture engine is open.booleanisFileTransitionRecordingSupported()Get file transition capability.booleanisOverwrite()Gets overwrite flag.booleanisPlaybackRandomPositioningSupported()Get random positioning capability of the playback engine.booleanisSessionInfoHandlingSupported()Get support for recording session info file handling.voidopenCapture()Opens the capture line.voidopenPlayback()Opens the playback line.voidpausePlayback()Pauses playback.voidremoveAudioController2Listener(AudioController2.AudioController2Listener acl)Removes controller listener.voidsetCaptureDeviceByinfo(DeviceInfo deviceInfo)voidsetCaptureDeviceByName(java.lang.String deviceName)Use the target mixer (recording) with the given name.voidsetMaxRecordingFrameLength(java.lang.Long maxFrameLength)Set max recording length.voidsetOverwrite(boolean overwrite)Sets overwrite flag.voidsetPlaybackAudioSource(AudioSource source)voidsetPlaybackDeviceByInfo(DeviceInfo deviceInfo)voidsetPlaybackDeviceByName(java.lang.String deviceName)Use the source mixer (playback) with the given name.voidsetPlaybackFile(java.io.File playbackFile)Set playback file.longsetPlaybackFramePosition(long newPosition)Sets the new frame position of playback.voidsetPlaybackStartFramePosition(long startPosition)Sets the start position.voidsetPlaybackStopFramePosition(long stopPosition)Sets the stop position.voidsetPreferredCaptureLineBufferSizeMilliSeconds(float preferredCaptureLineBufferSizeMilliSeconds)Set preferred capture line buffer size.voidsetPreferredPlaybackLineBufferSizeMilliSeconds(float preferredPlaybackLineBufferSizeMilliSeconds)Set preferred playback line buffer size.voidsetPrimaryRecordTarget(PrimaryRecordTarget primaryRecordTarget)Set primary record target.voidsetProperty(java.lang.String propertyName, java.lang.String value)Set a property for a specific implementation.voidsetRecordingAudioFileFormat(javax.sound.sampled.AudioFileFormat audiofileFormat)Set audio file format for recording.voidsetRecordingFile(java.io.File recordingFile)Sets recording file.voidsetRecordingSessionInfoFile(java.io.File recordingSessionInfoFile)Set the current used session info file.voidstartCapture()Starts the capturing of data.voidstartPlayback()Starts the playback.voidstartRecording()Starts recording to the given files.voidstopCapture()Stops capturing.voidstopPlayback()Stops playback.voidstopRecording()Stops recording.booleansupportsDeviceProviders()voidupdate(CaptureEvent captureEvent)voidupdate(PlayerEvent playerEvent)protected voidupdateListeners(AudioController2.AudioControllerEvent ace)
-
-
-
Method Detail
-
getPlaybackMixerInfos
public javax.sound.sampled.Mixer.Info[] getPlaybackMixerInfos() throws AudioControllerExceptionDescription copied from interface:AudioController2Get infos of available playback mixers.- Specified by:
getPlaybackMixerInfosin interfaceAudioController2- Returns:
- playback mixer infos
- Throws:
AudioControllerException
-
getCaptureMixerInfos
public javax.sound.sampled.Mixer.Info[] getCaptureMixerInfos() throws AudioControllerExceptionDescription copied from interface:AudioController2Get infos of available capture mixers.- Specified by:
getCaptureMixerInfosin interfaceAudioController2- Returns:
- capture mixer infos
- Throws:
AudioControllerException
-
setPlaybackDeviceByName
public void setPlaybackDeviceByName(java.lang.String deviceName) throws AudioControllerExceptionDescription copied from interface:AudioController2Use the source mixer (playback) with the given name.- Specified by:
setPlaybackDeviceByNamein interfaceAudioController2- Parameters:
deviceName- the name of the source mixer- Throws:
AudioControllerException
-
setCaptureDeviceByName
public void setCaptureDeviceByName(java.lang.String deviceName) throws AudioControllerExceptionDescription copied from interface:AudioController2Use the target mixer (recording) with the given name.- Specified by:
setCaptureDeviceByNamein interfaceAudioController2- Parameters:
deviceName- the name of the target mixer- Throws:
AudioControllerException
-
getPlaybackAudioFormat
public javax.sound.sampled.AudioFormat getPlaybackAudioFormat()
Description copied from interface:AudioController2Get 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 interfaceAudioController2- Returns:
- audio format
-
openPlayback
public void openPlayback() throws AudioControllerExceptionDescription copied from interface:AudioController2Opens the playback line.- Specified by:
openPlaybackin interfaceAudioController2- Throws:
AudioControllerException
-
closePlayback
public void closePlayback() throws AudioControllerExceptionDescription copied from interface:AudioController2Closes the playback line.- Specified by:
closePlaybackin interfaceAudioController2- Throws:
AudioControllerException
-
openCapture
public void openCapture() throws AudioControllerExceptionDescription copied from interface:AudioController2Opens the capture line.- Specified by:
openCapturein interfaceAudioController2- Throws:
AudioControllerException
-
closeCapture
public void closeCapture() throws AudioControllerExceptionDescription copied from interface:AudioController2Closes the capture line.- Specified by:
closeCapturein interfaceAudioController2- Throws:
AudioControllerException
-
isCaptureOpen
public boolean isCaptureOpen()
Description copied from interface:AudioController2Check if capture engine is open.- Specified by:
isCaptureOpenin interfaceAudioController2- Returns:
- true if open
-
setPlaybackFile
public void setPlaybackFile(java.io.File playbackFile) throws AudioControllerExceptionDescription copied from interface:AudioController2Set playback file.- Specified by:
setPlaybackFilein interfaceAudioController2- Parameters:
playbackFile- the file to play- Throws:
AudioControllerException
-
getPlaybackFile
public java.io.File getPlaybackFile()
Description copied from interface:AudioController2Gets playback files.the size of the array is equal the number of lines opened.
- Specified by:
getPlaybackFilein interfaceAudioController2- Returns:
- the file array of playbackfiles set
-
setPlaybackAudioSource
public void setPlaybackAudioSource(AudioSource source) throws AudioControllerException
- Specified by:
setPlaybackAudioSourcein interfaceAudioController2- Throws:
AudioControllerException
-
setOverwrite
public void setOverwrite(boolean overwrite)
Description copied from interface:AudioController2Sets overwrite flag. If the overwrite flag is set, existing recording files are overwritten without any exception or warning.- Specified by:
setOverwritein interfaceAudioController2- Parameters:
overwrite- overwrite flag
-
isOverwrite
public boolean isOverwrite()
Description copied from interface:AudioController2Gets overwrite flag. If the overwrite flag is set, existing recording files are overwritten without any exception or warning.- Specified by:
isOverwritein interfaceAudioController2- Returns:
- overwrite flag
-
setRecordingFile
public void setRecordingFile(java.io.File recordingFile)
Description copied from interface:AudioController2Sets recording file.- Specified by:
setRecordingFilein interfaceAudioController2
-
getRecordingFile
public java.io.File getRecordingFile()
Description copied from interface:AudioController2Gets recording files.the size of the array is equal the number of lines opened.
- Specified by:
getRecordingFilein interfaceAudioController2- Returns:
- recordingFiles
-
startPlayback
public void startPlayback() throws AudioControllerExceptionDescription copied from interface:AudioController2Starts the playback.- Specified by:
startPlaybackin interfaceAudioController2- Throws:
AudioControllerException
-
startCapture
public void startCapture() throws AudioControllerExceptionDescription copied from interface:AudioController2Starts the capturing of data. Can be used to capture data from the line without writing to files- Specified by:
startCapturein interfaceAudioController2- Throws:
AudioControllerException
-
startRecording
public void startRecording() throws AudioControllerExceptionDescription copied from interface:AudioController2Starts recording to the given files.- Specified by:
startRecordingin interfaceAudioController2- Throws:
AudioControllerException- See Also:
AudioController2.openCapture()
-
pausePlayback
public void pausePlayback() throws AudioControllerExceptionDescription copied from interface:AudioController2Pauses playback.- Specified by:
pausePlaybackin interfaceAudioController2- Throws:
AudioControllerException
-
stopPlayback
public void stopPlayback() throws AudioControllerExceptionDescription copied from interface:AudioController2Stops playback.- Specified by:
stopPlaybackin interfaceAudioController2- Throws:
AudioControllerException
-
stopCapture
public void stopCapture() throws AudioControllerExceptionDescription copied from interface:AudioController2Stops capturing.- Specified by:
stopCapturein interfaceAudioController2- Throws:
AudioControllerException
-
stopRecording
public void stopRecording() throws AudioControllerExceptionDescription copied from interface:AudioController2Stops recording.- Specified by:
stopRecordingin interfaceAudioController2- Throws:
AudioControllerException
-
getCaptureLevelInfos
public LevelInfo[] getCaptureLevelInfos()
Description copied from interface:AudioController2Gets levels of all channels. maximum level is 1.0 representing 0dB
minimum level is 0
array has channels * numLines entries- Specified by:
getCaptureLevelInfosin interfaceAudioController2- Returns:
- current audio levels
-
getPlaybackLevelInfos
public LevelInfo[] getPlaybackLevelInfos()
- Specified by:
getPlaybackLevelInfosin interfaceAudioController2
-
isPlaybackRandomPositioningSupported
public boolean isPlaybackRandomPositioningSupported()
Description copied from interface:AudioController2Get random positioning capability of the playback engine.- Specified by:
isPlaybackRandomPositioningSupportedin interfaceAudioController2- Returns:
- random positioning capability
-
getPlaybackFrameLength
public long getPlaybackFrameLength()
Description copied from interface:AudioController2Gets length of largest playback file in frames, -1 if not available- Specified by:
getPlaybackFrameLengthin interfaceAudioController2- Returns:
- length of largest playback file in frames
-
setPlaybackFramePosition
public long setPlaybackFramePosition(long newPosition) throws AudioControllerExceptionDescription copied from interface:AudioController2Sets the new frame position of playback.- Specified by:
setPlaybackFramePositionin interfaceAudioController2- Parameters:
newPosition- the requested position- Returns:
- the actually set position or POS_UNKNOWN (-1) if not supported
- Throws:
AudioControllerException
-
getPlaybackFramePosition
public long getPlaybackFramePosition()
Description copied from interface:AudioController2Get playback position.- Specified by:
getPlaybackFramePositionin interfaceAudioController2- Returns:
- current playback position in audio frames or POS_UNKNOWN (-1) if not supported
-
setPlaybackStartFramePosition
public void setPlaybackStartFramePosition(long startPosition)
Description copied from interface:AudioController2Sets the start position. Used to play only a segment of an audio file.- Specified by:
setPlaybackStartFramePositionin interfaceAudioController2- Parameters:
startPosition- position in audio frames from where to start
-
getPlaybackStartFramePosition
public long getPlaybackStartFramePosition()
Description copied from interface:AudioController2Gets the start position.- Specified by:
getPlaybackStartFramePositionin interfaceAudioController2- Returns:
- start position
-
setPlaybackStopFramePosition
public void setPlaybackStopFramePosition(long stopPosition)
Description copied from interface:AudioController2Sets 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 interfaceAudioController2- Parameters:
stopPosition- position in audio frames to stop
-
getPlaybackStopFramePosition
public long getPlaybackStopFramePosition()
Description copied from interface:AudioController2Gets the stop position.- Specified by:
getPlaybackStopFramePositionin interfaceAudioController2- Returns:
- stop position
-
getCaptureFramePosition
public long getCaptureFramePosition()
Description copied from interface:AudioController2Get recording position.- Specified by:
getCaptureFramePositionin interfaceAudioController2- Returns:
- current recording position in audio frames or -1 if not supported
-
getPropertyNames
public java.lang.String[] getPropertyNames()
Description copied from interface:AudioController2Get an implementation specific property names.- Specified by:
getPropertyNamesin interfaceAudioController2- Returns:
- property names
-
getPropertyDescription
public java.lang.String getPropertyDescription(java.lang.String propertyName)
Description copied from interface:AudioController2Get a description of the property.- Specified by:
getPropertyDescriptionin interfaceAudioController2- Returns:
- description
-
setProperty
public void setProperty(java.lang.String propertyName, java.lang.String value)Description copied from interface:AudioController2Set a property for a specific implementation.- Specified by:
setPropertyin interfaceAudioController2
-
getProperty
public java.lang.String getProperty(java.lang.String propertyName)
Description copied from interface:AudioController2Get an implementation specific property.- Specified by:
getPropertyin interfaceAudioController2- Returns:
- value of the property or null if there is no such property
-
addAudioController2Listener
public void addAudioController2Listener(AudioController2.AudioController2Listener acl)
Description copied from interface:AudioController2Adds controller listener.- Specified by:
addAudioController2Listenerin interfaceAudioController2- Parameters:
acl- controller listener
-
removeAudioController2Listener
public void removeAudioController2Listener(AudioController2.AudioController2Listener acl)
Description copied from interface:AudioController2Removes controller listener.- Specified by:
removeAudioController2Listenerin interfaceAudioController2- Parameters:
acl- controller listener
-
setRecordingAudioFileFormat
public void setRecordingAudioFileFormat(javax.sound.sampled.AudioFileFormat audiofileFormat)
Description copied from interface:AudioController2Set audio file format for recording.- Specified by:
setRecordingAudioFileFormatin interfaceAudioController2- Parameters:
audiofileFormat- audio file format
-
getAudioFileFormat
public javax.sound.sampled.AudioFileFormat getAudioFileFormat()
Description copied from interface:AudioController2Get audio format.- Specified by:
getAudioFileFormatin interfaceAudioController2- Returns:
- audio format
-
update
public void update(PlayerEvent playerEvent)
- Specified by:
updatein interfacePlayerListener- Specified by:
updatein interfaceUpdateListener<PlayerEvent>
-
update
public void update(CaptureEvent captureEvent)
- Specified by:
updatein interfaceCaptureListener
-
updateListeners
protected void updateListeners(AudioController2.AudioControllerEvent ace)
-
getPreferredCaptureLineBufferSizeMilliSeconds
public float getPreferredCaptureLineBufferSizeMilliSeconds()
Description copied from interface:AudioController2Get preferred capture line buffer size.- Specified by:
getPreferredCaptureLineBufferSizeMilliSecondsin interfaceAudioController2- Returns:
- line buffer size in milliseconds
-
setPreferredCaptureLineBufferSizeMilliSeconds
public void setPreferredCaptureLineBufferSizeMilliSeconds(float preferredCaptureLineBufferSizeMilliSeconds)
Description copied from interface:AudioController2Set preferred capture line buffer size.- Specified by:
setPreferredCaptureLineBufferSizeMilliSecondsin interfaceAudioController2- Parameters:
preferredCaptureLineBufferSizeMilliSeconds- line buffer size in milliseconds
-
getPreferredPlaybackLineBufferSizeMilliSeconds
public float getPreferredPlaybackLineBufferSizeMilliSeconds()
Description copied from interface:AudioController2Get preferred playback line buffer size.- Specified by:
getPreferredPlaybackLineBufferSizeMilliSecondsin interfaceAudioController2- Returns:
- line buffer size in milliseconds
-
setPreferredPlaybackLineBufferSizeMilliSeconds
public void setPreferredPlaybackLineBufferSizeMilliSeconds(float preferredPlaybackLineBufferSizeMilliSeconds)
Description copied from interface:AudioController2Set preferred playback line buffer size.- Specified by:
setPreferredPlaybackLineBufferSizeMilliSecondsin interfaceAudioController2- Parameters:
preferredPlaybackLineBufferSizeMilliSeconds- line buffer size in milliseconds
-
getPrimaryRecordTarget
public PrimaryRecordTarget getPrimaryRecordTarget()
Description copied from interface:AudioController2Get the primary recording target.- Specified by:
getPrimaryRecordTargetin interfaceAudioController2
-
setPrimaryRecordTarget
public void setPrimaryRecordTarget(PrimaryRecordTarget primaryRecordTarget)
Description copied from interface:AudioController2Set primary record target.- Specified by:
setPrimaryRecordTargetin interfaceAudioController2
-
setMaxRecordingFrameLength
public void setMaxRecordingFrameLength(java.lang.Long maxFrameLength)
Description copied from interface:AudioController2Set max recording length.- Specified by:
setMaxRecordingFrameLengthin interfaceAudioController2- Parameters:
maxFrameLength- max recording length in frames, null for infinite recording
-
getMaxRecordingFrameLength
public java.lang.Long getMaxRecordingFrameLength()
Description copied from interface:AudioController2Get max recording length. Default is infinite recording (null).- Specified by:
getMaxRecordingFrameLengthin interfaceAudioController2- Returns:
- max recording length in frames, null for infinite recording
-
isFileTransitionRecordingSupported
public boolean isFileTransitionRecordingSupported()
Description copied from interface:AudioController2Get file transition capability. File transition recording is a feature, which allows to change the recording file during capture. The capture stream is not interrupted. The recording files can be concatened later to get one seamless recording file.- Specified by:
isFileTransitionRecordingSupportedin interfaceAudioController2- Returns:
- true if file transitioning is supported by this controller
-
getRecordingSessionInfoFile
public java.io.File getRecordingSessionInfoFile()
Description copied from interface:AudioController2Get the current used session info file.- Specified by:
getRecordingSessionInfoFilein interfaceAudioController2- Returns:
- session info file, null if not used (default)
-
setRecordingSessionInfoFile
public void setRecordingSessionInfoFile(java.io.File recordingSessionInfoFile)
Description copied from interface:AudioController2Set the current used session info file.- Specified by:
setRecordingSessionInfoFilein interfaceAudioController2- Parameters:
recordingSessionInfoFile- session info file, null if not used (default)
-
isSessionInfoHandlingSupported
public boolean isSessionInfoHandlingSupported()
Description copied from interface:AudioController2Get support for recording session info file handling.- Specified by:
isSessionInfoHandlingSupportedin interfaceAudioController2- Returns:
- true if recording session info file handling is supported
-
supportsDeviceProviders
public boolean supportsDeviceProviders()
- Specified by:
supportsDeviceProvidersin interfaceAudioController2
-
getDeviceProviderInfos
public java.util.List<DeviceProviderInfo> getDeviceProviderInfos() throws AudioControllerException
Description copied from interface:AudioController2Get available device providers.- Specified by:
getDeviceProviderInfosin interfaceAudioController2- Returns:
- device provider
- Throws:
AudioControllerException
-
setPlaybackDeviceByInfo
public void setPlaybackDeviceByInfo(DeviceInfo deviceInfo) throws AudioControllerException
- Specified by:
setPlaybackDeviceByInfoin interfaceAudioController2- Throws:
AudioControllerException
-
setCaptureDeviceByinfo
public void setCaptureDeviceByinfo(DeviceInfo deviceInfo) throws AudioControllerException
- Specified by:
setCaptureDeviceByinfoin interfaceAudioController2- Throws:
AudioControllerException
-
getInstance
public DeviceProvider getInstance(DeviceProviderInfo providerInfo) throws AudioControllerException
- Specified by:
getInstancein interfaceAudioController2- Throws:
AudioControllerException
-
convertLegacyDeviceName
public DeviceInfo convertLegacyDeviceName(java.lang.String deviceName) throws AudioControllerException
- Specified by:
convertLegacyDeviceNamein interfaceAudioController2- Throws:
AudioControllerException
-
-