Пример #1
0
 public PureDataInfo(PureDataInfo info, PureData pureData)
 {
     this.name              = info.name;
     this.path              = info.path;
     this.samples           = info.samples;
     this.frequency         = info.frequency;
     this.channels          = info.channels;
     this.length            = info.length;
     this.loadOnAwake       = info.loadOnAwake;
     this.output            = info.output;
     this.isFixed           = info.isFixed;
     this.playRangeStart    = info.playRangeStart;
     this.playRangeEnd      = info.playRangeEnd;
     this.volume            = info.volume;
     this.pitch             = info.pitch;
     this.randomVolume      = info.randomVolume;
     this.randomPitch       = info.randomPitch;
     this.fadeIn            = info.fadeIn;
     this.fadeOut           = info.fadeOut;
     this.loop              = info.loop;
     this.dopplerLevel      = info.dopplerLevel;
     this.volumeRolloffMode = info.volumeRolloffMode;
     this.minDistance       = info.minDistance;
     this.maxDistance       = info.maxDistance;
     this.panLevel          = info.panLevel;
     this.pureData          = pureData;
 }
Пример #2
0
		public PureDataInfo(PureDataInfo info, PureData pureData) {
			this.name = info.name;
			this.path = info.path;
			this.samples = info.samples;
			this.frequency = info.frequency;
			this.channels = info.channels;
			this.length = info.length;
			this.loadOnAwake = info.loadOnAwake;
			this.output = info.output;
			this.isFixed = info.isFixed;
			this.playRangeStart = info.playRangeStart;
			this.playRangeEnd = info.playRangeEnd;
			this.volume = info.volume;
			this.pitch = info.pitch;
			this.randomVolume = info.randomVolume;
			this.randomPitch = info.randomPitch;
			this.fadeIn = info.fadeIn;
			this.fadeOut = info.fadeOut;
			this.loop = info.loop;
			this.dopplerLevel = info.dopplerLevel;
			this.volumeRolloffMode = info.volumeRolloffMode;
			this.minDistance = info.minDistance;
			this.maxDistance = info.maxDistance;
			this.panLevel = info.panLevel;
			this.pureData = pureData;
		}
		public override void OnEnable() {
			base.OnEnable();
			
			setup = (PureDataSetup)target;
			info = setup.Info;
			infoProperty = serializedObject.FindProperty("info");
			clip = setup.Clip;
		}
		public void SetInfo(string clipName, PureDataInfo info) {
			if (pureData.generalSettings.ApplicationPlaying) {
				nameInfoDict[clipName] = info;
			}
			else {
				infos[GetInfoIndex(clipName)] = info;
			}
		}
Пример #5
0
        public override void OnEnable()
        {
            base.OnEnable();

            setup        = (PureDataSetup)target;
            info         = setup.Info;
            infoProperty = serializedObject.FindProperty("info");
            clip         = setup.Clip;
        }
Пример #6
0
 public PureDataClip(PureDataInfo info, PureData pureData)
 {
     this.name      = info.Name;
     this.path      = info.path;
     this.samples   = info.samples;
     this.frequency = info.frequency;
     this.channels  = info.channels;
     this.length    = info.length;
     this.pureData  = pureData;
 }
Пример #7
0
 public void SetInfo(string clipName, PureDataInfo info)
 {
     if (pureData.generalSettings.applicationPlaying)
     {
         nameInfoDict[clipName] = info;
     }
     else
     {
         infos[GetInfoIndex(clipName)] = info;
     }
 }
Пример #8
0
        public PureDataInfo GetInfo(string clipName)
        {
            PureDataInfo info = null;

            try {
                info = pureData.generalSettings.applicationPlaying ? nameInfoDict[clipName] : infos.Find(i => i.Name == clipName);
            }
            catch {
                Logger.LogError(string.Format("Info named {0} was not found.", clipName));
            }

            return(info);
        }
