public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            base.GetPropertyHeight(property, label);

            _audioOption = property.GetValue<AudioOption>();
            _dynamicValue = _audioOption.Value;
            _hasCurve = _audioOption.HasCurve();
            _typeProperty = property.FindPropertyRelative("_type");
            _delayProperty = property.FindPropertyRelative("_delay");

            UpdateProperties();

            InitializeValue(_typeProperty.GetValue<AudioOption.Types>());

            float height = 16f;

            if (property.isExpanded)
            {
                height += 38f + EditorGUI.GetPropertyHeight(_valueProperty, label, true);

                if (_timeProperty != null)
                    height += EditorGUI.GetPropertyHeight(_timeProperty) + 2f;
                if (_easeProperty != null)
                    height += EditorGUI.GetPropertyHeight(_easeProperty) + 2f;
            }

            return height;
        }
Beispiel #2
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            base.GetPropertyHeight(property, label);

            audioOption   = property.GetValue <AudioOption>();
            dynamicValue  = audioOption.Value;
            hasCurve      = audioOption.HasCurve();
            typeProperty  = property.FindPropertyRelative("type");
            delayProperty = property.FindPropertyRelative("delay");

            UpdateProperties();
            InitializeValue(typeProperty.GetValue <AudioOption.Types>());

            float height = 16f;

            if (property.isExpanded)
            {
                height += 38f + EditorGUI.GetPropertyHeight(valueProperty, label, true);

                if (timeProperty != null)
                {
                    height += EditorGUI.GetPropertyHeight(timeProperty) + 2f;
                }
                if (easeProperty != null)
                {
                    height += EditorGUI.GetPropertyHeight(easeProperty) + 2f;
                }
            }

            return(height);
        }
Beispiel #3
0
    protected override void HandleMovement(float input)
    {
        if (igniorePlayerInput)
        {
            return;
        }

        base.HandleMovement(input);

        if (grounded && input != 0)
        {
            onGroundTimer += Time.deltaTime;
            if (onGroundTimer > hopAfter)
            {
                AudioPlayer.Play("Synth_Impact_Up_1", AudioOption.Pitch(0.5F));                 // Player hops

                grounded = false;
                velocity = new Vector2(velocity.x, hopForce);
            }
        }
        else
        {
            onGroundTimer = 0;
        }
    }
Beispiel #4
0
 public void Copy(AudioDelayedOption reference)
 {
     option       = reference.option;
     recycle      = reference.recycle;
     getDeltaTime = reference.getDeltaTime;
     delayCounter = reference.delayCounter;
 }
Beispiel #5
0
        void InitializeValue(AudioOption.Types type)
        {
            if (dynamicValue.IsArray || (dynamicValue.Type == DynamicValue.ValueTypes.Null && dynamicValue.Value == null))
            {
                dynamicValue.Value = AudioOption.GetDefaultValue(type);
            }

            if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale)
            {
                var data = audioOption.GetValue <Vector3>();

                valueProperty.SetValue(data.x);
                timeProperty.SetValue(data.y);
                easeProperty.SetValue((TweenUtility.Ease)data.z);
            }
            else if (type == AudioOption.Types.FadeIn || type == AudioOption.Types.FadeOut)
            {
                var data = audioOption.GetValue <Vector2>();

                valueProperty.SetValue(data.x);
                easeProperty.SetValue((TweenUtility.Ease)data.y);
            }
            else
            {
                valueProperty.SetValue(dynamicValue.Value);
            }
        }
Beispiel #6
0
        protected void ApplyOptionDelayed(AudioOption option, bool recycle)
        {
            var delayedOption = TypePoolManager.Create <AudioDelayedOption>();

            delayedOption.Initialize(option, recycle, getDeltaTime);
            delayedOptions.Add(delayedOption);
        }
