Beispiel #1
0
		/// <summary>
		/// Initialize a filter parameter handler for a track filter. 
		/// paramName should be the exact name of the property
		/// to tweak. If player is null, the default player is used instead.
		/// </summary>
		public GATFilterParam( int trackNb, int slotNb, string paramName, GATPlayer player = null )
		{
			Type t;
			GATTrack track;

			if( player == null )
				player = GATManager.DefaultPlayer;

			track  = player.GetTrack( trackNb );

			if( track == null )
			{
				throw new GATException( "Track " + trackNb + " does not exist." );
			}

			Filter = track.FiltersHandler.GetFilterAtSlot( slotNb );

			if( Filter == null )
			{
				throw new GATException( "No filter found in slot " + slotNb + " of track " + trackNb );
			}
			
			t = Filter.GetType();
			
			_propInfo = t.GetProperty( paramName, BindingFlags.Public | BindingFlags.Instance );

			if( _propInfo == null )
			{
				throw new GATException( "No such filter!" );
			}
		}
Beispiel #2
0
        private void UpdateObservedStream()
        {
            IGATAudioThreadStream stream = null;

            if (observeTrack)
            {
                GATPlayer player = observedAudioStreamComp as GATPlayer;
                if (player == null)
                {
                    Debug.LogWarning("Could not find Player to observe track " + observedAudioStreamComp.name);
                    return;
                }

                GATTrack track = player.GetTrack(observedChannel);

                stream = (( IGATAudioThreadStreamOwner )track).GetAudioThreadStream(0);
            }
            else if (observedAudioStreamComp != null)
            {
                stream = observedAudioStreamComp as IGATAudioThreadStream;

                if (stream == null)
                {
                    IGATAudioThreadStreamOwner streamOwner;
                    streamOwner = observedAudioStreamComp as IGATAudioThreadStreamOwner;
                    if (streamOwner != null)
                    {
                        stream = streamOwner.GetAudioThreadStream(0);
                    }

                    if (stream == null)
                    {
                        Debug.LogWarning("Could not find IGATAudioThreadStream or IGATAudioThreadStreamOwner on GameObject " + observedAudioStreamComp.name);
                        observedAudioStreamComp = _cachedStreamComp;
                        return;
                    }
                }
            }

            if (_observedStream != null)
            {
                _observedStream.RemoveAudioThreadStreamClient(this);
            }

            if (stream != null)
            {
                stream.AddAudioThreadStreamClient(this);
            }
            else
            {
                _dataIsUpdated = false;
                _needsData     = true;
                HandleNoMoreData();
            }

            _observedStream   = stream;
            _cachedStreamComp = observedAudioStreamComp;
        }
Beispiel #3
0
        /// <summary>
        /// Call from derived classes to attempt to
        /// get a valid stream from the streamComponent and
        /// store it in _stream.
        /// </summary>
        protected void GetStream()
        {
            if (streamComponent == null)
            {
                streamComponent = gameObject.GetComponent(typeof(IGATAudioThreadStreamOwner));
            }

            if (streamIsTrack)
            {
                GATPlayer player = streamComponent as GATPlayer;
                if (player == null)
                {
                    throw new GATException("Cannot find GATPlayer to observe track stream. ");
                }

                if (streamIndex >= player.NbOfTracks)
                {
                    throw new GATException("Track does not exist!");
                }

                GATTrack track = player.GetTrack(streamIndex);

                _stream = track.GetAudioThreadStream(0);
            }
            else
            {
                IGATAudioThreadStreamOwner owner = streamComponent as IGATAudioThreadStreamOwner;

                _stream = owner.GetAudioThreadStream(streamIndex);

                if (owner == null)
                {
                    throw new GATException("Component is not a stream!");
                }

                if (streamIndex >= owner.NbOfStreams)
                {
                    throw new GATException("Requested stream index does not exist.");
                }
            }
        }
        protected override void Start()
        {
            base.Start();

            if (_stream == null)
            {
                this.enabled = false;
            }

            if (_stream.NbOfChannels != 1)
            {
                this.enabled = false;
                throw new GATException("Only mono streams can be routed to a track. You may use GATAudioThreadStreamSplitter to split an interleaved stream in as many mono streams.");
            }

            GATTrack track = player.GetTrack(trackNumber);

            _streamToTrack = new GATAudioThreadStreamToTrack(track, _stream, exclusive);

            _streamToTrack.Start();
        }