Avatar

Please consider registering
Guest

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 sp_TopicIcon
Class within Class problem
No permission to create posts
September 20, 2013
3:38 pm
Avatar
Peter
Member
Members
Forum Posts: 41
Member Since:
September 12, 2013
sp_UserOfflineSmall Offline

Hi Will

I constructed a simple class SinOscillator to calculate one sinewave. After that I constructed a class MultiSin containing 4 x SinOscillator with f, f*2, f*3, f*4 (a kind of simple Hammond). This works fine.

After that I constructed within the main plugin 2 x MultiSin to have more than one note, lets say you play a C and an G. But now it seems that the 2 MultiSin use the same SinOscillator set. (The played notes are not C and G but one single note 2.5 times higher than C ).

What is necessary to have a correct MultiSin[index1]SinOscillator[index2] adressing ?? And by the way, is it possible to have indexed user control variables for the faders (e.g. m_fMyVariable[index] ) ??

Many thanks for your help.

Peter

September 21, 2013
9:23 pm
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

I have created a simple plug-in that replicates what you are trying to do (link is at the end of this reply). I use forwarding functions to set the parameters but it looks like you want to access each sine component individually. I put both ways of doing this so check the code carefully.

// in MultiSine.h
// array of four
CSine sineArray[4];

// in the plug_in.h
CMultiSine multiSineArray[2];

// in userInterfaceChange() as an example:
multiSineArray[0].sineArray[0].setFo(m_fOsc1Fo);
multiSineArray[0].sineArray[1].setFo(2*m_fOsc1Fo);
multiSineArray[0].sineArray[2].setFo(3*m_fOsc1Fo);
multiSineArray[0].sineArray[3].setFo(4*m_fOsc1Fo);

As for your question on indexing variables; you can do this indirectly by using the RackAFX linked list of GUI control objects. Each GUI control (slider, button) on the UI is indexed from 0->39 for the sliders and 41-44 for the button banks). This ID value is also shown at the top of the table when you setup a slider.

Each control is encapsulated in a CUICtrl object. These are then stored in a linked list in the plugin object. The CUICtrl object has a pointer to your member variable and uses this to change the value as the user moves the slider. You can access this pointer and de-reference it to use it. For example in userInterfaceChange again, and using my method of calling one function that internally sets the 4 frequencies:

// accessing the m_fOsc2Fo with an index from the UIControl array
// get the pointer; I know it is slider #1
CUICtrl* pUICtrl = getUICtrlByControlID(1);

// check to make sure its valid before using, just to make sure...
if(pUICtrl)
// use it by de-referencing the Cooked data
multiSineArray[1].setFo(*pUICtrl->m_pUserCookedFloatData);

You can get the whole plug-in project here:

http://www.willpirkle.com/Downloads/ArrayOfObjects.zip

Will

September 21, 2013
9:33 pm
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

BTW: the UI Control object and list are explained on pp 504-505 in my book.

- Will

September 22, 2013
9:23 pm
Avatar
Peter
Member
Members
Forum Posts: 41
Member Since:
September 12, 2013
sp_UserOfflineSmall Offline

Hi Will,

thanks - now my project works. (I used the Gordon-Smith Oscillator as a simple solution). All I had to do is to move my function definitions from the .cpp to the correspondent .h file and declare them as inline. Likewise I moved the multiple sine object declaration from the .cpp to the .h file. I do not understand this completely but I am very happy with this solution. The inline declaration generates much lesser CPU load now.

Peter

September 22, 2013
10:32 pm
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

Hi Peter:

It should not make a difference whether the functions are inline in the .h file or in the .cpp file as far as functionality goes.

However, the member object declarations (multi-sine object) *must* be in the .h file. That is the original source of your problem.

Also, remember to compile in Release mode (after you debug) as this will greatly reduce CPU load.

- Will

Forum Timezone: America/New_York

Most Users Ever Online: 36

Currently Online:
6 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Skyler: 47

Peter: 41

Derek: 41

clau_ste: 39

Frodson: 38

Gwen: 32

EZB: 24

lppier: 23

Msaldaña: 18

Jorge: 17

Member Stats:

Guest Posters: 1

Members: 476

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 30

Topics: 482

Posts: 1876

Newest Members:

sam, annaharris, Marie Weaver, kev, Steven, Mr Anderson, mguy, omelc

Moderators: W Pirkle: 143

Administrators: Tom: 65, JD Young: 80, Will Pirkle: 0, W Pirkle: 143