Beispiel #7
0
        protected override void ApplyOptionNow(AudioOption option, bool recycle)
        {
            if (state != AudioStates.Stopped)
            {
                switch (option.Type)
                {
                case AudioOption.Types.VolumeScale:
                    float[] volumeData = option.GetValue <float[]>();
                    SetVolumeScale(volumeData[0], volumeData[1], (TweenUtility.Ease)volumeData[2], true);
                    break;

                case AudioOption.Types.PitchScale:
                    float[] pitchData = option.GetValue <float[]>();
                    SetPitchScale(pitchData[0], pitchData[1], (TweenUtility.Ease)pitchData[2], true);
                    break;

                case AudioOption.Types.RandomVolume:
                    float randomVolume = option.GetValue <float>();
                    Settings.RandomVolume         = randomVolume;
                    volumeModifier.RandomModifier = 1f + UnityEngine.Random.Range(-randomVolume, randomVolume);
                    break;

                case AudioOption.Types.RandomPitch:
                    float randomPitch = option.GetValue <float>();
                    Settings.RandomPitch         = randomPitch;
                    pitchModifier.RandomModifier = 1f + UnityEngine.Random.Range(-randomPitch, randomPitch);
                    break;

                case AudioOption.Types.FadeIn:
                    float[] fadeInData = option.GetValue <float[]>();
                    Settings.FadeIn     = fadeInData[0];
                    Settings.FadeInEase = (TweenUtility.Ease)fadeInData[1];
                    break;

                case AudioOption.Types.FadeOut:
                    float[] fadeOutData = option.GetValue <float[]>();
                    Settings.FadeIn     = fadeOutData[0];
                    Settings.FadeInEase = (TweenUtility.Ease)fadeOutData[1];
                    break;

                case AudioOption.Types.Loop:
                    Settings.Loop = option.GetValue <bool>();
                    break;

                default:
                    for (int i = 0; i < sources.Count; i++)
                    {
                        sources[i].ApplyOption(option, false);
                    }
                    break;
                }
            }

            if (recycle)
            {
                TypePoolManager.Recycle(ref option);
            }
        }
 public static extern void CreateToast(
     [MarshalAs(UnmanagedType.LPWStr)] string appName,
     [MarshalAs(UnmanagedType.LPWStr)] string appUserModelId,
     [MarshalAs(UnmanagedType.LPWStr)] string toastMessage,
     [MarshalAs(UnmanagedType.FunctionPtr)] ToastEventCallback eventCallback,
     [MarshalAs(UnmanagedType.LPWStr)] string attribution    = null,
     [MarshalAs(UnmanagedType.I4)] Duration duration         = Duration.System,
     [MarshalAs(UnmanagedType.I4)] AudioSystemFile audioFile = AudioSystemFile.DefaultSound,
     [MarshalAs(UnmanagedType.I4)] AudioOption audioOption   = AudioOption.Default);
Beispiel #9
0
 /// <summary>
 /// Modifies a setting of the AudioItem and, when appropriate, of its hierarchy.
 /// </summary>
 /// <param name="option"> The AudioOption to be applied. </param>
 /// <param name="recycle"> Should the AudioOption be recycled after it has been applied? If true, the AudioOption will become obsolete after it has been applied. </param>
 public void ApplyOption(AudioOption option, bool recycle = true)
 {
     if (option.Delay > 0f)
     {
         ApplyOptionDelayed(option, recycle);
     }
     else
     {
         ApplyOptionNow(option, recycle);
     }
 }
Beispiel #10
0
        void SetValue(AudioOption.Types type, bool hasCurve)
        {
            serializedObject.ApplyModifiedProperties();

            var valueType = AudioOption.ToValueType(type, hasCurve);

            dynamicValue.SetType(valueType, isArray);

            if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale)
            {
                dynamicValue.Value = new Vector3(valueProperty.GetValue <float>(), timeProperty.GetValue <float>(), (float)easeProperty.GetValue <TweenUtility.Ease>());
            }
            else if (type == AudioOption.Types.FadeIn || type == AudioOption.Types.FadeOut)
            {
                dynamicValue.Value = new Vector2(valueProperty.GetValue <float>(), (float)easeProperty.GetValue <TweenUtility.Ease>());
            }
            else
            {
                dynamicValue.Value = valueProperty.GetValue();
            }

            dynamicValue.Serialize();
            serializedObject.Update();
        }
 bool HasCurve(AudioOption.Types type, object value)
 {
     return
         type == AudioOption.Types.SpatialBlend ||
         type == AudioOption.Types.ReverbZoneMix ||
         type == AudioOption.Types.Spread ||
         (type == AudioOption.Types.RolloffMode && (AudioRolloffMode)value == AudioRolloffMode.Custom);
 }
        void SetValue(AudioOption.Types type, bool hasCurve)
        {
            _serializedObject.ApplyModifiedProperties();

            DynamicValue.ValueTypes valueType;
            bool isArray;

            AudioOption.ToValueType(type, hasCurve, out valueType, out isArray);
            _dynamicValue.SetValueType(valueType, isArray);

            if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale)
                _dynamicValue.SetValue(new float[] { _valueProperty.GetValue<float>(), _timeProperty.GetValue<float>(), (float)_easeProperty.GetValue<TweenManager.Ease>() });
            else if (type == AudioOption.Types.FadeIn || type == AudioOption.Types.FadeOut)
                _dynamicValue.SetValue(new float[] { _valueProperty.GetValue<float>(), (float)_easeProperty.GetValue<TweenManager.Ease>() });
            else
                _dynamicValue.SetValue(_valueProperty.GetValue());

            _serializedObject.Update();
        }
        void InitializeValue(AudioOption.Types type)
        {
            if (_dynamicValue.GetValueType() == DynamicValue.ValueTypes.Null && _dynamicValue.GetValue() == null)
                _dynamicValue.SetValue(AudioOption.GetDefaultValue(type));

            if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale)
            {
                float[] data = _audioOption.GetValue<float[]>();
                data = data == null || data.Length != 3 ? AudioOption.GetDefaultValue(type) as float[] : data;

                _valueProperty.SetValue(data[0]);
                _timeProperty.SetValue(data[1]);
                _easeProperty.SetValue((TweenManager.Ease)data[2]);
            }
            else if (type == AudioOption.Types.FadeIn || type == AudioOption.Types.FadeOut)
            {
                float[] data = _audioOption.GetValue<float[]>();
                data = data == null || data.Length != 2 ? AudioOption.GetDefaultValue(type) as float[] : data;

                _valueProperty.SetValue(data[0]);
                _easeProperty.SetValue((TweenManager.Ease)data[1]);
            }
            else
                _valueProperty.SetValue(_dynamicValue.GetValue());
        }
        SerializedProperty GetValueProperty(AudioOption.Types type, bool hasCurve, SerializedObject dummy)
        {
            string propertyName = type.ToString() + (hasCurve ? "Curve" : "");

            SerializedProperty valueProperty = dummy.FindProperty(propertyName);

            return valueProperty;
        }
        SerializedProperty GetTimeProperty(AudioOption.Types type, SerializedObject dummy)
        {
            SerializedProperty timeProperty = null;

            if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale)
                timeProperty = dummy.FindProperty("EaseTime");

            return timeProperty;
        }
        SerializedProperty GetEaseProperty(AudioOption.Types type, SerializedObject dummy)
        {
            SerializedProperty easeProperty = null;

            if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale || type == AudioOption.Types.FadeIn || type == AudioOption.Types.FadeOut)
                easeProperty = dummy.FindProperty("EaseType");

            return easeProperty;
        }
        void SetValue(AudioOption.Types type, bool hasCurve)
        {
            serializedObject.ApplyModifiedProperties();

            var valueType = AudioOption.ToValueType(type, hasCurve);
            dynamicValue.SetType(valueType, isArray);

            if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale)
                dynamicValue.Value = new Vector3(valueProperty.GetValue<float>(), timeProperty.GetValue<float>(), (float)easeProperty.GetValue<TweenUtility.Ease>());
            else if (type == AudioOption.Types.FadeIn || type == AudioOption.Types.FadeOut)
                dynamicValue.Value = new Vector2(valueProperty.GetValue<float>(), (float)easeProperty.GetValue<TweenUtility.Ease>());
            else
                dynamicValue.Value = valueProperty.GetValue();

            dynamicValue.Serialize();
            serializedObject.Update();
        }
