Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.service.neomedia
Class DTMFInbandTone

java.lang.Object
  extended by net.java.sip.communicator.service.neomedia.DTMFInbandTone

public class DTMFInbandTone
extends Object

Manages the generation of the inband DMTF signal. A signal is identified by a value (1, 2, 3, 4, 5, 6, 7, 8, 9, *, #, A, B, C and D) and each signal is produced by the composition of 2 frequencies (as defined below). (cf. ITU recommendation Q.23) +------------------------------------------------+ | | 1209 Hz | 1336 Hz | 1477 Hz | 1633 Hz | +------------------------------------------------+ | 697 Hz | 1 | 2 | 3 | A | | 770 Hz | 4 | 5 | 6 | B | | 852 Hz | 7 | 8 | 9 | C | | 941 Hz | * | 0 | # | D | +------------------------------------------------+

Author:
Vincent Lucas

Field Summary
static DTMFInbandTone DTMF_INBAND_0
          The "0" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_1
          The "1" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_2
          The "2" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_3
          The "3" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_4
          The "4" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_5
          The "5" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_6
          The "6" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_7
          The "7" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_8
          The "8" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_9
          The "9" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_A
          The "A" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_B
          The "B" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_C
          The "C" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_D
          The "D" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_SHARP
          The "#" DTMF Inband Tone.
static DTMFInbandTone DTMF_INBAND_STAR
          The "*" DTMF Inband Tone.
 
Constructor Summary
DTMFInbandTone(String value, double frequency1, double frequency2)
          Creates a new instance of an inband tone.
 
Method Summary
 double getAudioSampleContinuous(double samplingFrequency, int sampleNumber)
          Generates a sample for the current tone signal.
 int getAudioSampleDiscrete(double samplingFrequency, int sampleNumber, int sampleSizeInBits)
          Generates a sample for the current tone signal converted into a discrete signal.
 int[] getAudioSamples(double samplingFrequency, int sampleSizeInBits)
          Generates a signal sample for the current tone signal and stores it into the byte data array.
 double getFrequency1()
          Returns the first frequency coded by this tone.
 double getFrequency2()
          Returns the second frequency coded by this tone.
 String getValue()
          Returns this tone value as a string representation.
static DTMFInbandTone mapTone(DTMFTone tone)
          Maps between protocol and media inband DTMF objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DTMF_INBAND_0

public static final DTMFInbandTone DTMF_INBAND_0
The "0" DTMF Inband Tone.


DTMF_INBAND_1

public static final DTMFInbandTone DTMF_INBAND_1
The "1" DTMF Inband Tone.


DTMF_INBAND_2

public static final DTMFInbandTone DTMF_INBAND_2
The "2" DTMF Inband Tone.


DTMF_INBAND_3

public static final DTMFInbandTone DTMF_INBAND_3
The "3" DTMF Inband Tone.


DTMF_INBAND_4

public static final DTMFInbandTone DTMF_INBAND_4
The "4" DTMF Inband Tone.


DTMF_INBAND_5

public static final DTMFInbandTone DTMF_INBAND_5
The "5" DTMF Inband Tone.


DTMF_INBAND_6

public static final DTMFInbandTone DTMF_INBAND_6
The "6" DTMF Inband Tone.


DTMF_INBAND_7

public static final DTMFInbandTone DTMF_INBAND_7
The "7" DTMF Inband Tone.


DTMF_INBAND_8

public static final DTMFInbandTone DTMF_INBAND_8
The "8" DTMF Inband Tone.


DTMF_INBAND_9

public static final DTMFInbandTone DTMF_INBAND_9
The "9" DTMF Inband Tone.


DTMF_INBAND_STAR

public static final DTMFInbandTone DTMF_INBAND_STAR
The "*" DTMF Inband Tone.


DTMF_INBAND_SHARP

public static final DTMFInbandTone DTMF_INBAND_SHARP
The "#" DTMF Inband Tone.


DTMF_INBAND_A

public static final DTMFInbandTone DTMF_INBAND_A
The "A" DTMF Inband Tone.


DTMF_INBAND_B

public static final DTMFInbandTone DTMF_INBAND_B
The "B" DTMF Inband Tone.


DTMF_INBAND_C

public static final DTMFInbandTone DTMF_INBAND_C
The "C" DTMF Inband Tone.


DTMF_INBAND_D

public static final DTMFInbandTone DTMF_INBAND_D
The "D" DTMF Inband Tone.

Constructor Detail

DTMFInbandTone

public DTMFInbandTone(String value,
                      double frequency1,
                      double frequency2)
Creates a new instance of an inband tone. The value given is the main identifier which determines which are the two frequencies to used to generate this tone.

Parameters:
value - The identifier of the tone. Available values are (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, *, #, A, B, C and D).
frequency1 - The first frequency which composes the tone. Available values corresponds to DTMFInbandTone.frequencyList1.
frequency2 - The second frequency which composes the tone. Available values corresponds to DTMFInbandTone.frequencyList2.
Method Detail

getValue

public String getValue()
Returns this tone value as a string representation.

Returns:
this tone value.

getFrequency1

public double getFrequency1()
Returns the first frequency coded by this tone.

Returns:
the first frequency coded by this tone.

getFrequency2

public double getFrequency2()
Returns the second frequency coded by this tone.

Returns:
the second frequency coded by this tone.

getAudioSampleContinuous

public double getAudioSampleContinuous(double samplingFrequency,
                                       int sampleNumber)
Generates a sample for the current tone signal.

Parameters:
samplingFrequency - The sampling frequency (codec clock rate) in Hz of the stream which will encapsulate this signal.
sampleNumber - The sample number of this signal to be produced. The sample number corresponds to the abscissa of the signal function.
Returns:
the sample generated. This sample corresponds to the ordinate of the signal function

getAudioSampleDiscrete

public int getAudioSampleDiscrete(double samplingFrequency,
                                  int sampleNumber,
                                  int sampleSizeInBits)
Generates a sample for the current tone signal converted into a discrete signal.

Parameters:
samplingFrequency - The sampling frequency (codec clock rate) in Hz of the stream which will encapsulate this signal.
sampleNumber - The sample number of this signal to be produced. The sample number corresponds to the abscissa of the signal function.
sampleSizeInBits - The size of each sample (8 for a byte, 16 for a short and 32 for an int)
Returns:
the sample generated. This sample corresponds to the ordinate of the signal function

getAudioSamples

public int[] getAudioSamples(double samplingFrequency,
                             int sampleSizeInBits)
Generates a signal sample for the current tone signal and stores it into the byte data array.

Parameters:
samplingFrequency - The sampling frequency (codec clock rate) in Hz of the stream which will encapsulate this signal.
sampleSizeInBits - The size of each sample (8 for a byte, 16 for a short and 32 for an int)
Returns:
The data array containing the DTMF signal.

mapTone

public static DTMFInbandTone mapTone(DTMFTone tone)
Maps between protocol and media inband DTMF objects.

Parameters:
tone - The DTMF tone as defined in the service protocol, which is only composed by a value as its identifier.
Returns:
the corresponding DTMF tone which contains a value as an identifier and two frequencies composing the inband tone.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.