public void SetInputFile(string fileName, Channel channel = Channel.Left, int repeat = 1) { switch (channel) { case Channel.Left: { if (decoderLeft == null) { decoderLeft = new PCMDecoder(16, 16000, 1, false, this); } for (var i = 0; i < repeat; i++) { decoderLeft.LoadFile(fileName); } inputFileLeft = fileName; } break; case Channel.Right: { if (decoderRight == null) { decoderRight = new PCMDecoder(16, 16000, 1, false, this); } for (var i = 0; i < repeat; i++) { decoderRight.LoadFile(fileName); } inputFileRight = fileName; } break; } }
private void Start() { if (enableTx.Value) { if (OutputFile == "") { this.Log(LogLevel.Error, "Starting transmission without an output file!"); return; } encoder = new PCMEncoder(sampleWidth, sampleFrequency, numberOfChannels, false); encoder.SetBufferingBySamplesCount(maxSamplesCount.Value); encoder.Output = OutputFile; } if (enableRx.Value) { if (InputFile == "") { this.Log(LogLevel.Error, "Starting reception without an input file!"); return; } decoder = new PCMDecoder(sampleWidth, sampleFrequency, numberOfChannels, false, this); decoder.LoadFile(InputFile); } StartRxTxThread(); }
private void StartRx() { // All three flags must be set to start the acquisition, as they are stored in 3 separate registers this function will be called two times before we are ready to start if (rxEnabled.Value == false || slaveEnabled.Value == false || slaveClockEnabled.Value == false) { this.Log(LogLevel.Debug, @"Reception has not been started - it needs I2S_RX_CFG.ENABLE, I2S_SLV_SETUP.SLAVE_EN and I2S_CLKCFG_SETUP.SLAVE_CLK_EN to be set. Current state: I2S_RX_CFG.ENABLE = {0}, I2S_SLV_SETUP.SLAVE_EN = {1}, I2S_CLKCFG_SETUP.SLAVE_CLK_EN = {2}", rxEnabled.Value, slaveEnabled.Value, slaveClockEnabled.Value); return; } if (InputFile == "") { this.Log(LogLevel.Error, "Starting reception without an input file! Aborting"); return; } decoder = new PCMDecoder(rxSampleWidth, RxSampleFrequency, rxChannels, false, this); decoder.LoadFile(InputFile); this.Log(LogLevel.Debug, "Starting reception"); if (rxContinuous.Value) { if (RxSampleFrequency == 0) { this.Log(LogLevel.Error, "Sampling frequency not set. Aborting continuous reception"); return; } rxThread = machine.ObtainManagedThread(InputFrames, (int)RxSampleFrequency); rxThread.Start(); } else { InputFrames(); } }
public LiteX_I2S_Slave(Machine machine, DataFormat format, uint sampleWidthBits, uint samplingRateHz, uint numberOfChannels) : base(machine, format, sampleWidthBits, samplingRateHz) { decoder = new PCMDecoder(sampleWidthBits, samplingRateHz, numberOfChannels, false, this); SamplesPushFrequency = 100; }