Beispiel #18
0
 protected abstract void ApplyOptionNow(AudioOption option, bool recycle);
Beispiel #19
0
        public void ApplyAudioOption(AudioOption option, AudioSource audioSource)
        {
            switch (option.type)
            {
            case AudioOption.OptionTypes.FadeIn:
                fadeIn = option.GetValue <float>();
                break;

            case AudioOption.OptionTypes.FadeInCurve:
                fadeInCurve = option.GetValue <AnimationCurve>();
                break;

            case AudioOption.OptionTypes.FadeOut:
                fadeOut = option.GetValue <float>();
                break;

            case AudioOption.OptionTypes.FadeOutCurve:
                fadeOutCurve = option.GetValue <AnimationCurve>();
                break;

            case AudioOption.OptionTypes.RandomVolume:
                randomVolume = option.GetValue <float>();
                break;

            case AudioOption.OptionTypes.RandomPitch:
                randomPitch = option.GetValue <float>();
                break;

            case AudioOption.OptionTypes.DoNotKill:
                doNotKill = option.GetValue <bool>();
                break;

            case AudioOption.OptionTypes.Clip:
                audioSource.clip = option.GetValue <AudioClip>();
                break;

            case AudioOption.OptionTypes.Mute:
                audioSource.mute = option.GetValue <bool>();
                break;

            case AudioOption.OptionTypes.BypassEffects:
                audioSource.bypassEffects = option.GetValue <bool>();
                break;

            case AudioOption.OptionTypes.BypassListenerEffects:
                audioSource.bypassListenerEffects = option.GetValue <bool>();
                break;

            case AudioOption.OptionTypes.BypassReverbZones:
                audioSource.bypassReverbZones = option.GetValue <bool>();
                break;

            case AudioOption.OptionTypes.Loop:
                audioSource.loop = option.GetValue <bool>();
                break;

            case AudioOption.OptionTypes.Priority:
                audioSource.priority = option.GetValue <int>();
                break;

            case AudioOption.OptionTypes.Volume:
                audioSource.volume = option.GetValue <float>();
                break;

            case AudioOption.OptionTypes.Pitch:
                audioSource.pitch = option.GetValue <float>();
                break;

            case AudioOption.OptionTypes.DopplerLevel:
                audioSource.dopplerLevel = option.GetValue <float>();
                break;

            case AudioOption.OptionTypes.VolumeRolloff:
                audioSource.rolloffMode = option.GetValue <AudioRolloffMode>();
                break;

            case AudioOption.OptionTypes.MinDistance:
                audioSource.minDistance = option.GetValue <float>();
                break;

            case AudioOption.OptionTypes.PanLevel:
                audioSource.panLevel = option.GetValue <float>();
                break;

            case AudioOption.OptionTypes.Spread:
                audioSource.spread = option.GetValue <float>();
                break;

            case AudioOption.OptionTypes.MaxDistance:
                audioSource.maxDistance = option.GetValue <float>();
                break;

            case AudioOption.OptionTypes.Pan2D:
                audioSource.pan = option.GetValue <float>();
                break;
            }
        }
