コード例 #1
0
  void processAudio(AudioBuffer &buffer) {
    float delayTime, feedback, wetDry;
    delayTime = getParameterValue(PARAMETER_A);
    feedback  = getParameterValue(PARAMETER_B);
    wetDry    = getParameterValue(PARAMETER_D);
    int size = buffer.getSize();
    int32_t newDelay;
    if(abs(time - delayTime) > 0.01){
      newDelay = delayTime * (delayBuffer.getSize()-1);
      time = delayTime;
    }else{
      newDelay = delay;
    }
    float* x = buffer.getSamples(0);
    float y;
    for (int n = 0; n < size; n++){
//       y = buf[i] + feedback * delayBuffer.read(delay);
//       buf[i] = wetDry * y + (1.f - wetDry) * buf[i];
//       delayBuffer.write(buf[i]);
      if(newDelay - delay > 4){
	y = getDelayAverage(delay-5, 5);
	delay -= 5;
      }else if(delay - newDelay > 4){
	y = getDelayAverage(delay+5, 5);
	delay += 5;
      }else{
	y = delayBuffer.read(delay);
      }
      x[n] = wetDry * y + (1.f - wetDry) * x[n];  // crossfade for wet/dry balance
      delayBuffer.write(feedback * x[n]);
    }
  }
コード例 #2
0
void printBuffer(CircularBuffer<BufferType> cb)
{
		unsigned int i;
		for(i=0; i< cb.getSize(); i++)
			cout << cb.read(i) << ", ";
		cout << "\n\n";
}
コード例 #3
0
ファイル: LpfDelayPatch.hpp プロジェクト: mazbox/OwlPatches
  void processAudio(AudioBuffer &buffer){
    float y[getBlockSize()];
    setCoeffs(getLpFreq(), 0.8f);
    float delayTime = getParameterValue(PARAMETER_A); // get delay time value    
    float feedback  = getParameterValue(PARAMETER_B); // get feedback value
    float wetDry    = getParameterValue(PARAMETER_D); // get gain value

    if(abs(time - delayTime) < 0.01)
      delayTime = time;
    else
      time = delayTime;
        
    float delaySamples = delayTime * (delayBuffer.getSize()-1);        
    int size = buffer.getSize();
    float* x = buffer.getSamples(0);
    process(size, x, y);     // low pass filter for delay buffer
    for(int n = 0; n < size; n++){
        
      //linear interpolation for delayBuffer index
      dSamples = olddelaySamples + (delaySamples - olddelaySamples) * n / size;
        
      y[n] = y[n] + feedback * delayBuffer.read(dSamples);
      x[n] = (1.f - wetDry) * x[n] + wetDry * y[n];  //crossfade for wet/dry balance
      delayBuffer.write(x[n]);
    }
    olddelaySamples = delaySamples;
  }
コード例 #4
0
void
dump(CircularBuffer<unsigned>& cb)
{
  std::cout << "Capacity: " << cb.getCapacity() << std::endl;
  std::cout << "Size: " << cb.getSize() << std::endl;
  for (unsigned i = 0; i < cb.getSize(); ++i)
    std::cout << i << ' ' << cb(i) << std::endl;
}
コード例 #5
0
ファイル: squelch.cpp プロジェクト: Isssmael/improv
int checkForSquelch(MidiMessage& message, CircularBuffer<MidiMessage>& memory, 
      int mintime, int maxtime, int curtime) {
   int i;
   if (memory.getSize() == 0) {
      return 0;
   }

   for (i=0; i<memory.getSize(); i++) {
      if ((curtime - (int)memory[i].time) < mintime) {
         continue;
      }
      if ((curtime - (int)memory[i].time) > maxtime) {
         break;
      }
      if ((memory[i].p0() == message.p0()) && (memory[i].p1() == message.p1())) {
         return 1;
      }
   }

   return 0;
}
int main (int argc, const char * argv[])
{
	//Create a new circular buffer for unsigned integers
	CircularBuffer< UINT > buffer;

	//Resize the buffer
	buffer.resize( 10 );
	
	//Add some values to the buffer so we fill it
	for(UINT i=0; i<buffer.getSize(); i++){
		cout << "Adding " << i << " to buffer\n";
		buffer.push_back( i );
		
		//Print the values in the buffer
		cout << "Values: \t\t";
		for(UINT j=0; j<buffer.getSize(); j++){
			cout << buffer[j] << "\t";
		}cout << endl;
		
		//Print the raw values in the buffer
		cout << "RawValues: \t\t";
		for(UINT j=0; j<buffer.getSize(); j++){
			cout << buffer(j) << "\t";
		}cout << endl;
	}
	
	//Get all the data in the buffer as a vector
	vector<UINT> data = buffer.getDataAsVector();
	cout << "Data: \t\t\t";
	for(UINT j=0; j<data.size(); j++){
		cout << data[j] << "\t";
	}
	cout << endl;
	
    return EXIT_SUCCESS;
}
コード例 #7
0
 void processAudio(AudioBuffer &buffer){
   int size = buffer.getSize();
   unsigned int delaySamples;
     
   rate     = getParameterValue(PARAMETER_A) * 0.000005f; // flanger needs slow rate
   depth    = getParameterValue(PARAMETER_B);
   feedback = getParameterValue(PARAMETER_C)* 0.707; // so we keep a -3dB summation of the delayed signal
     
   for (int ch = 0; ch<buffer.getChannels(); ++ch) {
       for (int i = 0 ; i < size; i++) {
           float* buf = buffer.getSamples(ch);
           delaySamples = (depth * modulate(rate)) * (delayBuffer.getSize()-1); // compute delay according to rate and depth
           buf[i] += feedback * delayBuffer.read(delaySamples); // add scaled delayed signal to dry signal
           delayBuffer.write(buf[i]); // update delay buffer
       }
   }
 }
