Load

This function loads a sound from a sound (*.wav) file.

Syntax

Parameters

Returns

Returns the loaded sound. If the sound cannot be loaded, NULL is returned.

Remarks

Only sounds in mono format can be played with 3D spatialization. Stereo sounds will not be affected by position.

Example

#include "Leadwerks.h"

using namespace Leadwerks;

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

while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
context->SetColor(0, 0, 0, 0);
context->Clear();

context->SetColor(1, 1, 1, 0);
context->SetBlendMode(Blend::Alpha);
context->DrawText("Sound length: " + String(sound->GetLength()) + " seconds", 2, 2);
context->SetBlendMode(Blend::Solid);

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