Beispiel #20
0
 public void Initialize(AudioOption option, bool recycle, Func <float> getDeltaTime)
 {
     this.option       = option;
     this.recycle      = recycle;
     this.getDeltaTime = getDeltaTime;
 }
Beispiel #21
0
            public void run(bool to1dir, bool allFiles, List <OutputFileObj> videos, List <OutputFileObj> others, MainWindow window,
                            CodecOption codec, AudioOption audioOp, ResolutionOption res, QualityOption quality, VideoTypeOption typeOp)
            {
                Console.WriteLine(
                    "Running Configurartion:" +
                    "\n  Codec: " + Enum.GetName(typeof(CodecOption), codec) +
                    "\n  Audio Codec: " + Enum.GetName(typeof(AudioOption), audioOp) +
                    "\n  Video Resolution: " + Enum.GetName(typeof(ResolutionOption), res) +
                    "\n Video Type: " + Enum.GetName(typeof(VideoTypeOption), typeOp));

                int totalVideos = videos.Count * 100;

                window.Dispatcher.Invoke(() => window.allVideoFilesProgressBar.Maximum = 100);

                Converter = new FFMpegConverter();
                int        index   = 0;
                MainWindow _window = window;
                Thread     _t      = Thread.CurrentThread;

                Converter.ConvertProgress += (sender, e) =>
                {
                    try
                    {
                        _window.Dispatcher.Invoke(() =>
                        {
                            Console.WriteLine("Processed: " + e.Processed);
                            _window.currFileProgressBar.Value = (float)e.Processed.TotalSeconds / (float)e.TotalDuration.TotalSeconds * 100;
                            Console.WriteLine((float)e.Processed.TotalSeconds / (float)e.TotalDuration.TotalSeconds * 100);
                            Console.WriteLine(_window.currFileProgressBar.Value);
                            _window.allVideoFilesProgressBar.Value = 100 / (float)videos.Count * index +
                                                                     (float)e.Processed.TotalSeconds / (float)e.TotalDuration.TotalSeconds * 100 / (float)videos.Count;
                        });
                    }
                    catch (TaskCanceledException tce)
                    {
                        _t.Abort();
                    }
                };
                foreach (OutputFileObj video in videos)
                {
                    var videoMedia = new NReco.VideoInfo.FFProbe().GetMediaInfo(video.Path);
                    window.Dispatcher.Invoke(() =>
                    {
                        window.currFileProgressBar.Maximum = 100;
                    });

                    if (typeOp != VideoTypeOption.copy)
                    {
                        video.OutPath = System.IO.Path.ChangeExtension(video.OutPath, "." + Enum.GetName(typeof(VideoTypeOption), typeOp));
                    }

                    if (audioOp == AudioOption.flac &&
                        System.IO.Path.GetExtension(video.Path).ToLower() ==
                        "." + Enum.GetName(typeof(VideoTypeOption), VideoTypeOption.mp4).ToLower())
                    {
                        audioOp = AudioOption.copy;
                    }

                    string scaleString =
                        res == ResolutionOption.copy ? "" :
                        res == ResolutionOption._1080 ? "-vf scale=-2:1080" :
                        res == ResolutionOption._720 ? "-vf scale=-2:720" :
                        res == ResolutionOption._480 ? "-vf scale=-2:480" :
                        res == ResolutionOption._240 ? "-vf scale=-2:240" : "";

                    Func <string> getCopyCodec = () =>
                    {
                        string videoCodec = videoMedia.Streams.ToList().Find(
                            (item) => item.CodecType.ToLower() == "video").CodecName;
                        if (videoCodec.Contains("h264"))
                        {
                            return("libx264");
                        }
                        if (videoCodec.Contains("hevc"))
                        {
                            return("libx265");
                        }
                        return("libx264");
                    };

                    string codecString =
                        codec == CodecOption.copy ? getCopyCodec() :
                        codec == CodecOption.h264 ? "libx264" :
                        codec == CodecOption.HEVC ? "libx265" : getCopyCodec();

                    string Command = string.Format(
                        "-c:v {3} {0} -crf {1} -c:a {2} -stats -y",
                        scaleString, (int)quality,
                        Enum.GetName(typeof(AudioOption), (int)audioOp), codecString);

                    Console.WriteLine("Input Path: '" + video.Path + "'");
                    Console.WriteLine("Output Path: '" + video.OutPath + "'");

                    System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(video.OutPath));
                    Console.WriteLine("Created direcotory: '" + System.IO.Path.GetDirectoryName(video.OutPath) + "'");
                    Console.WriteLine("Running Command: '" + Command + "'");
                    Converter.ConvertMedia(video.Path, null, video.OutPath, null, new ConvertSettings()
                    {
                        CustomOutputArgs = Command
                    });
                    Console.WriteLine("Video converted");

                    index++;
                }
            }
