Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 public void PrepareForData(bool sendPreamble)
 {
     this.nextGenerator = new PrepareForDataGenerator(sampleRate, freqOne, freqZero, sendPreamble);
 }
Exemplo n.º 4
0
 public void Repeat(bool sendPause, int[] bits)
 {
     this.nextGenerator = new RepeatGenerator(sampleRate, freqOne, freqZero, sendPause ? 500 : 0, bits);
 }
Exemplo n.º 5
0
 public void SendANSam()
 {
     this.nextGenerator = new ANSamGenerator(sampleRate);
 }
Exemplo n.º 6
0
 public void Silence()
 {
     this.nextGenerator = new SilenceGenerator();
 }