Package ipsk.audio
Interface AudioController2
-
- All Known Subinterfaces:
AudioController3
,AudioController4
- All Known Implementing Classes:
J2AudioController2
,J2AudioController3
,J2AudioController4
public interface AudioController2
Manages audio recording and playback. This interface allows easy recording of playback and recording auf audio. After the number of lines (usingA typical scenario for a session:
- Set audio file format for the session.
- Optionally set the devices to use.
- Open for recording.
- Start recording.
- Stop recording.
- Wait for CaptureRecordedEvent.
- Close capture.
- Open playback.
- Optionally set start/stop position.
- Start playback.
- Optionally pause playback.
- Start playback again.
- Stop playback or the playback finishes at the end of file(s)
- Wait for PlaybackStopEvent and close playback.
- Author:
- Klaus Jänsch, klausj@phonetik.uni-muenchen.de
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
AudioController2.AudioController2Listener
Audio controller listener interface.static interface
AudioController2.AudioControllerEvent
Alle events thrown by the controller must implement this interface.static class
AudioController2.DeviceType
-
Method Summary
All Methods Instance Methods Abstract 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<? extends 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()
-
-
-
Method Detail
-
getPlaybackMixerInfos
javax.sound.sampled.Mixer.Info[] getPlaybackMixerInfos() throws AudioControllerException
Get infos of available playback mixers.- Returns:
- playback mixer infos
- Throws:
AudioControllerException
-
getCaptureMixerInfos
javax.sound.sampled.Mixer.Info[] getCaptureMixerInfos() throws AudioControllerException
Get infos of available capture mixers.- Returns:
- capture mixer infos
- Throws:
AudioControllerException
-
setPlaybackDeviceByName
void setPlaybackDeviceByName(java.lang.String deviceName) throws AudioControllerException
Use the source mixer (playback) with the given name.- Parameters:
deviceName
- the name of the source mixer- Throws:
AudioControllerException
-
setCaptureDeviceByName
void setCaptureDeviceByName(java.lang.String deviceName) throws AudioControllerException
Use the target mixer (recording) with the given name.- Parameters:
deviceName
- the name of the target mixer- Throws:
AudioControllerException
-
supportsDeviceProviders
boolean supportsDeviceProviders()
-
convertLegacyDeviceName
DeviceInfo convertLegacyDeviceName(java.lang.String deviceName) throws AudioControllerException
- Throws:
AudioControllerException
-
getDeviceProviderInfos
java.util.List<? extends DeviceProviderInfo> getDeviceProviderInfos() throws AudioControllerException
Get available device providers.- Returns:
- device provider
- Throws:
AudioControllerException
-
getInstance
DeviceProvider getInstance(DeviceProviderInfo providerInfo) throws AudioControllerException
- Throws:
AudioControllerException
-
setPlaybackDeviceByInfo
void setPlaybackDeviceByInfo(DeviceInfo deviceInfo) throws AudioControllerException
- Throws:
AudioControllerException
-
setCaptureDeviceByinfo
void setCaptureDeviceByinfo(DeviceInfo deviceInfo) throws AudioControllerException
- Throws:
AudioControllerException
-
setRecordingAudioFileFormat
void setRecordingAudioFileFormat(javax.sound.sampled.AudioFileFormat audiofileFormat)
Set audio file format for recording.- Parameters:
audiofileFormat
- audio file format
-
getAudioFileFormat
javax.sound.sampled.AudioFileFormat getAudioFileFormat()
Get audio format.- Returns:
- audio format
-
getPlaybackAudioFormat
javax.sound.sampled.AudioFormat getPlaybackAudioFormat()
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.- Returns:
- audio format
-
openPlayback
void openPlayback() throws AudioControllerException
Opens the playback line.- Throws:
AudioControllerException
-
closePlayback
void closePlayback() throws AudioControllerException
Closes the playback line.- Throws:
AudioControllerException
-
openCapture
void openCapture() throws AudioControllerException
Opens the capture line.- Throws:
AudioControllerException
-
closeCapture
void closeCapture() throws AudioControllerException
Closes the capture line.- Throws:
AudioControllerException
-
setPlaybackFile
void setPlaybackFile(java.io.File playbackFile) throws AudioControllerException
Set playback file.- Parameters:
playbackFile
- the file to play- Throws:
AudioControllerException
-
getPlaybackFile
java.io.File getPlaybackFile()
Gets playback files.the size of the array is equal the number of lines opened.
- Returns:
- the file array of playbackfiles set
-
setPlaybackAudioSource
void setPlaybackAudioSource(AudioSource source) throws AudioControllerException
- Throws:
AudioControllerException
-
setOverwrite
void setOverwrite(boolean overwrite)
Sets overwrite flag. If the overwrite flag is set, existing recording files are overwritten without any exception or warning.- Parameters:
overwrite
- overwrite flag
-
isOverwrite
boolean isOverwrite()
Gets overwrite flag. If the overwrite flag is set, existing recording files are overwritten without any exception or warning.- Returns:
- overwrite flag
-
setPrimaryRecordTarget
void setPrimaryRecordTarget(PrimaryRecordTarget primaryRecordTarget)
Set primary record target.- Parameters:
primaryRecordTarget
-
-
getPrimaryRecordTarget
PrimaryRecordTarget getPrimaryRecordTarget()
Get the primary recording target.
-
setRecordingFile
void setRecordingFile(java.io.File recordingFile)
Sets recording file.- Parameters:
recordingFile
-
-
getRecordingFile
java.io.File getRecordingFile()
Gets recording files.the size of the array is equal the number of lines opened.
- Returns:
- recordingFiles
-
startPlayback
void startPlayback() throws AudioControllerException
Starts the playback.- Throws:
AudioControllerException
-
startCapture
void startCapture() throws AudioControllerException
Starts the capturing of data. Can be used to capture data from the line without writing to files- Throws:
AudioControllerException
-
startRecording
void startRecording() throws AudioControllerException
Starts recording to the given files.- Throws:
AudioControllerException
- See Also:
openCapture()
-
pausePlayback
void pausePlayback() throws AudioControllerException
Pauses playback.- Throws:
AudioControllerException
-
stopPlayback
void stopPlayback() throws AudioControllerException
Stops playback.- Throws:
AudioControllerException
-
stopCapture
void stopCapture() throws AudioControllerException
Stops capturing.- Throws:
AudioControllerException
-
stopRecording
void stopRecording() throws AudioControllerException
Stops recording.- Throws:
AudioControllerException
-
getCaptureLevelInfos
LevelInfo[] getCaptureLevelInfos()
Gets levels of all channels. maximum level is 1.0 representing 0dB
minimum level is 0
array has channels * numLines entries- Returns:
- current audio levels
-
getPlaybackLevelInfos
LevelInfo[] getPlaybackLevelInfos()
-
isPlaybackRandomPositioningSupported
boolean isPlaybackRandomPositioningSupported()
Get random positioning capability of the playback engine.- Returns:
- random positioning capability
-
getPlaybackFrameLength
long getPlaybackFrameLength()
Gets length of largest playback file in frames, -1 if not available- Returns:
- length of largest playback file in frames
-
setPlaybackFramePosition
long setPlaybackFramePosition(long newPosition) throws AudioControllerException
Sets the new frame position of playback.- Parameters:
newPosition
- the requested position- Returns:
- the actually set position or POS_UNKNOWN (-1) if not supported
- Throws:
AudioControllerException
-
getPlaybackFramePosition
long getPlaybackFramePosition()
Get playback position.- Returns:
- current playback position in audio frames or POS_UNKNOWN (-1) if not supported
-
setPlaybackStartFramePosition
void setPlaybackStartFramePosition(long startPosition)
Sets the start position. Used to play only a segment of an audio file.- Parameters:
startPosition
- position in audio frames from where to start
-
getPlaybackStartFramePosition
long getPlaybackStartFramePosition()
Gets the start position.- Returns:
- start position
-
setPlaybackStopFramePosition
void setPlaybackStopFramePosition(long stopPosition)
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).- Parameters:
stopPosition
- position in audio frames to stop
-
getPlaybackStopFramePosition
long getPlaybackStopFramePosition()
Gets the stop position.- Returns:
- stop position
-
getCaptureFramePosition
long getCaptureFramePosition()
Get recording position.- Returns:
- current recording position in audio frames or -1 if not supported
-
isCaptureOpen
boolean isCaptureOpen()
Check if capture engine is open.- Returns:
- true if open
-
getPropertyNames
java.lang.String[] getPropertyNames()
Get an implementation specific property names.- Returns:
- property names
-
getPropertyDescription
java.lang.String getPropertyDescription(java.lang.String propertyName)
Get a description of the property.- Parameters:
propertyName
-- Returns:
- description
-
setProperty
void setProperty(java.lang.String propertyName, java.lang.String value)
Set a property for a specific implementation.- Parameters:
propertyName
-value
-
-
getProperty
java.lang.String getProperty(java.lang.String propertyName)
Get an implementation specific property.- Parameters:
propertyName
-- Returns:
- value of the property or null if there is no such property
-
addAudioController2Listener
void addAudioController2Listener(AudioController2.AudioController2Listener acl)
Adds controller listener.- Parameters:
acl
- controller listener
-
removeAudioController2Listener
void removeAudioController2Listener(AudioController2.AudioController2Listener acl)
Removes controller listener.- Parameters:
acl
- controller listener
-
getPreferredCaptureLineBufferSizeMilliSeconds
float getPreferredCaptureLineBufferSizeMilliSeconds()
Get preferred capture line buffer size.- Returns:
- line buffer size in milliseconds
-
setPreferredCaptureLineBufferSizeMilliSeconds
void setPreferredCaptureLineBufferSizeMilliSeconds(float preferredCaptureLineBufferSizeMilliSeconds)
Set preferred capture line buffer size.- Parameters:
preferredCaptureLineBufferSizeMilliSeconds
- line buffer size in milliseconds
-
getPreferredPlaybackLineBufferSizeMilliSeconds
float getPreferredPlaybackLineBufferSizeMilliSeconds()
Get preferred playback line buffer size.- Returns:
- line buffer size in milliseconds
-
setPreferredPlaybackLineBufferSizeMilliSeconds
void setPreferredPlaybackLineBufferSizeMilliSeconds(float preferredPlaybackLineBufferSizeMilliSeconds)
Set preferred playback line buffer size.- Parameters:
preferredPlaybackLineBufferSizeMilliSeconds
- line buffer size in milliseconds
-
setMaxRecordingFrameLength
void setMaxRecordingFrameLength(java.lang.Long maxFrameLength)
Set max recording length.- Parameters:
maxFrameLength
- max recording length in frames, null for infinite recording
-
getMaxRecordingFrameLength
java.lang.Long getMaxRecordingFrameLength()
Get max recording length. Default is infinite recording (null).- Returns:
- max recording length in frames, null for infinite recording
-
isFileTransitionRecordingSupported
boolean isFileTransitionRecordingSupported()
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.- Returns:
- true if file transitioning is supported by this controller
-
isSessionInfoHandlingSupported
boolean isSessionInfoHandlingSupported()
Get support for recording session info file handling.- Returns:
- true if recording session info file handling is supported
-
getRecordingSessionInfoFile
java.io.File getRecordingSessionInfoFile()
Get the current used session info file.- Returns:
- session info file, null if not used (default)
-
setRecordingSessionInfoFile
void setRecordingSessionInfoFile(java.io.File recordingSessionInfoFile)
Set the current used session info file.- Parameters:
recordingSessionInfoFile
- session info file, null if not used (default)
-
-