Click or drag to resize

DTMF Class

Dual Tone Multi-Frequency Class.
Inheritance Hierarchy
SystemObject
  GSF.Media.SoundDTMF
    GSF.Media.SoundTouchTone

Namespace: GSF.Media.Sound
Assembly: GSF.Media (in GSF.Media.dll) Version: 2.4.207-beta
Syntax
public class DTMF
View Source

The DTMF type exposes the following members.

Constructors
 NameDescription
Public methodDTMF Constructs a new DTMF.
Public methodDTMF(Double, Double, Double) Constructs a new DTMF using specified parameters.
Top
Properties
 NameDescription
Public propertyStatic memberBusySignalGets the DTMF instances representing a telephone busy signal.
Public propertyStatic memberDialToneGets the DTMF instance representing a telephone dial tone.
Public propertyStatic memberEmergencyBroadcastSystemAlertGets the DTMF instance representing the Emergency Broadcast System alert tone.
Public propertyStatic memberOffHookGets the DTMF instances representing a telephone off-the-hook signal.
Top
Methods
 NameDescription
Public methodStatic memberComputeFrequencies Computes a dual-tone multi-frequency sound for the given DTMF information and time.
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodStatic memberGenerate(WaveFile, DTMF, Double) Generates the specified dual-tone multi-frequency storing it in the specified WaveFile.
Public methodStatic memberGenerate(WaveFile, DTMF, Double) Generates a single instance of each of the specified dual-tone multi-frequencies storing them in the specified WaveFile.
Public methodStatic memberGenerate(WaveFile, DTMF, Double, Int32) Generates the specified dual-tone multi-frequency repeatCount times storing it in the specified WaveFile.
Public methodStatic memberGenerate(WaveFile, DTMF, Double, Int32) Generates the specified dual-tone multi-frequencies repeatCount times storing them in the specified WaveFile.
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Fields
 NameDescription
Public fieldDurationFrequency duration, in seconds, of DTMF.
Public fieldHighFrequencyHigh frequency of DTMF.
Public fieldLowFrequencyLow frequency of DTMF.
Top
Extension Methods
 NameDescription
Public Extension MethodGetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Public Extension MethodGetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Top
Example
This example generates some familiar dual tone multi-frequency sounds and plays them over the computer's speakers:
C#
using System;
using GSF.Media;
using GSF.Media.Sound;

static class Program
{
    static void Main()
    {
        WaveFile waveFile = new WaveFile(SampleRate.Hz8000, BitsPerSample.Bits16, DataChannels.Mono);
        double volume = 0.25D;  // Set volume of tones to 25% of maximum
        DTMF tone;

        // Get the dial tone dual-frequencies
        tone = DTMF.DialTone;

        // Change the duration of the dial-tone to 3 seconds
        tone.Duration = 3.0D;

        // Generate a dial tone
        DTMF.Generate(waveFile, tone, volume);

        // Generate a busy-signal tone, repeat four times
        DTMF.Generate(waveFile, DTMF.BusySignal, volume, 4);

        // Generate an off-the-hook tone, repeat eight times
        DTMF.Generate(waveFile, DTMF.OffHook, volume, 8);

        // Get the EBS Alert dual-frequencies
        tone = DTMF.EmergencyBroadcastSystemAlert;

        // The official duration of an EBS Alert is 22.5 seconds, but
        // the noise is rather annoying - so we set it to 4 seconds
        tone.Duration = 4.0D;

        // Generate the EBS Alert noise
        DTMF.Generate(waveFile, tone, volume);

        // Play all the generated tones
        waveFile.Play();

        Console.ReadKey();
    }
}
See Also