예제 #1
0
        private void PlaySound(SoundResource sound)
        {
            // Adjust the sound back to normal settings if it is a looping sound that is already playing
            if ((currentPlayHandle != null) && currentPlayHandle.IsPlaying() && Looping)
            {
                AdjustSound(Loudness, PitchOffset);
                return;
            }

            StopSound(false);

            PlaySettings playSettings = (Looping ? PlaySettings.Looped : PlaySettings.PlayOnce);

            playSettings.DontSync   = false;
            playSettings.Loudness   = LoudnessPercentToDb(Loudness + LoudnessVariance * RandomNegOneToOne());
            playSettings.PitchShift = PitchOffset + PitchVariance * RandomNegOneToOne();

            if (Spatialized)
            {
                if (audio != null)
                {
                    currentPlayHandle = audio.PlaySoundOnComponent(sound, playSettings);
                }
                else
                {
                    currentPlayHandle = ScenePrivate.PlaySoundAtPosition(sound, ObjectPrivate.Position, playSettings);
                }
            }
            else
            {
                currentPlayHandle = ScenePrivate.PlaySound(sound, playSettings);
            }
        }
예제 #2
0
    public override void Init()
    {
        //myVolume = ScenePrivate.PlayStream(StreamChannel.MediaChannel, 0);
        scenePlayHandle = ScenePrivate.PlayStream(StreamChannel.AudioChannel1, 0.0f);  //turns off scene audio
        ObjectPrivate.TryGetFirstComponent(out audio);
        if (audio == null)
        {
            Log.Write("Did Not Find Audio Component");
            ScenePrivate.Chat.MessageAllUsers("Media Screen for Youtube Viewer requires an Audio Emitter");
        }
        else
        {
            Log.Write("Found Audio Component");
            currentPlayHandle = audio.PlayStreamOnComponent(StreamChannel.AudioChannel1, volume);
            currentPlayHandle.SetLoudness(volume);

            SubscribeToAll("VolumeUp", VolumeUp);
            SubscribeToAll("VolumeDown", VolumeDown);
            SubscribeToAll("VolumeOn", VolumeOn);
            SubscribeToAll("VolumeOff", VolumeOff);
        }

        Log.Write("Script Started");

        Script.UnhandledException += UnhandledException; // Catch errors and keep running unless fatal
    }
예제 #3
0
 private void StopSound(bool fadeout)
 {
     if (currentPlayHandle != null)
     {
         currentPlayHandle.Stop(fadeout);
         currentPlayHandle = null;
     }
 }
예제 #4
0
 private void StopSound(AnimationData obj)
 {
     if (playHandle != null)
     {
         playHandle.Stop();
         playHandle = null;
     }
 }
    private void PlayNote(SoundResource PlaySample, float PitchShiftIn)
    {
        bool NoLoop = true;

        playSettings = NoLoop ? PlaySettings.PlayOnce : PlaySettings.Looped;

        playSettings.Loudness   = loudnessIn; // set in Configuration
        playSettings.DontSync   = true;       // TrackDont_Sync[LoopIn2];
        playSettings.PitchShift = PitchShiftIn;
        //playHandle[LoopIn2] = ScenePrivate.PlaySound(TrackSamples[LoopIn2][PlayIndexIn], playSettings);
        playHandleSimple = ScenePrivate.PlaySound(PlaySample, playSettings);
    }
예제 #6
0
 private void StartSound(AnimationData obj)
 {
     StopSound(obj);
     if (playHandle == null)
     {
         if (audioComp == null)
         {
             playHandle = ScenePrivate.PlaySound(Sound, playSettings);
         }
         else
         {
             playHandle = audioComp.PlaySoundOnComponent(Sound, playSettings);
         }
     }
 }
예제 #7
0
    private void RevealLetter(string inLetter)
    {
        int  rowCntr = 0;
        bool hit     = false;

        do
        {
            //Log.Write("Current Text: " + CurrentText[rowCntr]);
            //Log.Write("Hidden Text: " + HiddenText[rowCntr]);
            int    columnCntr      = 0;
            string MessageEventOut = BoardName + (rowCntr + 1).ToString();
            string LineText        = HiddenText[rowCntr];
            if (CenterMyText)
            {
                LineText = CenterText(LineText);
            }

            do
            {
                string boardLetter = LineText.Substring(columnCntr, 1).ToUpper();
                //Log.Write("row: " + rowCntr + " column: " + columnCntr + " boardLetter: " + boardLetter + " inLetter: " + inLetter);
                if (boardLetter == inLetter)
                {
                    //Log.Write("LetterMatch");
                    SendChar sendChar = new SendChar();
                    sendChar.CharIndex  = columnCntr;
                    sendChar.CharToSend = inLetter;
                    //Log.Write("MessageEvent: " + MessageEvent + " Sending Letter: " + CharToSendOut + " To Letter #: " + sendChar.CharIndex);
                    PostScriptEvent(ScriptId.AllScripts, MessageEventOut, sendChar);
                    currentPlayHandle = ScenePrivate.PlaySound(MatchSound, playSettings);
                    hit = true;
                    Wait(TimeSpan.FromSeconds(0.5));
                }
                columnCntr++;
            } while (columnCntr < LineText.Length);

            rowCntr++;
        } while (rowCntr < HiddenText.Count());
        if (!hit)
        {
            currentPlayHandle = ScenePrivate.PlaySound(MissSound, playSettings);
        }
        //DisplayBoard(CurrentText);
    }
