Handles pre-processing of samples and keeps track of update times of it's processing properties. Properties may be set at any time, all IGATProcessedSample objects that refer to the GATEnvelope will update their data accordingly. EnvelopeModule component wraps a GATEnvelope in an inspector friendly package if needed.
예제 #1
0
 /// <summary>
 /// Flushs all cached samples associated with the specified envelope.
 /// </summary>
 /// <param name="envelope">Envelope.</param>
 public void FlushCacheForEnvelope(GATEnvelope envelope)
 {
     if (_cache == null)
     {
         return;
     }
     _cache.FlushCacheForEnvelope(envelope);
 }
예제 #2
0
        void OnEnable()
        {
            if (_pulse != null && _mapLengthToPulse)
            {
                _pulse.onWillPulse += OnWillPulse;
            }

            if (Envelope == null)
            {
                Envelope = new GATEnvelope(_length, _fadeIn, _fadeOut, _offset, _normalize, _normalizeValue);
            }
        }
예제 #3
0
            public ProcessedAudioChunk(GATData sourcesample, GATEnvelope ienvelope, GATProcessedSamplesCache parentCache, double pitch = 1d)
            {
                sourceSample = sourcesample;
                envelope     = ienvelope;
                _parentCache = parentCache;

                if (envelope == GATEnvelope.nullEnvelope)                  //_cachedLength will never change
                {
                    _cachedLength = sourcesample.Count;
                }
                else
                {
                    _cachedLength = envelope.Length;
                }

                SetPitch(pitch);
            }
예제 #4
0
        /// <summary>
        /// Flushs all cached samples associated with the specified envelope.
        /// </summary>
        /// <param name="envelope">Envelope.</param>
        public void FlushCacheForEnvelope(GATEnvelope envelope)
        {
            List <ProcessedAudioChunk> chunks;
            List <ProcessedAudioChunk> chunksToRemove = new List <ProcessedAudioChunk>();
            ProcessedAudioChunk        chunk;
            int i;

            if (envelope == null)
            {
                envelope = GATEnvelope.nullEnvelope;
            }

            foreach (KeyValuePair <GATData, List <ProcessedAudioChunk> > chunksByName in _processedChunksInMemory)
            {
                chunks = chunksByName.Value;

                if (chunks.Count == 0)
                {
                    continue;
                }

                for (i = 0; i < chunks.Count; i++)
                {
                    chunk = chunks[i];
                    if (chunk.envelope == envelope)
                    {
                        chunk.CleanUp();
                        chunksToRemove.Add(chunk);
                    }
                }

                if (chunksToRemove.Count > 0)
                {
                    for (i = 0; i < chunksToRemove.Count; i++)
                    {
                        chunks.Remove(chunksToRemove[i]);
                    }

                    chunksToRemove.Clear();
                }
            }
        }
예제 #5
0
		/// <summary>
		/// Flushs all cached samples associated with the specified envelope.
		/// </summary>
		/// <param name="envelope">Envelope.</param>
		public void FlushCacheForEnvelope( GATEnvelope envelope )
		{
			List< ProcessedAudioChunk > chunks;
			List< ProcessedAudioChunk > chunksToRemove = new List< ProcessedAudioChunk >();
			ProcessedAudioChunk 	    chunk;
			int i;
			
			if( envelope == null )
				envelope = GATEnvelope.nullEnvelope;
			
			foreach( KeyValuePair< GATData, List< ProcessedAudioChunk > > chunksByName in _processedChunksInMemory )
			{
				chunks = chunksByName.Value;
				
				if( chunks.Count == 0 )
					continue;
				
				for( i = 0; i < chunks.Count; i++ )
				{
					chunk = chunks[ i ];
					if( chunk.envelope == envelope )
					{
						chunk.CleanUp();
						chunksToRemove.Add ( chunk );
					}
				}
				
				if( chunksToRemove.Count > 0 )
				{
					for( i = 0; i < chunksToRemove.Count; i++ )
					{
						chunks.Remove( chunksToRemove[ i ] );
					}
					
					chunksToRemove.Clear();
				}
			}
		}
예제 #6
0
		public IGATProcessedSample GetProcessedSample( GATData sourceSample, double pitch, GATEnvelope envelope )
		{
			if( envelope == null )
				envelope = GATEnvelope.nullEnvelope;
			
			int i;
			
			List<ProcessedAudioChunk> chunks = _processedChunksInMemory[ sourceSample ];
			ProcessedAudioChunk sample;
			
			for( i = 0; i < chunks.Count; i++ )
			{
				if( chunks[i].envelope == envelope && chunks[i].Pitch == pitch )
				{
					sample = chunks[i];
					return sample;
				}
			}
			
			sample = new ProcessedAudioChunk( sourceSample, envelope, this, pitch ); //Here is the main dif with base class
			chunks.Add( sample );
			return sample;
		}
