Plugin works but doesn't initialise properly | FX Book Questions | Forum


Please consider registering

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Plugin works but doesn't initialise properly
October 6, 2015 - 6:12 pm
Member Since: September 17, 2015
Forum Posts: 5
sp_UserOfflineSmall Offline

When I start my plugin for testing it initialises with a "blown up" frequency response (see link for picture):

I'm sure there's an initialisation step I missing to avoid this. I'm basically dumping my code into the slider id switch statement to change the parameters:
bool __stdcall CGenericBiQuadMultifilter::userInterfaceChange(int nControlIndex)
// decode the control index, or delete the switch and use brute force calls
case 0:
m_fVolume = pow(10.0, m_fVolume_dB/20.0);
case 1:
if(m_u_filter_type == FO_LPF)
fc = m_fSlider_fc;
Q = m_fSlider_Q;
theta_c = 2*pi*fc/fs;
gamma = cos(theta_c)/(1 + sin(theta_c));

m_f_a0_left = (1 - gamma)/2;
m_f_a0_right = (1 - gamma)/2;
m_f_a1_left = (1 - gamma)/2;
m_f_a1_right = (1 - gamma)/2;
m_f_a2_left = 0.0;
m_f_a2_right = 0.0;
m_f_b1_left = -gamma;
m_f_b1_right = -gamma;
m_f_b2_left = 0.0;
m_f_b2_right = 0.0;




return true;

This is happening with all my plugins so far ( I really want to get rid of this dodgy coding error). Any help would be most appreciated! Laugh

October 7, 2015 - 12:17 am
Member Since: January 29, 2017
Forum Posts: 690
sp_UserOfflineSmall Offline

This part of your code is for calculating the coefficients only. If you want to check these calculations, there is an easy way to do this with RackAFX:

Open RackAFX and choose Modules -> HP/LP Filter

This built-in module implements the 1st and 2nd order LPF and HPF that are in the book.

Next, choose View -> Block Diagram

A block diagram appears for the filter. Now, move the Fc slider around - you can see the filter coefficients update as you move the control (of course you can also do this with audio streaming).

If you set a breakpoint in your code to catch the calculations, you can compare the coefficients to the ones in the Block Diagram and see if you have any errors.

If the coefficients look good, my guess would be that you are not zero-ing out your z^-1 storage registers in prepareForPlay() -- if there is garbage in those registers when the filter cranks up, it will result in a blow-up.

- Will

October 7, 2015 - 2:53 am
Member Since: September 17, 2015
Forum Posts: 5
sp_UserOfflineSmall Offline

Thanks for the advice Will. I'll check it out and get back! Also, your books are brilliant! Cheers! Laugh

Forum Timezone: America/New_York

Most Users Ever Online: 152

Currently Online:
6 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Chaes: 56

Skyler: 48

StevieD: 46

Derek: 46

Frodson: 45

Peter: 43

TheSmile: 43

Nickolai: 43

clau_ste: 39

jeanlecode: 37

Member Stats:

Guest Posters: 1

Members: 775

Moderators: 1

Admins: 6

Forum Stats:

Groups: 13

Forums: 42

Topics: 846

Posts: 3353

Moderators: W Pirkle: 690