Ejemplo n.º 1
0
        // 提示音提醒 方法
        private void Ring()
        {
            Stream stream = TitleContainer.OpenStream(SoundModel.GetSoundUriByID(soundId));

            effectInstance = SoundEffect.FromStream(stream).CreateInstance();
            FrameworkDispatcher.Update();
            int times = 20;

            new Thread(new ParameterizedThreadStart(param =>
            {
                do
                {
                    if (effectInstance.State.Equals(SoundState.Stopped))
                    {
                        effectInstance.Play();

                        times--;
                    }
                    Thread.Sleep(2000);

                    if (times == 0)
                    {
                        break;
                    }

                    if (loopPlay == false)
                    {
                        break;
                    }
                } while (true);
            })).Start();
        }
Ejemplo n.º 2
0
        private static async Task Say(IAudioClient connection, SoundModel sound)
        {
            try
            {
                await connection.SetSpeakingAsync(true); // send a speaking indicator

                var psi = new ProcessStartInfo
                {
                    FileName  = "ffmpeg",
                    Arguments = $@"-i ""{sound.path}"" -ac 2 -f s16le -ar 48000 pipe:1",
                    RedirectStandardOutput = true,
                    UseShellExecute        = false
                };
                var ffmpeg = Process.Start(psi);

                var output  = ffmpeg.StandardOutput.BaseStream;
                var discord = connection.CreatePCMStream(AudioApplication.Mixed);
                await output.CopyToAsync(discord);

                await discord.FlushAsync();

                await connection.SetSpeakingAsync(false); // we're not speaking anymore

                Program.playingSound = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine($"- {ex.StackTrace}");
            }
        }
Ejemplo n.º 3
0
    // Use this for initialization
    public void SetUp(CameraHandler p_camera, SpawnPoint p_spawnPoint, SoundModel p_soundModel)
    {
        _rigidBody            = GetComponent <Rigidbody2D>();
        _animator             = GetComponent <Animator>();
        _camera               = p_camera;
        _spawnPoint           = p_spawnPoint;
        _originalBugScaleSize = transform.localScale;

        soundModel           = p_soundModel;
        audioSource          = GetComponent <AudioSource>();
        _mosquitoMovement    = new MosquitoMovement(this, _camera);
        _mosquitoBloodSucker = new MosquitoBloodSuck(this,
                                                     transform.Find("BUG_BODY DOWN").GetComponent <Anima2D.SpriteMeshInstance>());

        _seperableReporters = GetComponentsInChildren <CollisionReporter>().ToList().FindAll(x => x.isBreakable);

        foreach (Transform child in transform)
        {
            bodyContainer.Add(child.transform.name, new MosquitoBodyContainer(child.transform, child.localPosition, child.localRotation));
        }

        _camera.ForceAlignWithTarget(transform);

        _subtitleText = transform.Find("world_ui/subtitle").GetComponent <Text>();
        _typeWriter   = GetComponentInChildren <TextEffect.TypeWriter>();
        _typeWriter.AddMessage(_subtitleText, "OK, I'm in");
        Init();
    }
Ejemplo n.º 4
0
        public async Task UploadSound(string command = null)
        {
            if (command == null && Context.Message.Attachments.Count <= 0)
            {
                await Context.User.SendMessageAsync("Please upload the file here and use the following command. !upload soundName");

                return;
            }
            if (Context.Message.Attachments.ElementAt(0).Filename.Contains(".mp3"))
            {
                using (var client = new WebClient())
                {
                    client.DownloadFile(Context.Message.Attachments.ElementAt(0).Url, "./sounds/" + command + ".mp3");
                }

                var temp = new SoundModel
                {
                    command = command,
                    path    = "./sounds/" + command + ".mp3",
                };
                SoundManager.SoundManager.AddSound(temp);
                await Context.User.SendMessageAsync("Sound is uploaded with command " + command + ". Tell TPU to enable the command");
            }
            else
            {
                await Context.User.SendMessageAsync("Only .mp3 files are allowed. Please convert it first");
            }
        }
Ejemplo n.º 5
0
    public SoundModel LoadAudio()
    {
        SoundModel model = new SoundModel();

        model.bgmDict = Resources.LoadAll<AudioClip>("Audio/BGM").ToDictionary(bgm => bgm.name);
        model.clipDict = Resources.LoadAll<AudioClip>("Audio/SE").ToDictionary(se => se.name);

        return model;
    }
