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 void
addAudioController2Listener(AudioController2.AudioController2Listener acl)
Adds controller listener.void
closeCapture()
Closes the capture line.void
closePlayback()
Closes the playback line.DeviceInfo
convertLegacyDeviceName(java.lang.String deviceName)
javax.sound.sampled.AudioFileFormat
getAudioFileFormat()
Get audio format.long
getCaptureFramePosition()
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.DeviceProvider
getInstance(DeviceProviderInfo providerInfo)
java.lang.Long
getMaxRecordingFrameLength()
Get max recording length.javax.sound.sampled.AudioFormat
getPlaybackAudioFormat()
Get audio format for playback.java.io.File
getPlaybackFile()
Gets playback files.long
getPlaybackFrameLength()
Gets length of largest playback file in frames, -1 if not availablelong
getPlaybackFramePosition()
Get playback position.LevelInfo[]
getPlaybackLevelInfos()
javax.sound.sampled.Mixer.Info[]
getPlaybackMixerInfos()
Get infos of available playback mixers.long
getPlaybackStartFramePosition()
Gets the start position.long
getPlaybackStopFramePosition()
Gets the stop position.float
getPreferredCaptureLineBufferSizeMilliSeconds()
Get preferred capture line buffer size.float
getPreferredPlaybackLineBufferSizeMilliSeconds()
Get preferred playback line buffer size.PrimaryRecordTarget
getPrimaryRecordTarget()
Get the primary recording target.java.lang.String
getProperty(java.lang.String propertyName)
Get an implementation specific property.java.lang.String
getPropertyDescription(java.lang.String propertyName)
Get a description of the property.java.lang.String[]
getPropertyNames()
Get an implementation specific property names.java.io.File
getRecordingFile()
Gets recording files.java.io.File
getRecordingSessionInfoFile()
Get the current used session info file.boolean
isCaptureOpen()
Check if capture engine is open.boolean
isFileTransitionRecordingSupported()
Get file transition capability.boolean
isOverwrite()
Gets overwrite flag.boolean
isPlaybackRandomPositioningSupported()
Get random positioning capability of the playback engine.boolean
isSessionInfoHandlingSupported()
Get support for recording session info file handling.void
openCapture()
Opens the capture line.void
openPlayback()
Opens the playback line.void
pausePlayback()
Pauses playback.void
removeAudioController2Listener(AudioController2.AudioController2Listener acl)
Removes controller listener.void
setCaptureDeviceByinfo(DeviceInfo deviceInfo)
void
setCaptureDeviceByName(java.lang.String deviceName)
Use the target mixer (recording) with the given name.void
setMaxRecordingFrameLength(java.lang.Long maxFrameLength)
Set max recording length.void
setOverwrite(boolean overwrite)
Sets overwrite flag.void
setPlaybackAudioSource(AudioSource source)
void
setPlaybackDeviceByInfo(DeviceInfo deviceInfo)
void
setPlaybackDeviceByName(java.lang.String deviceName)
Use the source mixer (playback) with the given name.void
setPlaybackFile(java.io.File playbackFile)
Set playback file.long
setPlaybackFramePosition(long newPosition)
Sets the new frame position of playback.void
setPlaybackStartFramePosition(long startPosition)
Sets the start position.void
setPlaybackStopFramePosition(long stopPosition)
Sets the stop position.void
setPreferredCaptureLineBufferSizeMilliSeconds(float preferredCaptureLineBufferSizeMilliSeconds)
Set preferred capture line buffer size.void
setPreferredPlaybackLineBufferSizeMilliSeconds(float preferredPlaybackLineBufferSizeMilliSeconds)
Set preferred playback line buffer size.void
setPrimaryRecordTarget(PrimaryRecordTarget primaryRecordTarget)
Set primary record target.void
setProperty(java.lang.String propertyName, java.lang.String value)
Set a property for a specific implementation.void
setRecordingAudioFileFormat(javax.sound.sampled.AudioFileFormat audiofileFormat)
Set audio file format for recording.void
setRecordingFile(java.io.File recordingFile)
Sets recording file.void
setRecordingSessionInfoFile(java.io.File recordingSessionInfoFile)
Set the current used session info file.void
startCapture()
Starts the capturing of data.void
startPlayback()
Starts the playback.void
startRecording()
Starts recording to the given files.void
stopCapture()
Stops capturing.void
stopPlayback()
Stops playback.void
stopRecording()
Stops recording.boolean
supportsDeviceProviders()
void
update(CaptureEvent captureEvent)
void
update(PlayerEvent playerEvent)
protected void
updateListeners(AudioController2.AudioControllerEvent ace)
-
-
-
Method Detail
-
getPlaybackMixerInfos
public javax.sound.sampled.Mixer.Info[] getPlaybackMixerInfos() throws AudioControllerException
Description copied from interface:AudioController2
Get infos of available playback mixers.- Specified by:
getPlaybackMixerInfos
in interfaceAudioController2
- Returns:
- playback mixer infos
- Throws:
AudioControllerException
-
getCaptureMixerInfos
public javax.sound.sampled.Mixer.Info[] getCaptureMixerInfos() throws AudioControllerException
Description copied from interface:AudioController2
Get infos of available capture mixers.- Specified by:
getCaptureMixerInfos
in interfaceAudioController2
- Returns:
- capture mixer infos
- Throws:
AudioControllerException
-
setPlaybackDeviceByName
public void setPlaybackDeviceByName(java.lang.String deviceName) throws AudioControllerException
Description copied from interface:AudioController2
Use the source mixer (playback) with the given name.- Specified by:
setPlaybackDeviceByName
in interfaceAudioController2
- Parameters:
deviceName
- the name of the source mixer- Throws:
AudioControllerException
-
setCaptureDeviceByName
public void setCaptureDeviceByName(java.lang.String deviceName) throws AudioControllerException
Description copied from interface:AudioController2
Use the target mixer (recording) with the given name.- Specified by:
setCaptureDeviceByName
in interfaceAudioController2
- Parameters:
deviceName
- the name of the target mixer- Throws:
AudioControllerException
-
getPlaybackAudioFormat
public javax.sound.sampled.AudioFormat getPlaybackAudioFormat()
Description copied from interface:AudioController2
Get 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:
getPlaybackAudioFormat
in interfaceAudioController2
- Returns:
- audio format
-
openPlayback
public void openPlayback() throws AudioControllerException
Description copied from interface:AudioController2
Opens the playback line.- Specified by:
openPlayback
in interfaceAudioController2
- Throws:
AudioControllerException
-
closePlayback
public void closePlayback() throws AudioControllerException
Description copied from interface:AudioController2
Closes the playback line.- Specified by:
closePlayback
in interfaceAudioController2
- Throws:
AudioControllerException
-
openCapture
public void openCapture() throws AudioControllerException
Description copied from interface:AudioController2
Opens the capture line.- Specified by:
openCapture
in interfaceAudioController2
- Throws:
AudioControllerException
-
closeCapture
public void closeCapture() throws AudioControllerException
Description copied from interface:AudioController2
Closes the capture line.- Specified by:
closeCapture
in interfaceAudioController2
- Throws:
AudioControllerException
-
isCaptureOpen
public boolean isCaptureOpen()
Description copied from interface:AudioController2
Check if capture engine is open.- Specified by:
isCaptureOpen
in interfaceAudioController2
- Returns:
- true if open
-
setPlaybackFile
public void setPlaybackFile(java.io.File playbackFile) throws AudioControllerException
Description copied from interface:AudioController2
Set playback file.- Specified by:
setPlaybackFile
in interfaceAudioController2
- Parameters:
playbackFile
- the file to play- Throws:
AudioControllerException
-
getPlaybackFile
public java.io.File getPlaybackFile()
Description copied from interface:AudioController2
Gets playback files.the size of the array is equal the number of lines opened.
- Specified by:
getPlaybackFile
in interfaceAudioController2
- Returns:
- the file array of playbackfiles set
-
setPlaybackAudioSource
public void setPlaybackAudioSource(AudioSource source) throws AudioControllerException
- Specified by:
setPlaybackAudioSource
in interfaceAudioController2
- Throws:
AudioControllerException
-
setOverwrite
public void setOverwrite(boolean overwrite)
Description copied from interface:AudioController2
Sets overwrite flag. If the overwrite flag is set, existing recording files are overwritten without any exception or warning.- Specified by:
setOverwrite
in interfaceAudioController2
- Parameters:
overwrite
- overwrite flag
-
isOverwrite
public boolean isOverwrite()
Description copied from interface:AudioController2
Gets overwrite flag. If the overwrite flag is set, existing recording files are overwritten without any exception or warning.- Specified by:
isOverwrite
in interfaceAudioController2
- Returns:
- overwrite flag
-
setRecordingFile
public void setRecordingFile(java.io.File recordingFile)
Description copied from interface:AudioController2
Sets recording file.- Specified by:
setRecordingFile
in interfaceAudioController2
-
getRecordingFile
public java.io.File getRecordingFile()
Description copied from interface:AudioController2
Gets recording files.the size of the array is equal the number of lines opened.
- Specified by:
getRecordingFile
in interfaceAudioController2
- Returns:
- recordingFiles
-
startPlayback
public void startPlayback() throws AudioControllerException
Description copied from interface:AudioController2
Starts the playback.- Specified by:
startPlayback
in interfaceAudioController2
- Throws:
AudioControllerException
-
startCapture
public void startCapture() throws AudioControllerException
Description copied from interface:AudioController2
Starts the capturing of data. Can be used to capture data from the line without writing to files- Specified by:
startCapture
in interfaceAudioController2
- Throws:
AudioControllerException
-
startRecording
public void startRecording() throws AudioControllerException
Description copied from interface:AudioController2
Starts recording to the given files.- Specified by:
startRecording
in interfaceAudioController2
- Throws:
AudioControllerException
- See Also:
AudioController2.openCapture()
-
pausePlayback
public void pausePlayback() throws AudioControllerException
Description copied from interface:AudioController2
Pauses playback.- Specified by:
pausePlayback
in interfaceAudioController2
- Throws:
AudioControllerException
-
stopPlayback
public void stopPlayback() throws AudioControllerException
Description copied from interface:AudioController2
Stops playback.- Specified by:
stopPlayback
in interfaceAudioController2
- Throws:
AudioControllerException
-
stopCapture
public void stopCapture() throws AudioControllerException
Description copied from interface:AudioController2
Stops capturing.- Specified by:
stopCapture
in interfaceAudioController2
- Throws:
AudioControllerException
-
stopRecording
public void stopRecording() throws AudioControllerException
Description copied from interface:AudioController2
Stops recording.- Specified by:
stopRecording
in interfaceAudioController2
- Throws:
AudioControllerException
-
getCaptureLevelInfos
public LevelInfo[] getCaptureLevelInfos()
Description copied from interface:AudioController2
Gets levels of all channels. maximum level is 1.0 representing 0dB
minimum level is 0
array has channels * numLines entries- Specified by:
getCaptureLevelInfos
in interfaceAudioController2
- Returns:
- current audio levels
-
getPlaybackLevelInfos
public LevelInfo[] getPlaybackLevelInfos()
- Specified by:
getPlaybackLevelInfos
in interfaceAudioController2
-
isPlaybackRandomPositioningSupported
public boolean isPlaybackRandomPositioningSupported()
Description copied from interface:AudioController2
Get random positioning capability of the playback engine.- Specified by:
isPlaybackRandomPositioningSupported
in interfaceAudioController2
- Returns:
- random positioning capability
-
getPlaybackFrameLength
public long getPlaybackFrameLength()
Description copied from interface:AudioController2
Gets length of largest playback file in frames, -1 if not available- Specified by:
getPlaybackFrameLength
in interfaceAudioController2
- Returns:
- length of largest playback file in frames
-
setPlaybackFramePosition
public long setPlaybackFramePosition(long newPosition) throws AudioControllerException
Description copied from interface:AudioController2
Sets the new frame position of playback.- Specified by:
setPlaybackFramePosition
in 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:AudioController2
Get playback position.- Specified by:
getPlaybackFramePosition
in 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:AudioController2
Sets the start position. Used to play only a segment of an audio file.- Specified by:
setPlaybackStartFramePosition
in interfaceAudioController2
- Parameters:
startPosition
- position in audio frames from where to start
-
getPlaybackStartFramePosition
public long getPlaybackStartFramePosition()
Description copied from interface:AudioController2
Gets the start position.- Specified by:
getPlaybackStartFramePosition
in interfaceAudioController2
- Returns:
- start position
-
setPlaybackStopFramePosition
public void setPlaybackStopFramePosition(long stopPosition)
Description copied from interface:AudioController2
Sets 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:
setPlaybackStopFramePosition
in interfaceAudioController2
- Parameters:
stopPosition
- position in audio frames to stop
-
getPlaybackStopFramePosition
public long getPlaybackStopFramePosition()
Description copied from interface:AudioController2
Gets the stop position.- Specified by:
getPlaybackStopFramePosition
in interfaceAudioController2
- Returns:
- stop position
-
getCaptureFramePosition
public long getCaptureFramePosition()
Description copied from interface:AudioController2
Get recording position.- Specified by:
getCaptureFramePosition
in interfaceAudioController2
- Returns:
- current recording position in audio frames or -1 if not supported
-
getPropertyNames
public java.lang.String[] getPropertyNames()
Description copied from interface:AudioController2
Get an implementation specific property names.- Specified by:
getPropertyNames
in interfaceAudioController2
- Returns:
- property names
-
getPropertyDescription
public java.lang.String getPropertyDescription(java.lang.String propertyName)
Description copied from interface:AudioController2
Get a description of the property.- Specified by:
getPropertyDescription
in interfaceAudioController2
- Returns:
- description
-
setProperty
public void setProperty(java.lang.String propertyName, java.lang.String value)
Description copied from interface:AudioController2
Set a property for a specific implementation.- Specified by:
setProperty
in interfaceAudioController2
-
getProperty
public java.lang.String getProperty(java.lang.String propertyName)
Description copied from interface:AudioController2
Get an implementation specific property.- Specified by:
getProperty
in 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:AudioController2
Adds controller listener.- Specified by:
addAudioController2Listener
in interfaceAudioController2
- Parameters:
acl
- controller listener
-
removeAudioController2Listener
public void removeAudioController2Listener(AudioController2.AudioController2Listener acl)
Description copied from interface:AudioController2
Removes controller listener.- Specified by:
removeAudioController2Listener
in interfaceAudioController2
- Parameters:
acl
- controller listener
-
setRecordingAudioFileFormat
public void setRecordingAudioFileFormat(javax.sound.sampled.AudioFileFormat audiofileFormat)
Description copied from interface:AudioController2
Set audio file format for recording.- Specified by:
setRecordingAudioFileFormat
in interfaceAudioController2
- Parameters:
audiofileFormat
- audio file format
-
getAudioFileFormat
public javax.sound.sampled.AudioFileFormat getAudioFileFormat()
Description copied from interface:AudioController2
Get audio format.- Specified by:
getAudioFileFormat
in interfaceAudioController2
- Returns:
- audio format
-
update
public void update(PlayerEvent playerEvent)
- Specified by:
update
in interfacePlayerListener
- Specified by:
update
in interfaceUpdateListener<PlayerEvent>
-
update
public void update(CaptureEvent captureEvent)
- Specified by:
update
in interfaceCaptureListener
-
updateListeners
protected void updateListeners(AudioController2.AudioControllerEvent ace)
-
getPreferredCaptureLineBufferSizeMilliSeconds
public float getPreferredCaptureLineBufferSizeMilliSeconds()
Description copied from interface:AudioController2
Get preferred capture line buffer size.- Specified by:
getPreferredCaptureLineBufferSizeMilliSeconds
in interfaceAudioController2
- Returns:
- line buffer size in milliseconds
-
setPreferredCaptureLineBufferSizeMilliSeconds
public void setPreferredCaptureLineBufferSizeMilliSeconds(float preferredCaptureLineBufferSizeMilliSeconds)
Description copied from interface:AudioController2
Set preferred capture line buffer size.- Specified by:
setPreferredCaptureLineBufferSizeMilliSeconds
in interfaceAudioController2
- Parameters:
preferredCaptureLineBufferSizeMilliSeconds
- line buffer size in milliseconds
-
getPreferredPlaybackLineBufferSizeMilliSeconds
public float getPreferredPlaybackLineBufferSizeMilliSeconds()
Description copied from interface:AudioController2
Get preferred playback line buffer size.- Specified by:
getPreferredPlaybackLineBufferSizeMilliSeconds
in interfaceAudioController2
- Returns:
- line buffer size in milliseconds
-
setPreferredPlaybackLineBufferSizeMilliSeconds
public void setPreferredPlaybackLineBufferSizeMilliSeconds(float preferredPlaybackLineBufferSizeMilliSeconds)
Description copied from interface:AudioController2
Set preferred playback line buffer size.- Specified by:
setPreferredPlaybackLineBufferSizeMilliSeconds
in interfaceAudioController2
- Parameters:
preferredPlaybackLineBufferSizeMilliSeconds
- line buffer size in milliseconds
-
getPrimaryRecordTarget
public PrimaryRecordTarget getPrimaryRecordTarget()
Description copied from interface:AudioController2
Get the primary recording target.- Specified by:
getPrimaryRecordTarget
in interfaceAudioController2
-
setPrimaryRecordTarget
public void setPrimaryRecordTarget(PrimaryRecordTarget primaryRecordTarget)
Description copied from interface:AudioController2
Set primary record target.- Specified by:
setPrimaryRecordTarget
in interfaceAudioController2
-
setMaxRecordingFrameLength
public void setMaxRecordingFrameLength(java.lang.Long maxFrameLength)
Description copied from interface:AudioController2
Set max recording length.- Specified by:
setMaxRecordingFrameLength
in interfaceAudioController2
- Parameters:
maxFrameLength
- max recording length in frames, null for infinite recording
-
getMaxRecordingFrameLength
public java.lang.Long getMaxRecordingFrameLength()
Description copied from interface:AudioController2
Get max recording length. Default is infinite recording (null).- Specified by:
getMaxRecordingFrameLength
in interfaceAudioController2
- Returns:
- max recording length in frames, null for infinite recording
-
isFileTransitionRecordingSupported
public boolean isFileTransitionRecordingSupported()
Description copied from interface:AudioController2
Get 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:
isFileTransitionRecordingSupported
in interfaceAudioController2
- Returns:
- true if file transitioning is supported by this controller
-
getRecordingSessionInfoFile
public java.io.File getRecordingSessionInfoFile()
Description copied from interface:AudioController2
Get the current used session info file.- Specified by:
getRecordingSessionInfoFile
in interfaceAudioController2
- Returns:
- session info file, null if not used (default)
-
setRecordingSessionInfoFile
public void setRecordingSessionInfoFile(java.io.File recordingSessionInfoFile)
Description copied from interface:AudioController2
Set the current used session info file.- Specified by:
setRecordingSessionInfoFile
in interfaceAudioController2
- Parameters:
recordingSessionInfoFile
- session info file, null if not used (default)
-
isSessionInfoHandlingSupported
public boolean isSessionInfoHandlingSupported()
Description copied from interface:AudioController2
Get support for recording session info file handling.- Specified by:
isSessionInfoHandlingSupported
in interfaceAudioController2
- Returns:
- true if recording session info file handling is supported
-
supportsDeviceProviders
public boolean supportsDeviceProviders()
- Specified by:
supportsDeviceProviders
in interfaceAudioController2
-
getDeviceProviderInfos
public java.util.List<DeviceProviderInfo> getDeviceProviderInfos() throws AudioControllerException
Description copied from interface:AudioController2
Get available device providers.- Specified by:
getDeviceProviderInfos
in interfaceAudioController2
- Returns:
- device provider
- Throws:
AudioControllerException
-
setPlaybackDeviceByInfo
public void setPlaybackDeviceByInfo(DeviceInfo deviceInfo) throws AudioControllerException
- Specified by:
setPlaybackDeviceByInfo
in interfaceAudioController2
- Throws:
AudioControllerException
-
setCaptureDeviceByinfo
public void setCaptureDeviceByinfo(DeviceInfo deviceInfo) throws AudioControllerException
- Specified by:
setCaptureDeviceByinfo
in interfaceAudioController2
- Throws:
AudioControllerException
-
getInstance
public DeviceProvider getInstance(DeviceProviderInfo providerInfo) throws AudioControllerException
- Specified by:
getInstance
in interfaceAudioController2
- Throws:
AudioControllerException
-
convertLegacyDeviceName
public DeviceInfo convertLegacyDeviceName(java.lang.String deviceName) throws AudioControllerException
- Specified by:
convertLegacyDeviceName
in interfaceAudioController2
- Throws:
AudioControllerException
-
-