예제 #1
0
        public void GenerateAudioTestWithROI()
        {
            String testString = "fEwS21";
            var    stream     = AudioFactory.GenerateAudio(testString, -7);

            Assert.IsNotNull(stream);
        }
예제 #2
0
        public void Construct_FileDoesNotExist_DoesNotCreateFile()
        {
            var path = Path.GetRandomFileName();
            var x    = AudioFactory.AudioSession(path);

            Assert.IsFalse(File.Exists(path));
        }
예제 #3
0
 public void CanStop_NonExistantFile_False()
 {
     using (var x = AudioFactory.CreateAudioSession(Path.GetRandomFileName()))
     {
         Assert.IsFalse(x.CanStop);
     }
 }
예제 #4
0
 public void Construct_FileDoesExistButEmpty_OK()
 {
     using (var f = new TempFile())
     {
         var x = AudioFactory.AudioSession(f.Path);
     }
 }
예제 #5
0
        public void Play_GiveThaiFileName_ShouldHearTwoSounds()
        {
            using (var d = new TemporaryFolder("palaso media test"))
            {
                var soundPath = d.Combine("ก.wav");
                File.Create(soundPath).Close();
                using (var f = TempFile.TrackExisting(soundPath))
                {
                    var w = new BackgroundWorker();
                    // ReSharper disable once RedundantDelegateCreation
                    w.DoWork += new DoWorkEventHandler((o, args) => SystemSounds.Exclamation.Play());

                    using (var x = AudioFactory.CreateAudioSession(f.Path))
                    {
                        x.StartRecording();
                        w.RunWorkerAsync();
                        Thread.Sleep(2000);
                        x.StopRecordingAndSaveAsWav();
                    }

                    using (var y = AudioFactory.CreateAudioSession(f.Path))
                    {
                        y.Play();
                        Thread.Sleep(1000);
                        y.StopPlaying();
                    }
                }
            }
        }
예제 #6
0
 public void Play_FileDoesNotExist_Throws()
 {
     using (var x = AudioFactory.CreateAudioSession(Path.GetRandomFileName()))
     {
         Assert.Throws <FileNotFoundException>(() => x.Play());
     }
 }
예제 #7
0
 public RecordingSession()
 {
     _tempFile = new TempFile();
     _recorder = AudioFactory.CreateAudioSession(_tempFile.Path);
     _recorder.StartRecording();
     Thread.Sleep(100);
 }
예제 #8
0
 public void StopRecording_NotRecording_Throws()
 {
     using (var x = AudioFactory.CreateAudioSession(Path.GetRandomFileName()))
     {
         Assert.Throws <ApplicationException>(() => x.StopRecordingAndSaveAsWav());
     }
 }
예제 #9
0
 private void Awake()
 {
     _instance     = this;
     mUIManager    = new UIManager();
     mAudioFactory = new AudioFactory();
     mAudioManager = new AudioManager();
 }
        public void RecordThenPlay_SmokeTest()
        {
            using (var f = new TempFile())
            {
                var w = new BackgroundWorker();
                // ReSharper disable once RedundantDelegateCreation
                w.DoWork += new DoWorkEventHandler((o, args) => SystemSounds.Exclamation.Play());

                using (var x = AudioFactory.CreateAudioSession(f.Path))
                {
                    x.StartRecording();
                    w.RunWorkerAsync();
                    Thread.Sleep(1000);
                    x.StopRecordingAndSaveAsWav();
                    bool stopped = false;
                    (x as ISimpleAudioWithEvents).PlaybackStopped += (o, args) => { stopped = true; };
                    var watch = Stopwatch.StartNew();
                    x.Play();
                    while (!stopped)
                    {
                        Thread.Sleep(20);
                        Application.DoEvents();
                        if (watch.ElapsedMilliseconds > 2000)
                        {
                            x.StopPlaying();
                            Assert.Fail("stop event not received");
                        }
                    }
                }
            }
        }
예제 #11
0
 public void CanRecord_FileDoesNotExist_True()
 {
     using (var x = AudioFactory.CreateAudioSession(Path.GetRandomFileName()))
     {
         Assert.IsTrue(x.CanRecord);
     }
 }
예제 #12
0
 public void CanRecord_ConstructWithEmptyFile_True()
 {
     using (var f = new TempFile())
     {
         var x = AudioFactory.AudioSession(f.Path);
         Assert.IsTrue(x.CanRecord);
     }
 }
예제 #13
0
 public void Play_DoesPlay()
 {
     using (var file = TempFile.FromResource(Resources.finished, ".wav")) {
         var x = AudioFactory.AudioSession(file.Path);
         Assert.DoesNotThrow(() => x.Play());
         Assert.DoesNotThrow(() => x.StopPlaying());
     }
 }
