示例#1
0
 public static void Run(float f = 10, bool[] data = null)
 {
     //
     // Data
     //
     if(data==null) data = new bool[]{ false, false, false, true };
     //
     // Baseband and carrier generation
     //
     BinaryData b = new BinaryData(data, 30 * f); // baseband
     //
     //mod
     //
     Signal ask_mod = ASK.Modulate(b, f, 1);
     Signal psk_mod = PSK.BPSK_Modulate(b, f);
     Signal fsk_mod = FSK.BFSK_Modulate(b, f, 2 * f);
     //
     //demod
     //
     BinaryData ask_d = (BinaryData)ASK.DeModulate(ask_mod, f);
     BinaryData psk_d = (BinaryData)PSK.BPSK_Demodulate(psk_mod, f);
     BinaryData fsk_d = (BinaryData)FSK.BFSK_DeModulate(fsk_mod, f, 2 * f);
     //
     // display
     //
     Debug.Print("ASK : "); ask_d.Display();
     Debug.Print("PSK : "); psk_d.Display();
     Debug.Print("FSK : "); fsk_d.Display();
 }
示例#2
0
        public static Signal NRZ_Polar(BinaryData data, float high_volt, float low_volt)
        {
            for (int i = 0 ; i < data.Samples.Length ; i++)
            {
                data.Samples[i] = (data.Samples[i] > 0) ? high_volt : low_volt;
            }

            return data;
        }
示例#3
0
 public static Signal BFSK_Modulate(BinaryData baseband, float f1, float f2)
 {
     Signal modFSK = new Signal();
     float tmp = 1 / baseband.SamplingRate; //(30 * Math.Max(f1,f2));
     float t = 0;
     BaseSignalGenerator s = new BaseSignalGenerator(    SignalType.Sine);
     modFSK.Samples = new double[baseband.Samples.Length];
     modFSK.SamplingRate = baseband.SamplingRate;
     for (int i = 0 ; i < baseband.Samples.Length ; i++)
     {
         if (baseband.Samples[i] == 1)
         {
             s.Frequency = f1;
         }
         else
         {
             s.Frequency = f2;
         }
         modFSK.Samples[i] = s.GetValue(t);
         t += tmp;
     }
     return modFSK;
 }