be.hogent.tarsos.dsp.pitch
Class DTMF

java.lang.Object
  extended by be.hogent.tarsos.dsp.pitch.DTMF

public class DTMF
extends java.lang.Object

Utility class to generate Dual-tone multi-frequency (DTMF) signaling tones. This class also contains a list of valid DTMF frequencies and characters. See the WikiPedia article on DTMF.

Author:
Joren Six

Field Summary
static char[][] DTMF_CHARACTERS
          The list of valid DTMF characters.
static double[] DTMF_FREQUENCIES
          The list of valid DTMF frequencies.
 
Constructor Summary
DTMF()
           
 
Method Summary
static float[] audioBufferDTMF(double f0, double f1, int size)
          Creates an audio buffer in a float array of the defined size.
static float[] generateDTMFTone(char character)
          Generate a DTMF - tone for a valid DTMF character.
static boolean isDTMFCharacter(char character)
          Checks if the given character is present in DTMF_CHARACTERS.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DTMF_FREQUENCIES

public static final double[] DTMF_FREQUENCIES
The list of valid DTMF frequencies. See the WikiPedia article on DTMF.


DTMF_CHARACTERS

public static final char[][] DTMF_CHARACTERS
The list of valid DTMF characters. See the WikiPedia article on DTMF for the relation between the characters and frequencies.

Constructor Detail

DTMF

public DTMF()
Method Detail

generateDTMFTone

public static float[] generateDTMFTone(char character)
Generate a DTMF - tone for a valid DTMF character.

Parameters:
character - a valid DTMF character (present in DTMF_CHARACTERS}
Returns:
a float buffer of predefined length (7168 samples) with the correct DTMF tone representing the character.

isDTMFCharacter

public static boolean isDTMFCharacter(char character)
Checks if the given character is present in DTMF_CHARACTERS.

Parameters:
character - the character to check.
Returns:
True if the given character is present in DTMF_CHARACTERS, false otherwise.

audioBufferDTMF

public static float[] audioBufferDTMF(double f0,
                                      double f1,
                                      int size)
Creates an audio buffer in a float array of the defined size. The sample rate is 44100Hz by default. It mixes the two given frequencies with an amplitude of 0.5.

Parameters:
f0 - The first fundamental frequency.
f1 - The second fundamental frequency.
size - The size of the float array (sample rate is 44.1kHz).
Returns:
An array of the defined size.