COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 02-19-2010, 04:12 AM   #1
Soundbytes
Human being with feelings
 
Soundbytes's Avatar
 
Join Date: May 2006
Posts: 58
Default IPlug Example Synth

Here is a little synth that I tweaked a bit to get familiar with the IPlug framework.
Download: http://soundbytes.de/stuff/IPlugExampleSynth.zip

The synth is based on the example instrument by Theo Niessink that can
be downloaded from his website:
http://www.taletn.com/temp/IPlugInstrument.zip

Thanks Theo for making it available. :-)


Usage:

- download and install the latest version of the WDL library
http://www.cockos.com/wdl/
- copy the ExampleSynth folder from the IPlugExampleSynth.zip
archive into the wdl/IPlug/ directory.
- build both the IPlug and Lice projects from the IPlug directory.
- now build the ExampleSynth Project. You will need at least VS2005
(express versions should be ok) and/or Xcode 3.0


Changes:

- added two more waveforms - saw and triangle
- all sound generation code went into a newly added sbVoice class
- reduced CPU consumption by pulling all redundant calculations
as well as the Midi queue parser out off the render loop.
- The Example uses function pointers to switch between different
processing modes. This is a very effective method to avoid
branching in the render process.
- added Project files for Xcode (OS X) and for Visual Studio (Win)
The Projects were built on Visual Studio 2005 and Xcode 3.2.

The Plugin is confirmed to run fine with Savihost, Chainer, Reaper (mac au+vst)
Aulab and Logic.

Any further enhancements to the project are most welcome.
TODO:
- Custom GUI
- basic envelope
- polyphony
- ... Your ideas here ...

have fun

Andreas Sumerauer

BTW: If you think this thing sounds crappy then you are absolutely right.
Soundbytes is offline   Reply With Quote
Old 02-19-2010, 04:47 PM   #2
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,652
Default

Hey, my example is evolving, cool!

Quote:
Originally Posted by Soundbytes View Post
- The Example uses function pointers to switch between different processing modes. This is a very effective method to avoid branching in the render process.
I like that, perhaps I should try that myself.
Tale is offline   Reply With Quote
Old 02-19-2010, 05:02 PM   #3
RRokkenAudio
Human being with feelings
 
RRokkenAudio's Avatar
 
Join Date: Jun 2009
Location: Buffalo, NY
Posts: 777
Default

Yeah, that was the first thing I noticed, I haden't even thought about that before, def gonna use it when needed.
RRokkenAudio is offline   Reply With Quote
Old 02-22-2010, 08:30 AM   #4
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

thanks andreas, this is really cool. I am also working on some examples, pulling all these bits together.

I have a question about this though:

>- reduced CPU consumption by pulling all redundant calculations
>as well as the Midi queue parser out off the render loop.

I haven't really gone through your code properly yet, but don't you need to parse the MIDI messages in the loop in order to handle notes sample-accurately?

cheers,

oli
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 02-22-2010, 08:59 AM   #5
Soundbytes
Human being with feelings
 
Soundbytes's Avatar
 
Join Date: May 2006
Posts: 58
Default

Quote:
Originally Posted by olilarkin View Post

>- reduced CPU consumption by pulling all redundant calculations
>as well as the Midi queue parser out off the render loop.

I haven't really gone through your code properly yet, but don't you need to parse the MIDI messages in the loop in order to handle notes sample-accurately?
No, that is not required. The midi messages come with a time stamp.
I am using this info to cut the render block in smaller slices.
All midi processing is then done at the proper timing position in a separate function that is called inbetween these slices.
This way the render process is cleanly separated from the event processing which is still sample accurate.
Check the midiSlice() function to see how the slicing is done.

Note that the renderAllMidi() process that calls midiSlice() is only used as long as there are midi messages present in the queue. When the queue is empty the renderAllStatic() process is used. The switching between this processes is done with function pointers. One great advantage of using function pointers over polymorphism is that the pointer address is readily available as a number and does not have to be dereferenced every time it is used.

Andreas
Soundbytes is offline   Reply With Quote
Old 02-22-2010, 10:54 AM   #6
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

Thanks for the example Soundbytes!

Quote:
Originally Posted by Tale View Post
I like that
Yeah me too, especially this function pointers one which is very clean!
Thanks again!
Jeffos is offline   Reply With Quote
Old 02-26-2010, 05:09 AM   #7
Soundbytes
Human being with feelings
 
Soundbytes's Avatar
 
Join Date: May 2006
Posts: 58
Default Example Synth Update

Here is an updated version of the synth:
Download: http://soundbytes.de/stuff/IPlugExampleSynth.zip

Changes:

- The Example Synth now uses the swell library that is included with wdl.
This allows cross platform use of many WIN32 API functions
- Added a sb_thread object that allows easy thread creation and management.
- Added a dummy sample loader to the synth example that shows
how the sb_thread class can be used.
- Added a few MessageBox() based dialog boxes to show that these work cross
platform too.

The daughter thread is started when the first Resume() is called and lives until the plugin object is destroyed.
It is a dummy sample loader. instead of loading a sample it pops up a dialog box.

Note that the audio output continues undisturbed while the dialog is open. If it were started by the main thread it would block the audio process.

A real world implementation of a sample loader would have to make sure that the sample table is not accessed by the audio thread until the new sample table is in place.

have fun!

Andreas

Last edited by Soundbytes; 02-26-2010 at 05:16 AM.
Soundbytes is offline   Reply With Quote
Old 02-26-2010, 07:10 AM   #8
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

thanks andreas!

>- Added a few MessageBox() based dialog boxes to show that these work cross
platform too.

do you think this means that win32 style popup menus should work too? That is something i'd really like to add to my iplug guis!

cheers,

oli
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 02-26-2010, 07:28 AM   #9
Soundbytes
Human being with feelings
 
Soundbytes's Avatar
 
Join Date: May 2006
Posts: 58
Default

Quote:
Originally Posted by olilarkin View Post
>- Added a few MessageBox() based dialog boxes to show that these work cross
platform too.

do you think this means that win32 style popup menus should work too? That is something i'd really like to add to my iplug guis!
I don't know. Check the swell.h header file. I think it contains all supported win32 api calls. If you find the ones you need for your application then give it a try.
Soundbytes 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 01:18 AM.


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