Beispiel #1
0
        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();
            }
        }