C# 클래스 kOS.Sound.ProceduralSoundWave

Creates an arbitrary audio wave reference example note and populates an AudioClip with it.
These are used with the SoundMaker class to provide a means to do crude FM wave sounds.
Each of the "FM wave generators" in the kOS computer's "audio chip" is a derived class of this.
To make a new FM wave type, just inherit from this class and override SampleFunction with your own mathematical function that describes the sound wave in the time domain. The base class should populate the audio clip for you from that.
상속: IProceduralSoundWave
파일 보기 프로젝트 열기: KSP-KOS/KOS 1 사용 예제들

공개 메소드들

메소드 설명
InitSettings ( ) : void

Meant to be overridden if a derived type has to change settings before GenerateClip() is called.

IMPORTANT: When making a derivative of ProceduralSoundWave, put your initializations HERE not in the constructor, because the base constructor will call this before it does things, where if you set them in your derived constructor, then GenerateClip() would be getting called before your settings in your constructor happened.

If you override it, be sure to explicitly call the base version too.

ProceduralSoundWave ( ) : kOS.Safe.Sound

Important: when making a derivative of ProceduralSoundWave, put your initializations of important things inside InitSettings(), not in your constructor. Instead make your constructor call the base constructor and do nothing else. The base constructor will call your InitSettings() for you. This is important because you need to populate your settings BEFORE the base constructor tries to call GenerateClip(). If you populated your settings inside your own constructor, that would be too late.

SampleFunction ( float t ) : float

Override this in your derived class to make a wave generator of whatever type you like. It should be a time-domain picture of the sound wave over one wave period, outputting values from -1 to +1 for a given time t.

비공개 메소드들

메소드 설명
FillBuffer ( float sampleData, int numChannels ) : void

The workhorse under the hood for GenerateClip().

GenerateClip ( ) : void

Generates the AudioClip (happens as part of the constructor).
It does this by querying your SampleFunction() to build a reference wave in memory.

메소드 상세

InitSettings() 공개 메소드

Meant to be overridden if a derived type has to change settings before GenerateClip() is called.

IMPORTANT: When making a derivative of ProceduralSoundWave, put your initializations HERE not in the constructor, because the base constructor will call this before it does things, where if you set them in your derived constructor, then GenerateClip() would be getting called before your settings in your constructor happened.

If you override it, be sure to explicitly call the base version too.
public InitSettings ( ) : void
리턴 void

ProceduralSoundWave() 공개 메소드

Important: when making a derivative of ProceduralSoundWave, put your initializations of important things inside InitSettings(), not in your constructor. Instead make your constructor call the base constructor and do nothing else. The base constructor will call your InitSettings() for you. This is important because you need to populate your settings BEFORE the base constructor tries to call GenerateClip(). If you populated your settings inside your own constructor, that would be too late.
public ProceduralSoundWave ( ) : kOS.Safe.Sound
리턴 kOS.Safe.Sound

SampleFunction() 공개 메소드

Override this in your derived class to make a wave generator of whatever type you like. It should be a time-domain picture of the sound wave over one wave period, outputting values from -1 to +1 for a given time t.
public SampleFunction ( float t ) : float
t float
리턴 float