Tremolo Patch

Home Forums OWL Patches Tremolo Patch

Tagged: ,

This topic contains 6 replies, has 4 voices, and was last updated by  Foxvo 4 years, 6 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #269

    Martin Klang
    Keymaster

    Simple sine wave tremolo with adjustable frequency and gain!

    #define m_SR 44100
    class TremoloPatch : public SampleBasedPatch {
    private:
      double omega;
    public:
      TremoloPatch() : omega(0) {}
      void processAudio(AudioInputBuffer &input, AudioOutputBuffer &output){
        float phi, gain;
        getParameterValue(PARAMETER_A, phi);
        getParameterValue(PARAMETER_B, gain);
        int size = input.getSize();
        float buf[size];
        input.getSamples(0, size, buf);
        for(int i=0; i<size; ++i){
          omega += phi * 10 * 2*PI / m_SR;
          buf[i] = (float)(((1 + cos(omega))/2) * buf[i] * gain);
        }
        output.setSamples(0, size, buf);
      }
    };
    #484

    Seb
    Participant

    Been trying to get this patch working in VC++2012 but am having some problems with the buffer allocation

    #ifndef __TremoloPatch_hpp__
    #define __TremoloPatch_hpp__
    #define _USE_MATH_DEFINES
    #define m_SR 44100
    
    #include "StompBox.h"
    #include <math.h>
    
    class TremoloPatch : public Patch {
    private:
      double omega;
    public:
      TremoloPatch() : omega(0) {}
      void processAudio(AudioInputBuffer &input, AudioOutputBuffer &output){
    	float phi = getParameterValue(PARAMETER_A);
        float gain = getParameterValue(PARAMETER_B);
        int size = input.getSize();
        float buf[size];
        input.getSamples(0, size, buf);
        for(int i=0; i<size; ++i){
          omega += phi * 10 * 2*M_PI / m_SR;
          buf[i] = (float)(((1 + cos(omega))/2) * buf[i] * gain);
        }
        output.setSamples(0, size, buf);
      }
    };
    
    #endif // __TremoloPatch_hpp__

    I get the build error “error C2057: expected constant expression” in relation to float buf[size];

    Any idea how to get around this?

    #485

    Foxvo
    Participant

    Seb, try this:


    int size = input.getSize();
    float* buf = input.getSamples();

    Got no errors in vc++2012.

    #486

    Seb
    Participant

    Worked a dream. Here’s the patch for record

    
    #ifndef __TremoloPatch_hpp__
    #define __TremoloPatch_hpp__
    #define _USE_MATH_DEFINES
    #define m_SR 44100
    
    #include "StompBox.h"
    #include <math.h>
    
    class TremoloPatch : public Patch {
    private:
      double omega;
    public:
      TremoloPatch() : omega(0) {}
      void processAudio(AudioInputBuffer &input, AudioOutputBuffer &output){
    	float phi = getParameterValue(PARAMETER_A);
        float gain = getParameterValue(PARAMETER_B);
        int size = input.getSize();
    	float* buf = input.getSamples();
        input.getSamples(0, size, buf);
        for(int i=0; i<size; ++i){
          omega += phi * 10 * 2*M_PI / m_SR;
          buf[i] = (float)(((1 + cos(omega))/2) * buf[i] * gain);
        }
        output.setSamples(0, size, buf);
      }
    };
    

    #endif // __TremoloPatch_hpp__

    #487

    sleeven
    Participant

    Is there an audio sample of this patch at work? I’m excited to hear some of the sounds people are creating!

    #488

    Foxvo
    Participant

    Gonna record some samples of this patch tomorrow.

    • This reply was modified 4 years, 6 months ago by  Foxvo.
    #500

    Foxvo
    Participant

    [audio src="https://www.dropbox.com/s/hhf06530mm0t6an/tremolo.wav" /]

    Something like this. Nothing special, but intresting and simple. I think, I have to add depth control into this patch.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.


Latest News

Links

Follow us on Twitter