# Developing with gen~ & iPlug2

**URL:** <https://iplug2.discourse.group/t/developing-with-gen-iplug2/587>\
**Category:** Uncategorized\
**Created:** [14 March 2022 17:05 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587 "2022-03-14T17:05:29Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [14 March 2022 17:05 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/1 "2022-03-14T17:05:29Z")

</div>

hello all,

first time posting & hope to start a wee discussion on finding a way to get this working in iPlug2

@olilarkin was really nice and past on some old iPlug1 code that had [cycling74s gen~](https://docs.cycling74.com/max8/vignettes/gen_overview) working within it. ive done some chopping up & have been trying to get something working, but lo and behold, problems have popped up, thats fine

gen~ is a really nice piece of tech I feel would be a great addition & Oli has expressed interest in it as well, plus I feel that since FAUST is possible, why not gen~. having your visual coded effect to be used as a plugin is just a really great thing.  
I have tried in JUCE, but damn, the documentation is terrible for it & out of date, plus JUCE is damn thorough with C++ and can get too much, so iPlug2 feels a much better path in the ling run

anyhow…

my troubles have started right away from not doing much of anything, just a simple duplication of the effect example, then having the gen~ code imported into the project & then trying to use the `gen_exported.h`, much like how FAUST is done.  
except the gen~ code has pointers & the such going on. but trying the code from the original iPlug build, it starts borking out & im trying to figure that out. bear in mind im not a C++ whiz like many, still learning the current iPlug2 as well

and here is my working out, it is named the same & uses the same `.maxpat`

> **[GitHub - lewlepton/iPlugGen: a iPlug2 gen~ marriage, without the want to take...](https://github.com/lewlepton/iPlugGen)**
>
> a iPlug2 gen~ marriage, without the want to take the others crockery if they divorce - GitHub - lewlepton/iPlugGen: a iPlug2 gen~ marriage, without the want to take the others crockery if they divorce

the started problem is using the pointer from the `gen` setup in `iPlugGen.h`, which is then being setup in `iPlugGen.cpp`  
`gen = (CommonState *)create(44100., DEFAULT_BLOCK_SIZE);`

anyhow. hope someone can point me in the correct direction & even we could work a good method for this out

thanks

Lewsi

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [14 March 2022 17:06 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/2 "2022-03-14T17:06:19Z")

</div>

since im a new user, it wouldn’t allow me to post up more than 1 link

so here is original iPlug gen~ example on GitHub, comes with the `.maxpat`

> **[GitHub - uniphonic/IPlugGen: An IPlug Project that works with Cycling 74's Max...](https://github.com/uniphonic/IPlugGen)**
>
> An IPlug Project that works with Cycling 74's Max 6 gen~ code export functionality - GitHub - uniphonic/IPlugGen: An IPlug Project that works with Cycling 74's Max 6 gen~ code export funct...

thanks

Lewsi

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [14 March 2022 19:00 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/3 "2022-03-14T19:00:47Z")

</div>

silly me, I did forget the `namespace`. so did get slightly a better response, but still working this out

---

<div class="post-metadata">

**Author:** ![AlexHarker](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@AlexHarker](https://iplug2.discourse.group/u/AlexHarker)\
**Post date:** [15 March 2022 16:25 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/4 "2022-03-15T16:25:59Z")

</div>

Ah - missed this last reply after taking a look at this…

First step is to makes sure you include gen\_exported:: on the function calls.  
Next you need to compile genlibs.cpp/json.c/json\_builder.c so that it links.

That gets me to a point of building with your repo.

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [15 March 2022 16:49 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/5 "2022-03-15T16:49:06Z")

</div>

thanks for that @AlexHarker ive been trying to fugure it out, but im lost on the compile `json_builder.c`. ive looked, but have not found info on it. cycling74 docs are, I found, lacking somewhat

thanks again

---

<div class="post-metadata">

**Author:** ![AlexHarker](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@AlexHarker](https://iplug2.discourse.group/u/AlexHarker)\
**Post date:** [15 March 2022 17:01 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/6 "2022-03-15T17:01:58Z")

</div>

The files you need to build are all in the gen\_dsp folder which has been added to the Xcode project, although you can’t directly add files from a folder reference in Xcode - they need to be from a group.

You need to add those files to each target you want to build (and similarly on windows) otherwise the build won’t link as there will be missing symbols.

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [15 March 2022 18:10 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/7 "2022-03-15T18:10:20Z")

</div>

kisses to you @AlexHarker - a bit of faffing around it worked & will have a play & then post up the results, also update the GitHub repo with a proper working copy

again, thanks xxx

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [15 March 2022 22:32 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/8 "2022-03-15T22:32:28Z")

</div>

ok. im getting close, thanks @AlexHarker  
but after following some of the original iPlugGen project, I am getting errors & it crashes after trying to get UI in at any point from the originals code.  
so, reaching out again after trying for a while & seeing how this could be implemented. trying to figure out how to access the separate controls.  
thesis just using the `APP` part. nit tried with anything else just yet, just making sure it works on 1 thing first

it get sounds, grainy sound, but it does work in that respect. **beware of feedback** if you try it yourself. I have even edited the `.maxpat` `gen~` to make sure it was going thru it to iPlug & it did, which is nice the link is near done

ive updated my GitHub repo with the changes

---

<div class="post-metadata">

**Author:** ![AlexHarker](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@AlexHarker](https://iplug2.discourse.group/u/AlexHarker)\
**Post date:** [15 March 2022 22:43 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/9 "2022-03-15T22:43:46Z")

</div>

Are there any specific things to look at in the GUI?

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [15 March 2022 23:09 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/10 "2022-03-15T23:09:21Z")

</div>

currently its crashing at the moment I add in the `for` loop, or more so when I get things in the `for` loop in the setup trying to grab the `params` of the exported gen file

for the `UI`, I was looking at `setparameter` in the gen~ file. but also making sure I look at `AttachController`, though did have some code I seemed to have gotten rid of that im trying to remember I typed

---

<div class="post-metadata">

**Author:** ![AlexHarker](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@AlexHarker](https://iplug2.discourse.group/u/AlexHarker)\
**Post date:** [15 March 2022 23:31 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/11 "2022-03-15T23:31:53Z")

</div>

kNumParams is currently 3 but your gen code has 4 parameters. That is likely your crash. I can run the following code in the constructor if I pass the correct number of parameters when constructing the plugin (I am passing num\_params() rather than kNumParams).

```auto
for (int i = 0; i< num_params(); i++) {
    ParamInfo* p = gen->params+i;
    GetParam(i)->InitDouble(p->name, p->defaultvalue, p->outputmin, p->outputmax, 0.00001, p->units);
}

```

Also you are currently calling perform once per sample \* once per channel.

You only need to call perform once in ProcessBlock() as perform processes blocks of samples in multiple channels. You can remove both of the loops in this method.

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [16 March 2022 00:12 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/12 "2022-03-16T00:12:09Z")

</div>

ah aye, the for loops, whoops silly me that slipped by.  
thats the grainy sound dealt with. checking out the change of the `kNumParams` & no crash anymore

```auto
: Plugin(info, MakeConfig(num_params(), kNumPresets)){

```

sorted the params in the `.h` with the extra setting as well, just to make sure.  
that has fixed things when doing the load, which is closer to getting this done, phew hahaha. did get a very brief bit of control on, so now working that out  
feels like it getting close now. so now its working on accessing all the controls easily. getting close 👍

thanks again for the help @AlexHarker

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [17 March 2022 13:10 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/13 "2022-03-17T13:10:14Z")

</div>

ok. now there is a full working flanger example for `app` working

I do plan to solve/fix the VST/AU version, since that is my personal goal. but this is a great start. only tested in macOS, no idea about windows

> **[GitHub - lewlepton/iPlugGen: a iPlug2 gen~ marriage, without the want to take...](https://github.com/lewlepton/iPlugGen)**
>
> a iPlug2 gen~ marriage, without the want to take the others crockery if they divorce - GitHub - lewlepton/iPlugGen: a iPlug2 gen~ marriage, without the want to take the others crockery if they divorce

but if anyone has ideas, please do share 🖤

also thanks goes to @AlexHarker for their help & patience 🖤

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [18 March 2022 00:02 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/14 "2022-03-18T00:02:55Z")

</div>

VST3 working

 ![iPlugGen_VST3](https://global.discourse-cdn.com/free1/uploads/iplug2/original/1X/d2b813b59dc7d6dbf4f64dc2311ccd9232d3135c.jpeg)

AUv3 is still not currently building, & getting a `Command Rez failed with a nonzero exit code` message for AUv2, its pointing to `IPlugAU.r`

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [20 March 2022 23:21 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/15 "2022-03-20T23:21:41Z")

</div>

ok. now I wanna build rom this a wee bit more. I was thinking of different support in terms of getting this to work on VST, which was done via VST3 [no point in doing VST2 since that needs an account, plus no point in the end]  
but trying to do AUv2 & AUv3 have proved somewhat troublesome & errors are popping up, though I am doing the same setup for VST3. having `.cpp` files in the compile section

anyhow. there are many errors popping up, stating that it hasn’t got certain functions. so just trying to get these squashed, but am asking if anyone else may have a problem or fix

 ![Screenshot 2022-03-20 at 23.20.03](https://global.discourse-cdn.com/free1/uploads/iplug2/original/1X/15e667485053c44b514d7a04d59def1aebb3e3db.png)

though this isnt just the only errors, these were after putting in `.cpp` fils into the compile

the repo has been updated with my current finding & play arounds, this is in xcode, so no windows

> **[GitHub - lewlepton/iPlugGen: a iPlug2 gen~ marriage, without the want to take...](https://github.com/lewlepton/iPlugGen)**
>
> a iPlug2 gen~ marriage, without the want to take the others crockery if they divorce - GitHub - lewlepton/iPlugGen: a iPlug2 gen~ marriage, without the want to take the others crockery if they divorce

thanks

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [21 March 2022 21:26 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/16 "2022-03-21T21:26:00Z")

</div>

ok. I solved in AUv2 problem, so that builds, which is great. the AUv3 is still very much buggy, but will work thru that another time. happy to at least get VST3 & AUv2 working 👍

---

<div class="post-metadata">

**Author:** ![olilarkin](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/olilarkin/32/2_2.png) [@olilarkin](https://iplug2.discourse.group/u/olilarkin)\
**Post date:** [22 March 2022 08:16 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/17 "2022-03-22T08:16:00Z")

</div>

I am still working on AUv3 macOS support in iPlug2. On iOS it is working well but there are still some issues with macOS, some of which I’ve addressed very recently, and would require re-duplicating a template project

---

<div class="post-metadata">

**Author:** ![lewlepton](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/lewlepton/32/256_2.png) [@lewlepton](https://iplug2.discourse.group/u/lewlepton)\
**Post date:** [22 March 2022 08:57 UTC](https://iplug2.discourse.group/t/developing-with-gen-iplug2/587/18 "2022-03-22T08:57:28Z")

</div>

good to know. I thought the AUv3 on macOS looked less on the compile side hahaha  
Though it’s nice the iOS version is working

Thank you for the hard work 👍