예제 #8
0
    public override void Init()
    {
        _allowedAgents = SplitStringIntoHashSet(AllowedAgents);

        _commandsUsage = new Dictionary <string, string>
        {
            { "/help", "" },
            { "/stream", "[url - leave blank to stop stream]" },
            { "/volume", "[0-100 increments of 10]" }
        };

        ScenePrivate.Chat.Subscribe(Chat.DefaultChannel, OnChat);

        scenePlayHandle = ScenePrivate.PlayStream(StreamChannel.AudioChannel, LoudnessPercentToDb(AudioStreamLoudness));
        if (DebugLogging)
        {
            Log.Write("setHandle " + scenePlayHandle);
        }
    }
예제 #9
0
    public override void Init()
    {
        // Check to make sure a sound has been configured in the editor
        if (LoopingSound == null)
        {
            Log.Write("LoopingSoundComponentScript has no configured sound to play!");
            return;
        }

        if (!ObjectPrivate.TryGetFirstComponent(out _audio))
        {
            Log.Write("LoopingSoundComponentScript is on an object that does not have an audio emitter.");
            return;
        }

        ObjectPrivate.AddInteractionData addData = (ObjectPrivate.AddInteractionData)WaitFor(ObjectPrivate.AddInteraction, "Play sound", true);

        addData.Interaction.Subscribe((InteractionData data) =>
        {
            // If not sound is playing, start one up
            if (_playHandle == null)
            {
                PlaySettings playSettings = PlaySettings.Looped;
                playSettings.Loudness     = (60.0f * (Loudness / 100.0f)) - 48.0f; // Convert percentage to decibels (dB)

                _playHandle = _audio.PlaySoundOnComponent(LoopingSound, playSettings);
            }
            // Else if a sound is playing, stop it
            else
            {
                if (_playHandle.IsPlaying())
                {
                    _playHandle.Stop();
                }

                _playHandle = null;
            }
        });
    }
예제 #10
0
    private void PlayOnAgent(AgentPrivate agent)
    {
        try
        {
            SessionId agentId = agent.AgentInfo.SessionId;
            Stop(agentId);

            PlaySettings playSettings = PlaySettings.PlayOnce;
            playSettings.Loudness = Relative_Loudness;
            if (agent.IsValid)
            {
                PlayHandle playHandle = agent.PlaySound(Sound, playSettings);
                if (playHandle != null)
                {
                    playHandles.Add(agentId, playHandle);
                    playHandle.OnFinished(() => Stop(agentId));
                }
            }
        }
        catch (Exception e)
        {
            Log.Write(LogLevel.Warning, "Voiceover", $"Exception {e.GetType().Name} in PlayOnAgent");
        }
    }
예제 #11
0
        void Setup(StreamChannel channel, string eventName, float loudness)
        {
            unsubscribes += SubscribeToAll(eventName, (ScriptEventData subData) =>
            {
                StopSound(true);

                if (PrivateMedia)
                {
                    ISimpleData simpleData = subData.Data?.AsInterface <ISimpleData>();

                    if (simpleData != null && simpleData.AgentInfo != null)
                    {
                        AgentPrivate agent = ScenePrivate.FindAgent(simpleData.AgentInfo.SessionId);

                        if (agent != null && agent.IsValid)
                        {
                            try
                            {
                                if (Spatialized)
                                {
                                    if (audio != null)
                                    {
                                        currentPlayHandle = agent.PlayStreamOnComponent(channel, audio, loudness);
                                    }
                                    else
                                    {
                                        currentPlayHandle = agent.PlayStreamAtPosition(channel, ObjectPrivate.Position, loudness);
                                    }
                                }
                                else
                                {
                                    currentPlayHandle = agent.PlayStream(channel, loudness);
                                }
                            }
                            catch (ThrottleException)
                            {
                                // Throttled
                                Log.Write(LogLevel.Warning, "PlayStream request throttle hit. Stream not set.");
                            }
                            catch (NullReferenceException)
                            {
                                // User Left, ignore.
                            }
                        }
                    }
                }
                else
                {
                    try
                    {
                        if (Spatialized)
                        {
                            if (audio != null)
                            {
                                currentPlayHandle = audio.PlayStreamOnComponent(channel, loudness);
                            }
                            else
                            {
                                currentPlayHandle = ScenePrivate.PlayStreamAtPosition(channel, ObjectPrivate.Position, loudness);
                            }
                        }
                        else
                        {
                            currentPlayHandle = ScenePrivate.PlayStream(channel, loudness);
                        }
                    }
                    catch (ThrottleException)
                    {
                        // Throttled
                        Log.Write(LogLevel.Warning, "PlayStream request throttle hit. Stream not set.");
                    }
                }
            });
        }
