Commit 9c3fe4e8 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Renaming signal sources special methods and moving on to signal source buffers instead of audiofile

parent 80dfbd66
...@@ -16,8 +16,10 @@ ...@@ -16,8 +16,10 @@
#include <VABaseDefinitions.h> #include <VABaseDefinitions.h>
#include <VABase.h> #include <VABase.h>
#include <VASamples.h>
#include <string> #include <string>
#include <vector>
/*! /*!
...@@ -152,6 +154,7 @@ public: ...@@ -152,6 +154,7 @@ public:
*/ */
virtual ~IVACore(); virtual ~IVACore();
//! Returns the core version //! Returns the core version
virtual void GetVersionInfo( CVACoreVersionInfo* pVersionInfo ) const = 0; virtual void GetVersionInfo( CVACoreVersionInfo* pVersionInfo ) const = 0;
...@@ -203,6 +206,7 @@ public: ...@@ -203,6 +206,7 @@ public:
*/ */
virtual void Reset() = 0; virtual void Reset() = 0;
//! Attaches a handler for core events to the core instance //! Attaches a handler for core events to the core instance
/** /**
* @note Attaching event handlers it always possible, * @note Attaching event handlers it always possible,
...@@ -224,12 +228,14 @@ public: ...@@ -224,12 +228,14 @@ public:
*/ */
virtual void DetachCoreEventHandler( IVACoreEventHandler* pCoreEventHandler ) = 0; virtual void DetachCoreEventHandler( IVACoreEventHandler* pCoreEventHandler ) = 0;
//! Get all registered modules of the core //! Get all registered modules of the core
virtual void GetModules( std::vector< CVAModuleInfo >& voModuleInfos ) const = 0; virtual void GetModules( std::vector< CVAModuleInfo >& voModuleInfos ) const = 0;
//! Calls a module and returns the answer //! Calls a module and returns the answer
virtual CVAStruct CallModule( const std::string& sModuleName, const CVAStruct& oArgs ) = 0; virtual CVAStruct CallModule( const std::string& sModuleName, const CVAStruct& oArgs ) = 0;
//! Adds a search path to the core instance //! Adds a search path to the core instance
/** /**
* \param sPath Local relative or absolute path * \param sPath Local relative or absolute path
...@@ -240,6 +246,7 @@ public: ...@@ -240,6 +246,7 @@ public:
//! Returns a struct with entries for each search paths //! Returns a struct with entries for each search paths
virtual CVAStruct GetSearchPaths() const = 0; virtual CVAStruct GetSearchPaths() const = 0;
virtual int CreateDirectivityFromParameters( const CVAStruct& oParams, const std::string& sName = "" ) = 0; virtual int CreateDirectivityFromParameters( const CVAStruct& oParams, const std::string& sName = "" ) = 0;
//! Create a directivity from a file path //! Create a directivity from a file path
inline int CreateDirectivityFromFile( const std::string& sFilePath, const std::string& sName = "" ) inline int CreateDirectivityFromFile( const std::string& sFilePath, const std::string& sName = "" )
...@@ -304,7 +311,38 @@ public: ...@@ -304,7 +311,38 @@ public:
* *
* \return Signal source ID * \return Signal source ID
*/ */
virtual std::string CreateAudiofileSignalSource( const std::string& sFilePath, const std::string& sName = "" ) = 0; inline std::string CreateSignalSourceBufferFromFile(const std::string& sFilePath, const std::string& sName = "")
{
CVAStruct oParams;
oParams["filepath"] = sFilePath;
return CreateSignalSourceBufferFromParameters(oParams, sName);
};
//! Creates an audiofile signal source
/**
* Creates a signal source which streams the samples of an audiofile.
* The audiofile must be mono and its sampling rate must match that
* of the core.
*
* \param sFilePath Filename/path
* \param sName Name (optional, e.g. "Trumpet")
*
* \return Signal source ID
*/
virtual std::string CreateSignalSourceBufferFromSamples(const CVASampleBuffer& oSamples, const std::string& sName = "")
{
CVAStruct oParams;
oParams["samples"]["ch1"] = oSamples;
return CreateSignalSourceBufferFromParameters(oParams, sName);
};
virtual std::string CreateSignalSourceBufferMultichannelFromSamples( const std::vector< CVASampleBuffer >& voSamples, const std::string& sName = "")
{
CVAStruct oParams;
for (size_t i = 0; i < voSamples.size(); i++)
oParams["samples"]["ch" + std::to_string(long(i+1))] = voSamples[i];
return CreateSignalSourceBufferFromParameters(oParams, sName);
};
virtual std::string CreateSignalSourceBufferFromParameters(const CVAStruct& oParams, const std::string& sName = "") = 0;
//! Creates a text-to-speech (TTS) signal source //! Creates a text-to-speech (TTS) signal source
/** /**
...@@ -314,7 +352,7 @@ public: ...@@ -314,7 +352,7 @@ public:
* *
* @return Signal source ID * @return Signal source ID
*/ */
virtual std::string CreateTextToSpeechSignalSource( const std::string& sName = "" ) = 0; virtual std::string CreateSignalSourceTextToSpeech( const std::string& sName = "" ) = 0;
//! Creates a sequencer signal source //! Creates a sequencer signal source
/** /**
...@@ -324,7 +362,7 @@ public: ...@@ -324,7 +362,7 @@ public:
* *
* \return Signal source ID * \return Signal source ID
*/ */
virtual std::string CreateSequencerSignalSource( const std::string& sName = "" ) = 0; virtual std::string CreateSignalSourceSequencer( const std::string& sName = "" ) = 0;
//! Creates a network-based signal source //! Creates a network-based signal source
/** /**
...@@ -339,20 +377,20 @@ public: ...@@ -339,20 +377,20 @@ public:
* *
* @return ID of signal source * @return ID of signal source
*/ */
virtual std::string CreateNetworkStreamSignalSource( const std::string& sInterface, const int iPort, const std::string& sName = "" ) = 0; virtual std::string CreateSignalSourceNetworkStream( const std::string& sInterface, const int iPort, const std::string& sName = "" ) = 0;
//! Creates a rotating engine source //! Creates a rotating engine source
/** /**
* \param sName Name of the engine * \param sName Name of the engine
* \return ID of signal source * \return ID of signal source
*/ */
virtual std::string CreateEngineSignalSource( const std::string& sName = "" ) = 0; virtual std::string CreateSignalSourceEngine( const CVAStruct& oParams, const std::string& sName = "" ) = 0;
//! Creates a machine signal source //! Creates a machine signal source
/** /**
* \param sName Name of the machine * \param sName Name of the machine
*/ */
virtual std::string CreateMachineSignalSource( const std::string& sName = "" ) = 0; virtual std::string CreateSignalSourceMachine(const CVAStruct& oParams, const std::string& sName = "" ) = 0;
//! Deletes a signal source //! Deletes a signal source
/** /**
...@@ -399,87 +437,145 @@ public: ...@@ -399,87 +437,145 @@ public:
virtual void GetSignalSourceInfos( std::vector< CVASignalSourceInfo >& voInfos ) const = 0; virtual void GetSignalSourceInfos( std::vector< CVASignalSourceInfo >& voInfos ) const = 0;
//! Returns the playback state flag (bit-vector) of an audiofile signal source //! Returns the playback state flag (bit-vector) of an audiofile signal source
virtual int GetAudiofileSignalSourcePlaybackState( const std::string& sSignalSourceID ) const = 0; virtual int GetSignalSourceBufferPlaybackState( const std::string& sSignalSourceID ) const = 0;
//! Set the playback state of an audiofile signal source //! Set the playback state of an audiofile signal source
/** /**
* Start, stop or pause the playback of an audiofile using the playback action flags (bit-vector). * Start, stop or pause the playback of an audiofile using the playback action flags (bit-vector).
*/ */
virtual void SetAudiofileSignalSourcePlaybackAction( const std::string& sSignalSourceID, int iPlaybackAction ) = 0; virtual void SetSignalSourceBufferPlaybackAction( const std::string& sSignalSourceID, int iPlaybackAction ) = 0;
//! Set the playback position of an audiofile signal source //! Set the playback position of an audiofile signal source
/** /**
* \param sSignalSourceID Signal source ID * \param sSignalSourceID Signal source ID
* \param dPlaybackPosition Playback position [s] * \param dPlaybackPosition Playback position [s]
*/ */
virtual void SetAudiofileSignalSourcePlaybackPosition( const std::string& sSignalSourceID, double dPlaybackPosition ) = 0; virtual void SetSignalSourceBufferPlaybackPosition( const std::string& sSignalSourceID, double dPlaybackPosition ) = 0;
//! Set playback looping mode (true = looping) //! Set playback looping mode (true = looping)
/** /**
* \param sSignalSourceID Signal source ID * \param sSignalSourceID Signal source ID
* \param bLooping Playback is looping * \param bLooping Playback is looping
*/ */
virtual void SetAudiofileSignalSourceIsLooping( const std::string& sSignalSourceID, bool bLooping ) = 0; virtual void SetSignalSourceBufferIsLooping( const std::string& sSignalSourceID, bool bLooping ) = 0;
//! Get playback looping mode (true = looping) //! Get playback looping mode (true = looping)
/** /**
* \param sSignalSourceID Signal source ID * \param sSignalSourceID Signal source ID
*/ */
virtual bool GetAudiofileSignalSourceIsLooping( const std::string& sSignalSourceID ) const = 0; virtual bool GetSignalSourceBufferIsLooping( const std::string& sSignalSourceID ) const = 0;
//! Starts the signal of a machine source //! Starts the signal of a machine source
/** /**
* \param sSignalSourceID Signal source ID * \param sSignalSourceID Signal source ID
*/ */
void StartMachineSignalSource( const std::string& sSignalSourceID ); inline void SetSignalSourceMachineStartMachine(const std::string& sSignalSourceID)
{
CVAStruct oParams;
oParams["set"] = "action";
oParams["value"] = "start";
SetSignalSourceParameters(sSignalSourceID, oParams);
};
//! Halts the signal of a machine source //! Halts the signal of a machine source
/** /**
* \param sSignalSourceID Signal source ID * \param sSignalSourceID Signal source ID
*/ */
void HaltMachineSignalSource( const std::string& sSignalSourceID ); inline void SetSignalSourceMachineHaltMachine(const std::string& sSignalSourceID)
{
CVAStruct oParams;
oParams["set"] = "action";
oParams["value"] = "stop";
SetSignalSourceParameters(sSignalSourceID, oParams);
};
//! Returns the state of a machine signal source //! Returns the state of a machine signal source
/** /**
* \param sSignalSourceID Signal source ID * \param sSignalSourceID Signal source ID
* \return Machine state * \return Machine state
*/ */
std::string GetMachineSignalSourceStateStr( const std::string& sSignalSourceID ) const; inline std::string GetSignalSourceMachineStateStr(const std::string& sSignalSourceID) const
{
CVAStruct oParams, oRet;
oParams["get"] = "state";
oRet = GetSignalSourceParameters(sSignalSourceID, oParams);
if (oRet.HasKey("state"))
if (oRet["state"].IsString())
return oRet["state"].ToString();
else
return "error";
else
return "unkown";
};
//! Sets the speed of a machine signal source //! Sets the speed of a machine signal source
/** /**
* \param sSignalSourceID Signal source ID * \param sSignalSourceID Signal source ID
* \param dSpeed Machine speed (0 .. not-too-large) * \param dSpeed Machine speed (0 .. not-too-large)
*/ */
void SetMachineSignalSourceSpeed( const std::string& sSignalSourceID, double dSpeed ); inline void SetSignalSourceMachineSpeed(const std::string& sSignalSourceID, double dSpeed)
{
CVAStruct oParams;
oParams["set"] = "S";
oParams["value"] = dSpeed;
SetSignalSourceParameters(sSignalSourceID, oParams);
};
//! Sets the speed of a machine signal source //! Sets the speed of a machine signal source
/** /**
* \param sSignalSourceID Signal source ID * \param sSignalSourceID Signal source ID
* \return Machine speed * \return Machine speed
*/ */
double GetMachineSignalSourceSpeed( const std::string& sSignalSourceID ) const; inline double GetSignalSourceMachineSpeed(const std::string& sSignalSourceID) const
{
CVAStruct oParams, oRet;
oParams["get"] = "speed";
oRet = GetSignalSourceParameters(sSignalSourceID, oParams);
if (oRet.HasKey("speed"))
if (oRet["speed"].IsNumeric())
return double(oRet["speed"]);
return 1.0f;
};
//! Set start file sample of machine signal source //! Set start file sample of machine signal source
/** /**
* \param sSignalSourceID Signal source ID * \param sSignalSourceID Signal source ID
* \param sFilePath Path to audio file * \param sFilePath Path to audio file
*/ */
void SetMachineSignalSourceStartFile( const std::string& sSignalSourceID, const std::string& sFilePath ); inline void SetSignalSourceMachineStartFile(const std::string& sSignalSourceID, const std::string& sFilePath)
{
CVAStruct oParams;
oParams["set"] = "StartSoundFilePath";
oParams["value"] = sFilePath;
SetSignalSourceParameters(sSignalSourceID, oParams);
};
//! Set idle file sample of machine signal source //! Set idle file sample of machine signal source
/** /**
* \param sSignalSourceID Signal source ID * \param sSignalSourceID Signal source ID
* \param sFilePath Path to audio file * \param sFilePath Path to audio file
*/ */
void SetMachineSignalSourceIdleFile( const std::string& sSignalSourceID, const std::string& sFilePath ); inline void SetSignalSourceMachineIdleFile( const std::string& sSignalSourceID, const std::string& sFilePath )
{
CVAStruct oParams;
oParams["set"] = "IdleSoundFilePath";
oParams["value"] = sFilePath;
SetSignalSourceParameters(sSignalSourceID, oParams);
};
//! Set stop file sample of machine signal source //! Set stop file sample of machine signal source
/** /**
* \param sSignalSourceID Signal source ID * \param sSignalSourceID Signal source ID
* \param sFilePath Path to audio file * \param sFilePath Path to audio file
*/ */
void SetMachineSignalSourceStopFile( const std::string& sSignalSourceID, const std::string& sFilePath ); inline void SetSignalSourceMachineStopFile(const std::string& sSignalSourceID, const std::string& sFilePath)
{
CVAStruct oParams;
oParams["set"] = "StopSoundFilePath";
oParams["value"] = sFilePath;
SetSignalSourceParameters(sSignalSourceID, oParams);
};
//! Adds a sound playback for a sequencer signal source //! Adds a sound playback for a sequencer signal source
/** /**
...@@ -492,14 +588,14 @@ public: ...@@ -492,14 +588,14 @@ public:
* *
* \return Playback ID * \return Playback ID
*/ */
virtual int AddSoundPlayback( const std::string& sSignalSourceID, const int iSoundID, const int iFlags, const double dTimecode = 0 ) = 0; virtual int AddSignalSourceSequencerSoundPlayback( const std::string& sSignalSourceID, const int iSoundID, const int iFlags, const double dTimecode = 0 ) = 0;
//! Removes an existing sound playback from a sequencer signal source //! Removes an existing sound playback from a sequencer signal source
/** /**
* \return true, if the playback has been removed * \return true, if the playback has been removed
* false, otherwise * false, otherwise
*/ */
virtual bool RemoveSoundPlayback( const int iID ) = 0; virtual bool RemoveSignalSourceSequencerSoundPlayback( const int iID ) = 0;
// TODO: AlterSoundPlayback? // TODO: AlterSoundPlayback?
...@@ -523,6 +619,7 @@ public: ...@@ -523,6 +619,7 @@ public:
*/ */
virtual CVAStruct GetSignalSourceParameters( const std::string& sSignalSourceID, const CVAStruct& oParams ) const = 0; virtual CVAStruct GetSignalSourceParameters( const std::string& sSignalSourceID, const CVAStruct& oParams ) const = 0;
//! Returns wheather a synchronized scene modification is in progress //! Returns wheather a synchronized scene modification is in progress
virtual bool IsUpdateLocked() const = 0; virtual bool IsUpdateLocked() const = 0;
...@@ -545,6 +642,7 @@ public: ...@@ -545,6 +642,7 @@ public:
*/ */
virtual int UnlockUpdate() = 0; virtual int UnlockUpdate() = 0;
//! Create a sound source //! Create a sound source
/** /**
* This method creates a new sound source and returns its ID. * This method creates a new sound source and returns its ID.
...@@ -638,7 +736,10 @@ public: ...@@ -638,7 +736,10 @@ public:
* *
* \param Sound source identifier * \param Sound source identifier
*/ */
void RemoveSoundSourceSignalSource( const int iID ); inline void RemoveSoundSourceSignalSource(const int iID)
{
SetSoundSourceSignalSource(iID, "");
};
//! Auralisierungsmodus einer Schallquelle zurückgeben (Bitvektor) //! Auralisierungsmodus einer Schallquelle zurückgeben (Bitvektor)
virtual int GetSoundSourceAuralizationMode( const int iID ) const = 0; virtual int GetSoundSourceAuralizationMode( const int iID ) const = 0;
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <algorithm> #include <algorithm>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
#include <string>
const double DECIBEL_MINUS_INFINITY = -1.5E-308; const double DECIBEL_MINUS_INFINITY = -1.5E-308;
...@@ -402,81 +401,3 @@ const std::vector<CVAIntLiteral>& IVACore::GetLiterals() ...@@ -402,81 +401,3 @@ const std::vector<CVAIntLiteral>& IVACore::GetLiterals()
return g_oCoreLiterals; return g_oCoreLiterals;
} }
void IVACore::StartMachineSignalSource( const std::string& sSignalSourceID )
{
CVAStruct oParams;
oParams[ "set" ] = "action";
oParams[ "value" ] = "start";
SetSignalSourceParameters( sSignalSourceID, oParams );
}
void IVACore::HaltMachineSignalSource( const std::string& sSignalSourceID )
{
CVAStruct oParams;
oParams[ "set" ] = "action";
oParams[ "value" ] = "stop";
SetSignalSourceParameters( sSignalSourceID, oParams );
}
std::string IVACore::GetMachineSignalSourceStateStr( const std::string& sSignalSourceID ) const
{
CVAStruct oParams, oRet;
oParams[ "get" ] = "state";
oRet = GetSignalSourceParameters( sSignalSourceID, oParams );
if( oRet.HasKey( "state" ) )
if( oRet[ "state" ].IsString() )
return oRet[ "state" ].ToString();
else
return "error";
else
return "unkown";
}
void IVACore::SetMachineSignalSourceSpeed( const std::string& sSignalSourceID, double dSpeed )
{
CVAStruct oParams;
oParams[ "set" ] = "S";
oParams[ "value" ] = dSpeed;
SetSignalSourceParameters( sSignalSourceID, oParams );
}
double IVACore::GetMachineSignalSourceSpeed( const std::string& sSignalSourceID ) const
{
CVAStruct oParams, oRet;
oParams[ "get" ] = "speed";
oRet = GetSignalSourceParameters( sSignalSourceID, oParams );
if( oRet.HasKey( "speed" ) )
if( oRet[ "speed" ].IsNumeric() )
return double( oRet[ "speed" ] );
return 1.0f;
}
void IVACore::SetMachineSignalSourceStartFile( const std::string& sSignalSourceID, const std::string& sFilePath )
{
CVAStruct oParams;
oParams[ "set" ] = "StartSoundFilePath";
oParams[ "value" ] = sFilePath;
SetSignalSourceParameters( sSignalSourceID, oParams );
}
void IVACore::SetMachineSignalSourceIdleFile( const std::string& sSignalSourceID, const std::string& sFilePath )
{
CVAStruct oParams;
oParams[ "set" ] = "IdleSoundFilePath";
oParams[ "value" ] = sFilePath;
SetSignalSourceParameters( sSignalSourceID, oParams );
}
void IVACore::SetMachineSignalSourceStopFile( const std::string& sSignalSourceID, const std::string& sFilePath )
{
CVAStruct oParams;
oParams[ "set" ] = "StopSoundFilePath";
oParams[ "value" ] = sFilePath;
SetSignalSourceParameters( sSignalSourceID, oParams );
}
void IVACore::RemoveSoundSourceSignalSource( const int iID )
{
SetSoundSourceSignalSource( iID, "" );
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment