Esempio n. 1
0
        private static void OnTimer(object state)
        {
            m_serialPort.Write(m_ymParser.Bytes, m_frameIndex * PACKET_WRITE_SIZE, Math.Min(Math.Max(m_ymParser.Bytes.Length - m_frameIndex * PACKET_WRITE_SIZE, 0), PACKET_WRITE_SIZE));

            TimeSpan timeSpan = TimeSpan.FromSeconds((((m_frameIndex + 1) * PACKET_WRITE_COUNT) / m_ymParser.FrameRate));

            Console.Write("\r{0}/{1} - Frame {2}/{3}    ", timeSpan.ToString(), m_ymParser.TotalTime, (m_frameIndex + 1) * PACKET_WRITE_COUNT, m_ymParser.FrameCount);

            if ((++m_frameIndex * PACKET_WRITE_COUNT) >= (m_ymParser.FrameCount - 1))
            {
                // m_frameIndex = m_ymParser.FrameLoop;

                StopTimer();

                if (++m_songIndex == m_songArray.Length)
                {
                    m_songIndex = 0;
                }

                m_ymParser = new YMParser(m_songArray[m_songIndex]);

                OutputYmInfo();

                StartTimer();
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            m_exitEventHandler += OnExit;
            SetConsoleCtrlHandler(m_exitEventHandler, true);

            string startupPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string songsPath   = Path.Combine(startupPath, "Songs");

            m_songArray = Directory.GetFiles(songsPath, "*.YM");

            Random random = new Random();

            m_songArray = m_songArray.OrderBy(x => random.Next()).ToArray();

            Console.WriteLine("YMPlayer, simple streamer for YM2149.");
            Console.WriteLine("Opening file");

            Console.WriteLine("Opening serial port");
            m_serialPort = new SerialPort("COM4", 9600);
            m_serialPort.Open();

            m_ymParser = new YMParser(m_songArray[m_songIndex]);

            OutputYmInfo();

            StartTimer();

            while (true)
            {
                ;
            }
        }