예제 #14
0
        public void Construct_FileDoesNotExist_DoesNotCreateFile()
        {
            var path = Path.GetRandomFileName();

            // ReSharper disable once UnusedVariable
            using (var x = AudioFactory.CreateAudioSession(path)) { }
            Assert.IsFalse(File.Exists(path));             // File doesn't exist after disposal
        }
예제 #15
0
 public void Construct_FileDoesExistButEmpty_OK()
 {
     using (var f = new TempFile())
     {
         // ReSharper disable once UnusedVariable
         using (var x = AudioFactory.CreateAudioSession(f.Path)) { }
     }
 }
예제 #16
0
        private ISimpleAudioSession RecordSomething(TempFile f)
        {
            var x = AudioFactory.CreateAudioSession(f.Path);

            x.StartRecording();
            Thread.Sleep(100);
            x.StopRecordingAndSaveAsWav();
            return(x);
        }
예제 #17
0
 public void Play_FileEmpty_Throws()
 {
     using (var f = new TempFile())
     {
         var x = AudioFactory.AudioSession(f.Path);
         Assert.Throws <Exception>(() =>
                                   x.Play());
     }
 }
예제 #18
0
 public void Play_FileEmpty_Throws()
 {
     using (var f = new TempFile())
     {
         using (var x = AudioFactory.CreateAudioSession(f.Path))
         {
             Assert.Throws <FileLoadException>(() => x.Play());
         }
     }
 }
예제 #19
0
        public void Record_DoesRecord()
        {
            string fpath = "/tmp/dump.ogg";
            var    x     = AudioFactory.AudioSession(fpath);

            Assert.DoesNotThrow(() => x.StartRecording());
            Assert.IsTrue(x.IsRecording);
            Thread.Sleep(1000);
            Assert.DoesNotThrow(() => x.StopRecordingAndSaveAsWav());
        }
예제 #20
0
 public void IsRecording_WhileRecording_True()
 {
     using (var f = new TempFile())
     {
         var x = AudioFactory.AudioSession(f.Path);
         x.StartRecording();
         Thread.Sleep(100);
         Assert.IsTrue(x.IsRecording);
         x.StopRecordingAndSaveAsWav();
     }
 }
예제 #21
0
        private List <AMedia> Initialize()
        {
            var audioFactory = new AudioFactory();
            var videoFactory = new VideoFactory();

            if (_mediaLibrary == null)
            {
                _mediaLibrary = new List <AMedia>();
                _mediaLibrary.AddRange(new FileSystemConnector().ReadXml());
            }
            return(_mediaLibrary);
        }
예제 #22
0
        public AudioApplicationContext()
        {
            m_audio = AudioFactory.Create();
            m_menu  = new ContextMenuStrip();

            // Initialize Tray Icon
            m_trayIcon = new NotifyIcon()
            {
                Icon             = Resources.Speaker,
                Visible          = true,
                ContextMenuStrip = m_menu
            };
            m_trayIcon.MouseDown += TrayIcon_MouseDown;
        }
예제 #23
0
 public void Record_DoesRecord()
 {
     using (var folder = new TemporaryFolder("Record_DoesRecord"))
     {
         string fpath = Path.Combine(folder.Path, "dump.ogg");
         using (var x = AudioFactory.CreateAudioSession(fpath))
         {
             Assert.DoesNotThrow(() => x.StartRecording());
             Assert.IsTrue(x.IsRecording);
             Thread.Sleep(1000);
             Assert.DoesNotThrow(() => x.StopRecordingAndSaveAsWav());
         }
     }
 }
예제 #24
0
        //-----------------------------------------------------------------------------
        // Game::LoadContent()
        //		Allows you to load all content needed for your engine,
        //	    such as objects, graphics, etc.
        //-----------------------------------------------------------------------------
        public override void LoadContent()
        {
            // Moving this line into Initialize() causes
            // stupid AccessViolationExceptions
            SpriteCollisionManager.Self.Preallocate(2, 4);
            // The NULL one is for resizable sprites
            SpriteCollisionManager.Self.Create(Sprite.Name.NULL);

            // Create all the AudioSources
            AudioFactory audioFactory = new AudioFactory();

            audioFactory.LoadAllAudio();

            // Initilize the texture system
            TextureManager.Self.Create(Texture.Name.InvadersFromSpace, "invaders-from-space.tga");

            // Create all the Images ever needed
            ImageFactory imageFactory = new ImageFactory();

            imageFactory.Create();

            // Create all the SpriteEntites and SpriteCollisions ever needed
            SpriteEntityFactory spriteFactory = new SpriteEntityFactory();

            spriteFactory.Create();


            Console.WriteLine(" ");
            Console.WriteLine("//////////////////////////////////////////////////");
            Console.WriteLine("//          INSTRUCTIONS                        //");
            Console.WriteLine("//                                              //");
            Console.WriteLine("//    Left Arrow  = Go Left                     //");
            Console.WriteLine("//    Right Arrow = Go Right                    //");
            Console.WriteLine("//    Space       = Fire Missile                //");
            Console.WriteLine("//    D           = Toggle Collider Rendering   //");
            Console.WriteLine("//////////////////////////////////////////////////");
            Console.WriteLine(" ");


            ///////////////////
            // Begin Scene Setup
            ///////////////////

            // Create first scene
            StartScene firstScene = new StartScene();

            SceneManager.Self.LoadScene(firstScene);
        }
