VAAudiofileSignalSource.h 2.38 KB
Newer Older
1 2 3 4 5 6
/*
 *  --------------------------------------------------------------------------------------------
 *
 *    VVV        VVV A           Virtual Acoustics (VA) | http://www.virtualacoustics.org
 *     VVV      VVV AAA          Licensed under the Apache License, Version 2.0
 *      VVV    VVV   AAA
7
 *       VVV  VVV     AAA        Copyright 2015-2018
8 9 10 11 12 13 14 15
 *        VVVVVV       AAA       Institute of Technical Acoustics (ITA)
 *         VVVV         AAA      RWTH Aachen University
 *
 *  --------------------------------------------------------------------------------------------
 */

#ifndef IW_VACORE_AUDIOFILESIGNALSOURCE
#define IW_VACORE_AUDIOFILESIGNALSOURCE
Jonas Stienen's avatar
Jonas Stienen committed
16 17 18

#include <VAAudioSignalSource.h>

19
#include <ITADataSourceDelegator.h>
Jonas Stienen's avatar
Jonas Stienen committed
20 21 22
#include <ITASampleBuffer.h>
#include <ITASampleFrame.h>

23
#include <atomic>
Jonas Stienen's avatar
Jonas Stienen committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#include <string>

class ITABufferDatasource;

class CVAAudiofileSignalSource : public IVAAudioSignalSource, ITADatasourceDelegator
{
public:
	CVAAudiofileSignalSource( const std::string& sFileName, double dRequiredSampleRate,int iBlockLength );
	CVAAudiofileSignalSource( int iBufferLength, double dSampleRate, int iBlockLength );

	virtual ~CVAAudiofileSignalSource();

	int GetPlaybackState() const;
	void SetPlaybackAction( int iPlayStateTransission );

	void SetCursorSeconds( double dPos );

	bool GetIsLooping() const;
	void SetIsLooping( bool bLooping );

	// --= Schnittstelle IVAAudioSignalSource =-------------------------

	int GetType() const;
	std::string GetTypeString() const;
	std::string GetDesc() const;
	std::string GetStateString() const;
	std::string GetStateString( int iPlayState ) const;
51
	IVAInterface* GetAssociatedCore() const;
Jonas Stienen's avatar
Jonas Stienen committed
52 53 54 55 56 57
	const float* GetStreamBlock(const CVAAudiostreamState* pStreamInfo);

	void SetParameters( const CVAStruct& ) {};
	CVAStruct GetParameters( const CVAStruct& ) const { return CVAStruct(); };

private:
58
	IVAInterface* m_pAssociatedCore;
Jonas Stienen's avatar
Jonas Stienen committed
59
	ITABufferDatasource* m_pBufferDataSource;
60 61
	std::atomic< int > m_iCurrentPlayState;
	std::atomic< int > m_iRequestedPlaybackAction; //!< User-triggered playback action
Jonas Stienen's avatar
Jonas Stienen committed
62 63 64 65 66
	ITASampleBuffer m_sbOutBuffer;
	ITASampleFrame m_sfAudioBuffer; //!< Audio buffer with multiple channels for smooth switching on update
	int m_iActiveAudioBufferChannel;
	bool m_bCrossfadeChannelSwitch;

67 68
	void HandleRegistration( IVAInterface* pParentCore );
	void HandleUnregistration( IVAInterface* pParentCore );
Jonas Stienen's avatar
Jonas Stienen committed
69 70
};

71
#endif // IW_VACORE_AUDIOFILESIGNALSOURCE