Exemple #1
0
 public ToneGenerator(int sampleRate, int dataFreq)
 {
     this.sampleRate       = sampleRate;
     this.freqOne          = dataFreq - 100;
     this.freqZero         = dataFreq + 100;
     this.currentGenerator = new SilenceGenerator();
     this.nextGenerator    = null;
     SetWaveFormat(sampleRate, 1);
 }
Exemple #2
0
        public override int Read(float[] samples, int offset, int sampleCount)
        {
            var numRead = currentGenerator.Generate(samples, offset, sampleCount);

            if (currentGenerator.IsDone)
            {
                if (nextGenerator != null)
                {
                    currentGenerator = nextGenerator;
                    nextGenerator    = null;
                }
                else if (currentGenerator.ReadyForData)
                {
                    currentGenerator = new DataGenerator(sampleRate, freqOne, freqZero, false);
                    nextGenerator    = null;
                }
            }
            return(numRead);
        }
Exemple #3
0
 public void PrepareForData(bool sendPreamble)
 {
     this.nextGenerator = new PrepareForDataGenerator(sampleRate, freqOne, freqZero, sendPreamble);
 }
Exemple #4
0
 public void Repeat(bool sendPause, int[] bits)
 {
     this.nextGenerator = new RepeatGenerator(sampleRate, freqOne, freqZero, sendPause ? 500 : 0, bits);
 }
Exemple #5
0
 public void SendANSam()
 {
     this.nextGenerator = new ANSamGenerator(sampleRate);
 }
Exemple #6
0
 public void Silence()
 {
     this.nextGenerator = new SilenceGenerator();
 }