justin = { main feed , music , code , askjf , pubkey };
Ask Justin Frankel
No reasonable question unanswered since 2009!

Suggested topics: programming, music, sleep, coffee, etc.

Note: please do not ask questions about REAPER features, bugs or scheduling, use the forums instead.


Name: Ask: Human (enter yes):
[back to index] | [unreplied] | [replied] | [recent comments] | [all]

Question: I want to make function which returns input data shifted by x samples (like plugin latency)
Asked by Franci (46.122.98.x) on February 5 2013, 6:57pm
Reply on February 6 2013, 4:02am (edited at February 6 2013, 4:03am):
    Ah, like a FIFO queue? How about:
    class delay {
        double *m_buf;
        int m_len,m_pos;
    public:
        delay(int len) { m_len=len; m_buf=(double*)calloc(sizeof(double),len); m_pos=0; }
        ~delay() { free(m_buf); }
        double process(double in) {
            double ret=m_buf[m_pos];
            m_buf[m_pos]=in;
            if (++m_pos>=m_len) m_pos=0;
            return ret;
        }
    };
    

Comment:
    Your Name:   -- Site Owner's Name:  (for human-verification)

    Comment:    

    
  
[back to index] | [unreplied] | [replied] | [recent comments] | [all]
Copyright 2025 Justin Frankel. | RSS