Class MicrophoneSourceNode

java.lang.Object
com.codename1.media.audio.AudioNode
com.codename1.media.audio.MicrophoneSourceNode

public final class MicrophoneSourceNode extends AudioNode

Live captured audio as a graph source, the Codename One counterpart of the Web Audio MediaStreamAudioSourceNode for a microphone. Created by BaseAudioContext.createMicrophoneSource(AudioBuffer) over the AudioBuffer a recorder fills when it is built with MediaRecorderBuilder.redirectToAudioBuffer(true).

The node outputs one or two channels, as the capture delivers them (a capture with more keeps the first two), resampled to the context's rate. It keeps its delay short: when the graph falls behind it drops the oldest captured audio rather than fall further behind, and when capture stalls it outputs silence. Call close() to detach it from the buffer.

  • Method Details

    • getSource

      public AudioBuffer getSource()

      The buffer this node reads.

      Returns

      the capture buffer

    • close

      public void close()
      Stops listening to the capture buffer; the node outputs silence after what it already received. Recording itself is the recorder's to stop.