From 97f336d064c8fb5c752840ab7b35656ce7d26fe5 Mon Sep 17 00:00:00 2001 From: Owen Green Date: Thu, 6 Sep 2018 17:38:29 +0100 Subject: [PATCH] fdNRTBase.hpp: Changes due to buffer wrapper refactoring --- include/fdNRTBase.hpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/include/fdNRTBase.hpp b/include/fdNRTBase.hpp index 0ef5cc1..605d153 100644 --- a/include/fdNRTBase.hpp +++ b/include/fdNRTBase.hpp @@ -56,9 +56,6 @@ namespace sc{ // BufferAdaptor({0,{static_cast(frames),static_cast(channels)}},NRTBuf::data), mBufnum(bufnum), mWorld(world) { - mChans = this->channels; - mFrames = this->frames; - } ~SCBufferView() = default; @@ -80,20 +77,20 @@ namespace sc{ FluidTensorView samps(size_t channel, size_t rankIdx = 0) override { - FluidTensorView v{this->data,0, static_cast(mFrames),static_cast(mChans * mRank)}; + FluidTensorView v{this->data,0, static_cast(frames),static_cast(channels)}; return v.col(rankIdx + channel * mRank ); } //Return a view of all the data FluidTensorView samps() override { - return {this->data,0, static_cast(mFrames), static_cast(mChans * mRank)}; + return {this->data,0, static_cast(frames), static_cast(channels)}; } //Return a 2D chunk FluidTensorView samps(size_t offset, size_t nframes, size_t chanoffset, size_t chans) override { - FluidTensorView v{this->data,0, static_cast(mFrames), static_cast(mChans * mRank)}; + FluidTensorView v{this->data,0, static_cast(frames), static_cast(channels)}; return v(fluid::slice(offset,nframes), fluid::slice(chanoffset,chans)); @@ -101,22 +98,19 @@ namespace sc{ } - size_t numSamps() const override + size_t numFrames() const override { - if(valid()) - { - return this->frames; - } - return 0; + return valid() ? this->frames : 0 ; } size_t numChans() const override { - if(valid()) - { - return this->channels; - } - return 0; + return valid() ? this->channels / mRank : 0; + } + + size_t rank() const override + { + return valid() ? mRank :0; } @@ -128,8 +122,7 @@ namespace sc{ mRank = rank; mWorld->ft->fBufAlloc(this, channels * rank, frames, this->samplerate); - mFrames = this->frames; - mChans = this->channels / mRank; + // FluidTensorView v= FluidTensorView(NRTBuf::data,0,static_cast(frames),static_cast(channels * rank)); // @@ -153,6 +146,7 @@ namespace sc{ long mBufnum; World* mWorld; + size_t mRank = 1; };