PDA

View Full Version : Some half baked examples


olilarkin
02-23-2010, 03:58 PM
I have been putting together some examples using iPlug (somewhat based on other peoples examples here). They are a work in progress, and i'm only really posting them at this early stage because i could do with some other eyes looking at one particular example IPlugPolySynth, that is causing me major grief! One nice thing is that the examples are set up to use a shell script i made that can rapidly duplicate a project, renaming all the right bits (this is only tested on OSX although it might work on windows using cygwin).
I put the wdl distribution in my zip file, i hope cockos don't mind. Hopefully the examples should all compile straight away with Xcode 2.4+ or VS2008 express.

http://www.olilarkin.co.uk/temp/oliplug.zip

about the polysynth:

Eventually I want to implement a generic voice allocation/polyphony system, with support for unison and also monophonic modes, however i need to cross the first hurdle and get the basic thing working!
At the moment i have an olPolyHandler and olVoice class defined in olPoly.h. olVoice is an abstract class. demoVoice.h contains a synth voice with table lookup oscillator and envelope that inherits from olVoice. However, I get very unpredictable results when playing polyphonically (usually the audio dies on the second note). If anyone can shed any light on what i might be doing wrong, that would be great. It also has a problem on windows at the moment (to do with the olPolyHandler destructor) which might mean you can't test with reaper. Again, any tips about this would be much appreciated.

Also any general comments about my approach to this problem would be really useful!

thanks,

oli

cc_
02-24-2010, 12:49 AM
Very interesting! Are you planning on releasing the code under the same terms as wdl?

I took a quick look, I didn't see where you were resizing the mVoices array when you added a new voice... either I didn't look carefully enough or that could be your problem...

olilarkin
02-24-2010, 03:59 AM
>Very interesting! Are you planning on releasing the code under the same terms as wdl?

yes

>I took a quick look, I didn't see where you were resizing the mVoices array when you added a new voice... either I didn't look carefully enough or that could be your problem...

BINGO! thanks!

http://www.olilarkin.co.uk/temp/olPoly.h

Soundbytes
02-24-2010, 04:09 AM
I took a quick look, I didn't see where you were resizing the mVoices array when you added a new voice... either I didn't look carefully enough or that could be your problem...

Yep, that seems to be the problem. Your array has only one element. Once a second voice is added you will write out of bounds.

Soundbytes
02-24-2010, 09:54 AM
BTW: Since you are developing on Mac: Have you seen the au instrument sinsynth example? It is available as download from developer.apple.com. Look under code examples.
Another au instrument source is available as an Xcode project template.
Xcode > File > New Project > System Plugin > Audio Unit Instrument.

It looks like both these have a working polyphony handler complete with note stealing implemented. I did not check this out in detail because I am using my own solution. At least the examples look like a good starting point to get a clearer picture of what to keep in mind and not least to find some inspiration for your own implementation.

Andreas

olilarkin
02-24-2010, 02:16 PM
thanks, i did see that. My one is working quite well now, except for some memory not getting freed properly when the plugin's deleted (throws and error on windows but not on mac!) I will put together a new zip when i've done some more work on it.

cheers,

oli

junioreq
02-24-2010, 07:52 PM
hmmm mSampleRate(44100.) No zeros? and also:

IPlugin::IPlugin(IPlugInstanceInfo instanceInfo)
: IPLUG_CTOR(kNumParams, kNumPrograms, instanceInfo), mGain(1.), mSampleRate(44100.), mSamplePeriod(1./44100.)
{

Didn't even think about initializing there! :)

also:

Why is there a switch around : mGain = GetParam(kGain)->DBToAmp(); ??

olilarkin
02-25-2010, 01:44 AM
>hmmm mSampleRate(44100.) No zeros? and also:

don't know what you mean. If the the sample rate changes, it gets updated.

>mGain = GetParam(kGain)->DBToAmp(); ??

what example are you looking at? i assume the switch is to switch between different parameters

junioreq
02-25-2010, 01:49 AM
44100. no zero 44100.0

And you have some sort of switch in onparam change, doesnt look like its really switching anything. I'm doing mine still like the stock example. Like, theres only 1 option not 2 for the switch.

Tale
02-25-2010, 04:19 AM
44100. no zero 44100.0
44100. and 44100.0 mean the same thing: They tell the compiler to generate a double floating point number. Some prefer to add the trailing zero, but it's not required. Note that you probably won't want to write 44100 (without a dot) in this case, because that would tell the compiler to generate an integer number.

And you have some sort of switch in onparam change, doesnt look like its really switching anything. I'm doing mine still like the stock example. Like, theres only 1 option not 2 for the switch.
At this moment there is only one parameter, so the switch statement could be replaced with a simple if statement. However, olilarkin will probably want to add more parameters in the near future, so then the switch statement makes perfect sense.