Stepp

m

(editor)

prop

Tempo

Count

Step

Pitch

Pitches

Audio Files

Voice

func

(Stepp.cs)

//can be run while sequencer is active

AddPitchAtStep(pitch, step)

RemovePitchAtStep(pitch,step)

private

Voice[]

voices;

class

Voice

{ ... }

(var)

public

readonly

AudioSource

audioSource;

int

pitch

step

(func)

public

(constructor)

Voice (AudioSource inAudioSource, int inPitch, int inStep){ ... }

(init)

audioSource = inAudioSource;

pitch = inPitch;

step = inStep;

int

(step)

double

stepDuration;

The duration of a single step at the current temp;

lastStep;

//The last step that the sequencer was on. Used to determine when step boundaries are crossed.

currentStep;

//The current step that the sequencer is on.

advancedStepDelegate

r

Add callbacks to the advancedStepDelegateto be notified when the sequencer advances to a new step. The demo sequencer uses this to update the position of the Step­Indicator game object.

(define)

public

delegate

void

SteppCallback(int step);

SteppCallback

advancedStepDelegate;

(path/config)

(call)

private void Updat(){ ... }

if ((currentStep >= 0) && (advancedStepDelegate != null)) { ... }

advancedStepDelegate(currentStep);

(passes int currentStep)

(Sequencer)

StartSequencer()

StopSequencer()

ClearAllPitches()

(example scene)

SequencerController.cs

(var)

public

Stepp

stepSequencer

Button

playButton

GameObject

stepIndicator

(func)

private

void

Start(){ ... }

stepSequencer.advancedStepDelegate += HandleSequencerStepAdvance;

playButton.MouseUpAsButton += HandlePowerButtonPressed;

HandleSequencerStepAdvance( int step ){ ... }

if (stepIndicator.GetComponent<Renderer>().enabled == false) { ... }

stepIndicator.GetComponent<Renderer>().enabled = true;

Vector3 position = stepIndicator.transform.position;

position.x = (step*2.0f) - 7.0f;

stepIndicator.transform.position = position;

HandlePowerButtonPressed( bool selected ){ ... }

if (selected) { ... }

stepSequencer.StartSequencer();

else { ... }

stepSequencer.StopSequencer();

stepIndicator.GetComponent<Renderer>().enabled = false;

Button.cs

(var)

public

Stepp

stepSequencer

Sprite

selectedSprite

deselectedSprite

delegate

void

ButtonHandler(bool selected);

ButtonHandler

MouseUpAsButton;

bool

Selected{ ... }

//wth is this???

get{ ... }

return selected;

set{ ... }

selected = value;

//wth is value defined???

//special in the language

SpriteRenderer spriteRenderer = (SpriteRenderer)GetComponent<Renderer>();

spriteRenderer.sprite = (Selected) ? selectedSprite : deselectedSprite;

private

bool

selected = false;

(func)

private

void

OnMouseUpAsButton(){ ... }

Selected = !Selected;

if (MouseUpAsButton != null) { ... }

MouseUpAsButton(Selected);

Trigger.cs

:Button

(var)

public

int

pitch

step

(func)

private

void

Awake(){ ... }

MouseUpAsButton += HandleMouseUpAsButton;

stepSequencer.advancedStepDelegate += HandleSequencerAdvancedStep;

HandleMouseUpAsButton(bool selected){ ... }

if (selected) { ... }

stepSequencer.AddPitchAtStep(pitch, step);

else { ... }

stepSequencer.RemovePitchAtStep(pitch, step);

HandleSequencerAdvancedStep(int inStep){ ... }

if ((inStep == step) && Selected) { ... }

StopCoroutine("TriggerAnimation");

StartCoroutine("TriggerAnimation");

IEnumerator

//wth is IEnumerator

r

You don't use IEnumerable "over" foreach. Implementing IEnumerable makes using foreach possible.When you write code like:foreach (Foo bar in baz){ ...}it's functionally equivalent to writing:IEnumerator bat = baz.GetEnumerator();while (bat.MoveNext()){ bar = (Foo)bat.Current ...}By "functionally equivalent," I mean that's actually what the compiler turns the code into. You can't use foreach on baz in this example unless baz implements IEnumerable.IEnumerable means that baz implements the methodIEnumerator GetEnumerator()The IEnumerator object that this method returns must implement the methodsbool MoveNext()andObject Current()The first method advances to the next object in the IEnumerable object that created the enumerator, returning false if it's done, and the second returns the current object.Anything in .Net that you can iterate over implements IEnumerable. If you're building your own class, and it doesn't already inherit from a class that implements IEnumerable, you can make your class usable in foreach statements by implementing IEnumerable (and by creating an enumerator class that its new GetEnumerator method will return).

TriggerAnimation(){ ... }

yield return new WaitForSeconds(0.3f);

Vector3 targetScale = transform.localScale;

targetScale.x = 1.2f;

targetScale.y = 1.2f;

transform.localScale = targetScale;

yield return null;

targetScale = transform.localScale;

targetScale.x = 1.0f;

targetScale.y = 1.0f;

transform.localScale = targetScale;

//Why return null??? As opposed to doing nothing???