void PlayStreakEnd(PatternSample sampleInfo, double dspTime) { _rtSample = new GATRealTimeSample(sampleBank.GetAudioData(sampleInfo.SampleName)); // grab the sample and wrap it in GATRealtimeSample for realtime pitch shifting _rtSample.Pitch = sampleInfo.Pitch; // set it's pitch to be the same as the end of streak pitch _rtSample.PlayScheduledThroughTrack(dspTime, 2); //play through track 2, which is panned to the right and distorted float deltaTime = ( float )(dspTime - AudioSettings.dspTime); particles.transform.localPosition = new Vector3(PARTICLES_X, PARTICLES_Y_FACTOR * sampleInfo.SemiTones, PARTICLES_Z); //Adjust the particle system's y to reflect the pitch's height Invoke("PlayParticles", deltaTime); //Fire at appropriate time }
protected override void ButtonClicked(int buttonIndex) { if (_realTimeSample != null) { if (_realTimeSample.PlayingStatus == GATRealTimeSample.Status.Playing) // If a sample is already playing, we stop it { _realTimeSample.FadeOutAndStop(.5d); //fade occurs at buffer level, no coroutines, no pops. } } string sampleName = ButtonLabels[buttonIndex]; // get the name of the clicked sample float pitch = SliderValues[buttonIndex]; // and the value of the corresponding slider GATData sampleData = sampleBank.GetAudioData(sampleName); // grab the audio data from the bank _realTimeSample = new GATRealTimeSample(sampleData); // wrap in a GATRealTimeSample for realtime monitoring and control _realTimeSample.Loop = true; _realTimeSample.Pitch = pitch; // set pitch _realTimeSample.PlayThroughTrack(TrackNb); // and play. Note that we ask the GATRealTimeInstance to play directly. There are many overloaded // Play methods - this is the simplest and routes playback through the default player. _playingSampleIndex = buttonIndex; // cache the index of the sample for easy monitoring of sliders ( see below ) }
void PlayStreakEnd( PatternSample sampleInfo, double dspTime ) { _rtSample = new GATRealTimeSample( sampleBank.GetAudioData( sampleInfo.SampleName ) ); // grab the sample and wrap it in GATRealtimeSample for realtime pitch shifting _rtSample.Pitch = sampleInfo.Pitch; // set it's pitch to be the same as the end of streak pitch _rtSample.PlayScheduledThroughTrack( dspTime, 2 ); //play through track 2, which is panned to the right and distorted float deltaTime = ( float )( dspTime - AudioSettings.dspTime ); particles.transform.localPosition = new Vector3( PARTICLES_X, PARTICLES_Y_FACTOR * sampleInfo.SemiTones, PARTICLES_Z ); //Adjust the particle system's y to reflect the pitch's height Invoke( "PlayParticles", deltaTime ); //Fire at appropriate time }