Exemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (_frameIndex < _frameCount)
            {
                if (_replayEnded)
                {
                    return;
                }

                if (_frameIndex == 0)
                {
                    _outputDevice.Play();
                    _audioSpeed.PlaybackRate = 1.5f;                                                   // .50f for half time, 1f for normal speed and 1.5f for double time
                    _audioFile.CurrentTime   = new TimeSpan(0, 0, 0, 0, _reader.ReplayFrames[1].Time); // set our audio position to the first replay frame time
                }

                int audioTime = (int)(_outputDevice.GetPosition() * 1500.0 / // 500.0 for half time, 1000.0 for normal speed and 1500.0 for double time
                                      _outputDevice.OutputWaveFormat.BitsPerSample /
                                      _outputDevice.OutputWaveFormat.Channels * 8 /
                                      _outputDevice.OutputWaveFormat.SampleRate);

                _currentFrame = _reader.ReplayFrames[_frameIndex]; // update our current frame

                UpdateReplayIndex(audioTime);                      // update replay index with audio time to make things smoother
            }
            else
            {
                _replayEnded = true;
            }

            base.Update(gameTime);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var load_res = LithUSS.Native.initLUSS(Path.Combine(Directory.GetCurrentDirectory(), "SynthData/"), Path.Combine(Directory.GetCurrentDirectory(), "Regina/"));

            if (load_res != 0)
            {
                throw new Exception();
            }

            while (true)
            {
                string ts = Console.ReadLine();
                if (String.IsNullOrEmpty(ts))
                {
                    continue;
                }
                var res = LithUSS.Native.synthesizeWholeText(ts, out byte[] b, 130, 100);
                Console.WriteLine(res);
                if (res == 0)
                {
                    using (var wo = new WasapiOut())
                    {
                        //var wp = new BufferedWaveProvider(new WaveFormat(22000, 1));
                        //wp.AddSamples(b, 0, b.Length);
                        wo.Init(new LithUSSWaveProvider(b));
                        wo.Play();
                        while (wo.PlaybackState == PlaybackState.Playing)
                        {
                            Console.WriteLine(wo.GetPosition());
                            Thread.Sleep(1000);
                        }
                    }
                }
                Console.WriteLine(b);
            }
        }