Beispiel #22
0
        private void RunRenderButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(inputDirTextBox.Text))
            {
                inputDirTextBox.Background = new SolidColorBrush(Colors.Red);
                return;
            }
            else
            {
                inputDirTextBox.Background = new SolidColorBrush(Colors.White);
            }

            if (string.IsNullOrWhiteSpace(outputDirTextBox.Text))
            {
                outputDirTextBox.Background = new SolidColorBrush(Colors.Red);
                return;
            }
            else
            {
                outputDirTextBox.Background = new SolidColorBrush(Colors.White);
            }

            DirObj dir = new DirObj
            {
                Path = inputDirTextBox.Text
            };

            bool dirError = !dir.renderFolder();

            if (dirError)
            {
                Console.WriteLine("We wasn't able to render folder");
                return;
            }

            dir.allFiles.ForEach(file => Console.WriteLine("Path: \"" + file.Path + "\""));
            List <OutputFileObj> videoFiles = new List <OutputFileObj>();
            List <OutputFileObj> otherFiles = new List <OutputFileObj>();

            Func <FileObj, ObservableCollection <CheckableItem>, CheckableItem> findCorrespondingItem = null;

            findCorrespondingItem = (file, items) => {
                foreach (CheckableItem item in items)
                {
                    if (item.Path == file.Path)
                    {
                        return(item);
                    }
                    var foundItem = findCorrespondingItem(file, item.Children);
                    if (foundItem != null)
                    {
                        return(foundItem);
                    }
                }
                return(null);
            };

            foreach (FileObj file in dir.allFiles)
            {
                if (findCorrespondingItem(file, items).IsChecked)
                {
                    string relPath = new Uri(inputDirTextBox.Text).MakeRelativeUri(new Uri(file.Path)).ToString();
                    string outPath = System.IO.Path.Combine(outputDirTextBox.Text, relPath);
                    outPath = Uri.UnescapeDataString(outPath);

                    if (videoExtensions.Contains(System.IO.Path.GetExtension(file.Name)))
                    {
                        videoFiles.Add(new OutputFileObj(file)
                        {
                            OutPath = outPath
                        });
                    }
                    else
                    {
                        otherFiles.Add(new OutputFileObj(file)
                        {
                            OutPath = outPath
                        });
                    }
                }
            }

            bool to1Dir       = videoTo1Dir.IsChecked == true;
            bool CopyAllFiles = copyAllFiles.IsChecked == true;

            CodecOption      codec      = (CodecOption)videoCodecCombo.SelectedItem;
            AudioOption      audioCodec = (AudioOption)audioCodecCombo.SelectedItem;
            ResolutionOption res        = Enum.GetValues(typeof(ResolutionOption)).Cast <ResolutionOption>().ToArray()[videoResolutionCombo.SelectedIndex];
            QualityOption    quality    = (QualityOption)videoQualityCombo.SelectedItem;
            VideoTypeOption  type       = (VideoTypeOption)videoTypeCombo.SelectedItem;

            runner = new runnerThread();

            Thread t = new Thread(() => { runner.run(
                                              to1Dir,
                                              CopyAllFiles,
                                              videoFiles,
                                              otherFiles,
                                              this,
                                              codec,
                                              audioCodec,
                                              res,
                                              quality,
                                              type); });

            t.Start();
        }