예제 #25
0
        public void RecordThenPlay_SmokeTest()
        {
            using (var f = new TempFile())
            {
                var w = new BackgroundWorker();
                w.DoWork += new DoWorkEventHandler((o, args) => SystemSounds.Exclamation.Play());

                var x = AudioFactory.AudioSession(f.Path);
                x.StartRecording();
                w.RunWorkerAsync();
                Thread.Sleep(1000);
                x.StopRecordingAndSaveAsWav();
                x.Play();
                Thread.Sleep(1000);
                x.StopPlaying();
            }
        }
예제 #26
0
 public void RecordAndStop_FileAlreadyExists_FileReplaced()
 {
     using (var f = new TempFile())
     {
         var old       = File.GetLastWriteTimeUtc(f.Path);
         var oldInfo   = new FileInfo(f.Path);
         var oldLength = oldInfo.Length;
         Assert.AreEqual(0, oldLength);
         var oldTimestamp = oldInfo.LastWriteTimeUtc;
         var x            = AudioFactory.AudioSession(f.Path);
         x.StartRecording();
         Thread.Sleep(1000);
         x.StopRecordingAndSaveAsWav();
         var newInfo = new FileInfo(f.Path);
         Assert.Greater(newInfo.LastWriteTimeUtc, oldTimestamp);
         Assert.Greater(newInfo.Length, oldLength);
     }
 }
예제 #27
0
 /// <summary>
 /// Returns a response message with audio as content
 /// </summary>
 /// <param name="id">Captcha string for which the audio is to be generated</param>
 /// <returns>HttpResponseMessage with "audio/wav" header</returns>
 public HttpResponseMessage Get(string id)
 {
     try
     {
         HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
         var audioStream = AudioFactory.GenerateAudio(id);
         audioStream.Position = 0;
         response.Content     = new StreamContent(audioStream);
         response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("audio/wav");
         return(response);
     }
     catch (Exception ex)
     {
         var res = new HttpResponseMessage();
         res.StatusCode = HttpStatusCode.BadRequest;
         return(res);
     }
 }
예제 #28
0
        private List <AMedia> Initialize()
        {
            var audioFactory = new AudioFactory();
            var videoFactory = new VideoFactory();

            if (_mediaLibrary == null)
            {
                _mediaLibrary = new List <AMedia>();
                _mediaLibrary.AddRange(new AMedia[]
                {
                    audioFactory.Create <Book>(),
                    audioFactory.Create <Song>(),
                    videoFactory.Create <Movie>(),
                    videoFactory.Create <Photo>()
                });
            }
            return(_mediaLibrary);
        }
예제 #29
0
        private List <AMedia> Initialize()
        {
            var audioFactory = new AudioFactory();
            var videoFactory = new VideoFactory();

            if (_mediaLibrary == null)
            {
                _mediaLibrary = new List <AMedia>();
                // _mediaLibrary.AddRange(new AMedia[]
                // {
                //   audioFactory.Create<Book>(),
                //   audioFactory.Create<Song>(),
                //   videoFactory.Create<Movie>(),
                //   videoFactory.Create<Photo>()
                // });
                _mediaLibrary.AddRange(new FileSystemConnector().ReadXml());
            }
            return(_mediaLibrary);
        }
예제 #30
0
        public void Play_DoesPlayMp3_SmokeTest()
        {
            // file disposed after playback stopped
            var file = TempFile.FromResource(Resources.ShortMp3, ".mp3");

            using (var x = AudioFactory.CreateAudioSession(file.Path))
            {
                (x as ISimpleAudioWithEvents).PlaybackStopped += (e, f) =>
                {
                    Debug.WriteLine(f);
                    Thread.Sleep(100);
                    file.Dispose();
                };
                Assert.That(x.IsPlaying, Is.False);
                Assert.DoesNotThrow(() => x.Play());
                Assert.That(x.IsPlaying, Is.True);
                Assert.DoesNotThrow(() => x.StopPlaying());
                Assert.That(x.IsPlaying, Is.False);
            }
        }