Ejemplo n.º 6
0
    public SoundController(SoundManager view,SoundModel model)
    {
        this.bgmManager      = view.transform.FindChild("BGMManager");
        this.seManager       = view.transform.FindChild("SEManager");
        this.bgmSource       = this.bgmManager.GetComponent<AudioSource>();

        this.view = view;
        this.soundModel = model;
        CreateSEChannels(this.soundModel.seVolume);
    }
Ejemplo n.º 7
0
        private void Reload()
        {
            SoundManager.GetSounds().ForEach(definition => SettingsManager.Cache.Add(SoundModel.fromDefinition(definition)));

            SettingsManager.Save();

            views.Clear();
            foreach (Definition definition in SoundManager.GetSounds())
            {
                views.Add(creationDelegate(SoundModel.fromDefinition(definition)));
            }
        }
Ejemplo n.º 8
0
 private void PlayList_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!isFirstTime && FacadeClass.soundIndex != PlayList.SelectedIndex)
     {
         string url = string.Concat(new List <string>()
         {
             FacadeClass.baseSoundURI, (SoundModel.GetEnumerable()).ElementAt(PlayList.SelectedIndex)
         });
         GeneralObject.MainFacade.PlayStopSound(GeneralObject._backgroundPlayer, playingCommand.play, url);
         FacadeClass.soundIndex = PlayList.SelectedIndex;
     }
     isFirstTime = false;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes the Settings Manager.
        /// </summary>
        public static void Init()
        {
            Log.Debug("Starting the SettingsManager");

            if (!File.Exists(AppSettings.SoundSettingsFilePath))
            {
                Cache = new List <SoundModel>();

                foreach (var definition in SoundManager.Cache.SoundList)
                {
                    Cache.Add(SoundModel.fromDefinition(definition));
                }

                CreateStandardFile();
            }
            else
            {
                try
                {
                    var readText = File.ReadAllText(AppSettings.SoundSettingsFilePath);

                    if (string.IsNullOrWhiteSpace(readText))
                    {
                        File.Delete(AppSettings.SoundSettingsFilePath);
                        CreateStandardFile();
                    }

                    List <JsonSoundModel> jsonModels = JsonConvert.DeserializeObject <List <JsonSoundModel> >(readText);

                    Cache = new List <SoundModel>();
                    foreach (JsonSoundModel model in jsonModels)
                    {
                        Cache.Add(SoundModel.fromJsonSoundModel(model));
                    }
                }
                catch (Exception exception)
                {
                    File.Delete(AppSettings.SoundSettingsFilePath);
                    Log.Error("Settings Manager initialization failed!", exception);
                }
            }

            Cache.RemoveAll(item => item.Name == "DummyItem");

            if (Settings.Default.EnableSoundHotKeys)
            {
                // When the Definitions are read in, the application can start setting up the Keybinds. (Keybinds are stored in the soundSettings.json!)
                KeybindManager.SetKeybinds();
            }
        }
        public static bool CheckDuplicate(SoundModel soundModel)
        {
            // Poor mans implementation.
            try
            {
                HotkeyManager.Current.AddOrReplace(soundModel.Name, soundModel.HotKey.Key, soundModel.HotKey.Modifier, PlaySound);
            }
            catch (HotkeyAlreadyRegisteredException)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 11
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (Arguments != null)
            {
                int saunaId = Arguments.GetInt(Helpers.Helpers.ARG_1);

                this.saunaModel = DbController.Instance.GetSauna(saunaId);
                this.soundModel = this.saunaModel.Sound;

                this.songsAdapter = new SongsAdapter(this.songModels);
            }
        }
Ejemplo n.º 12
0
 public SettingsForTwo()
 {
     InitializeComponent();
     FirstClick(null, null);
     SecondClicked          = false;
     Style.SelectedIndex    = GeneralObject.style;
     PlayList.ItemsSource   = SoundModel.GetEnumerable();
     DataContext            = GeneralObject._gameViewModel;
     Slider.Value           = GeneralObject._backgroundPlayer.Volume * 100;
     PlayList.SelectedIndex = SoundModel.GetEnumerable()
                              .ToList()
                              .IndexOf(SoundModel.GetEnumerable().Where(s => GeneralObject._backgroundPlayer.Source.ToString().Contains(s)).First());
     ClrPcker_Background.SelectedColorChanged += (sender, e) => { ClrPcker_Background_SelectedColorChanged(null, null); };
 }