Beispiel #23
0
        protected override void ApplyOptionNow(AudioOption option, bool recycle)
        {
            if (state != AudioStates.Stopped)
            {
                switch (option.Type)
                {
                case AudioOption.Types.VolumeScale:
                    var volumeData = option.GetValue <Vector3>();
                    SetVolumeScale(volumeData.x, volumeData.y, (TweenUtility.Ease)volumeData.z, true);
                    break;

                case AudioOption.Types.PitchScale:
                    var pitchData = option.GetValue <Vector3>();
                    SetPitchScale(pitchData.x, pitchData.y, (TweenUtility.Ease)pitchData.z, true);
                    break;

                case AudioOption.Types.RandomVolume:
                    float randomVolume = option.GetValue <float>();
                    settings.RandomVolume         = randomVolume;
                    volumeModifier.RandomModifier = 1f + UnityEngine.Random.Range(-randomVolume, randomVolume);
                    break;

                case AudioOption.Types.RandomPitch:
                    float randomPitch = option.GetValue <float>();
                    settings.RandomPitch         = randomPitch;
                    pitchModifier.RandomModifier = 1f + UnityEngine.Random.Range(-randomPitch, randomPitch);
                    break;

                case AudioOption.Types.FadeIn:
                    var fadeInData = option.GetValue <Vector2>();
                    settings.FadeIn     = fadeInData.x;
                    settings.FadeInEase = (TweenUtility.Ease)fadeInData.y;
                    break;

                case AudioOption.Types.FadeOut:
                    var fadeOutData = option.GetValue <Vector2>();
                    settings.FadeIn     = fadeOutData.x;
                    settings.FadeInEase = (TweenUtility.Ease)fadeOutData.y;
                    break;

                case AudioOption.Types.Loop:
                    bool loop = option.GetValue <bool>();
                    settings.Loop = loop;
                    source.loop   = loop && !hasBreak;
                    break;

                case AudioOption.Types.Clip:
                    var clip = option.GetValue <AudioClip>();
                    settings.Clip = clip;
                    source.clip   = clip;
                    break;

                case AudioOption.Types.Output:
                    var output = option.GetValue <AudioMixerGroup>();
                    settings.Output = output;
                    source.outputAudioMixerGroup = output;
                    break;

                case AudioOption.Types.DopplerLevel:
                    source.dopplerLevel = option.GetValue <float>();
                    break;

                case AudioOption.Types.RolloffMode:
                    if (option.HasCurve())
                    {
                        source.rolloffMode = AudioRolloffMode.Custom;
                        source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, option.GetValue <AnimationCurve>());
                    }
                    else
                    {
                        source.rolloffMode = option.GetValue <AudioRolloffMode>();
                    }
                    break;

                case AudioOption.Types.MinDistance:
                    source.minDistance = option.GetValue <float>();
                    break;

                case AudioOption.Types.MaxDistance:
                    source.maxDistance = option.GetValue <float>();
                    break;

                case AudioOption.Types.Spread:
                    if (option.HasCurve())
                    {
                        source.SetCustomCurve(AudioSourceCurveType.Spread, option.GetValue <AnimationCurve>());
                    }
                    else
                    {
                        source.spread = option.GetValue <float>();
                    }
                    break;

                case AudioOption.Types.Mute:
                    source.mute = option.GetValue <bool>();
                    break;

                case AudioOption.Types.BypassEffects:
                    source.bypassEffects = option.GetValue <bool>();
                    break;

                case AudioOption.Types.BypassListenerEffects:
                    source.bypassListenerEffects = option.GetValue <bool>();
                    break;

                case AudioOption.Types.BypassReverbZones:
                    source.bypassReverbZones = option.GetValue <bool>();
                    break;

                case AudioOption.Types.Priority:
                    source.priority = option.GetValue <int>();
                    break;

                case AudioOption.Types.StereoPan:
                    source.panStereo = option.GetValue <float>();
                    break;

                case AudioOption.Types.SpatialBlend:
                    if (option.HasCurve())
                    {
                        source.SetCustomCurve(AudioSourceCurveType.SpatialBlend, option.GetValue <AnimationCurve>());
                    }
                    else
                    {
                        source.spatialBlend = option.GetValue <float>();
                    }
                    break;

                case AudioOption.Types.ReverbZoneMix:
                    if (option.HasCurve())
                    {
                        source.SetCustomCurve(AudioSourceCurveType.ReverbZoneMix, option.GetValue <AnimationCurve>());
                    }
                    else
                    {
                        source.reverbZoneMix = option.GetValue <float>();
                    }
                    break;

                case AudioOption.Types.PlayRange:
                    var playRangeData = option.GetValue <Vector2>();
                    settings.PlayRangeStart = playRangeData.x;
                    settings.PlayRangeEnd   = playRangeData.y;
                    lastTime = source.time;
                    break;

                case AudioOption.Types.Time:
                    source.time = option.GetValue <float>();
                    lastTime    = source.time;
                    break;

                case AudioOption.Types.TimeSamples:
                    source.timeSamples = option.GetValue <int>();
                    lastTime           = source.time;
                    break;

                case AudioOption.Types.VelocityUpdateMode:
                    source.velocityUpdateMode = option.GetValue <AudioVelocityUpdateMode>();
                    break;

                case AudioOption.Types.IgnoreListenerPause:
                    source.ignoreListenerPause = option.GetValue <bool>();
                    break;

                case AudioOption.Types.IgnoreListenerVolume:
                    source.ignoreListenerVolume = option.GetValue <bool>();
                    break;

                case AudioOption.Types.Spatialize:
                    source.spatialize = option.GetValue <bool>();
                    break;
                }
            }

            if (recycle)
            {
                TypePoolManager.Recycle(ref option);
            }
        }
        protected override void ApplyOptionNow(AudioOption option, bool recycle)
        {
            if (state != AudioStates.Stopped)
            {
                switch (option.Type)
                {
                    case AudioOption.Types.VolumeScale:
                        float[] volumeData = option.GetValue<float[]>();
                        SetVolumeScale(volumeData[0], volumeData[1], (TweenUtility.Ease)volumeData[2], true);
                        break;
                    case AudioOption.Types.PitchScale:
                        float[] pitchData = option.GetValue<float[]>();
                        SetPitchScale(pitchData[0], pitchData[1], (TweenUtility.Ease)pitchData[2], true);
                        break;
                    case AudioOption.Types.RandomVolume:
                        float randomVolume = option.GetValue<float>();
                        Settings.RandomVolume = randomVolume;
                        volumeModifier.RandomModifier = 1f + UnityEngine.Random.Range(-randomVolume, randomVolume);
                        break;
                    case AudioOption.Types.RandomPitch:
                        float randomPitch = option.GetValue<float>();
                        Settings.RandomPitch = randomPitch;
                        pitchModifier.RandomModifier = 1f + UnityEngine.Random.Range(-randomPitch, randomPitch);
                        break;
                    case AudioOption.Types.FadeIn:
                        float[] fadeInData = option.GetValue<float[]>();
                        Settings.FadeIn = fadeInData[0];
                        Settings.FadeInEase = (TweenUtility.Ease)fadeInData[1];
                        break;
                    case AudioOption.Types.FadeOut:
                        float[] fadeOutData = option.GetValue<float[]>();
                        Settings.FadeIn = fadeOutData[0];
                        Settings.FadeInEase = (TweenUtility.Ease)fadeOutData[1];
                        break;
                    case AudioOption.Types.Loop:
                        Settings.Loop = option.GetValue<bool>();
                        break;
                    default:
                        for (int i = 0; i < sources.Count; i++)
                            sources[i].ApplyOption(option, false);
                        break;
                }
            }

            if (recycle)
                TypePoolManager.Recycle(ref option);
        }
