Package adams.flow.source.audiorecorder
Class AbstractAudioRecorder<T>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.source.audiorecorder.AbstractAudioRecorder<T>
-
- Type Parameters:
T- the type of data that the recorder generates
- All Implemented Interfaces:
adams.core.Destroyable,adams.core.GlobalInfoSupporter,adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.core.option.OptionHandler,adams.core.QuickInfoSupporter,adams.core.SizeOfHandler,adams.core.Stoppable,adams.core.StoppableWithFeedback,adams.flow.core.FlowContextHandler,Serializable
- Direct Known Subclasses:
AbstractFileBasedAudioRecorder
public abstract class AbstractAudioRecorder<T> extends adams.core.option.AbstractOptionHandler implements adams.core.QuickInfoSupporter, adams.flow.core.FlowContextHandler, adams.core.StoppableWithFeedbackAncestor for classes that record audio.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_BigEndianwhether big endian or little endian.protected intm_Bitsthe sample size in bits.protected intm_Channelsthe number of channels.protected adams.flow.core.Actorm_FlowContextthe flow context.protected floatm_SampleRatethe sample rate.protected booleanm_Signedwhether signed or unsigned.protected booleanm_Stoppedwhether recording has been stopped.
-
Constructor Summary
Constructors Constructor Description AbstractAudioRecorder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringbigEndianTipText()Returns the tip text for this property.StringbitsTipText()Returns the tip text for this property.StringchannelsTipText()Returns the tip text for this property.protected Stringcheck()Hook method for performing checks before attempting to generate the setups.voiddefineOptions()Adds options to the internal list of options.protected abstract TdoRecord()Records the audio.abstract Classgenerates()Returns the type of data that it outputs.protected AudioFormatgetAudioFormat()Returns the audio format based on the options.booleangetBigEndian()Returns whether to use big endian.intgetBits()Returns the sample size in bits.intgetChannels()Returns the number of channels to record.protected DataLine.InfogetDataLineInfo(AudioFormat format, adams.core.MessageCollection errors)Returns the data line info.adams.flow.core.ActorgetFlowContext()Returns the flow context, if any.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.floatgetSampleRate()Returns the sample rate to use (hertz).booleangetSigned()Returns whether to use signed data.booleanisStopped()Whether the execution has been stopped.Trecord()Records the audio.abstract booleanrequiresFlowContext()Returns whether flow context is actually required.StringsampleRateTipText()Returns the tip text for this property.voidsetBigEndian(boolean value)Sets whether to use big endian.voidsetBits(int value)Sets the sample size in bits.voidsetChannels(int value)Sets the number of channels to record.voidsetFlowContext(adams.flow.core.Actor value)Sets the flow context.voidsetSampleRate(float value)Sets the sample rate to use (hertz).voidsetSigned(boolean value)Sets whether to use signed data.StringsignedTipText()Returns the tip text for this property.voidstopExecution()Stops the execution.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_SampleRate
protected float m_SampleRate
the sample rate.
-
m_Bits
protected int m_Bits
the sample size in bits.
-
m_Channels
protected int m_Channels
the number of channels.
-
m_Signed
protected boolean m_Signed
whether signed or unsigned.
-
m_BigEndian
protected boolean m_BigEndian
whether big endian or little endian.
-
m_FlowContext
protected adams.flow.core.Actor m_FlowContext
the flow context.
-
m_Stopped
protected boolean m_Stopped
whether recording has been stopped.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.core.option.AbstractOptionHandler
-
setFlowContext
public void setFlowContext(adams.flow.core.Actor value)
Sets the flow context.- Specified by:
setFlowContextin interfaceadams.flow.core.FlowContextHandler- Parameters:
value- the actor
-
getFlowContext
public adams.flow.core.Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContextin interfaceadams.flow.core.FlowContextHandler- Returns:
- the actor, null if none available
-
requiresFlowContext
public abstract boolean requiresFlowContext()
Returns whether flow context is actually required.- Returns:
- true if required
-
check
protected String check()
Hook method for performing checks before attempting to generate the setups.- Returns:
- null if successful, otherwise error message
-
setSampleRate
public void setSampleRate(float value)
Sets the sample rate to use (hertz).- Parameters:
value- the sample rate
-
getSampleRate
public float getSampleRate()
Returns the sample rate to use (hertz).- Returns:
- the reader
-
sampleRateTipText
public String sampleRateTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setBits
public void setBits(int value)
Sets the sample size in bits.- Parameters:
value- the number of bits
-
getBits
public int getBits()
Returns the sample size in bits.- Returns:
- the number of bits
-
bitsTipText
public String bitsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setChannels
public void setChannels(int value)
Sets the number of channels to record.- Parameters:
value- the channels
-
getChannels
public int getChannels()
Returns the number of channels to record.- Returns:
- the channels
-
channelsTipText
public String channelsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setSigned
public void setSigned(boolean value)
Sets whether to use signed data.- Parameters:
value- true if signed data
-
getSigned
public boolean getSigned()
Returns whether to use signed data.- Returns:
- true if signed data
-
signedTipText
public String signedTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setBigEndian
public void setBigEndian(boolean value)
Sets whether to use big endian.- Parameters:
value- true if big endian
-
getBigEndian
public boolean getBigEndian()
Returns whether to use big endian.- Returns:
- true if big endian
-
bigEndianTipText
public String bigEndianTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceadams.core.QuickInfoSupporter- Returns:
- null if no info available, otherwise short string
-
generates
public abstract Class generates()
Returns the type of data that it outputs.- Returns:
- the data type
-
getAudioFormat
protected AudioFormat getAudioFormat()
Returns the audio format based on the options.- Returns:
- the audio format
-
getDataLineInfo
protected DataLine.Info getDataLineInfo(AudioFormat format, adams.core.MessageCollection errors)
Returns the data line info. Checks whether the format is supported.- Parameters:
format- the format to get the info forerrors- for storing error messages, like line is not supported- Returns:
- the info object
-
doRecord
protected abstract T doRecord()
Records the audio.- Returns:
- the generated data
-
record
public T record()
Records the audio.- Returns:
- the generated data
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceadams.core.Stoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStoppedin interfaceadams.core.StoppableWithFeedback- Returns:
- true if stopped
-
-