Animatroller.Framework.Expander.Raspberry.Connect C# (CSharp) Method

Connect() public method

public Connect ( LogicalDevice logicalDevice ) : Raspberry
logicalDevice LogicalDevice
return Raspberry
        public Raspberry Connect(LogicalDevice.AudioPlayer logicalDevice)
        {
            this.AudioTrackDone += (o, e) =>
                {
                    logicalDevice.RaiseAudioTrackDone();
                };

            logicalDevice.AudioChanged += (sender, e) =>
                {
                    switch (e.Command)
                    {
                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.PlayFX:
                            if (e.LeftVolume.HasValue && e.RightVolume.HasValue)
                                this.oscClient.Send("/audio/fx/play", e.AudioFile, (float)e.LeftVolume.Value, (float)e.RightVolume.Value);
                            else
                                this.oscClient.Send("/audio/fx/play", e.AudioFile);
                            break;

                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.PlayNewFX:
                            if (e.LeftVolume.HasValue && e.RightVolume.HasValue)
                                this.oscClient.Send("/audio/fx/playnew", e.AudioFile, (float)e.LeftVolume.Value, (float)e.RightVolume.Value);
                            else
                                this.oscClient.Send("/audio/fx/playnew", e.AudioFile);
                            break;

                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.CueFX:
                            this.oscClient.Send("/audio/fx/cue", e.AudioFile);
                            break;

                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.CueTrack:
                            this.oscClient.Send("/audio/trk/cue", e.AudioFile);
                            break;

                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.PlayTrack:
                            this.oscClient.Send("/audio/trk/play", e.AudioFile);
                            break;
                    }
                };

            logicalDevice.ExecuteCommand += (sender, e) =>
                {
                    switch (e.Command)
                    {
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PlayBackground:
                            this.oscClient.Send("/audio/bg/play");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PauseBackground:
                            this.oscClient.Send("/audio/bg/pause");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.ResumeFX:
                            this.oscClient.Send("/audio/fx/resume");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PauseFX:
                            this.oscClient.Send("/audio/fx/pause");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.NextBackground:
                            this.oscClient.Send("/audio/bg/next");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.BackgroundVolume:
                            this.oscClient.Send("/audio/bg/volume", (float)((LogicalDevice.Event.AudioCommandValueEventArgs)e).Value);
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.ResumeTrack:
                            this.oscClient.Send("/audio/trk/resume");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PauseTrack:
                            this.oscClient.Send("/audio/trk/pause");
                            break;
                    }
                };

            return this;
        }

Usage Example

コード例 #1
0
        public HalloweenScene2013(IEnumerable <string> args)
        {
            buttonTestHand    = new DigitalInput("Hand");
            buttonTestHead    = new DigitalInput("Head");
            buttonTestDrawer1 = new DigitalInput("Drawer 1");
            buttonTestDrawer2 = new DigitalInput("Drawer 2");
            buttonRunSequence = new DigitalInput("Run Seq!");
            buttonTestSound   = new DigitalInput("Test Sound");
            buttonTestPopEyes = new DigitalInput("Pop Eyes");
            buttonTestPopUp   = new DigitalInput("Pop Up");

            switchHand    = new Switch("Hand");
            switchHead    = new Switch("Head");
            switchDrawer1 = new Switch("Drawer 1");
            switchDrawer2 = new Switch("Drawer 2");
            switchPopEyes = new Switch("Pop Eyes");
            switchPopUp   = new Switch("Pop Up");

            audioPlayer = new AudioPlayer("Audio Player");

            raspberry.DigitalInputs[0].Connect(buttonTestHand);
            raspberry.DigitalInputs[1].Connect(buttonTestHead);
            raspberry.DigitalInputs[2].Connect(buttonTestDrawer1);
            raspberry.DigitalInputs[3].Connect(buttonTestDrawer2);
            raspberry.DigitalInputs[7].Connect(buttonRunSequence);
            raspberry.DigitalOutputs[7].Connect(switchHand);
            raspberry.DigitalOutputs[2].Connect(switchHead);
            raspberry.DigitalOutputs[5].Connect(switchDrawer1);
            raspberry.DigitalOutputs[6].Connect(switchDrawer2);
            raspberry.DigitalOutputs[3].Connect(switchPopEyes);
            raspberry.DigitalOutputs[4].Connect(switchPopUp);

            raspberry.Connect(audioPlayer);
        }
All Usage Examples Of Animatroller.Framework.Expander.Raspberry::Connect