Ejemplo n.º 1
0
        private async void stop_Click(object sender, RoutedEventArgs e)
        {
            await player.StopAsync();

            LogWrite("Stopped playing!");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
            WriteLine(@"Groorine Test Console");

            ViewMode myViewMode = ViewMode.Tone;

            if (args.Length > 0)
            {
                _useAutoPlay = true;
                _files       = args;
                _ptr         = 0;
                WriteLine("Play these files: ");
                foreach (var s in _files)
                {
                    WriteLine($"- {s}");
                }
            }
            else
            {
                Write("Do you want to use auto play?(Y/N) >");
                ConsoleKeyInfo r = ReadKey();
                _useAutoPlay = r.Key == ConsoleKey.Y;
            }


            _player = new DotNet45.Player(latency: 25);

            //Console.CancelKeyPress += async (s, e) =>
            //{
            //	e.Cancel = true;
            //	await _player.StopAsync();
            //};

            while (true)
            {
                if (!Menu())
                {
                    break;
                }
                Clear();
                do
                {
                    if (KeyAvailable)
                    {
                        switch (ReadKey().Key)
                        {
                        case ConsoleKey.Spacebar:
                            _player.StopAsync().Wait();
                            break;

                        case ConsoleKey.F1:
                            myViewMode = ViewMode.Tone;
                            Clear();
                            break;

                        case ConsoleKey.F2:
                            myViewMode = ViewMode.Channel;
                            Clear();
                            break;
                        }
                    }

                    SetCursorPosition(0, 0);
                    WriteLine($"File: {_ptr - 1}) {(_ptr > 0 ? _files[_ptr - 1] : "NULL")}");
                    WriteLine($"♪ {_player.CorePlayer.CurrentFile?.Title ?? "NULL"} - {_player.CorePlayer.CurrentFile?.Copyright ?? "NULL"}");
                    WriteLine($"LoopPoint: {_player.CorePlayer.CurrentFile?.LoopStart?.ToString() ?? "NULL"}");
                    WriteLine("[SPACE]: 再生停止\n" +
                              "[F1]: ToneView\n" +
                              "[F2]: ChannelView");
                    if (_player.CorePlayer.CurrentFile?.Length is long)
                    {
                        var l = (_player.CorePlayer.CurrentFile?.Length).Value;
                        WriteLine($"|{Arrow(80, _player.CorePlayer.Tick / (double)l)}| {_player.CorePlayer.Time / 1000d:###0.00 秒} / {_player.CorePlayer.MaxTime / 1000d:###0.00 秒}");
                    }
                    switch (myViewMode)
                    {
                    case ViewMode.Tone:
                        WriteLine("Tone View");
                        foreach (Tone t in GC.Player.Track.Tones /*.OrderBy(t => t?.Channel ?? int.MaxValue)*/)
                        {
                            if (t == null)
                            {
                                WriteLine("                                                                      ");
                            }
                            else
                            {
                                WriteLine(
                                    $"CH{t.Channel,2} ♪{t.NoteNum,3} V{t.Velocity,3} {t.RealTick,5}|{Arrow(10, t.RealTick / t.Gate)}|{t.Gate,5}             ");
                            }
                        }
                        break;

                    case ViewMode.Channel:
                        WriteLine("Channel View");
                        foreach (ValueTuple <int, IChannel, int> t in _player.CorePlayer.Tracks.Select((t, i) => new ValueTuple <int, IChannel, int>(t.ProgramChange, t.Channel, i)))
                        {
                            WriteLine($"CH{t.Item1,2} V|{Arrow(16, t.Item2.Volume / 127d)}| E|{Arrow(16, t.Item2.Expression / 127d)}| Pan|{Arrow(24, t.Item2.Panpot / 127)}| P.B.|{Arrow(24, (t.Item2.Pitchbend + 8192) / 16384d)}|");
                        }
                        break;
                    }


                    Thread.Sleep(1);
                } while (_player.IsPlaying);
            }
            _player.Dispose();
        }