private static void ReadSample()
        {
            var readSample = new ReadSample();

            readSample.Run();

            Console.ReadKey();
        }
Exemple #2
0
        protected void ReadPcm(Wavefile wave, SafeStream stream, int len,
                               int bits, int channels, bool intel)
        {
            //if (!wave->dontdelete_) sample_free(wave->idata_) ;
            //wave.m_Samples = new List<Sample>(len);
            wave.m_Samples = new BlockArray <Sample>(12);

            //int (*readfun)(Wavefile::Sample *, Stream *, int) ;

            ReadSample readFunction;

            if (bits == 16)
            {
                if (intel)                 // Intel byte order
                {
                    if (channels == 1)
                    {
                        //readfun = f_read_pcm_16bit_i ;
                        readFunction = new ReadSample(ReadPcmI16Mono);
                    }
                    else if (channels == 2)
                    {
                        //readfun = f_read_pcm_16bit_i_st ;
                        readFunction = new ReadSample(ReadPcmI16Stereo);
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
                else                 // Motorola byte order
                {
                    if (channels == 1)
                    {
                        //readfun = f_read_pcm_16bit_m ;
                        throw new NotImplementedException();
                    }
                    else if (channels == 2)
                    {
                        //readfun = f_read_pcm_16bit_m_st ;
                        throw new NotImplementedException();
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            }
            else if (bits == 8)
            {
                if (channels == 1)
                {
                    //readfun = f_read_pcm_8bit ;
                    throw new NotImplementedException();
                }
                else if (channels == 2)
                {
                    //readfun = f_read_pcm_8bit_st ;
                    throw new NotImplementedException();
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
            else
            {
                throw new InvalidOperationException();
            }

            //int a = 0 ;
            //while (a<len) {
            //    //int numread = readfun(wave->idata_+a, file, (len-a) <? BufSize) ;
            //    //if (numread==0) break ;
            //    a += numread ;
            //}

            Sample[] sample = new Sample[1];
            for (int i = 0; i < len; i++)
            {
                sample[0] = readFunction(stream);
                wave.m_Samples.Write(sample);
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            bool x = true;

            while (x)
            {
                Console.WriteLine("Enter the command to run");
                Console.WriteLine("Commands are : Train, Sort, Test, Show, Revise");
                string line = Console.ReadLine();
                line = line.ToUpper();
                try
                {
                    switch (line)
                    {
                    default:
                        break;

                    case "TRAIN":
                        bool c = true;
                        while (c)
                        {
                            Datasets.RunPredictions(Write);

                            /*
                             * Console.WriteLine("Enter a Datatype to Predict");
                             * string dt = Console.ReadLine();
                             * try
                             * {
                             *  Datatype datatype = (Datatype)Enum.Parse(typeof(Datatype), dt);
                             *  switch(datatype)
                             *  {
                             *      default:
                             *      case Datatype.Masterformat:
                             *          for(int i = 0; i < 1000; i++)
                             *          {
                             *              MasterformatNetwork.Propogate(Write);
                             *          }
                             *          break;
                             *      case Datatype.Command:
                             *          for(int i = 0; i < 1000; i++)
                             *          {
                             *              CmdNetwork.Propogate(Write);
                             *          }
                             *          break;
                             *      case Datatype.OccupantLoadFactor:
                             *          for(int i = 0; i < 1000; i++)
                             *          {
                             *              OLFNetwork.Propogate(Write);
                             *          }
                             *          break;
                             *  }
                             *  Console.WriteLine("Continue? Y / N");
                             *  string cont = Console.ReadLine().ToUpper();
                             *  if(cont == "N")
                             *      c = false;
                             * }
                             * catch
                             * {
                             * }
                             */
                        }
                        Datasets.RunPredictions(new WriteToCMDLine(Write));
                        break;

                    case "SORT":
                        Datatype.Masterformat.Sort();
                        break;

                    case "TEST":
                        Console.WriteLine("Enter a Datatype to Predict");
                        string l2 = Console.ReadLine();
                        bool   d  = true;
                        while (d)
                        {
                            Console.WriteLine("Enter a phrase to predict.");
                            string l3 = Console.ReadLine();
                            PredTest.TestPredictions(l3, l2, new WriteToCMDLine(Write));
                            Console.WriteLine("Continue? Y / N");
                            string l4 = Console.ReadLine().ToUpper();
                            if (l4 == "N")
                            {
                                c = false;
                            }
                            Console.WriteLine("");
                        }
                        break;

                    case "SHOW":
                        string s = "";
                        while (s != "X")
                        {
                            s = Console.ReadLine();
                            s.TestChars(new WriteToCMDLine(Write));
                        }
                        break;

                    case "READ":
                        ReadSample.Read(new WriteToCMDLine(Write));
                        break;

                    case "BUYSELL":
                    case "BS":
                        while (true)
                        {
                            TaskScheduler.Instance.ScheduleCycle(.006);

                            string l1 = Console.ReadLine();
                            if (l1 == "x")
                            {
                                break;
                            }
                        }
                        break;

                    case "EXIT":
                    case "E":
                    case "X":
                        x = false;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    WriteError(ex);
                }
            }
        }