상속: MonoBehaviour
 void Start()
 {
     m_intStartTime = 0;
     goPlayer = GameObject.FindGameObjectWithTag ("Player");
     tBarrel = this.transform.GetChild (0).transform.GetChild (0);
     seekPlayer = (SeekPlayer)goBullet.GetComponent<SeekPlayer>();
 }
예제 #2
0
        void MainView_IndicatorMoved(object sender, EventArgs e)
        {
            Player.SamplePosition        = MainView.IndicatorPosition;
            PreviewStream.SamplePosition = MainView.IndicatorPosition;
            var samples = new double[(int)(WaveData.Fs * 0.05)];

            PreviewStream.ReadSamples(samples, samples.Length);
            SeekPlayer.AddSample(samples);
        }
예제 #3
0
        void MainView_IndicatorMoveStart(object sender, EventArgs e)
        {
            if (WaveData == null)
            {
                return;
            }

            PlayingBeforeIndicatorMoving = WaveData != null && Player.PlaybackState == PlaybackState.Playing;
            PauseAudio();
            SeekPlayer.Play();
        }
예제 #4
0
        void MainView_IndicatorMoveFinish(object sender, EventArgs e)
        {
            if (WaveData == null)
            {
                return;
            }

            SeekPlayer.Stop();
            if (PlayingBeforeIndicatorMoving)
            {
                PlayAudio();
            }
        }
예제 #5
0
 void GoBoom(Player player)
 {
     Destroy(gameObject);
     for (int i = 0; i < ShardNum; i++)
     {
         Instantiate(shard, transform.position, transform.rotation);
         SeekPlayer seek = shard.GetComponent <SeekPlayer> ();
         if (seek != null)
         {
             seek.player = player;
         }
     }
 }
예제 #6
0
        void Window_Closing(object sender, CancelEventArgs e)
        {
            Player?.Stop();
            Player?.Dispose();
            SeekPlayer?.Dispose();

            ApplicationSettings.Setting.General.Position = new Point(Left, Top);
            ApplicationSettings.Setting.General.Size     = new Size(Width, Height);
            if (WindowState == WindowState.Minimized)
            {
                ApplicationSettings.Setting.General.State = WindowState.Normal;
            }
            else
            {
                ApplicationSettings.Setting.General.State = WindowState;
            }
            ApplicationSettings.Setting.Save();
        }
예제 #7
0
 private void Start()
 {
     instance   = gameObject.GetComponent <AIManager>();
     seekPlayer = new SeekPlayer(this.instance);
 }
예제 #8
0
        async void LoadWave(string filePath)
        {
            if (Player?.PlaybackState == PlaybackState.Playing)
            {
                PauseAudio();
            }

            await Task.Run(() =>
            {
                try
                {
                    WaveData = Wavefile.Read(filePath);

                    var waveLineCache = WaveLineCache.CreateCache(WaveData.Data, WaveData.Fs, WaveData.Hash);

                    Dispatcher.Invoke(() =>
                    {
                        MainView.Wave        = waveLineCache;
                        MainView.SampleRange = 0.To(30000);

                        SeekPlayer = new SeekPlayer(WaveData.Fs);

                        Player                  = new WavePlayer(WaveData.Fs);
                        Player.EnableLoop       = true;
                        Player.PlaybackStopped += (s, ea) =>
                        {
                            Player.SeekToStart();
                            MainView.IndicatorPosition = Player.GetCurrentSample();
                        };
                        PreviewStream = new RawWaveStream(WaveData.Data);
                        Player.SetStream(PreviewStream);

                        MainView.Progress    = 25.0;
                        MainView.MessageText = LangResources.ProgressMessage_AnalyzingWave;
                    });

                    var selectedOperator = SelectedOperator;
                    AnalyzedAudio        = CacheFile.FindCache <AnalyzedAudioCache>(WaveData.Hash + selectedOperator.GetType().FullName + ApplicationSettings.Setting.PitchOperation.FramePeriod)
                                           .GetOrElse(() =>
                    {
                        var aa = selectedOperator.Analyze(new WaveData(WaveData.Data, WaveData.Fs), ApplicationSettings.Setting.PitchOperation.FramePeriod, (p) =>
                        {
                            Dispatcher.Invoke(() =>
                            {
                                MainView.Progress = p * 0.75 + 25.0;
                            });
                        });
                        var result = new AnalyzedAudioCache(selectedOperator.GetType(), aa, WaveData.Data.Length, WaveData.Fs, WaveData.Hash);
                        CacheFile.SaveCache(result, WaveData.Hash + selectedOperator.GetType().FullName + ApplicationSettings.Setting.PitchOperation.FramePeriod);
                        return(result);
                    });

                    Dispatcher.Invoke(() =>
                    {
                        MainView.AudioScale         = new AudioScaleModel(AnalyzedAudio.AnalyzedAudio.F0, AnalyzedAudio.AnalyzedAudio.FramePeriod, AnalyzedAudio.SampleCount, AnalyzedAudio.SampleRate);
                        MainView.EditableAudioScale = new AudioScaleModel(AnalyzedAudio.AnalyzedAudio.F0, AnalyzedAudio.AnalyzedAudio.FramePeriod, AnalyzedAudio.SampleCount, AnalyzedAudio.SampleRate);
                        Lock = false;
                    });
                }
                catch (InvalidDataException)
                {
                    MessageBox.ShowWarning(LangResources.Error_UnsupportedWaveFile, LangResources.MessageBoxTitle_CannotLoadWaveFile);

                    Dispatcher.Invoke(() =>
                    {
                        Player?.Stop();
                        Player?.Dispose();
                        MainView.Wave       = null;
                        MainView.AudioScale = null;
                        Lock = false;
                    });
                }
                catch (Exception e)
                {
                    MessageBox.ShowWarning(LangResources.Error_CannodLoadWaveFile, exception: e);

                    Dispatcher.Invoke(() =>
                    {
                        Player?.Stop();
                        Player?.Dispose();
                        MainView.Wave       = null;
                        MainView.AudioScale = null;
                        Lock = false;
                    });
                }
            });
        }