Class Capture3

    • Field Detail

      • DEF_AUDIO_FILE_TYPE

        public static javax.sound.sampled.AudioFileFormat.Type DEF_AUDIO_FILE_TYPE
      • DEF_AUDIO_FORMAT

        public static javax.sound.sampled.AudioFormat DEF_AUDIO_FORMAT
      • DEF_AUDIO_FILE_FORMAT

        public static javax.sound.sampled.AudioFileFormat DEF_AUDIO_FILE_FORMAT
    • Constructor Detail

      • Capture3

        public Capture3()
        Create capture engine.
      • Capture3

        public Capture3​(javax.sound.sampled.Mixer device)
        Create capture engine which will capture audio data from given device.
        Parameters:
        device - audio device to use
      • Capture3

        public Capture3​(javax.sound.sampled.Mixer device,
                        java.io.File recFile,
                        javax.sound.sampled.AudioFileFormat aff)
        Create capture engine.
        Parameters:
        device - audio device to use
        recFile - recordingfile
        aff - audio file format
    • Method Detail

      • isNotifyLineActivation

        public boolean isNotifyLineActivation()
        Returns:
        the notifyLineActivation
      • setNotifyLineActivation

        public void setNotifyLineActivation​(boolean notifyLineActivation)
        Parameters:
        notifyLineActivation - the notifyLineActivation to set
      • isUseTempFile

        public boolean isUseTempFile()
      • setAudioFileFormat

        public void setAudioFileFormat​(javax.sound.sampled.AudioFileFormat aff)
        Set audio file format.
        Parameters:
        aff - audio file format
      • getAudioFileFormat

        public javax.sound.sampled.AudioFileFormat getAudioFileFormat()
        Get audio file format.
        Returns:
        audio file format
      • setAudioFormat

        public void setAudioFormat​(javax.sound.sampled.AudioFormat af)
        Set audio format.
        Parameters:
        af - audio format.
      • getAudioFormat

        public javax.sound.sampled.AudioFormat getAudioFormat()
        Get audio format.
        Returns:
        audio format
      • getMinLineBufferSize

        public java.lang.Integer getMinLineBufferSize()
        Get minimum line buffer size.
        Returns:
        minimum line buffer size or null if not available
      • getMaxLineBufferSize

        public java.lang.Integer getMaxLineBufferSize()
        Get maximum line bugffer size.
        Returns:
        maximum line buffer size or null if not available
      • start

        public void start()
        Start capturing or recording.
      • getMaxFrameLength

        public long getMaxFrameLength()
        Get maxim recording length in frames.
        Returns:
        max length in frames
      • getFramePosition

        public long getFramePosition()
        Get already captured frames.
        Returns:
        frames captured/recorded
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • addCaptureListener

        public void addCaptureListener​(CaptureListener pl)
        Add capture listener.
        Parameters:
        pl - capture listener
      • removeCaptureListener

        public void removeCaptureListener​(CaptureListener pl)
        Remove capture listener.
        Parameters:
        pl - capture listener
      • addAudioOutputStream

        public void addAudioOutputStream​(IAudioOutputStream aos)
        Add audio output stream.
        Parameters:
        aos - audio output stream
      • removeAudioOutputStream

        public void removeAudioOutputStream​(IAudioOutputStream aos)
        Remove audio output stream
        Parameters:
        aos - audio output stream
      • isRecording

        public boolean isRecording()
        Returns true if recording.
        Returns:
        true if recording
      • isCapturing

        public boolean isCapturing()
        Return true if capturing.
        Returns:
        true if capturing
      • setRecordingFile

        public void setRecordingFile​(java.io.File file)
        Set recording file.
        Parameters:
        file - recording file
      • setRecordingItem

        public void setRecordingItem​(java.io.File file,
                                     java.lang.String recId)
        Set recording file and ID.
        Parameters:
        file - recording file
        recId - recording ID
      • getRecordingFile

        public java.io.File getRecordingFile()
        Get recording file
        Returns:
        recording file
      • setMixer

        public void setMixer​(javax.sound.sampled.Mixer newCaptureMixer)
        Set the recording device to capture from. The given device will be used if the capture engine is opened the next time.
        Parameters:
        newCaptureMixer - recording device
      • isCaptureOnly

        public boolean isCaptureOnly()
        Returns true if the engine is only capturing, not recording to file.
        Returns:
        true if capturing
      • setCaptureOnly

        public void setCaptureOnly​(boolean captureOnly)
        Set capture only mode. In capture mode no recording file will be written. Capture mode may be used to measure input level without recording.
      • getPreferredBufferSize

        public java.lang.Integer getPreferredBufferSize()
        Get preferred buffer size in bytes.
        Returns:
        preferred buffer size or null if default
      • setPreferredBufferSize

        public void setPreferredBufferSize​(int preferredBufferSize)
        Set the buffer size of this capture engine in bytes.
        Parameters:
        preferredBufferSize -
      • getBufferSize

        public int getBufferSize()
        The actually set buffer size.
        Returns:
        buffer size
      • getPreferredLineBufferSize

        public java.lang.Integer getPreferredLineBufferSize()
        Get the preferred audio line buffer size setting.
        Returns:
        preferred audio line buffer size
      • setPreferredLineBufferSize

        public void setPreferredLineBufferSize​(java.lang.Integer preferredLineBufferSize)
        Set the buffer size of the audio line. It is recommended to set this to one second ( @see setPreferredLineBufferSizeMillis(Float) setPreferredLineBufferSizeMillis(Float)), which is the maximum line buffer size under Windows XP to avoid buffer overruns (especially during garbage collector runs). The default setting is to open the line with default JavaSound settings (500ms for Windows).
        Parameters:
        preferredLineBufferSize -
      • getLineBufferSize

        public java.lang.Integer getLineBufferSize()
        Get the last used line buffer size. Returns the last used line buffer size.
        Returns:
        audio line buffer size or null if capture was not started yet
      • getLineBufferSizeSeconds

        public java.lang.Float getLineBufferSizeSeconds()
        Get the last used line buffer size in seconds. Returns the last used line buffer size.
        Returns:
        audio line buffer size or null if capture line was not opened yet
      • isOpen

        public boolean isOpen()
        Return open status.
        Returns:
        false if capture engine is closed
      • getPreferredLineBufferSizeMillis

        public java.lang.Float getPreferredLineBufferSizeMillis()
        Get preferred line buffer size in milliseconds.
        Returns:
        preferred line buffer size in milliseconds or null if not set.
      • setPreferredLineBufferSizeMillis

        public void setPreferredLineBufferSizeMillis​(java.lang.Float preferredLineBufferSizeMillis)
        Set the buffer size of the audio line. It is recommended to set this to one second, which is the maximum line buffer size under Windows XP to avoid buffer overruns (especially during garbage collector runs). The default setting is to open the line with default JavSound settings (500ms for Windows).
        Parameters:
        preferredLineBufferSizeMillis - preferred line buffer size in milliseconds or null for default
      • isUseAWTEventThread

        public boolean isUseAWTEventThread()
        True if generated events will be queued to AWT event queue.
        Returns:
        true if AWT event queue is used
      • setUseAWTEventThread

        public void setUseAWTEventThread​(boolean useAWTEventThread)
        Determines if events should be queued to the AWTEventThread. For GUI applications it is recommended to set this to true, to avoid AWT/Swing deadlocks (Swing is not thread safe).
        Parameters:
        useAWTEventThread -
      • setMaxFrameLength

        public void setMaxFrameLength​(long maxFrameLength)
        Set the maximum length of recording in frames. The capture engine will stop if the amount of frames are recorded.
        Parameters:
        maxFrameLength - maximum recording length in frames
      • isForceOpening

        public boolean isForceOpening()
      • setForceOpening

        public void setForceOpening​(boolean forceOpening)
      • setPrimaryRecordTarget

        public void setPrimaryRecordTarget​(PrimaryRecordTarget primaryRecordTarget)
      • getRecordingSessionInfoFile

        public java.io.File getRecordingSessionInfoFile()
      • setRecordingSessionInfoFile

        public void setRecordingSessionInfoFile​(java.io.File recordingSessionInfoFile)
      • isWriteRecordingInfo

        public boolean isWriteRecordingInfo()
      • setWriteRecordingInfo

        public void setWriteRecordingInfo​(boolean writeRecordingInfo)
      • getRecId

        public java.lang.String getRecId()
      • setRecId

        public void setRecId​(java.lang.String recId)
      • getChannelRouting

        public ChannelRouting getChannelRouting()
        Get channel routing
        Returns:
        current applied channel routing
      • setChannelRouting

        public void setChannelRouting​(ChannelRouting channelRouting)
        Set channel routing
        Parameters:
        channelRouting - channel routing to set
      • main

        public static void main​(java.lang.String[] args)
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • update

        public void update​(javax.sound.sampled.LineEvent event)
        Specified by:
        update in interface javax.sound.sampled.LineListener