Class 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.StoppableWithFeedback
    Ancestor 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 boolean m_BigEndian
      whether big endian or little endian.
      protected int m_Bits
      the sample size in bits.
      protected int m_Channels
      the number of channels.
      protected adams.flow.core.Actor m_FlowContext
      the flow context.
      protected float m_SampleRate
      the sample rate.
      protected boolean m_Signed
      whether signed or unsigned.
      protected boolean m_Stopped
      whether recording has been stopped.
      • Fields inherited from class adams.core.option.AbstractOptionHandler

        m_OptionManager
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      String bigEndianTipText()
      Returns the tip text for this property.
      String bitsTipText()
      Returns the tip text for this property.
      String channelsTipText()
      Returns the tip text for this property.
      protected String check()
      Hook method for performing checks before attempting to generate the setups.
      void defineOptions()
      Adds options to the internal list of options.
      protected abstract T doRecord()
      Records the audio.
      abstract Class generates()
      Returns the type of data that it outputs.
      protected AudioFormat getAudioFormat()
      Returns the audio format based on the options.
      boolean getBigEndian()
      Returns whether to use big endian.
      int getBits()
      Returns the sample size in bits.
      int getChannels()
      Returns the number of channels to record.
      protected DataLine.Info getDataLineInfo​(AudioFormat format, adams.core.MessageCollection errors)
      Returns the data line info.
      adams.flow.core.Actor getFlowContext()
      Returns the flow context, if any.
      String getQuickInfo()
      Returns a quick info about the actor, which will be displayed in the GUI.
      float getSampleRate()
      Returns the sample rate to use (hertz).
      boolean getSigned()
      Returns whether to use signed data.
      boolean isStopped()
      Whether the execution has been stopped.
      T record()
      Records the audio.
      abstract boolean requiresFlowContext()
      Returns whether flow context is actually required.
      String sampleRateTipText()
      Returns the tip text for this property.
      void setBigEndian​(boolean value)
      Sets whether to use big endian.
      void setBits​(int value)
      Sets the sample size in bits.
      void setChannels​(int value)
      Sets the number of channels to record.
      void setFlowContext​(adams.flow.core.Actor value)
      Sets the flow context.
      void setSampleRate​(float value)
      Sets the sample rate to use (hertz).
      void setSigned​(boolean value)
      Sets whether to use signed data.
      String signedTipText()
      Returns the tip text for this property.
      void stopExecution()
      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
      • Methods inherited from interface adams.core.logging.LoggingLevelHandler

        getLoggingLevel
    • 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.
    • Constructor Detail

      • AbstractAudioRecorder

        public AbstractAudioRecorder()
    • Method Detail

      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.core.option.AbstractOptionHandler
      • setFlowContext

        public void setFlowContext​(adams.flow.core.Actor value)
        Sets the flow context.
        Specified by:
        setFlowContext in interface adams.flow.core.FlowContextHandler
        Parameters:
        value - the actor
      • getFlowContext

        public adams.flow.core.Actor getFlowContext()
        Returns the flow context, if any.
        Specified by:
        getFlowContext in interface adams.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:
        getQuickInfo in interface adams.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 for
        errors - 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:
        stopExecution in interface adams.core.Stoppable
      • isStopped

        public boolean isStopped()
        Whether the execution has been stopped.
        Specified by:
        isStopped in interface adams.core.StoppableWithFeedback
        Returns:
        true if stopped