예제 #7
0
			public ProcessedAudioChunk( GATData sourcesample, GATEnvelope ienvelope, GATProcessedSamplesCache parentCache, double pitch = 1d )
			{
				sourceSample = sourcesample;
				envelope 	= ienvelope;
				_parentCache = parentCache;
				
				if( envelope == GATEnvelope.nullEnvelope ) //_cachedLength will never change
				{
					_cachedLength = sourcesample.Count;
				}
				else
				{
					_cachedLength = envelope.Length;
				}

				SetPitch( pitch );
			}
예제 #8
0
 void Awake()
 {
     Envelope = new GATEnvelope(_length, _fadeIn, _fadeOut, _offset, _normalize, _normalizeValue);
 }
예제 #9
0
 public virtual IGATProcessedSample GetProcessedSample( int indexInBank, GATEnvelope envelope, double pitch = 1d )
 {
     return _cache.GetProcessedSample( _allSamples[ indexInBank ], pitch, envelope );
 }
예제 #10
0
 /// <summary>
 /// Gets a processed sample container that will automatically update according to the envelope.
 /// Play it directly, not via GATPlayer : all envelope updates will be handled, even when overlapping sounds have their envelope changed.
 /// Note that the pitch parameter will only be taken into account by GATResamplingSampleBank instances.
 /// </summary>
 /// <returns>
 /// An interface to the processed sample container.
 /// </returns>
 /// <param name='sampleName'>
 /// The sample's name in the loaded SoundBank
 /// </param>
 /// <param name='envelope'>
 /// The envelope may be null if you need the whole, unprocessed sample. 
 /// </param>
 public virtual IGATProcessedSample GetProcessedSample( string sampleName, GATEnvelope envelope, double pitch = 1d )
 {
     return _cache.GetProcessedSample( _samplesByName[ sampleName ], pitch, envelope );
 }
예제 #11
0
 /// <summary>
 /// Flushs all cached samples associated with the specified envelope.
 /// </summary>
 /// <param name="envelope">Envelope.</param>
 public void FlushCacheForEnvelope( GATEnvelope envelope )
 {
     if( _cache == null )
         return;
     _cache.FlushCacheForEnvelope( envelope );
 }
예제 #12
0
        void OnEnable()
        {
            if( _pulse != null && _mapLengthToPulse )
            {
                _pulse.onWillPulse += OnWillPulse;
            }

            if( Envelope == null )
                Envelope = new GATEnvelope( _length, _fadeIn, _fadeOut, _offset, _normalize, _normalizeValue );
        }
예제 #13
0
 void Awake()
 {
     Envelope = new GATEnvelope( _length, _fadeIn, _fadeOut, _offset, _normalize, _normalizeValue );
 }
예제 #14
0
 public virtual IGATProcessedSample GetProcessedSample(int indexInBank, GATEnvelope envelope, double pitch = 1d)
 {
     return(_cache.GetProcessedSample(_allSamples[indexInBank], pitch, envelope));
 }
예제 #15
0
 /// <summary>
 /// Gets a processed sample container that will automatically update according to the envelope.
 /// Play it directly, not via GATPlayer : all envelope updates will be handled, even when overlapping sounds have their envelope changed.
 /// Note that the pitch parameter will only be taken into account by GATResamplingSampleBank instances.
 /// </summary>
 /// <returns>
 /// An interface to the processed sample container.
 /// </returns>
 /// <param name='sampleName'>
 /// The sample's name in the loaded SoundBank
 /// </param>
 /// <param name='envelope'>
 /// The envelope may be null if you need the whole, unprocessed sample.
 /// </param>
 public virtual IGATProcessedSample GetProcessedSample(string sampleName, GATEnvelope envelope, double pitch = 1d)
 {
     return(_cache.GetProcessedSample(_samplesByName[sampleName], pitch, envelope));
 }
예제 #16
0
        public IGATProcessedSample GetProcessedSample(GATData sourceSample, double pitch, GATEnvelope envelope)
        {
            if (envelope == null)
            {
                envelope = GATEnvelope.nullEnvelope;
            }

            int i;

            List <ProcessedAudioChunk> chunks = _processedChunksInMemory[sourceSample];
            ProcessedAudioChunk        sample;

            for (i = 0; i < chunks.Count; i++)
            {
                if (chunks[i].envelope == envelope && chunks[i].Pitch == pitch)
                {
                    sample = chunks[i];
                    return(sample);
                }
            }

            sample = new ProcessedAudioChunk(sourceSample, envelope, this, pitch);               //Here is the main dif with base class
            chunks.Add(sample);
            return(sample);
        }