Package ipsk.audio
Interface AudioController2
-
- All Known Subinterfaces:
AudioController3,AudioController4
- All Known Implementing Classes:
J2AudioController2,J2AudioController3,J2AudioController4
public interface AudioController2Manages 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 interfaceAudioController2.AudioController2ListenerAudio controller listener interface.static interfaceAudioController2.AudioControllerEventAlle events thrown by the controller must implement this interface.static classAudioController2.DeviceType
-
Method Summary
All Methods Instance Methods Abstract 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<? extends 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()
-
-
-
Method Detail
-
getPlaybackMixerInfos
javax.sound.sampled.Mixer.Info[] getPlaybackMixerInfos() throws AudioControllerExceptionGet infos of available playback mixers.- Returns:
- playback mixer infos
- Throws:
AudioControllerException
-
getCaptureMixerInfos
javax.sound.sampled.Mixer.Info[] getCaptureMixerInfos() throws AudioControllerExceptionGet infos of available capture mixers.- Returns:
- capture mixer infos
- Throws:
AudioControllerException
-
setPlaybackDeviceByName
void setPlaybackDeviceByName(java.lang.String deviceName) throws AudioControllerExceptionUse 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 AudioControllerExceptionUse 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 AudioControllerExceptionOpens the playback line.- Throws:
AudioControllerException
-
closePlayback
void closePlayback() throws AudioControllerExceptionCloses the playback line.- Throws:
AudioControllerException
-
openCapture
void openCapture() throws AudioControllerExceptionOpens the capture line.- Throws:
AudioControllerException
-
closeCapture
void closeCapture() throws AudioControllerExceptionCloses the capture line.- Throws:
AudioControllerException
-
setPlaybackFile
void setPlaybackFile(java.io.File playbackFile) throws AudioControllerExceptionSet 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 AudioControllerExceptionStarts the playback.- Throws:
AudioControllerException
-
startCapture
void startCapture() throws AudioControllerExceptionStarts the capturing of data. Can be used to capture data from the line without writing to files- Throws:
AudioControllerException
-
startRecording
void startRecording() throws AudioControllerExceptionStarts recording to the given files.- Throws:
AudioControllerException- See Also:
openCapture()
-
pausePlayback
void pausePlayback() throws AudioControllerExceptionPauses playback.- Throws:
AudioControllerException
-
stopPlayback
void stopPlayback() throws AudioControllerExceptionStops playback.- Throws:
AudioControllerException
-
stopCapture
void stopCapture() throws AudioControllerExceptionStops capturing.- Throws:
AudioControllerException
-
stopRecording
void stopRecording() throws AudioControllerExceptionStops 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 AudioControllerExceptionSets 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)
-
-