예제 #1
0
        public Main()
        {
            InitializeComponent();

            rtlLut = new float[256];
            for (int i = 0; i < 256; i++)
            {
                rtlLut[i] = (i - 128) * (1f / 127f);
            }

            List <AudioDevice> audioDevices = AudioDevice.GetDevices(AudioDeviceDirection.Output);
            AudioDevice        df           = new AudioDevice("", "", 0, AudioDeviceDirection.Output, true);

            foreach (AudioDevice d in audioDevices)
            {
                Console.WriteLine(d.Name);
                if (d.IsDefault)
                {
                    df = d;
                }
            }

            audioFifo = new Queue <float>();
            audioLock = new object();

            pl        = new AudioPlayer(df.Index, audioSampleRate, (uint)(audioBufferInMs * audioSampleRate / 1000), audioBufferNeeded);
            rtlDevice = new RtlDevice(0);
            rtlDevice.SamplesAvailable += RtlDevice_SamplesAvailable;
            rtlDevice.Frequency         = 200600000;
            rtlDevice.SampleRate        = 2560000;

            fmCrusher             = new FmCrusher(2560000, audioSampleRate);
            fmCrusher.AudioEvent += FmCrusher_AudioEvent;
            rtlDevice.Start();
        }
예제 #2
0
        static void Main(string[] args)
        {
            #region Device List Block
            uint deviceCount = Native.rtlsdr_get_device_count();
            if (deviceCount == 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("No Available Devices");
                Console.ForegroundColor = defaultFg;
                waitClickAndExit();
            }

            Console.ForegroundColor = ConsoleColor.DarkCyan;
            for (uint i = 0; i < deviceCount; i++)
            {
                string devName = Native.rtlsdr_get_device_name(i);
                Console.WriteLine("Device({0}): {1}", i, devName);
            }
            Console.ForegroundColor = defaultFg;
            #endregion
            #region Device Select Block
            uint idx = 0;
            if (deviceCount > 1)
            {
                bool valid = false;
                while (!valid)
                {
                    Console.WriteLine("Please enter the device number: ");
                    string devNumStr = Console.ReadLine();
                    valid = uint.TryParse(devNumStr, out idx);
                }
            }
            #endregion
            #region Device Open Block
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Opening device {0}", idx);
            RtlDevice device = new RtlDevice(idx);
            Console.WriteLine("Tuner Type: {0}", device.TunerType.ToString());
            Console.WriteLine("Tuned to: {0}", device.Frequency);
            Console.WriteLine("Sample Rate: {0}", device.SampleRate);
            device.SamplesAvailable += Device_SamplesAvailable;
            Console.WriteLine("Starting Worker Thread");
            device.Start();
            Console.ForegroundColor = defaultFg;
            #endregion
            #region Exit Block
            Console.WriteLine("Press any key to exit.");
            Console.ReadLine();

            Console.WriteLine("Stopping device");
            device.Stop();

            Environment.Exit(0);
            #endregion
        }