Exemple #1
0
        void analize_dtfm(string filename)
        {
            try
            {
                using (var waveFile = new WaveFileReader(filename))
                //using (var waveFile = new WaveFileReader("dtmf_sample.wav"))
                {
                    foreach (var occurence in waveFile.DtmfTones())
                    {
                        string text = String.Format("TotalSeconds :{0:0.00} Key:{1} Duration:{2:0.000}",
                                                    occurence.Position.TotalSeconds, occurence.DtmfTone.Key, occurence.Duration.TotalSeconds);



                        listBox1.Items.Add(text);
                        PhoneKey key = occurence.DtmfTone.Key;

                        listBox1.Items.Add(key.ToString());
                        listBox1.Items.Add(occurence.DtmfTone.ToString());
                        listBox1.Items.Add(occurence.DtmfTone.LowTone.ToString());
                        listBox1.Items.Add(occurence.DtmfTone.HighTone.ToString());


                        ////listBox1.Items.Add(       $"{occurence.Position.TotalSeconds:00.000} s: "
                        ////                + $"{occurence.DtmfTone.Key} key "
                        ////                + $"(duration: {occurence.Duration.TotalSeconds:00.000} s)");

                        ////Console.WriteLine($"{occurence.Position.TotalSeconds:00.000} s: "
                        ////                + $"{occurence.DtmfTone.Key} key "
                        ////                + $"(duration: {occurence.Duration.TotalSeconds:00.000} s)");
                    }
                }
            }
            catch (SystemException exc)
            {
                MessageBox.Show("Please select WAV file");
            }
        }
Exemple #2
0
 /// <summary>Creates a new `DtmfChange` with the given identification and location.</summary>
 /// <param name="key">The key of the DTMF tone.</param>
 /// <param name="position">The position of the DTMF tone inside the audio data.</param>
 /// <param name="channel">The audio channel of the DTMF tone.</param>
 /// <param name="isStart">Indicates whether a DMTF tone started or stopped at the current position.</param>
 public DtmfChange(PhoneKey key, TimeSpan position, int channel, bool isStart)
 => (Key, Position, Channel, IsStart) = (key, position, channel, isStart);
Exemple #3
0
 public static float[] DtmfToneBlock(PhoneKey k) => Generate(k).FirstBlock();
Exemple #4
0
 /// <summary>Converts a `PhoneKey` to the two frequencies it is encoded with in audio data.</summary>
 /// <param name="key">The key to convert.</param>
 /// <returns>A `ValueTuple` holding the key's high frequency in the first position and its low frequency in the second position.</returns>
 public static (int high, int low) ToDtmfTone(this PhoneKey key) => key switch
Exemple #5
0
 public DtmfTone(int highTone, int lowTone, PhoneKey key)
 {
     HighTone = highTone;
     LowTone  = lowTone;
     Key      = key;
 }
Exemple #6
0
 /// <summary>Creates a new `DtmfTone` with the given identification and location.</summary>
 /// <param name="key">The key of the DTMF tone.</param>
 /// <param name="position">The position of the DTMF tone inside the audio data.</param>
 /// <param name="duration">The length of the DTMF tone.</param>
 /// <param name="channel">The audio channel of the DTMF tone.</param>
 public DtmfTone(PhoneKey key, TimeSpan position, TimeSpan duration, int channel)
 => (Key, Position, Duration, Channel) = (key, position, duration, channel);
 public static DtmfChange Stop(PhoneKey k, int channel = 0) => DtmfChange.Stop(k, new TimeSpan(), channel);
Exemple #8
0
 /// <summary>Generates single-channel PCM data playing the DTMF tone `key` infinitely.</summary>
 /// <param name="key">The DTMF tone to generate.</param>
 /// <param name="sampleRate">Optional sample rate of the PCM data. Defaults to `Config.DefaultSampleRate`.</param>
 /// <returns>An infinite sequence of PCM data playing the specified DMTF tone.</returns>
 public static IEnumerable <float> Generate(PhoneKey key, int sampleRate = Config.DefaultSampleRate)
 => Generate(key.ToDtmfTone(), sampleRate);