Beispiel #1
0
        private void AllocateFrequencyBands()
        {
            multibandManager = new MultibandManagerOneDemod(demodulators);
            if (nfa >= nfb)
            {
                return;
            }
            int nDemodsMinusOne = demodulators.Count() - 1;

            if (nDemodsMinusOne == 0)
            {
                demodulator.nfa = m_nfa;
                demodulator.nfb = m_nfb;
                return;
            }

            // defer assigning nfa and nfb until the demodulator starts
            List <FrequencyBand> bands = new List <FrequencyBand>();

            bands.Add(new FrequencyBand(m_nfa));

            // iterate over all but first and last
            double diff   = m_nfb - m_nfa;
            double range  = diff / (nDemodsMinusOne + 1);
            int    num    = nDemodsMinusOne + 1;
            bool   enable = true;

            if (range < MIN_RANGE_HZ)
            {   // limit multi-processing to wider than this
                num = (int)(diff / MIN_RANGE_HZ);
                if (num <= 1)
                {
                    // the best we can do is put the whole range in one decoder
                    num    = 1;
                    enable = false;
                }
                range = diff / num;
            }
            for (int i = 1; i <= nDemodsMinusOne; i++)
            {
                if (enable)
                {
                    int lowBound = (int)(m_nfa + i * range);
                    if (lowBound >= m_nfb)
                    {
                        enable = false;
                    }
                    bands.Last().nfb = lowBound + FREQ_OVERLAP_HZ;
                    bands.Add(new FrequencyBand(lowBound - FREQ_OVERLAP_HZ));
                }
                enabled[i] = enable;
            }
            bands.Last().nfb = m_nfb;
            multibandManager = new MultibandManager(bands.ToArray(), demodulators);
        }
Beispiel #2
0
        private XDft.RxSinkRepeater rxSinkRepeater; // need help repeating the RX audio to each decoder

        // have to know at construction time how many decoders
        public MultiDemodulatorWrapper(int instanceNumber, uint numDemodulators = 1)
        {
            if (numDemodulators > MAX_MULTIPROC)
            {
                numDemodulators = (uint)MAX_MULTIPROC;
            }
            if (numDemodulators == 0)
            {
                numDemodulators = 1;
            }

            demodulators     = new XDft.Demodulator[numDemodulators];
            wsjtSharedMems   = new XDft.WsjtSharedMemory[numDemodulators];
            wsjtExes         = new XDft.WsjtExe[numDemodulators];
            enabled          = new bool[numDemodulators];
            sharedMemoryKeys = new string[numDemodulators];

            for (uint i = 0; i < numDemodulators; i++)
            {
                demodulators[i] = new XDft.Demodulator();
                enabled[i]      = true;

                // The first decoder gets the same subdirectory name as a single decoder
                string sharedMemoryKey = "DigiRite-" + instanceNumber.ToString();
                if (i != 0) // subsequent ones get extra goop in their names
                {
                    sharedMemoryKey += "-" + i.ToString();
                }
                wsjtSharedMems[i] = new XDft.WsjtSharedMemory(sharedMemoryKey, false);
                if (!wsjtSharedMems[i].CreateWsjtSharedMem())
                {
                    throw new System.Exception("Failed to create Shared Memory from " + sharedMemoryKey);
                }

                // The subprocess itself is managed by the XDft
                wsjtExes[i]             = new XDft.WsjtExe();
                wsjtExes[i].AppDataName = sharedMemoryKey;
                sharedMemoryKeys[i]     = sharedMemoryKey;

                if (!wsjtExes[i].CreateWsjtProcess(wsjtSharedMems[i]))
                {
                    Dispose();
                    throw new System.Exception("Failed to launch wsjt exe");
                }
            }
            multibandManager = new MultibandManagerOneDemod(demodulators);
        }