Base class for handling panning of mono samples to interlaced multi channel data.
Exemplo n.º 1
0
 public GATRealTimeSample(IGATDataOwner dataOwner, bool canPitchShift, AGATPanInfo ipaninfo = null) : base(dataOwner, ipaninfo)
 {
     // Note: for some reason, Unity's not picking up the Obsolete attribute...
     Debug.LogWarning("Obsolete ctor: canPitchShift parameter is now obsolete. Please use GATLoopedSample if you need to monitor and smoothly stop playback without pitch shift.");
     _dataSource = new GATDataSource(dataOwner.AudioData);
     _fader      = new Fader();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Wraps audio data in a looping container. Set NumberOfLoops to -1 for infinite looping.
        /// 0 for no loop. Pass a GATFixedPanInfo or GATDynamicPanInfo object if you intend to route
        /// playback directly to the player ( as opposed to through a track ).
        /// </summary>
        public GATLoopedSample(IGATDataOwner dataOwner, int numberOfLoops = -1, AGATPanInfo panInfo = null) : base(dataOwner, panInfo)
        {
            if (numberOfLoops != 0)
            {
                Loop = true;
            }

            NumberOfLoops = numberOfLoops;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Wraps audio data in a looping container. Set NumberOfLoops to -1 for infinite looping.
        /// 0 for no loop. Pass a GATFixedPanInfo or GATDynamicPanInfo object if you intend to route
        /// playback directly to the player ( as opposed to through a track ).
        /// </summary>
        public GATLoopedSample( IGATDataOwner dataOwner, int numberOfLoops = -1, AGATPanInfo panInfo = null )
            : base(dataOwner, panInfo)
        {
            if( numberOfLoops != 0 )
            {
                Loop = true;
            }

            NumberOfLoops = numberOfLoops;
        }
Exemplo n.º 4
0
 public void Init(GATData isample, AGATPanInfo panInfo, OnShouldMixSample callback, float gain = 1f)
 {
     AudioData          = isample;
     PanInfo            = panInfo;
     _onShouldMixSample = callback;
     _gain        = gain;
     IsFirstChunk = true;
     _count       = isample.Count;
     _fadeStart   = -1;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Plays the sample directly.
        /// Panning may be controlled through the provided
        /// AGATPanInfo instance.
        /// </summary>
        public IGATBufferedSampleOptions PlayData(GATData sample, AGATPanInfo panInfo, float gain = 1f, OnShouldMixSample mixCallback = null)
        {
            sample.Retain();
            BufferedSample newSample = GetBufferedSample();

            newSample.Init(sample, panInfo, mixCallback, gain);

            lock ( _samplesToEnqueue )
            {
                _samplesToEnqueue.Enqueue(newSample);
            }

            return(newSample);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Wrap a GATData or IGATProcessedSample for
 /// real time control over playback.
 /// </summary>
 /// <param name='dataOwner'>
 /// GATData or IGATProcessedSample.
 /// </param>
 /// <param name='ipaninfo'>
 /// Specify a GATFixedPanInfo or GATDynamicPanInfo
 /// reference if you intend to play directly( not through a track ).
 /// </param>
 public GATRealTimeSample(IGATDataOwner dataOwner, AGATPanInfo ipaninfo = null) : base(dataOwner, ipaninfo)
 {
     _dataSource = new GATDataSource(dataOwner == null ? null : dataOwner.AudioData);
     _fader      = new Fader();
 }
Exemplo n.º 7
0
			public IGATBufferedSampleOptions PlayScheduled( GATPlayer player, double dspTime, AGATPanInfo panInfo, float gain = 1f, GATPlayer.OnShouldMixSample mixCallback = null )
			{
				UpdateAudioData();
				return player.PlayDataScheduled( _audioData, dspTime, panInfo, gain, mixCallback ); //Only use AudioData property when playing, as it updates
			}
Exemplo n.º 8
0
			public IGATBufferedSampleOptions Play( AGATPanInfo panInfo, float gain = 1f, GATPlayer.OnShouldMixSample mixCallback = null )
			{
				UpdateAudioData();
				return GATManager.DefaultPlayer.PlayData( _audioData, panInfo, gain, mixCallback ); //Only use AudioData property when playing, as it updates
			}
Exemplo n.º 9
0
 /// <summary>
 /// Data owners include IGATProcessedSample and GATData obects.
 /// Specify a GATDynamicPanInfo or GATFixedPanInfo object to
 /// enable routing playback directly to the player ( not through tracks ).
 /// </summary>
 public AGATWrappedSample(IGATDataOwner dataOwner, AGATPanInfo ipaninfo = null)
 {
     panInfo    = ipaninfo;
     _dataOwner = dataOwner;
 }
Exemplo n.º 10
0
        /// <summary>
        /// Plays the sample directly.
        /// Panning may be controlled through the provided
        /// AGATPanInfo instance.
        /// Note that dspTime must be greater or equal
        /// to AudioSettings.dspTime + GATInfo.AudioBufferDuration, or the sample will not be
        /// added to the playing queue.
        /// </summary>
        public IGATBufferedSampleOptions PlayDataScheduled(GATData sample, double dspTime, AGATPanInfo panInfo, float gain = 1f, OnShouldMixSample mixCallback = null)
        {
            if (dspTime < AudioSettings.dspTime + GATInfo.AudioBufferDuration)             //Next buffer dspTime
            {
                                #if GAT_DEBUG
                Debug.LogWarning("cannot play at such short notice.");
                                #endif
                return(BufferedSample.VoidOptions);
            }
            sample.Retain();
            BufferedSample newSample = GetBufferedSample();
            newSample.scheduledDspTime = dspTime;

            newSample.Init(sample, panInfo, mixCallback, gain);

            lock ( _scheduledSamples )
            {
                _scheduledSamples.Enqueue(newSample);
            }

            return(newSample);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Data owners include IGATProcessedSample and GATData obects.
 /// Specify a GATDynamicPanInfo or GATFixedPanInfo object to
 /// enable routing playback directly to the player ( not through tracks ).
 /// </summary>
 public AGATWrappedSample( IGATDataOwner dataOwner, AGATPanInfo ipaninfo = null )
 {
     panInfo 	= ipaninfo;
     _dataOwner 	= dataOwner;
 }
Exemplo n.º 12
0
 public IGATBufferedSampleOptions PlayScheduled(GATPlayer player, double dspTime, AGATPanInfo panInfo, float gain = 1f, GATPlayer.OnShouldMixSample mixCallback = null)
 {
     UpdateAudioData();
     return(player.PlayDataScheduled(_audioData, dspTime, panInfo, gain, mixCallback));                  //Only use AudioData property when playing, as it updates
 }
Exemplo n.º 13
0
 public IGATBufferedSampleOptions Play(AGATPanInfo panInfo, float gain = 1f, GATPlayer.OnShouldMixSample mixCallback = null)
 {
     UpdateAudioData();
     return(GATManager.DefaultPlayer.PlayData(_audioData, panInfo, gain, mixCallback));                  //Only use AudioData property when playing, as it updates
 }