Commit 5bdf9523 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Fixing refactoring from ITABase and ITADataSources, also fixing some probable...

Fixing refactoring from ITABase and ITADataSources, also fixing some probable errors in sampler test (from compiler warnings)
parent 6230e155
......@@ -65,7 +65,7 @@ public:
virtual int GetMaximumNumberOfChannels() const=0;
//! Abtastrate [Hz] zurckgeben
virtual double GetSamplerate() const=0;
virtual double GetSampleRate() const=0;
//! Mono-Sample aus Puffer erzeugen
virtual int CreateSample(const float* pfData, int iLength, double dSamplerate, std::string sName="")=0;
......
......@@ -27,12 +27,12 @@ ITASoundSampleImpl::ITASoundSampleImpl(const std::string& sFilename, int iMaxNum
: m_sName(sName), m_sFilename(sFilename), m_iLength(0), m_iPlaybackRefCount(0), m_bOriginFile(true) {
ITAAudiofileReader* pReader = ITAAudiofileReader::create(sFilename);
if (pReader->getDomain() != ITA_TIME_DOMAIN) {
if (pReader->getDomain() != ITADomain::ITA_TIME_DOMAIN) {
delete pReader;
ITA_EXCEPT1(INVALID_PARAMETER, "Audiofile is not in time domain");
}
if (pReader->getNumberOfChannels() > (unsigned) iMaxNumberOfChannels) {
if (pReader->getNumberOfChannels() > iMaxNumberOfChannels) {
delete pReader;
ITA_EXCEPT1(INVALID_PARAMETER, "Audiofile has too much channels");
}
......
......@@ -25,7 +25,7 @@ ITACriticalSection ITASoundSamplePoolImpl::m_csSampleIDCount;
ITASoundSamplePoolImpl::ITASoundSamplePoolImpl(int iMaxNumberOfChannels, double dSamplerate) {
m_iMaxNumberOfChannels = iMaxNumberOfChannels;
m_dSamplerate = dSamplerate;
m_dSampleRate = dSamplerate;
}
ITASoundSamplePoolImpl::~ITASoundSamplePoolImpl() {
......@@ -47,8 +47,8 @@ int ITASoundSamplePoolImpl::GetMaximumNumberOfChannels() const {
return m_iMaxNumberOfChannels;
}
double ITASoundSamplePoolImpl::GetSamplerate() const {
return m_dSamplerate;
double ITASoundSamplePoolImpl::GetSampleRate() const {
return m_dSampleRate;
}
int ITASoundSamplePoolImpl::CreateSample(const float* pfData, int iLength, double dSamplerate, std::string sName) {
......@@ -62,7 +62,7 @@ int ITASoundSamplePoolImpl::CreateSample(const float* pfLeftChannelData, const f
}
int ITASoundSamplePoolImpl::CreateSample(const float** ppfChannelData, int iNumChannels, int iLength, double dSamplerate, std::string sName) {
if (dSamplerate != m_dSamplerate)
if (dSamplerate != m_dSampleRate)
ITA_EXCEPT1(INVALID_PARAMETER, "Invalid sampling rate");
if (iNumChannels > m_iMaxNumberOfChannels)
......@@ -99,7 +99,7 @@ int ITASoundSamplePoolImpl::LoadSample(const std::string& sFilename, std::string
}
// Versuchen das Sample zu laden
ITASoundSampleImpl* pSample = new ITASoundSampleImpl(sFilename, m_iMaxNumberOfChannels, m_dSamplerate, sName);
ITASoundSampleImpl* pSample = new ITASoundSampleImpl(sFilename, m_iMaxNumberOfChannels, m_dSampleRate, sName);
m_csSampleIDCount.enter();
int iSampleID = m_iSampleIDCount++;
......
......@@ -16,7 +16,7 @@ public:
~ITASoundSamplePoolImpl();
int GetMaximumNumberOfChannels() const;
double GetSamplerate() const;
double GetSampleRate() const;
int CreateSample(const float* pfData, int iLength, double dSamplerate, std::string sName="");
int CreateSample(const float* pfLeftChannelData, const float* pfRightChannelData, int iLength, double dSamplerate, std::string sName="");
int CreateSample(const float** ppfChannelData, int iNumChannels, int iLength, double dSamplerate, std::string sName="");
......@@ -32,7 +32,7 @@ private:
SampleMap m_mSamples; // Kontainer fr Sound Samples (ID -> Instanz)
ITACriticalSection m_csSamples; // Lokales Lock fr den Sample-Container
double m_dSamplerate; // Abtastrate [Hz]
double m_dSampleRate; // Abtastrate [Hz]
int m_iMaxNumberOfChannels; // Maximale Kanalanzahl
static int m_iSampleIDCount; // Globaler Zhler fr Sample-IDs
......
......@@ -46,7 +46,7 @@ ITASoundSamplerImpl::ITASoundSamplerImpl(int iOutputChannels, double dSamplerate
m_dMasterGain = 1.0;
// Standard Sampleclock = 1s Raster
m_pDefaultSampleClock = new ITASampleClock(ITADatasourceRealization::m_dSamplerate, 1.0);
m_pDefaultSampleClock = new ITASampleClock(ITADatasourceRealization::m_dSampleRate, 1.0);
m_pSampleClock = m_pDefaultSampleClock;
if (pSamplePool) {
......@@ -639,8 +639,8 @@ unsigned int ITASoundSamplerImpl::GetNumberOfChannels() const {
return ITADatasourceRealization::GetNumberOfChannels();
}
double ITASoundSamplerImpl::GetSamplerate() const {
return ITADatasourceRealization::GetSamplerate();
double ITASoundSamplerImpl::GetSampleRate() const {
return ITADatasourceRealization::GetSampleRate();
}
const float* ITASoundSamplerImpl::GetBlockPointer(unsigned int uiChannel, const ITAStreamInfo* pStreamInfo) {
......
......@@ -67,7 +67,7 @@ public:
//! Realisierung der Schnittstelle von ITADatasource
unsigned int GetBlocklength() const;
unsigned int GetNumberOfChannels() const;
double GetSamplerate() const;
double GetSampleRate() const;
const float* GetBlockPointer(unsigned int uiChannel, const ITAStreamInfo* pStreamInfo);
void IncrementBlockPointer();
......
......@@ -136,10 +136,10 @@ int main( int argc, char* argv[] )
int iBinauralTrackID = pSampler->AddStereoTrack();
ITASampleFrame oRainDropSignal( "SingleWaterDrip2_short.wav" );
int iBinauralSampleID = pPool->CreateSample( oRainDropSignal[0].data(), oRainDropSignal[0].data(), oRainDropSignal.length(), pPool->GetSamplerate(), "RainDrop" );
int iBinauralSampleID = pPool->CreateSample( oRainDropSignal[0].data(), oRainDropSignal[0].data(), oRainDropSignal.length(), pPool->GetSampleRate(), "RainDrop" );
ITASampleFrame oRainNoiseSignal( "whitenoise.wav" );
int iNoiseSampleID = pPool->CreateSample( oRainNoiseSignal[ 0 ].data(), oRainNoiseSignal[ 0 ].data(), oRainNoiseSignal.length(), pPool->GetSamplerate(), "RainDrop" );
int iNoiseSampleID = pPool->CreateSample( oRainNoiseSignal[ 0 ].data(), oRainNoiseSignal[ 0 ].data(), oRainNoiseSignal.length(), pPool->GetSampleRate(), "RainDrop" );
pSampler->AddPlaybackByTimecode( iNoiseSampleID, iBinauralTrackID, 0, false, 0.03f );
......@@ -164,7 +164,7 @@ int main( int argc, char* argv[] )
pRainMaker->Run();
ITAStreamProbe oOutputDumper( pSampler, "out.wav", ITA_FLOAT );
ITAStreamProbe oOutputDumper( pSampler, "out.wav", ITAQuantization::ITA_FLOAT );
ITAsioInitializeLibrary();
ITAsioInitializeDriver( "ASIO4ALL v2" );
......
......@@ -36,7 +36,7 @@ int main(int argc, char* argv[]) {
// Viervierteltakt!
double bpm = 220;
ITASampleClock sclock(sampler->GetSamplerate(), 4*60.0/bpm);
ITASampleClock sclock(sampler->GetSampleRate(), 4*60.0/bpm);
sampler->SetSampleClock(&sclock);
const int TRACK_CRASH = sampler->AddStereoTrack();
......@@ -83,58 +83,58 @@ int main(int argc, char* argv[]) {
for (int i=0; i<100; i++) {
if (randmatch(1/8.0)) sampler->AddPlaybackBySamplecount(SAMPLE_CRASH, TRACK_CRASH, t + 0*N4);
if( randmatch( 1 / 8.0 ) ) sampler->AddPlaybackBySamplecount( SAMPLE_CRASH, TRACK_CRASH, int( t + 0 * N4 ) );
double HH_ACCENT_GAIN = 0;
double HH_NORMAL_GAIN = -12;
// HiHat hinzufgen (On-beats akzentuiert)
for (int j=0; j<8; j++) {
sampler->AddPlaybackBySamplecount(SAMPLE_HIHAT, TRACK_HIHAT, t + j*N8,
sampler->AddPlaybackBySamplecount(SAMPLE_HIHAT, TRACK_HIHAT, int(t + j*N8), false,
db20_to_ratio(j%3 == 0 ? HH_ACCENT_GAIN : HH_NORMAL_GAIN));
}
sampler->AddPlaybackBySamplecount(SAMPLE_KICK, TRACK_KICK, t + 0*N4);
sampler->AddPlaybackBySamplecount( SAMPLE_KICK, TRACK_KICK, int( t + 0 * N4 ) );
if (!randmatch(1/10.0))
// Snare auf 3
sampler->AddPlaybackBySamplecount(SAMPLE_SNARE, TRACK_SNARE, t + 4*N8);
sampler->AddPlaybackBySamplecount( SAMPLE_SNARE, TRACK_SNARE, int( t + 4 * N8 ) );
else
if (randmatch(1/2.0)) {
// Snare auf 3, 3+ (zweiter etwas leiser)
sampler->AddPlaybackBySamplecount(SAMPLE_SNARE, TRACK_SNARE, t + 4*N8);
sampler->AddPlaybackBySamplecount(SAMPLE_SNARE, TRACK_SNARE, t + 5*N8, db20_to_ratio(-3));
sampler->AddPlaybackBySamplecount( SAMPLE_SNARE, TRACK_SNARE, int( t + 4 * N8 ) );
sampler->AddPlaybackBySamplecount( SAMPLE_SNARE, TRACK_SNARE, int( t + 5 * N8 ) , false, db20_to_ratio( -3 ) );
} else {
// Versetzte Snare
sampler->AddPlaybackBySamplecount(SAMPLE_SNARE, TRACK_SNARE, t + (4+randdisp())*N8);
sampler->AddPlaybackBySamplecount( SAMPLE_SNARE, TRACK_SNARE, int( t + ( 4 + randdisp() )*N8 ) );
}
// Zufall: 4+ auf der Basstrommel (etwas leiser)
if (randmatch(1/4.0)) sampler->AddPlaybackBySamplecount(SAMPLE_KICK, TRACK_KICK, t + 7*N8, db20_to_ratio(-3));
if( randmatch( 1 / 4.0 ) ) sampler->AddPlaybackBySamplecount( SAMPLE_KICK, TRACK_KICK, int( t + 7 * N8 ), false, db20_to_ratio( -3 ) );
// Zufall: 1+ auf der Basstrommel (etwas leiser)
if (randmatch(1/6.0)) sampler->AddPlaybackBySamplecount(SAMPLE_KICK, TRACK_KICK, t + 1*N8, db20_to_ratio(-1));
if( randmatch( 1 / 6.0 ) ) sampler->AddPlaybackBySamplecount( SAMPLE_KICK, TRACK_KICK, int( t + 1 * N8 ), false, db20_to_ratio( -1 ) );
if (randmatch(1/2.0))
sampler->AddPlaybackBySamplecount(SAMPLE_TOM1 + irandx(3), TRACK_TOMS, t + (2+randdisp())*N8);
sampler->AddPlaybackBySamplecount( SAMPLE_TOM1 + irandx( 3 ), TRACK_TOMS, int( t + ( 2 + randdisp() )*N8 ) );
else {
if (randmatch(1/4.0)) {
double u = irandx(2)==0 ? N8 : N16;
double p = irandx(10);
int j;
for (j=0; j<irandx(80); j++)
sampler->AddPlaybackBySamplecount(SAMPLE_TOM1 + irandx(3), TRACK_TOMS, t + (j+p)*u, randgain());
sampler->AddPlaybackBySamplecount( SAMPLE_TOM1 + irandx( 3 ), TRACK_TOMS, int( t + ( j + p )*u), false, randgain() );
if (randmatch(0.75))
sampler->AddPlaybackBySamplecount(SAMPLE_CRASH, TRACK_CRASH, t + (j+p+1)*u, randgain());
sampler->AddPlaybackBySamplecount( SAMPLE_CRASH, TRACK_CRASH, int( t + ( j + p + 1 )*u), false, randgain() );
}
}
t += 1;
}
WriteFromDatasourceToFile(sampler, "out.wav", 60*sampler->GetSamplerate(), 1.0, false, false);
WriteFromDatasourceToFile( sampler, "out.wav", int( 60 * sampler->GetSampleRate() ), 1.0f, false, false );
delete sampler;
} catch (ITAException& e) {
......
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