Ejemplo n.º 13
0
        private void phoneApplicationService_Deactivated(object sender, DeactivatedEventArgs e)
        {
            // 重复模式下,不添加到系统提示。
            if (timingViewModel.IsRepeat)
            {
                return;
            }
            Alarm alarm    = new Alarm("alarm");
            var   soundUri = SoundModel.GetSoundUriByID(soundId);

            if (string.IsNullOrEmpty(soundUri))
            {
                // alarm.sound 空白或滴
                alarm.Sound = new Uri("Sounds/BeepNone.wav", UriKind.Relative);
            }
            else
            {
                alarm.Sound = new Uri(soundUri, UriKind.Relative);
            }
            DateTime now      = DateTime.Now;
            DateTime showTime = DateTime.Parse(timingViewModel.ShowTime);

            now                  = now.AddHours(showTime.Hour);
            now                  = now.AddMinutes(showTime.Minute);
            now                  = now.AddSeconds(showTime.Second);
            alarm.BeginTime      = now;
            alarm.ExpirationTime = now.AddMinutes(5);

            alarm.Content = timingViewModel.InputCountdownTime.ToString("HH:mm:ss") + "\r\n" + timingViewModel.Name;
            try
            {
                if (alarm.BeginTime.Second <= 30 && alarm.BeginTime.Hour == DateTime.Now.Hour && alarm.BeginTime.Minute == DateTime.Now.Minute)
                {
                    alarm.BeginTime = alarm.BeginTime.AddMinutes(1);
                }

                if (ScheduledActionService.Find(alarm.Name) != null)
                {
                    ScheduledActionService.Remove(alarm.Name);
                    Logger.Log("ScheduledActionService.Replace(alarm);");
                }
                ScheduledActionService.Add(alarm);
                Logger.Log(" ScheduledActionService.Add(alarm);");
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
Ejemplo n.º 14
0
        public void Play(int id)
        {
            if (effectInstance != null && effectInstance.State == SoundState.Playing)
            {
                effectInstance.Stop();
            }
            SoundModel selectedSound = Sounds.First(s => s.ID == id);

            var stream = TitleContainer.OpenStream(selectedSound.Uri);

            effectInstance = SoundEffect.FromStream(stream).CreateInstance();
            FrameworkDispatcher.Update();

            effectInstance.Play();
        }
Ejemplo n.º 15
0
        public ActionResult EditMusic()
        {
            if (Session["Status"] != null && Session["Status"].ToString() == "0")
            {
                var temp_music = new SoundModel()
                {
                    genre = db.Genres.ToList(), sound = db.Sounds.ToList(), sound_gener = db.Sound_gener.ToList()
                };

                return(View(temp_music));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 16
0
        public M4ViewModel(CModel cModel, IEventAggregator ea)
        {
            MyCModel = cModel;
            _ea      = ea;

            //モデルの生成
            MySoundModel = new SoundModel(MyCModel, _ea);
            _ea.GetEvent <LanguageChangeEvent>().Subscribe(ChangedLang);

            //TabItemのHeaderになる言葉を多言語設定の為Resoucesから取り出す
            Title = CModel.GetLocalizedValue <string>("TITLEM4");

            Plot1  = MySoundModel.PlotModelRT;
            MyType = EnumDefines.RBEnum.RB1;

            SetupTimer();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Changes the Sound and writes it to the disk.
        /// </summary>
        /// <param name="soundModel">Sound to change</param>
        public static void Update(SoundModel soundModel)
        {
            Log.Debug($"Changing Definition of {soundModel.Name}");

            for (int i = 0; i < Cache.Count; i++)
            {
                if (Cache[i].Name == soundModel.Name)
                {
                    Cache[i] = soundModel;
                    Save();

                    return;
                }
            }

            Log.Error("NO MATCH!");
        }
Ejemplo n.º 18
0
        public object Load(DataSourceBase ds, List <FormatParameter> parameters)
        {
            var sampleRate    = (int)parameters.FirstOrDefault(item => item.Name == "SAMPLE_RATE").Value;
            var bitsPerSample = (int)parameters.FirstOrDefault(item => item.Name == "BITS_PER_SAMPLE").Value;
            var channels      = (int)parameters.FirstOrDefault(item => item.Name == "CHANNELS").Value;

            //Remember to set source stream to begining
            ds.Stream.Seek(0, SeekOrigin.Begin);

            var reader         = new BinaryReader(ds.Stream);
            var pcmSampleBytes = reader.ReadBytes((int)ds.Stream.Length);

            var sound = new SoundModel();

            sound.BitsPerSample = bitsPerSample;
            sound.SampleRate    = sampleRate;
            sound.Channels      = channels;
            sound.Data          = pcmSampleBytes;
            return(sound);
        }
Ejemplo n.º 19
0
    public override void OnNotify(string p_event, params object[] p_objects)
    {
        base.OnNotify(p_event, p_objects);

        switch (p_event)
        {
        case EventFlag.Game.SetUp: {
            Debug.Log("Game Start");
            //PreparePhrase();
            view             = MainApp.Instance.view;
            _mosquitoHandler = view.GetViewObject <MosquitoHandler>();
            _background      = view.GetViewObject <BackgroundView>();
            _gameModel       = MainApp.Instance.model.FindModel <GameModel>();
            _soundModel      = MainApp.Instance.model.FindModel <SoundModel>();
            _camera          = Camera.main.transform.GetComponent <CameraHandler>();

            _gameUIController = GetComponentInChildren <GameUIController>();
            _gameUIController._modalView.CloseAll();
            GameStart();
        }
        break;

        case EventFlag.Game.GameEnd: {
            Debug.Log("Game end");
            //Call end game modal
            EndGameModal endGameModal = _gameUIController._modalView.GetModal <EndGameModal>();
            _gameUIController.OpenModal(endGameModal, p_objects);
        }
        break;

        case EventFlag.Game.Restart: {
            CleanUp();
            _mosquitoHandler.Init();
        } break;
        }
    }
Ejemplo n.º 20
0
 public async Task RemoveAsync(SoundModel sound)
 {
     await _soundRepository.RemoveAsync(sound.Adapt <SoundEntity>());
 }
Ejemplo n.º 21
0
 public SoundClassifier(IJSInProcessRuntime runtime, SoundModel model, SoundOptions serializableOptions = null)
 {
     Runtime = runtime;
     Init(model.ToString(), serializableOptions);
 }
Ejemplo n.º 22
0
 public SoundModel ToSoundModel()
 {
     return(SoundModel.fromDefinition(SoundManager.GetSound(Sound.Name)));
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Registers a Sound into the Manager.
 /// </summary>
 /// <param name="soundModel">Sound to be registered</param>
 private static void Add(SoundModel soundModel)
 {
     Log.Debug("Registering Definition!");
     Cache.Add(soundModel);
     Save();
 }
Ejemplo n.º 24
0
 public void Dispose()
 {
     this.soundModel = null;
     this.view = null;
 }
Ejemplo n.º 25
0
 public static void AddSound(SoundModel item)
 {
     soundList.Add(item);
     SoundLoader.writeList();
 }
Ejemplo n.º 26
0
        public async void FileDropped(DragEventArgs e)
        {
            var dragFileList = ((DataObject)e.Data)
                               .GetFileDropList();


            foreach (var file in dragFileList)
            {
                if (Path.GetExtension(file) != ".mp3")
                {
                    break;
                }

                _selectedKey          = string.Empty;
                _selectedFilename     = Path.GetFileName(file);
                _hookActivate         = true;
                VolumeSliderIsVisible = Visibility.Hidden;



                await Task.Run(() =>
                {
                    SetHookAlert = "”становите гор¤чую клавишу!";
                    while (_selectedKey == string.Empty)
                    {
                    }

                    _hookActivate         = false;
                    VolumeSliderIsVisible = Visibility.Visible;
                    SetHookAlert          = string.Empty;
                });

                if (_selectedKey != string.Empty)
                {
                    string filePath = Path
                                      .Combine(_musicPath, _selectedFilename);

                    if (!File.Exists(filePath))
                    {
                        try
                        {
                            File.Copy(file, filePath);
                        }
                        catch { }
                    }


                    SoundModel sound = new SoundModel
                    {
                        HotKey = _selectedKey
                                 .ToString()
                                 .Replace("KEY_", string.Empty)
                                 .Replace("OEM_", string.Empty),

                        SoundName = _selectedFilename
                                    .Substring(0, _selectedFilename.Length - 4),

                        FullPath = filePath,

                        Id = (Music.Count + 1)
                    };

                    Music.Add(sound);
                    _selectedFilename = string.Empty;

                    await _soundService.CreateAsync(sound);
                }
            }
        }