blip_buf clock<rate bug workaround, part 2?
This commit is contained in:
		
							parent
							
								
									f7f1734c7d
								
							
						
					
					
						commit
						73204b5378
					
				| 
						 | 
					@ -86,9 +86,16 @@
 | 
				
			||||||
void DivDispatchContainer::setRates(double gotRate) {
 | 
					void DivDispatchContainer::setRates(double gotRate) {
 | 
				
			||||||
  int outs=dispatch->getOutputCount();
 | 
					  int outs=dispatch->getOutputCount();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int rate=dispatch->rate;
 | 
				
			||||||
 | 
					  rateMul=0;
 | 
				
			||||||
 | 
					  while (rateMul<8 && rate<gotRate) {
 | 
				
			||||||
 | 
					    rate*=2;
 | 
				
			||||||
 | 
					    rateMul++;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (int i=0; i<outs; i++) {
 | 
					  for (int i=0; i<outs; i++) {
 | 
				
			||||||
    if (bb[i]==NULL) continue;
 | 
					    if (bb[i]==NULL) continue;
 | 
				
			||||||
    blip_set_rates(bb[i],dispatch->rate,gotRate);
 | 
					    blip_set_rates(bb[i],rate,gotRate);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  rateMemory=gotRate;
 | 
					  rateMemory=gotRate;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -120,7 +127,13 @@ void DivDispatchContainer::grow(size_t size) {
 | 
				
			||||||
        logE("not enough memory!"); \
 | 
					        logE("not enough memory!"); \
 | 
				
			||||||
        return; \
 | 
					        return; \
 | 
				
			||||||
      } \
 | 
					      } \
 | 
				
			||||||
      blip_set_rates(bb[i],dispatch->rate,rateMemory); \
 | 
					      int rate=dispatch->rate; \
 | 
				
			||||||
 | 
					      rateMul=0; \
 | 
				
			||||||
 | 
					      while (rateMul<8 && rate<rateMemory) { \
 | 
				
			||||||
 | 
					        rate*=2; \
 | 
				
			||||||
 | 
					        rateMul++; \
 | 
				
			||||||
 | 
					      } \
 | 
				
			||||||
 | 
					      blip_set_rates(bb[i],rate,rateMemory); \
 | 
				
			||||||
 \
 | 
					 \
 | 
				
			||||||
      if (bbIn[i]==NULL) bbIn[i]=new short[bbInLen]; \
 | 
					      if (bbIn[i]==NULL) bbIn[i]=new short[bbInLen]; \
 | 
				
			||||||
      if (bbOut[i]==NULL) bbOut[i]=new short[bbInLen]; \
 | 
					      if (bbOut[i]==NULL) bbOut[i]=new short[bbInLen]; \
 | 
				
			||||||
| 
						 | 
					@ -134,6 +147,8 @@ void DivDispatchContainer::grow(size_t size) {
 | 
				
			||||||
void DivDispatchContainer::acquire(size_t offset, size_t count) {
 | 
					void DivDispatchContainer::acquire(size_t offset, size_t count) {
 | 
				
			||||||
  CHECK_MISSING_BUFS;
 | 
					  CHECK_MISSING_BUFS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
 | 
					  for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
 | 
				
			||||||
    if (i>=outs) {
 | 
					    if (i>=outs) {
 | 
				
			||||||
      bbInMapped[i]=NULL;
 | 
					      bbInMapped[i]=NULL;
 | 
				
			||||||
| 
						 | 
					@ -160,6 +175,8 @@ void DivDispatchContainer::flush(size_t count) {
 | 
				
			||||||
void DivDispatchContainer::fillBuf(size_t runtotal, size_t offset, size_t size) {
 | 
					void DivDispatchContainer::fillBuf(size_t runtotal, size_t offset, size_t size) {
 | 
				
			||||||
  CHECK_MISSING_BUFS;
 | 
					  CHECK_MISSING_BUFS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int step=1<<rateMul;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (dcOffCompensation && runtotal>0) {
 | 
					  if (dcOffCompensation && runtotal>0) {
 | 
				
			||||||
    dcOffCompensation=false;
 | 
					    dcOffCompensation=false;
 | 
				
			||||||
    for (int i=0; i<outs; i++) {
 | 
					    for (int i=0; i<outs; i++) {
 | 
				
			||||||
| 
						 | 
					@ -171,8 +188,9 @@ void DivDispatchContainer::fillBuf(size_t runtotal, size_t offset, size_t size)
 | 
				
			||||||
    for (int i=0; i<outs; i++) {
 | 
					    for (int i=0; i<outs; i++) {
 | 
				
			||||||
      if (bbIn[i]==NULL) continue;
 | 
					      if (bbIn[i]==NULL) continue;
 | 
				
			||||||
      if (bb[i]==NULL) continue;
 | 
					      if (bb[i]==NULL) continue;
 | 
				
			||||||
      for (size_t j=0; j<runtotal; j++) {
 | 
					      int s=0;
 | 
				
			||||||
        temp[i]=bbIn[i][j];
 | 
					      for (size_t j=0; j<runtotal; j+=step) {
 | 
				
			||||||
 | 
					        temp[i]=bbIn[i][s++];
 | 
				
			||||||
        blip_add_delta_fast(bb[i],j,temp[i]-prevSample[i]);
 | 
					        blip_add_delta_fast(bb[i],j,temp[i]-prevSample[i]);
 | 
				
			||||||
        prevSample[i]=temp[i];
 | 
					        prevSample[i]=temp[i];
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					@ -181,8 +199,9 @@ void DivDispatchContainer::fillBuf(size_t runtotal, size_t offset, size_t size)
 | 
				
			||||||
    for (int i=0; i<outs; i++) {
 | 
					    for (int i=0; i<outs; i++) {
 | 
				
			||||||
      if (bbIn[i]==NULL) continue;
 | 
					      if (bbIn[i]==NULL) continue;
 | 
				
			||||||
      if (bb[i]==NULL) continue;
 | 
					      if (bb[i]==NULL) continue;
 | 
				
			||||||
      for (size_t j=0; j<runtotal; j++) {
 | 
					      int s=0;
 | 
				
			||||||
        temp[i]=bbIn[i][j];
 | 
					      for (size_t j=0; j<runtotal; j+=step) {
 | 
				
			||||||
 | 
					        temp[i]=bbIn[i][s++];
 | 
				
			||||||
        blip_add_delta(bb[i],j,temp[i]-prevSample[i]);
 | 
					        blip_add_delta(bb[i],j,temp[i]-prevSample[i]);
 | 
				
			||||||
        prevSample[i]=temp[i];
 | 
					        prevSample[i]=temp[i];
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -190,6 +190,7 @@ struct DivDispatchContainer {
 | 
				
			||||||
  short* bbIn[DIV_MAX_OUTPUTS];
 | 
					  short* bbIn[DIV_MAX_OUTPUTS];
 | 
				
			||||||
  short* bbOut[DIV_MAX_OUTPUTS];
 | 
					  short* bbOut[DIV_MAX_OUTPUTS];
 | 
				
			||||||
  bool lowQuality, dcOffCompensation;
 | 
					  bool lowQuality, dcOffCompensation;
 | 
				
			||||||
 | 
					  unsigned char rateMul, runPosSub;
 | 
				
			||||||
  double rateMemory;
 | 
					  double rateMemory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void setRates(double gotRate);
 | 
					  void setRates(double gotRate);
 | 
				
			||||||
| 
						 | 
					@ -210,6 +211,8 @@ struct DivDispatchContainer {
 | 
				
			||||||
    lastAvail(0),
 | 
					    lastAvail(0),
 | 
				
			||||||
    lowQuality(false),
 | 
					    lowQuality(false),
 | 
				
			||||||
    dcOffCompensation(false),
 | 
					    dcOffCompensation(false),
 | 
				
			||||||
 | 
					    rateMul(0),
 | 
				
			||||||
 | 
					    runPosSub(0),
 | 
				
			||||||
    rateMemory(0.0) {
 | 
					    rateMemory(0.0) {
 | 
				
			||||||
    memset(bb,0,DIV_MAX_OUTPUTS*sizeof(blip_buffer_t*));
 | 
					    memset(bb,0,DIV_MAX_OUTPUTS*sizeof(blip_buffer_t*));
 | 
				
			||||||
    memset(temp,0,DIV_MAX_OUTPUTS*sizeof(int));
 | 
					    memset(temp,0,DIV_MAX_OUTPUTS*sizeof(int));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue