C# Class kOS.Sound.Voice

Represents one of the hardware voices in the "sound chip", and its settings.
Inheritance: UnityEngine.MonoBehaviour, IVoice
Show file Open project: KSP-KOS/KOS

Public Methods

Method Description
Awake ( ) : void
BeginProceduralSound ( IProceduralSoundWave waveGen, float frequency, float duration, float volume = 1f ) : bool

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.

BeginProceduralSound ( float frequency, float duration, float volume = 1f ) : bool

Begin a single note. You can pass in a frequency and it will "stretch" the reference sample to make it fit the given frequency.

ChangeFrequency ( float newFrequency ) : void

Change the frequency of the note in mid-note (for slide effects).

SetWave ( IProceduralSoundWave waveGen ) : void
Stop ( ) : void
Update ( ) : void

Maintains the volume level in accordance to the ADSR envelope rules, and the note's holding duration.

Private Methods

Method Description
InitNote ( ) : void

Called whenever a new note starts, to get the AudioSource and ProceduralSoundWave to use the note's values, and then start the note.

Method Details

Awake() public method

public Awake ( ) : void
return void

BeginProceduralSound() public method

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.
public BeginProceduralSound ( IProceduralSoundWave waveGen, float frequency, float duration, float volume = 1f ) : bool
waveGen IProceduralSoundWave a procedural sound wave loaded and prepped ahead of time
frequency float the note, expressed in Hertz (not musical scales)
duration float the note's duration, in seconds.
volume float the note's volume, from 0.0 up to 1.0
return bool

BeginProceduralSound() public method

Begin a single note. You can pass in a frequency and it will "stretch" the reference sample to make it fit the given frequency.
public BeginProceduralSound ( float frequency, float duration, float volume = 1f ) : bool
frequency float the note, expressed in Hertz (not musical scales)
duration float the note's duration, in seconds.
volume float the note's volume, from 0.0 up to 1.0
return bool

ChangeFrequency() public method

Change the frequency of the note in mid-note (for slide effects).
public ChangeFrequency ( float newFrequency ) : void
newFrequency float
return void

SetWave() public method

public SetWave ( IProceduralSoundWave waveGen ) : void
waveGen IProceduralSoundWave
return void

Stop() public method

public Stop ( ) : void
return void

Update() public method

Maintains the volume level in accordance to the ADSR envelope rules, and the note's holding duration.
public Update ( ) : void
return void