Beispiel #25
0
        /// <summary>
        /// Get Media options
        /// </summary>
        /// <param name="mediaNode"></param>
        /// <param name="nodeAttributes"></param>
        /// <param name="_options"></param>
        private static void ParseOptionsForMediaNode(XmlNode mediaNode, XmlAttributeCollection nodeAttributes, MediaOption _options, LayoutOption _layoutOption)
        {
            //Media Id
            _options.mediaId = int.Parse(nodeAttributes["id"].Value);

            // Type and Duration will always be on the media node
            _options.type = nodeAttributes["type"].Value;

            // Render as
            if (nodeAttributes["render"] != null)
            {
                _options.render = nodeAttributes["render"].Value;
            }

            //TODO: Check the type of node we have, and make sure it is supported.

            if (nodeAttributes["duration"].Value != "")
            {
                _options.duration = int.Parse(nodeAttributes["duration"].Value);
            }
            else
            {
                _options.duration = 60;
            }

            // We cannot have a 0 duration here... not sure why we would... but
            if (_options.duration == 0 && _options.type != "video" && _options.type != "localvideo")
            {
                //int emptyLayoutDuration = int.Parse(ApplicationSettings.Default.EmptyLayoutDuration.ToString());
                //_options.duration = (emptyLayoutDuration == 0) ? 10 : emptyLayoutDuration;
            }

            // There will be some stuff on option nodes
            XmlNode optionNode = mediaNode.SelectSingleNode("options");

            foreach (XmlNode option in optionNode.ChildNodes)
            {
                if (option.Name == "direction")
                {
                    _options.direction = option.InnerText;
                }
                else if (option.Name == "uri")
                {
                    _options.uri = option.InnerText;
                }
                else if (option.Name == "loop")
                {
                    _options.loop = int.Parse(option.InnerText);
                }
                else if (option.Name == "mute")
                {
                    _options.mute = int.Parse(option.InnerText);
                }
                else if (option.Name == "copyright")
                {
                    _options.copyrightNotice = option.InnerText;
                }
                else if (option.Name == "scrollSpeed")
                {
                    if (option.InnerText != null && option.InnerText != "")
                    {
                        _options.scrollSpeed = int.Parse(option.InnerText);
                    }
                    else
                    {
                        System.Diagnostics.Trace.WriteLine("Non integer scrollSpeed in XLF", "Region - SetNextMediaNode");
                    }
                }
                else if (option.Name == "updateInterval")
                {
                    //updateIntervalProvided = true;

                    if (option.InnerText != null && option.InnerText != "")
                    {
                        _options.updateInterval = int.Parse(option.InnerText);
                    }
                    else
                    {
                        // Update interval not defined, so assume a high value
                        _options.updateInterval = 3600;
                    }
                }
                else if (option.Name == "modeid")
                {
                    //updateIntervalProvided = true;

                    if (option.InnerText != null && option.InnerText != "")
                    {
                        _options.modeid = option.InnerText;
                    }
                    else
                    {
                        // Update interval not defined, so assume a high value
                        _options.modeid = "";
                    }
                }
                //Transition details
                else if (option.Name == "transIn")
                {
                    _options.transIn = option.InnerText;
                }
                else if (option.Name == "transInDirection")
                {
                    _options.transInDirection = option.InnerText;
                }
                else if (option.Name == "transInDuration")
                {
                    _options.transInDuration = double.Parse(option.InnerText);
                }
                else if (option.Name == "transOut")
                {
                    _options.transOut = option.InnerText;
                }
                else if (option.Name == "transOutDirection")
                {
                    _options.transOutDirection = option.InnerText;
                }
                else if (option.Name == "transOutDuration")
                {
                    _options.transOutDuration = double.Parse(option.InnerText);
                }
                //Shell Command Details
                else if (option.Name == "launchThroughCmd")
                {
                    _options.launchThroughCmd = option.InnerText;
                }
                else if (option.Name == "name")
                {
                    _options.scName = option.InnerText;
                }
                else if (option.Name == "terminateCommand")
                {
                    _options.terminateCommand = option.InnerText;
                }
                else if (option.Name == "useTaskkill")
                {
                    _options.useTaskkill = option.InnerText;
                }
                else if (option.Name == "windowsCommand")
                {
                    _options.windowsCommand = option.InnerText;
                }
            }

            // And some stuff on Raw nodes
            XmlNode rawNode = mediaNode.SelectSingleNode("raw");

            if (rawNode != null)
            {
                foreach (XmlNode raw in rawNode.ChildNodes)
                {
                    if (raw.Name == "text")
                    {
                        _options.text = raw.InnerText;
                    }
                    else if (raw.Name == "template")
                    {
                        _options.documentTemplate = raw.InnerText;
                    }
                    else if (raw.Name == "embedHtml")
                    {
                        _options.text = raw.InnerText;
                    }
                    else if (raw.Name == "embedScript")
                    {
                        _options.javaScript = raw.InnerText;
                    }
                }
            }

            // Audio Nodes?
            XmlNodeList audio = mediaNode.SelectNodes("audio");

            if (audio != null && audio.Count > 0)
            {
                AudioOption _audio = new AudioOption();
                foreach (XmlNode audioNode in audio)
                {
                    if (audioNode.HasChildNodes)
                    {
                        _audio.audioUrl = PlayerSettings.libraryPath + audioNode.InnerText;
                        if (audioNode.Attributes["loop"] != null)
                        {
                            _audio.loop = int.Parse(audioNode.Attributes["loop"].Value);
                        }

                        if (audioNode.Attributes["volume"] != null)
                        {
                            _audio.volume = int.Parse(audioNode.Attributes["volume"].Value);
                        }

                        _layoutOption.AudioNodeList.Add(
                            new AudioOption(
                                _options.mediaId,
                                _audio.volume,
                                _audio.loop,
                                _audio.audioUrl,
                                _options.regionId
                                )
                            );
                    }

                    _options.audio = true;
                }
            }

            CreateNextMediaNode(_options, _layoutOption);
        }
        SerializedProperty GetCurveProperty(AudioOption.Types type, object value, SerializedProperty property)
        {
            SerializedProperty curveProperty = null;

            if (HasCurve(type, value))
                curveProperty = property.FindPropertyRelative("curve");

            return curveProperty;
        }
 bool CanHaveCurve(AudioOption.Types type)
 {
     return type == AudioOption.Types.SpatialBlend || type == AudioOption.Types.ReverbZoneMix || type == AudioOption.Types.Spread || type == AudioOption.Types.RolloffMode;
 }
        void InitializeValue(AudioOption.Types type)
        {
            if (dynamicValue.IsArray || (dynamicValue.Type == DynamicValue.ValueTypes.Null && dynamicValue.Value == null))
                dynamicValue.Value = AudioOption.GetDefaultValue(type);

            if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale)
            {
                var data = audioOption.GetValue<Vector3>();

                valueProperty.SetValue(data.x);
                timeProperty.SetValue(data.y);
                easeProperty.SetValue((TweenUtility.Ease)data.z);
            }
            else if (type == AudioOption.Types.FadeIn || type == AudioOption.Types.FadeOut)
            {
                var data = audioOption.GetValue<Vector2>();

                valueProperty.SetValue(data.x);
                easeProperty.SetValue((TweenUtility.Ease)data.y);
            }
            else
                valueProperty.SetValue(dynamicValue.Value);
        }
Beispiel #29
0
        private int AccessCDAudio( AudioOption Action )
        {
            ReturnCode = GetStringBuilder();

            switch(Action)
            {
                case(AudioOption.OpenCDAudio):
                    string DriveIdentifier = ((string)Drives[CurrentDrive]).Substring(0,1).ToLower();
                    this.CommandLine = "open " + DriveIdentifier + @":\ type cdaudio alias cd";
                    break;
                case(AudioOption.CloseCDAudio):
                    this.CommandLine = "close cd";
                    break;
            }

            return MciSendString( CommandLine, ReturnCode, ReturnCode.Length, new IntPtr(0) );
        }
        SerializedProperty GetCurveProperty(AudioOption.Types type, object value, SerializedProperty property)
        {
            SerializedProperty curveProperty = null;

            if (type == AudioOption.Types.SpatialBlend || type == AudioOption.Types.ReverbZoneMix || type == AudioOption.Types.Spread || (type == AudioOption.Types.RolloffMode && (AudioRolloffMode)value == AudioRolloffMode.Custom))
                curveProperty = property.FindPropertyRelative("_curve");

            return curveProperty;
        }