Пример #9
0
        public void UpdateInfos()
        {
            foreach (AudioClip clip in Resources.LoadAll <AudioClip>(""))
            {
                PureDataInfo info = infos.Find(i => i.Name == clip.name);

                if (info == null)
                {
                    infos.Add(new PureDataInfo(clip, pureData));
                }
                else
                {
                    info.Update(clip);
                }
            }
        }
        public void SetClip(PureDataClip clip)
        {
            Clip = clip;
            Load();
            SwitchOff();
            SetSourceSwitch(true);

            Info  = new PureDataInfo(pureData.infoManager.GetInfo(clip.Name), pureData);
            State = PureDataStates.Waiting;
            SetPaused(false);
            SetOutput(Info.output);
            SetVolume(Info.volume + Info.volume * HelperFunctions.RandomRange(-Info.randomVolume, Info.randomVolume));
            SetPitch(Info.pitch + Info.pitch * HelperFunctions.RandomRange(-Info.randomPitch, Info.randomPitch));
            SetPlayRange(Info.playRangeStart, Info.playRangeEnd);
            SetFadeIn(Info.fadeIn);
            SetFadeOut(Info.fadeOut);
            SetLoop(Info.loop);
        }
        void ShowPreviewButton(PureDataSetup setup, GameObject gameObject, Rect selectionrect)
        {
                        #if UNITY_EDITOR
            Texture      previewIcon = UnityEditor.EditorGUIUtility.ObjectContent(null, typeof(AudioSource)).image;
            PureDataInfo info        = setup.Info;
            float        width       = selectionrect.width;
            selectionrect.width   = 30;
            selectionrect.height  = 16;
            selectionrect.x       = width - 2 + gameObject.GetHierarchyDepth() * 14;
            selectionrect.height += 1;
            GUIStyle style = new GUIStyle("MiniToolbarButtonLeft");
            style.fixedHeight  += 1;
            style.contentOffset = new Vector2(-4, 0);
            style.clipping      = TextClipping.Overflow;

            if (GUI.Button(selectionrect, previewIcon, style))
            {
                UnityEditor.Selection.activeObject = gameObject;

                if (previewAudioSource != null)
                {
                    previewAudioSource.gameObject.Remove();
                }

                previewAudioSource = setup.Clip.PlayOnListener();
                if (previewAudioSource != null)
                {
                    previewAudioSource.volume = info.volume + info.volume * Random.Range(-info.randomVolume, info.randomVolume);
                    previewAudioSource.pitch  = info.pitch + info.pitch * Random.Range(-info.randomPitch, info.randomPitch);
                    previewAudioSource.time   = previewAudioSource.pitch >= 0 ? previewAudioSource.clip.length * info.playRangeStart : previewAudioSource.clip.length * Mathf.Min(info.playRangeEnd, 0.99999F);
                    previewStopTime           = previewAudioSource.pitch >= 0 ? previewAudioSource.clip.length * info.playRangeEnd : previewAudioSource.clip.length * info.playRangeStart;
                    routine = DestroyAfterPlaying(previewAudioSource);
                }
            }
            else if (Event.current.isMouse && Event.current.type == EventType.MouseDown)
            {
                if (previewAudioSource != null)
                {
                    previewAudioSource.gameObject.Remove();
                }
                routine = null;
            }
                        #endif
        }
		public int GetInfoIndex(PureDataInfo info) {
			return infos.IndexOf(info);
		}
Пример #13
0
 public int GetInfoIndex(PureDataInfo info)
 {
     return(infos.IndexOf(info));
 }
Пример #14
0
		public void SetClip(PureDataClip clip) {
			Clip = clip;
			Load();
			SwitchOff();
			SetSourceSwitch(true);
			
			Info = new PureDataInfo(pureData.infoManager.GetInfo(clip.Name), pureData);
			State = PureDataStates.Waiting;
			SetPaused(false);
			SetOutput(Info.output);
			SetVolume(Info.volume + Info.volume * HelperFunctions.RandomRange(-Info.randomVolume, Info.randomVolume));
			SetPitch(Info.pitch + Info.pitch * HelperFunctions.RandomRange(-Info.randomPitch, Info.randomPitch));
			SetPlayRange(Info.playRangeStart, Info.playRangeEnd);
			SetFadeIn(Info.fadeIn);
			SetFadeOut(Info.fadeOut);
			SetLoop(Info.loop);
		}
Пример #15
0
		public PureDataClip(PureDataInfo info, PureData pureData) {
			this.name = info.Name;
			this.path = info.path;
			this.samples = info.samples;
			this.frequency = info.frequency;
			this.channels = info.channels;
			this.length = info.length;
			this.pureData = pureData;
		}