COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 02-23-2010, 03:58 PM   #1
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default Some half baked examples

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
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 02-24-2010, 12:49 AM   #2
cc_
Human being with feelings
 
Join Date: Mar 2009
Posts: 256
Default

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...
cc_ is offline   Reply With Quote
Old 02-24-2010, 03:59 AM   #3
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

>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
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 02-24-2010, 04:09 AM   #4
Soundbytes
Human being with feelings
 
Soundbytes's Avatar
 
Join Date: May 2006
Posts: 58
Default

Quote:
Originally Posted by cc_ View Post
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 is offline   Reply With Quote
Old 02-24-2010, 09:54 AM   #5
Soundbytes
Human being with feelings
 
Soundbytes's Avatar
 
Join Date: May 2006
Posts: 58
Default polyphony handler code samples

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
Soundbytes is offline   Reply With Quote
Old 02-24-2010, 02:16 PM   #6
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

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
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 02-24-2010, 07:52 PM   #7
junioreq
Human being with feelings
 
junioreq's Avatar
 
Join Date: Aug 2008
Location: Buffalo NY
Posts: 1,091
Default

hmmm mSampleRate(44100.) No zeros? and also:

Code:
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(); ??
junioreq is offline   Reply With Quote
Old 02-25-2010, 01:44 AM   #8
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

>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
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 02-25-2010, 01:49 AM   #9
junioreq
Human being with feelings
 
junioreq's Avatar
 
Join Date: Aug 2008
Location: Buffalo NY
Posts: 1,091
Default

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.
junioreq is offline   Reply With Quote
Old 02-25-2010, 04:19 AM   #10
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,652
Default

Quote:
Originally Posted by junioreq View Post
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.

Quote:
Originally Posted by junioreq View Post
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.
Tale is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:07 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.