コード例 #8
0
 void processAudio(AudioBuffer &buffer)
 {
   float delayTime, feedback, dly;
   delayTime = 0.05+0.95*getParameterValue(PARAMETER_A);
   feedback  = getParameterValue(PARAMETER_B);
   int32_t newDelay;
   newDelay = alpha*delayTime*(delayBuffer.getSize()-1) + (1-alpha)*delay; // Smoothing
   dryWet = alpha*getParameterValue(PARAMETER_D) + (1-alpha)*dryWet;       // Smoothing
     
   float* x = buffer.getSamples(0);
   int size = buffer.getSize();
   for (int n = 0; n < size; n++)
   {
     dly = (delayBuffer.read(delay)*(size-1-n) + delayBuffer.read(newDelay)*n)/size;
     delayBuffer.write(feedback * dly + x[n]);
     x[n] = dly*dryWet + (1.f - dryWet) * x[n];  // dry/wet
   }
   delay=newDelay;
 }
コード例 #9
0
ファイル: DubDelayPatch.hpp プロジェクト: UIKit0/OwlPatches-1
    void processAudio(AudioBuffer &buffer) {

        float feedback, wet, _delayTime, _tone, delaySamples;

        _delayTime = getParameterValue(PARAMETER_A);
        feedback = 2*getParameterValue(PARAMETER_B)+0.01;
        _tone = getParameterValue(PARAMETER_C);
        wet = getParameterValue(PARAMETER_D);

        tone = 0.05*_tone + 0.95*tone;
        tf.setTone(tone);

        float* buf = buffer.getSamples(0);
        for (int i = 0 ; i < buffer.getSize(); i++) {
            delayTime = 0.01*_delayTime + 0.99*delayTime;
            delaySamples = delayTime * (delayBuffer.getSize()-1);
            buf[i] = dist(tf.processSample(buf[i] + (wet * delayBuffer.read(delaySamples))));
//            delayBuffer.write(dist(tf.processSample(feedback * buf[i],0)));
            delayBuffer.write(feedback * buf[i]);
        }
    }
コード例 #10
0
  void processAudio(AudioBuffer &buffer)
  {
    float delayTime, feedback, wetDry,drive;
    delayTime = getParameterValue(PARAMETER_A);
    feedback  = getParameterValue(PARAMETER_B);
    drive     = getParameterValue(PARAMETER_C);
    wetDry    = getParameterValue(PARAMETER_D);
     
     
       drive += 0.03;
        drive *= 40;

      
    int newDelay;
    newDelay = delayTime * (delayBuffer.getSize()-1);
      
    float* x = buffer.getSamples(0);
    float y = 0;
      
    int size = buffer.getSize();
    for (int n = 0; n < size; n++)     {
        y = (delayBuffer.read(delay)*(size-1-n) + delayBuffer.read(newDelay)*n)/size + x[n];
   
        y = nonLinear(y * 1.5);
        
        delayBuffer.write(feedback * y);
        
        y = (nonLinear(y * drive)) * 0.25;
      
        
        x[n] = (y *  (1 - wetDry)) +  (x[n] * wetDry);

      
    }
    delay=newDelay;
  }