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(); }
/// <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; }
/// <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; }
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; }
/// <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); }
/// <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(); }
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 }
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 }
/// <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; }
/// <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); }
/// <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; }
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 }
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 }