Solving compiler problems with audio sample

parent f4091697
......@@ -32,9 +32,6 @@
class ITA_BASE_API CITAAudioSample : public ITASampleFrame
{
public:
inline CITAAudioSample() {};
//! Create empty audio sample
/**
* Requires initialization or load to be used, otherwise methods will throw ITAException.
......
#include <ITAAudioSample.h>
#include <ITAException.h>
#include <samplerate.h>
CITAAudioSample::CITAAudioSample( const float fSampleRate )
: m_fSampleRate( fSampleRate )
{
......@@ -18,10 +20,10 @@ CITAAudioSample::CITAAudioSample( const CITAAudioSample* pSource )
ITASampleFrame::write( pSource, pSource->GetLength() );
}
CITAAudioSample::CITAAudioSample( const CITAAudioSample& sbSource )
CITAAudioSample::CITAAudioSample( const CITAAudioSample& sfSource )
{
Init( sbSource.GetNumChannels(), sbSource.GetLength(), sbSource.GetSampleRate() );
ITASampleFrame::write( sbSource, sbSource.GetLength() );
Init( sfSource.GetNumChannels(), sfSource.GetLength(), sfSource.GetSampleRate() );
ITASampleFrame::write( sfSource, sfSource.GetLength() );
}
void CITAAudioSample::Init( const int iNumChannels, const int iLength, const float fSampleRate, const bool bZeroInit /*= true */ )
......@@ -30,6 +32,30 @@ void CITAAudioSample::Init( const int iNumChannels, const int iLength, const flo
ITASampleFrame::Init( iNumChannels, iLength, bZeroInit );
}
void CITAAudioSample::Load( const ITASampleFrame& sfSource, const float fSourceSampleRate )
{
if( fSourceSampleRate <= 0.0f )
ITA_EXCEPT_INVALID_PARAMETER( "Source sample rate must be greater zero." );
// Same sample rate
if( fabs( fSourceSampleRate - m_fSampleRate ) < 1e-20 )
{
Init( sfSource.GetNumChannels(), sfSource.GetLength(), m_fSampleRate );
ITASampleFrame::write( sfSource, sfSource.GetLength() );
return;
}
const int iConverter = SRC_SINC_MEDIUM_QUALITY;
int iSRCError;
SRC_STATE* pSRC = src_new( iConverter, sfSource.GetNumChannels(), &iSRCError );
if( pSRC == nullptr )
ITA_EXCEPT_INVALID_PARAMETER( "Could not create sample rate converter, samplerate error was: " + std::to_string( iSRCError ) );
const float fSRCRation = GetSampleRate() / fSourceSampleRate;
SRC_DATA src_data;
}
void CITAAudioSample::LoadWithSampleTypeConversion( const std::string& sFilePath )
{
if( m_fSampleRate <= 0.0f )
......
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