Ejemplo n.º 1
0
        public void RecordSamples(IGSRunConfig runConfig)
        {
            var frequency = runConfig.SampleFrequency;
            var count     = runConfig.SampleCount;
            var rate      = runConfig.SampleRate;
            var filename  = runConfig.FileName;
            var pi        = Math.PI;
            var omega     = 2 * pi * frequency / rate;

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }
            for (int i = 0; i < count; i++)
            {
                var sample = Math.Sin(omega * i) * (65535 - 1) / 2;
                var ss     = Convert.ToInt16(sample);
                binList.Add(ss);
            }

            using BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.Create));
            foreach (var @ushort in binList)
            {
                writer.Write(@ushort);
            }

            writer.Close();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Usage: GenerateSamples {fileOut}{SampleFrequency (Hz)}{SampleDuration (ms)}{SampleRate optional -- defaults to 44100 }");
                return;
            }
            IGSRunConfig runConfig = GSFacade.SetRunConfig(args);

            GSFacade.RecordSamples(runConfig);
        }
Ejemplo n.º 3
0
        public static void RecordSamples(IGSRunConfig runConfig)
        {
            iSampleRecorder sr = new SampleRecorder();

            sr.RecordSamples(runConfig);
        }