public void UpdateChange(ISoundFactory factory)
            {
                if (currentSound != emitter.Sound)
                {
                    // Changed:
                    disposeSound();
                }

                if (buffer == null && emitter.Sound != null)
                {
                    loadSound(factory);
                    currentSound = emitter.Sound;
                }

                if (emitter.Playing && !oldPlaying)
                {
                    loadSound(factory);
                    sourceVoice.SubmitSourceBuffer(buffer);
                    sourceVoice.Start();
                }
                else if (!emitter.Playing && oldPlaying)
                {
                    sourceVoice.Stop();
                    sourceVoice.FlushSourceBuffers();
                }
            }
 public void Update(ISoundFactory factory)
 {
     if (sourceVoice != null && sourceVoice.State.BuffersQueued == 0)
     {
         emitter.Playing = false;
         sourceVoice.Stop();
         sourceVoice.FlushSourceBuffers();
     }
 }
Esempio n. 3
0
        public static ISoundFactory StubSoundFactory(string[] supportedExtensions = null)
        {
            ISoundFactory soundFactory = MockRepository.GenerateStub <ISoundFactory>();

            soundFactory.Stub(factory => factory.Create()).Return(null)
            .WhenCalled(invocation => invocation.ReturnValue = MockRepository.GenerateStub <ISound>());
            soundFactory.Stub(factory => factory.SupportedExtensions).Return(supportedExtensions);
            return(soundFactory);
        }
Esempio n. 4
0
 public SoundBoard ToSoundBoard(ISoundFactory soundFactory)
 {
     return(new SoundBoard
     {
         Name = Name,
         Sounds = new ObservableCollection <ISound>(
             from sound in Sounds
             select sound.ToSound(soundFactory))
     });
 }
Esempio n. 5
0
        public Scene(string name, ISoundFactory soundFactory, ISoundService soundService)
        {
            if (name.IsNullorWhitespace())
            {
                throw new ArgumentNullException(nameof(name));
            }

            _soundFactory = soundFactory ?? throw new ArgumentNullException(nameof(soundFactory));

            _soundService = soundService ?? throw new ArgumentNullException(nameof(soundService));
        }
Esempio n. 6
0
        public ISound ToSound(ISoundFactory soundFactory)
        {
            ISound sound = soundFactory.Create();

            sound.Delay           = Delay;
            sound.FileName        = FileName;
            sound.Name            = Name;
            sound.IsLooped        = IsLooped;
            sound.VolumeInPercent = VolumeInPercent;
            return(sound);
        }
 public MainWindowViewModel(ISoundBoardRepository soundBoardRepository, IDialogService dialogService,
                            IObservableSoundService soundService, IKernel container,
                            ISoundFactory soundFactory)
 {
     _soundBoardRepository = soundBoardRepository;
     _dialogService        = dialogService;
     _container            = container;
     _soundFactory         = soundFactory;
     SoundService          = soundService;
     Commands = new CommandsRepository(this, _soundFactory);
     SoundContextMenuCommands       = new SoundContextMenuCommands(this, _dialogService, container);
     ActiveSoundContextMenuCommands = new ActiveSoundContextMenuCommands(this);
     LoadSoundBoards();
 }
Esempio n. 8
0
        private static MainWindowViewModel CreateTarget(ISoundBoardRepository soundBoardRepository = null,
                                                        IDialogService dialogService = null, IKernel container = null, IObservableSoundService soundService = null,
                                                        ISoundFactory soundFactory   = null)
        {
            if (container == null)
            {
                container = new StandardKernel();
                container.Bind <MainWindow>().ToMethod(context => new MainWindow());
            }

            return(new MainWindowViewModel(
                       soundBoardRepository ?? MockRepository.GenerateStub <ISoundBoardRepository>(),
                       dialogService ?? MockRepository.GenerateStub <IDialogService>(),
                       soundService ?? CommonStubsFactory.StubObservableSoundService(),
                       container,
                       soundFactory ?? CommonStubsFactory.StubSoundFactory(new string[] { "*.a", "*.b" })));
        }
Esempio n. 9
0
        public void Drop_EffectIsCopyAndTargetCollectionIsActiveSoundsDataIsADataObjectContainingMultipleFiles_AddsASoundForEachSupportedFileToSoundService()
        {
            //Arrange
            ISoundFactory soundFactory = CommonStubsFactory.StubSoundFactory(new string[]
            {
                "*.mp3",
                "*.m4a",
                "*.ogg"
            });

            Target = CreateTarget(soundFactory: soundFactory);

            ICollection <ISound> targetCollection = Target.SoundService.ActiveSounds;
            DataObject           droppeDataObject = new DataObject();

            string[] supportedFiles =
            {
                "Taking the hobbits to isengard.mp3",
                "The way i tend to be.m4a",
                "-Human.ogg"
            };

            StringCollection fileDropList = new StringCollection
            {
                "Unsupported File.wav",
                "Unsupported File2.agg",
                "Unsupported File2.bleurrg",
                "Unsupported File2.idk"
            };

            fileDropList.AddRange(supportedFiles);
            droppeDataObject.SetFileDropList(fileDropList);

            IDropInfo dropInfo = MockRepository.GenerateStub <IDropInfo>();

            dropInfo.Effects = DragDropEffects.Copy;
            dropInfo.Stub(info => info.TargetCollection).Return(targetCollection);
            dropInfo.Stub(info => info.Data).Return(droppeDataObject);

            //Act
            Target.Drop(dropInfo);

            //Assert
            targetCollection.Should().OnlyContain(sound => supportedFiles.Any(s => s == sound.FileName));
        }
            private void loadSound(ISoundFactory factory)
            {
                using (var stream = factory.OpenWaveStream(emitter.Sound))
                {
                    buffer            = new AudioBuffer();
                    buffer.AudioData  = stream;
                    buffer.AudioBytes = (int)stream.Length;
                    buffer.Flags      = BufferFlags.EndOfStream;

                    if (emitter.Loop)
                    {
                        buffer.LoopCount = XAudio2.LoopInfinite;
                    }


                    sourceVoice = new SourceVoice(TW.Audio.XAudio2Device, stream.Format);
                    sourceVoice.SubmitSourceBuffer(buffer);
                    sourceVoice.Start();
                }
            }
Esempio n. 11
0
 public SoundManager(ISoundFactory soundFactory)
 {
     this.soundFactory = soundFactory;
 }
 public SoundEmitterUpdater(ISoundFactory factory)
 {
     this.factory = factory;
 }
 public CommandsRepository(MainWindowViewModel viewModel, ISoundFactory soundFactory)
 {
     _viewModel    = viewModel;
     _soundFactory = soundFactory;
     CreateCommands();
 }
 private static ISoundBoardRepository CreateSoundBoardRepository(ISoundFactory soundFactory)
 {
     return(IsInDesignMode
                         ? (ISoundBoardRepository) new DesignModeSoundBoardRepository()
                         : new XmlSerializingSoundBoardRepository(soundFactory));
 }
Esempio n. 15
0
 public XmlSerializingSoundBoardRepository(ISoundFactory soundFactory)
 {
     _soundFactory = soundFactory;
 }