コード例 #1
0
        public void Execute()
        {
            // Using nested command patterns to simulate a console menu.
            CommandRespiratory cr = new CommandRespiratory();

            cr.AddCommand("play", typeof(PlayCommand), (string[] param) => new PlayCommand(_soundPlayer));
            cr.AddCommand("playlooping", typeof(PlayLoopingCommand), (string[] param) => new PlayLoopingCommand(_soundPlayer));
            cr.AddCommand("stop", typeof(StopCommand), (string[] param) => new StopCommand(_soundPlayer));

            CommandDirector cd = new CommandDirector(cr);

            cd.Title = "Windows SoundPlayer";
            cd.Start();

            _soundPlayer.Stop();
        }
コード例 #2
0
        public SimpleOscillationDemoCommand()
        {
            wasapiOut                 = new WasapiOut();
            signalGenerator           = new SignalGenerator(sampleRate, channels);
            signalGenerator.Frequency = frequency;
            signalGenerator.Gain      = gain;

            wasapiOut.Init(signalGenerator);

            CommandRespiratory cr = new CommandRespiratory();

            cr.AddCommand("play", typeof(PlayCommand), (string[] param) => new PlayCommand(wasapiOut));
            cr.AddCommand("stop", typeof(StopCommand), (string[] param) => new StopCommand(wasapiOut));
            cr.AddCommand("setvolume", typeof(SetVolumeCommand), (string[] param) => new SetVolumeCommand(param, signalGenerator));
            cr.AddCommand("setfreq", typeof(SetFrequencyCommand), (string[] param) => new SetFrequencyCommand(param, signalGenerator));

            cd       = new CommandDirector(cr);
            cd.Title = "Simple Oscillation";
        }
コード例 #3
0
        public NAudioPlaybackDemoCommand()
        {
            _waveOut = new WaveOut();
            _reader  = new AudioFileReader(GlobalDef.WavUrl);
            _waveOut.Init(_reader);

            // Setting up commands.
            CommandRespiratory cr = new CommandRespiratory();

            cr.AddCommand("play", typeof(PlayCommand), (string[] param) => new PlayCommand(_waveOut));
            cr.AddCommand("stop", typeof(StopCommand), (string[] param) => new StopCommand(_waveOut));
            cr.AddCommand("forward", typeof(ForwardCommand), (string[] param) => new ForwardCommand(_reader));
            cr.AddCommand("reverse", typeof(ReverseCommand), (string[] param) => new ReverseCommand(_reader));
            cr.AddCommand("reset", typeof(ResetCommand), (string[] param) => new ResetCommand(_reader));
            cr.AddCommand("getdevices", typeof(GetDevicesCommand), (string[] param) => new GetDevicesCommand());
            cr.AddCommand("setvolume", typeof(SetVolumeCommand), (string[] param) => new SetVolumeCommand(param, _waveOut));

            cd       = new CommandDirector(cr);
            cd.Title = "NAudio Playback";
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: matte250/CSoundExample
        static void Main(string[] args)
        {
            // Setting up commands.
            CommandRespiratory mainCommandRespiratory = new CommandRespiratory();

            mainCommandRespiratory.AddCommand(
                "windowssoundplayer",
                typeof(WindowsSoundPlayerDemoCommand),
                (string[] param) => new WindowsSoundPlayerDemoCommand());
            mainCommandRespiratory.AddCommand(
                "naudioplayback",
                typeof(NAudioPlaybackDemoCommand),
                (string[] param) => new NAudioPlaybackDemoCommand());
            mainCommandRespiratory.AddCommand(
                "simpleoscillation",
                typeof(SimpleOscillationDemoCommand),
                (string[] param) => new SimpleOscillationDemoCommand());

            CommandDirector mainCommandDirector = new CommandDirector(mainCommandRespiratory);

            mainCommandDirector.Title = "NAudio Demos";
            mainCommandDirector.Start();
        }