GetPitch

This function gets the pitch of a source.

Syntax

Returns

Returns the source pitch.

Example

#include "Leadwerks.h"

using namespace Leadwerks;

Source* source = NULL;

int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
//Load a sound
Sound* sound = Sound::Load("Sound/Music/menutheme.wav");

source = Source::Create();
source->SetSound(sound);
source->SetLoopMode(true);
source->Play();

while (true)
{
//Press up/down keys to alter pitch
float pitch = source->GetPitch();
if (window->KeyDown(Key::Up)) pitch += Leadwerks::Time::GetSpeed()*0.01;
if (window->KeyDown(Key::Down)) pitch -= Leadwerks::Time::GetSpeed()*0.01;
source->SetPitch(pitch);

if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Time::Update();
context->SetColor(0, 0, 0, 0);
context->Clear();

context->SetColor(1, 1, 1, 0);
context->SetBlendMode(Blend::Alpha);
context->DrawText("Pitch: " + String(source->GetPitch()), 2, 2);

context->Sync();
}
return 0;
}