Пример #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!" );
            }
        }
Пример #2
0
        /// <summary>
        /// Initialize a filter parameter handler for a player filter.
        /// If player is null, the default player is used instead.
        /// paramName should be the exact name of the property
        /// to tweak.
        /// </summary>
        public GATFilterParam( int slotNb, string paramName, GATPlayer player = null )
        {
            Type t;

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

            Filter = player.FiltersHandler.GetFilterAtSlot( slotNb );

            if( Filter == null )
            {
                throw new GATException( "No filter found in slot " + slotNb + " of player." );
            }

            t = Filter.GetType();

            _propInfo = t.GetProperty( paramName, BindingFlags.Public | BindingFlags.Instance );

            if( _propInfo == null )
            {
                throw new GATException( "No such filter!" );
            }
        }
Пример #3
0
			public IGATBufferedSampleOptions PlayScheduled( GATPlayer player, double dspTime, int trackNb, float gain = 1f, GATPlayer.OnShouldMixSample mixCallback = null )
			{
				UpdateAudioData();
				return player.PlayDataScheduled( _audioData, dspTime, trackNb, gain, mixCallback ); //Only use AudioData property when playing, as it updates
			}
Пример #4
0
			public IGATBufferedSampleOptions PlayScheduled( double dspTime, AGATPanInfo panInfo, float gain = 1f, GATPlayer.OnShouldMixSample mixCallback = null )
			{
				UpdateAudioData();
				return GATManager.DefaultPlayer.PlayDataScheduled( _audioData, dspTime, panInfo, gain, mixCallback ); //Only use AudioData property when playing, as it updates
			}
Пример #5
0
			public IGATBufferedSampleOptions Play( int trackNb, float gain = 1f, GATPlayer.OnShouldMixSample mixCallback = null )
			{
				UpdateAudioData();
				return GATManager.DefaultPlayer.PlayData( _audioData, trackNb, gain, mixCallback ); //Only use AudioData property when playing, as it updates
			}
Пример #6
0
			public IGATBufferedSampleOptions Play( GATPlayer player, AGATPanInfo panInfo, float gain = 1f, GATPlayer.OnShouldMixSample mixCallback = null )
			{
				UpdateAudioData();
				return player.PlayData( _audioData, panInfo, gain, mixCallback ); //Only use AudioData property when playing, as it updates
			}
Пример #7
0
 public virtual void InitTrack( GATPlayer parentPlayer, int trackNb )
 {
     int i;
     _player = parentPlayer;
     _trackNb = trackNb;
     _filtersHandler = ScriptableObject.CreateInstance< GATFiltersHandler >();
     _filtersHandler.InitFiltersHandler( 1 ); //GATTracks are mono, panning occurs after filtering.
     _gains = new float[ GATInfo.NbOfChannels ];
     for( i = 0; i < _gains.Length; i++ )
     {
         _gains[ i ] = .5f;
     }
     OnEnable();
 }
Пример #8
0
 void OnEnable()
 {
     _player = target as GATPlayer;
     SetupTracksInfo();
 }
Пример #9
0
 void OnEnable()
 {
     _player = target as GATPlayer;
     SetupTracksInfo();
 }
Пример #10
0
        void OnEnable()
        {
            Frequency = _frequency;

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

            if( isTrackFilter )
            {
                _filterParam = new GATFilterParam( _trackNb, filterSlot, paramName, player );
            }
            else
            {
                _filterParam = new GATFilterParam( filterSlot, paramName, player );
            }

            player.onPlayerWillMix += OnPlayerWillMix;
        }
Пример #11
0
        protected override void Awake()
        {
            base.Awake();

            _sampleCount = UpdatedSampleCount();

            if( _player == null )
            {
                _player = GATManager.DefaultPlayer;
            }
        }
Пример #12
0
        void InitManager()
        {
            __uniqueInstance = this;

            #if !UNITY_5
            if( _speakerModeInit == SpeakerModeBehaviour.Stereo )
            {
                AudioSettings.speakerMode = AudioSpeakerMode.Stereo;
            }
            else
            {
                AudioSettings.speakerMode = AudioSettings.driverCaps;
            }
            #endif

            if( GATInfo.UniqueInstance == null )
            {
                GATInfo.Init();
            }

            GATInfo.UniqueInstance.SetSyncDspTime( AudioSettings.dspTime );
            GATInfo.UniqueInstance.SetPulseLatency( _PulseLatency );
            GATInfo.UniqueInstance.SetMaxIOChannels( _MaxIOChannels );

            if( __allocator == null )
            {
            #if UNITY_EDITOR
                if( Application.isPlaying )
            #endif
                {
                    __allocator = new GATDataAllocator( _AllocatorInitSettings );
                }
            }

            //Static initializers
            GATPlayer.InitStatics();

            if( _defaultPlayer == null )
            {
                GameObject go = new GameObject( "DefaultPlayer" );
                go.transform.parent = transform;
                go.AddComponent< AudioSource >();
                _defaultPlayer = go.AddComponent< GATPlayer >();
                _defaultPlayer.AddTrack< GATTrack >();
            }

            DefaultPlayer = _defaultPlayer;

            #if GAT_IOS && !UNITY_EDITOR
            GATiOS.InitializeNativeGAudio( GATInfo.OutputSampleRate, GATInfo.AudioBufferSizePerChannel, ( byte )GATInfo.NbOfChannels );
            #endif
        }
Пример #13
0
        /// <summary>
        /// Starts playback through the user specified player.
        /// </summary>
        public void PlayThroughTrack( GATPlayer player, int trackNb, float gain = 1f )
        {
            #if GAT_DEBUG
            if( IsPlaying )
            {
                Debug.LogWarning( "Already playing!" );
                return;
            }
            #endif

            IsPlaying 		= true;
            _keepLooping 	= true;
            _nextIndex 		= _attackStartIndex; //reset the play head
            _currentState 	= State.Attack;
            _data 			= _dataOwner.AudioData;

            if( !_noLoop )
            {
                UpdateZeroCrossings();
            }

            player.PlayData( _data, trackNb, gain, PlayerWillMixSample );
        }
Пример #14
0
 void Awake()
 {
     if( player == null )
     {
         player = GATManager.DefaultPlayer;
     }
 }
Пример #15
0
        /// <summary>
        /// Plays the sample through the specified player's track trackNb
        /// </summary>
        public void PlayThroughTrack( GATPlayer player, int trackNb, float gain = 1f )
        {
            if( PlayingStatus != Status.ReadyToPlay )
                return;

            PlayingStatus = Status.Scheduled;
            player.PlayData( _dataOwner.AudioData, trackNb, gain, PlayerWillMixSample );
            _endDspTime = AudioSettings.dspTime + MaxDuration;
        }
Пример #16
0
        /// <summary>
        /// Plays the sample directly through the specified player.
        /// If no AGATPanInfo reference was specified when creating the instance,
        /// doesn't do anything.
        /// </summary>
        public void PlayScheduled( GATPlayer player, double dspTime, float gain = 1f )
        {
            if( panInfo == null )
            {
                #if GAT_DEBUG
                Debug.LogWarning( "No panInfo set!" );
                return;
                #endif
            }
            if( PlayingStatus != Status.ReadyToPlay )
                return;

            PlayingStatus = Status.Scheduled;
            player.PlayDataScheduled( _dataOwner.AudioData, dspTime, panInfo, gain, PlayerWillMixSample );
            _endDspTime = dspTime + MaxDuration;
        }