// ----------------------------------------------------------------------------
// Blitz-Irrlicht 1.8.3 Wrapper by Ed Musolino 2015
// Based off of Frank Dodd's Irrlicht 1.7 Freebasic Wrapper (2006-2010)
// ----------------------------------------------------------------------------

//  This software is provided 'as-is', without any express Or implied
//  warranty.  In no event will the authors be held liable For any damages
//  arising from the use of this software.

//  Permission is granted To anyone To use this software For any purpose,
//  including commercial applications, And To alter it And redistribute it
//  freely, subject To the following restrictions:

//  1. The Origin of this software must Not be misrepresented; you must not
//     claim that you wrote the original software. If you use this software
//     in a product, an acknowledgement in the product documentation would be
//     appreciated but is Not required.
//  2. Altered source versions must be clearly marked as such, And must Not be
//     misrepresented as being the original software.
//  3. This notice may Not be removed Or altered from any source distribution.
//
// /////////////////////////////////////////////////////////////////////////////

/* ////////////////////////////////////////////////////////////////////////////
includes
*/

#include <stdio.h>
#include "bIrrlicht.h"


/* ////////////////////////////////////////////////////////////////////////////
global variables
*/

/* ////////////////////////////////////////////////////////////////////////////
external variables
*/
extern ISoundEngine* engine;


/* ////////////////////////////////////////////////////////////////////////////
Global Function Declarations

all of the below functions are declared as C functions and are exposed without
any mangled names so that they can be easily imported into imperative
languages like FreeBasic
*/
extern "C"
{

/* ////////////////////////////////////////////////////////////////////////////
SYSTEM FUNCTIONS
*/
/* ----------------------------------------------------------------------------
Get the length of the sound in milliseconds
*/
DLL_EXPORT unsigned int BBCALL iSoundLength( ISound * sound )
{
    return sound->getPlayLength();
}

/* ----------------------------------------------------------------------------
Get the position of play in the sound in milliseconds
*/
DLL_EXPORT unsigned int BBCALL iGetPlayPosition( ISound * sound )
{
    return sound->getPlayPosition();
}

/* ----------------------------------------------------------------------------
Get the position of play in the sound in milliseconds
*/
DLL_EXPORT bool BBCALL iSoundPlaying( ISound * sound )
{
    return !(sound->isFinished());
}

/* ----------------------------------------------------------------------------
Pause and unpause the sound
*/
DLL_EXPORT void BBCALL iPauseSound( ISound * sound, bool pause )
{
    sound->setIsPaused( pause );
}

/* ----------------------------------------------------------------------------
Set the playback speed of the sound
*/
DLL_EXPORT bool BBCALL iPlaySpeed( ISound * sound, float speed )
{
    return sound->setPlaybackSpeed( speed );
}

/* ----------------------------------------------------------------------------
Set the playback position of the sound
*/
DLL_EXPORT bool BBCALL iSetPlayPosition( ISound * sound, unsigned int position )
{
    return sound->setPlayPosition( position );
}

/* ----------------------------------------------------------------------------
Set the volume of the sound
*/
DLL_EXPORT void BBCALL iSoundVolume( ISound * sound, float volume )
{
    sound->setVolume( volume );
}

/* ----------------------------------------------------------------------------
Stop the sound playing
*/
DLL_EXPORT void BBCALL iStopSound( ISound * sound )
{
    sound->stop();
}


/* ////////////////////////////////////////////////////////////////////////////
all of the above functions are declared as C functions and are exposed without
any mangled names
*/
}
