263 lines
10 KiB
C++
263 lines
10 KiB
C++
#pragma once
|
|
|
|
#if defined( DYNAMIC_SOUNDWICH_LIB )
|
|
#define SOUNDWICH_EXPORT __declspec(dllexport)
|
|
#else
|
|
#define SOUNDWICH_EXPORT
|
|
#endif
|
|
|
|
//#define ENABLE_STATISTICS
|
|
|
|
#include "Inc/Defs.h"
|
|
#include "Inc/Types.h"
|
|
#include "Inc/Results.h"
|
|
|
|
|
|
// These specify the native audio layers frame size and sample rate.
|
|
// This is the internal properties and does not necessarily have to match the system or device, any resampling will be performed by Soundwich
|
|
|
|
namespace Soundwich
|
|
{
|
|
static const uint32 DefaultFrameSize = 1024;
|
|
static const uint32 DefaultSampleRate = 48000;
|
|
|
|
class Component;
|
|
class Connection;
|
|
class Synth;
|
|
class EventIn;
|
|
class EventInWithId;
|
|
class ControlIn;
|
|
class SwitchIn;
|
|
class EventOut;
|
|
class ControlOut;
|
|
class SwitchOut;
|
|
|
|
class IEventOutCallback
|
|
{
|
|
public:
|
|
virtual ~IEventOutCallback(){}
|
|
virtual void OnEventOut( const EventOut* eventOut ) = 0;
|
|
};
|
|
|
|
class IControlOutCallback
|
|
{
|
|
public:
|
|
virtual ~IControlOutCallback(){}
|
|
virtual void OnControlOut( const ControlOut* controlOut, flt32 val ) = 0;
|
|
};
|
|
|
|
class ISwitchOutCallback
|
|
{
|
|
public:
|
|
virtual ~ISwitchOutCallback(){}
|
|
virtual void OnSwitchOut( const SwitchOut* switchOut, int32 val ) = 0;
|
|
};
|
|
|
|
class IJustDancePlayMenuMusicCallback
|
|
{
|
|
public:
|
|
virtual ~IJustDancePlayMenuMusicCallback(){}
|
|
virtual void OnPlayMenuMusic( const char * name, flt32 startFadeDuration, bool playAtEndOfPreviousBrick, int32 endBeatOverride, bool cancelAudioPreviewRequest, const char* eventNameCallback ) = 0;
|
|
};
|
|
|
|
class IJustDanceStopMenuMusicCallback
|
|
{
|
|
public:
|
|
virtual ~IJustDanceStopMenuMusicCallback(){}
|
|
virtual void OnStopMenuMusic( flt32 fadeOutDuration ) = 0;
|
|
};
|
|
|
|
class IJustDanceSoundEffectCallback
|
|
{
|
|
public:
|
|
virtual ~IJustDanceSoundEffectCallback(){}
|
|
virtual void OnPlaySoundEffect( const char * name ) = 0;
|
|
virtual void OnStopSoundEffect( const char * name ) = 0;
|
|
};
|
|
|
|
class IJustDanceSoundEffectOnTrackTransitionCallback
|
|
{
|
|
public:
|
|
virtual ~IJustDanceSoundEffectOnTrackTransitionCallback(){}
|
|
virtual void OnPlaySoundEffectOnTrackTransition( const char * name, int32 track ) = 0;
|
|
virtual void OnStopSoundEffectOnTrackTransition( const char * name ) = 0;
|
|
};
|
|
|
|
class IJustDanceRemoteSoundEffectCallback
|
|
{
|
|
public:
|
|
virtual ~IJustDanceRemoteSoundEffectCallback(){}
|
|
virtual void OnPlaySoundEffect( const char * name, int32 val, const char * controllerSoundName ) = 0;
|
|
virtual void OnStopSoundEffect( const char * name, int32 val, const char * controllerSoundName ) = 0;
|
|
};
|
|
|
|
class IJustDancePlayEventBusMusicCallback
|
|
{
|
|
public:
|
|
virtual ~IJustDancePlayEventBusMusicCallback(){}
|
|
virtual void OnPlayEventBusMusic( const char * name, flt32 fadeDurationOverride ) = 0;
|
|
};
|
|
|
|
class IJustDanceStopEventBusMusicCallback
|
|
{
|
|
public:
|
|
virtual ~IJustDanceStopEventBusMusicCallback(){}
|
|
virtual void OnStopEventBusMusic( const char * name, flt32 fadeDurationOverride ) = 0;
|
|
};
|
|
|
|
class IJustDanceStopAllEventBusMixesCallback
|
|
{
|
|
public:
|
|
virtual ~IJustDanceStopAllEventBusMixesCallback() {}
|
|
virtual void OnStopAllEventBusMixes(const bool includeMainMix, flt32 fadeDurationOverride) = 0;
|
|
};
|
|
|
|
class IJustDancePlayMusicMultiTrackCallback
|
|
{
|
|
public:
|
|
virtual ~IJustDancePlayMusicMultiTrackCallback(){}
|
|
virtual void OnPlayMusicMultiTrack( const char * name, const bool enterAtPreviousMultitrackPos, const char* eventNameCallback ) = 0;
|
|
};
|
|
|
|
class ISoundwichTracking
|
|
{
|
|
public:
|
|
virtual ~ISoundwichTracking() {}
|
|
virtual void OnUpdateTracking(const int activationId) = 0;
|
|
};
|
|
|
|
class IClientSystem
|
|
{
|
|
public:
|
|
virtual ~IClientSystem(){}
|
|
|
|
// performance timer
|
|
virtual uint64 GetHiResTime() const = 0;
|
|
|
|
virtual void * Alloc( size_t size ) = 0;
|
|
virtual void Free( void* ptr ) = 0;
|
|
|
|
virtual void LogLine( const char * /*line*/ ){};
|
|
};
|
|
|
|
class SOUNDWICH_EXPORT Engine
|
|
{
|
|
public:
|
|
void* operator new(size_t size);
|
|
void operator delete(void* memory);
|
|
|
|
static SoundResult Create( Engine** engine, IClientSystem* clientSystem = nullptr );
|
|
|
|
static SoundResult Destroy( Engine* engine );
|
|
|
|
// Data Path
|
|
|
|
SoundResult SetDataPath( const char* dataPath );
|
|
|
|
// Synths
|
|
|
|
SoundResult CreateSynthFromXmlFile( const char* name, Soundwich::Synth** synth, const char* fileName );
|
|
SoundResult CreateSynthFromMemory( const char* name, Soundwich::Synth** synth, void* data, uint32 size );
|
|
SoundResult CreateSynthFromXmlMemory( const char* name, Soundwich::Synth** synth, const char* xml );
|
|
|
|
SoundResult SaveSynthToFile( Soundwich::Synth* synth, const char* fileName );
|
|
SoundResult SaveSynthToXmlFile( Soundwich::Synth* synth, const char* fileName );
|
|
|
|
SoundResult DestroySynth( Synth* synth );
|
|
|
|
SoundResult ActivateSynth( Synth* synth );
|
|
SoundResult DeactivateSynth( Synth* synth );
|
|
|
|
// Accessors
|
|
|
|
SoundResult GetSynth( const char* name, Synth** synth );
|
|
|
|
SoundResult GetEventInComponent( Synth* synth, const char* componentName, EventIn** eventIn );
|
|
SoundResult GetEventInWithIdComponent( Synth* synth, const char* componentName, EventInWithId** eventInWithId );
|
|
SoundResult GetControlInComponent( Synth* synth, const char* componentName, ControlIn** controlIn );
|
|
SoundResult GetSwitchInComponent( Synth* synth, const char* componentName, SwitchIn** switchIn );
|
|
SoundResult GetEventOutComponent( Synth* synth, const char* componentName, EventOut** eventOut );
|
|
SoundResult GetControlOutComponent( Synth* synth, const char* componentName, ControlOut** controlOut );
|
|
SoundResult GetSwitchOutComponent( Synth* synth, const char* componentName, SwitchOut** switchOut );
|
|
|
|
// Tick
|
|
|
|
SoundResult Tick( );
|
|
|
|
// Interface Controls
|
|
|
|
SoundResult SetEventIn( EventIn* eventIn );
|
|
SoundResult SetEventInWithId( EventInWithId* eventIn, int32 val );
|
|
SoundResult SetControlIn( ControlIn* controlIn, flt32 val );
|
|
SoundResult SetSwitchIn( SwitchIn* switchIn, int32 val );
|
|
|
|
// Debugging
|
|
|
|
SoundResult GetComponent( Soundwich::Synth* synth, const char* componentName, Soundwich::Component** component );
|
|
|
|
SoundResult SwitchTracking(Soundwich::Synth* synth, bool enable, const char* exportFilePath );
|
|
|
|
SoundResult SetSynthDebugLogging( Soundwich::Synth* synth, bool enable );
|
|
SoundResult SetComponentDebugLogging( Soundwich::Component* component, bool enable );
|
|
SoundResult SetConnectionDebugLogging( Soundwich::Connection* connection, bool enable );
|
|
|
|
// Callbacks
|
|
|
|
SoundResult RegisterEventOutCallback( IEventOutCallback* cb, EventOut* eventOut );
|
|
SoundResult RegisterControlOutCallback( IControlOutCallback* cb, ControlOut* controlOut );
|
|
SoundResult RegisterSwitchOutCallback( ISwitchOutCallback* cb, SwitchOut* switchOut );
|
|
SoundResult RegisterJustDancePlayMenuMusicCallback( IJustDancePlayMenuMusicCallback* cb );
|
|
SoundResult RegisterJustDanceStopMenuMusicCallback( IJustDanceStopMenuMusicCallback* cb );
|
|
SoundResult RegisterJustDanceSoundEffectCallback( IJustDanceSoundEffectCallback* cb );
|
|
SoundResult RegisterJustDanceSoundEffectOnTrackTransitionCallback( IJustDanceSoundEffectOnTrackTransitionCallback* cb );
|
|
SoundResult RegisterJustDanceRemoteSoundEffectCallback( IJustDanceRemoteSoundEffectCallback* cb );
|
|
SoundResult RegisterJustDancePlayEventBusMusicCallback( IJustDancePlayEventBusMusicCallback* cb );
|
|
SoundResult RegisterJustDanceStopEventBusMusicCallback( IJustDanceStopEventBusMusicCallback* cb );
|
|
SoundResult RegisterJustDanceStopAllEventBusMixesCallback(IJustDanceStopAllEventBusMixesCallback* cb);
|
|
SoundResult RegisterJustDancePlayMusicMultiTrackCallback( IJustDancePlayMusicMultiTrackCallback* cb );
|
|
SoundResult RegisterSoundwichTrackingCallback(ISoundwichTracking* cb);
|
|
|
|
SoundResult UnregisterEventOutCallback( IEventOutCallback* cb, EventOut* eventOut );
|
|
SoundResult UnregisterControlOutCallback( IControlOutCallback* cb, ControlOut* controlOut );
|
|
SoundResult UnregisterSwitchOutCallback( ISwitchOutCallback* cb, SwitchOut* switchOut );
|
|
SoundResult UnregisterJustDancePlayMenuMusicCallback( IJustDancePlayMenuMusicCallback* cb );
|
|
SoundResult UnregisterJustDanceStopMenuMusicCallback( IJustDanceStopMenuMusicCallback* cb );
|
|
SoundResult UnregisterJustDanceSoundEffectCallback( IJustDanceSoundEffectCallback* cb );
|
|
SoundResult UnregisterJustDanceSoundEffectOnTrackTransitionCallback( IJustDanceSoundEffectOnTrackTransitionCallback* cb );
|
|
SoundResult UnregisterJustDanceRemoteSoundEffectCallback( IJustDanceRemoteSoundEffectCallback* cb );
|
|
SoundResult UnregisterJustDancePlayEventBusMusicCallback( IJustDancePlayEventBusMusicCallback* cb );
|
|
SoundResult UnregisterJustDanceStopEventBusMusicCallback( IJustDanceStopEventBusMusicCallback* cb );
|
|
SoundResult UnregisterJustDanceStopAllEventBusMixesCallback(IJustDanceStopAllEventBusMixesCallback* cb);
|
|
SoundResult UnregisterJustDancePlayMusicMultiTrackCallback( IJustDancePlayMusicMultiTrackCallback* cb );
|
|
SoundResult UnregisterSoundwichTrackingCallback(ISoundwichTracking* cb);
|
|
|
|
public:
|
|
class Impl;
|
|
|
|
#if 1
|
|
Impl* GetImpl( ) { return _impl; }
|
|
#endif
|
|
|
|
private:
|
|
Impl* _impl;
|
|
|
|
public:
|
|
struct Stats
|
|
{
|
|
Stats( ) :
|
|
VoicesActive( 0 )
|
|
{
|
|
}
|
|
|
|
uint32 VoicesActive;
|
|
};
|
|
|
|
private:
|
|
Engine( );
|
|
~Engine( );
|
|
|
|
Engine( Engine& ) { }
|
|
Engine& operator=( Engine const& ) { return *this; }
|
|
};
|
|
}
|
|
|