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