예제 #12
0
    public override void Init()
    {
        //myVolume = ScenePrivate.PlayStream(StreamChannel.MediaChannel, 0);
        ObjectPrivate.TryGetFirstComponent(out audio);
        if (audio == null)
        {
            Log.Write("Did Not Find Audio Component");
            ScenePrivate.Chat.MessageAllUsers("Media Screen for Youtube Viewer requires an Audio Emitter");
        }
        else
        {
            Log.Write("Found Audio Component");
            currentPlayHandle = audio.PlayStreamOnComponent(StreamChannel.MediaChannel, volume);
        }

        Log.Write("Script Started");
        PlayList.Clear();
        if (Play1.Length > 0)
        {
            PlayList.Add(Play1);
        }
        if (Play2.Length > 0)
        {
            PlayList.Add(Play2);
        }
        if (Play3.Length > 0)
        {
            PlayList.Add(Play3);
        }
        if (Play4.Length > 0)
        {
            PlayList.Add(Play4);
        }
        if (Play5.Length > 0)
        {
            PlayList.Add(Play5);
        }
        if (Play6.Length > 0)
        {
            PlayList.Add(Play6);
        }
        if (Play7.Length > 0)
        {
            PlayList.Add(Play7);
        }
        if (Play8.Length > 0)
        {
            PlayList.Add(Play8);
        }
        if (Play9.Length > 0)
        {
            PlayList.Add(Play9);
        }
        if (Play10.Length > 0)
        {
            PlayList.Add(Play10);
        }
        if (Play11.Length > 0)
        {
            PlayList.Add(Play11);
        }
        if (Play12.Length > 0)
        {
            PlayList.Add(Play12);
        }
        if (Play13.Length > 0)
        {
            PlayList.Add(Play13);
        }
        if (Play14.Length > 0)
        {
            PlayList.Add(Play14);
        }
        if (Play15.Length > 0)
        {
            PlayList.Add(Play15);
        }

        Script.UnhandledException += UnhandledException; // Catch errors and keep running unless fatal
        //ScenePrivate.Chat.MessageAllUsers(WelcomeMessage);
        ScenePrivate.Chat.Subscribe(0, GetChatCommand);
        SubscribeToScriptEvent("SendPlayShuffle", GetCommands);
        SubscribeToScriptEvent("SendPlayList", GetCommands);
        SubscribeToScriptEvent("SendStop", GetCommands);
        SubscribeToScriptEvent("SendPrevious", GetCommands);
        SubscribeToScriptEvent("SendPause", GetCommands);
        SubscribeToScriptEvent("SendResume", GetCommands);
        SubscribeToScriptEvent("SendNext", GetCommands);
        SubscribeToScriptEvent("SendForceVideo", GetCommands);
        SubscribeToScriptEvent("SendVolumeDown", GetCommands);
        SubscribeToScriptEvent("SendVolumeUp", GetCommands);
        SubscribeToScriptEvent("SendEject", GetCommands);
        SubscribeToScriptEvent("play1", GetCommands);
        SubscribeToScriptEvent("play2", GetCommands);
        SubscribeToScriptEvent("play3", GetCommands);
        SubscribeToScriptEvent("play4", GetCommands);
        SubscribeToScriptEvent("play5", GetCommands);
        SubscribeToScriptEvent("play6", GetCommands);
        SubscribeToScriptEvent("play7", GetCommands);
        SubscribeToScriptEvent("play8", GetCommands);
        SubscribeToScriptEvent("play9", GetCommands);
        SubscribeToScriptEvent("play10", GetCommands);
        SubscribeToScriptEvent("play11", GetCommands);
        SubscribeToScriptEvent("play12", GetCommands);
        SubscribeToScriptEvent("play13", GetCommands);
        SubscribeToScriptEvent("play14", GetCommands);
        SubscribeToScriptEvent("play1", GetCommands);
    }