Ejemplo n.º 1
0
 /// <summary>
 /// Begin a single note from a ProceduralSoundWave reference sample.
 /// You can pass in a frequency and it will "stretch" the reference sample
 /// to make it fit the given frequency.
 /// </summary>
 /// <param name="waveGen">a procedural sound wave loaded and prepped ahead of time</param>
 /// <param name="frequency">the note, expressed in Hertz (not musical scales)</param>
 /// <param name="duration">the note's duration, in seconds.</param>
 /// <param name="volume">the note's volume, from 0.0 up to 1.0</param>
 /// <returns>false if frequency is less than zero, indicating a rest</returns>
 public bool BeginProceduralSound(IProceduralSoundWave waveGen, float frequency, float duration, float volume = 1f)
 {
     SetWave(waveGen); // update the wave even if called for a rest note
     if (frequency > 0)
     {
         Volume           = volume;
         noteAttackStart  = Time.unscaledTime;
         noteReleaseStart = Time.unscaledTime + duration;
         needNoteInit     = true;
         ChangeFrequency(frequency);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 2
0
Archivo: Voice.cs Proyecto: KSP-KOS/KOS
 public void SetWave(IProceduralSoundWave waveGen)
 {
     Waveform = waveGen;
     source.Stop(); // stop the source so that the new wave gets queued up
     needNoteInit = true; // re-sample the pitch value
 }
Ejemplo n.º 3
0
Archivo: Voice.cs Proyecto: KSP-KOS/KOS
 /// <summary>
 /// Begin a single note from a ProceduralSoundWave reference sample.
 /// You can pass in a frequency and it will "stretch" the reference sample
 /// to make it fit the given frequency.
 /// </summary>
 /// <param name="waveGen">a procedural sound wave loaded and prepped ahead of time</param>
 /// <param name="frequency">the note, expressed in Hertz (not musical scales)</param>
 /// <param name="duration">the note's duration, in seconds.</param>
 /// <param name="volume">the note's volume, from 0.0 up to 1.0</param>
 /// <returns>false if frequency is less than zero, indicating a rest</returns>
 public bool BeginProceduralSound(IProceduralSoundWave waveGen, float frequency, float duration, float volume = 1f)
 {
     SetWave(waveGen); // update the wave even if called for a rest note
     if (frequency > 0)
     {
         Volume = volume;
         noteAttackStart = Time.unscaledTime;
         noteReleaseStart = Time.unscaledTime + duration;
         needNoteInit = true;
         ChangeFrequency(frequency);
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 public void SetWave(IProceduralSoundWave waveGen)
 {
     Waveform = waveGen;
     source.Stop();       // stop the source so that the new wave gets queued up
     needNoteInit = true; // re-sample the pitch value
 }