ocvolume.audio
Class micInput

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--ocvolume.audio.micInput
All Implemented Interfaces:
java.lang.Runnable

public class micInput
extends java.lang.Thread

description: continuous record voice from microphone, with at least 600ms pause in between words or discrete recording with at least 100ms in the front and end being silent default is continuous recording
calls: none
called by: volume
input: digitalize speech signal
output: speech signal stored in array


Field Summary
protected static javax.sound.sampled.AudioFormat format
          audio format
protected static boolean SAMPLE_BIG_ENDIAN
          use little-endian
00000100 00000001
first byte 00000001
second byte 00000100
protected static int SAMPLE_BITS
          sample size - 16 bits
protected static int SAMPLE_BUFFER_SIZE
          buffersize 2 seconds
protected static int SAMPLE_CHANNELS
          sample channels
protected static javax.sound.sampled.AudioFormat.Encoding SAMPLE_ENCODING
          encoding method "pulse-code modulation" predefined encoding
protected static float SAMPLE_FRAME_RATE
          sample frame rate
protected static int SAMPLE_FRAME_SIZE
          sample frame size
protected static float SAMPLE_RATE
          capture amound of sample per second, can be changed in the constructor 16 kHz
protected  java.util.Vector vBufferWord
          word buffer
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
micInput()
          Constructor
 
Method Summary
 boolean byteArrayComplete()
          return true if a word is stored in the buffer
calls: none
called by: volume
 void newWord()
          read the next element in the word buffer
calls: none
called by: volume
 void removeOldWord()
          remove the first element in the word buffer
calls: none
called by: volume
 short returnShort(int IndexNum)
          return the signed short with given index
calls: none
called by: volume
 short[] returnShortArray()
          return the signed short array
calls: none
called by: volume
 int returnShortSize()
          return the length of the array of the short array
calls: none
called by: volume
 void run()
          recording from the microphone
calls: none
called by: volume
 void setContinuous()
          set the recording method to continuous
calls: none
called by: volume
 void setDiscrete()
          set the recording method to discrete
calls: none
called by: volume
 void stopRecord()
          Stop the mic input
calls: none
called by: volume
 int wordBufferSize()
          return how many words are in the buffer
calls: none
called by: volume
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SAMPLE_ENCODING

protected static final javax.sound.sampled.AudioFormat.Encoding SAMPLE_ENCODING
encoding method "pulse-code modulation" predefined encoding


SAMPLE_RATE

protected static final float SAMPLE_RATE
capture amound of sample per second, can be changed in the constructor 16 kHz

See Also:
Constant Field Values

SAMPLE_BITS

protected static final int SAMPLE_BITS
sample size - 16 bits

See Also:
Constant Field Values

SAMPLE_CHANNELS

protected static final int SAMPLE_CHANNELS
sample channels

See Also:
Constant Field Values

SAMPLE_FRAME_RATE

protected static final float SAMPLE_FRAME_RATE
sample frame rate

See Also:
Constant Field Values

SAMPLE_FRAME_SIZE

protected static final int SAMPLE_FRAME_SIZE
sample frame size

See Also:
Constant Field Values

SAMPLE_BIG_ENDIAN

protected static final boolean SAMPLE_BIG_ENDIAN
use little-endian
00000100 00000001
first byte 00000001
second byte 00000100

See Also:
Constant Field Values

SAMPLE_BUFFER_SIZE

protected static final int SAMPLE_BUFFER_SIZE
buffersize 2 seconds

See Also:
Constant Field Values

format

protected static final javax.sound.sampled.AudioFormat format
audio format


vBufferWord

protected java.util.Vector vBufferWord
word buffer

Constructor Detail

micInput

public micInput()
Constructor

Method Detail

run

public void run()
recording from the microphone
calls: none
called by: volume

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

stopRecord

public void stopRecord()
Stop the mic input
calls: none
called by: volume


wordBufferSize

public int wordBufferSize()
return how many words are in the buffer
calls: none
called by: volume

Returns:
number of words in the buffer

byteArrayComplete

public boolean byteArrayComplete()
return true if a word is stored in the buffer
calls: none
called by: volume

Returns:
true or false indicating whether a word is in the buffer

newWord

public void newWord()
read the next element in the word buffer
calls: none
called by: volume


removeOldWord

public void removeOldWord()
remove the first element in the word buffer
calls: none
called by: volume


setContinuous

public void setContinuous()
set the recording method to continuous
calls: none
called by: volume


setDiscrete

public void setDiscrete()
set the recording method to discrete
calls: none
called by: volume


returnShortSize

public int returnShortSize()
return the length of the array of the short array
calls: none
called by: volume

Returns:
length of signal

returnShort

public short returnShort(int IndexNum)
return the signed short with given index
calls: none
called by: volume

Parameters:
IndexNum - index number
Returns:
signal at given index

returnShortArray

public short[] returnShortArray()
return the signed short array
calls: none
called by: volume

Returns:
signal array