View Full Version : ReaEQ type graph
junioreq
12-10-2009, 03:48 PM
Anyone have any luck getting graphics to draw with lice? Thinking about making a typical EQ like ReaEQ or a compressor that shows the knee, You know what i'm talking about :)
Don't really know where to start.
~Rob.
RRokkenAudio
01-17-2010, 10:13 AM
Does anyone have a screenshot of a plug using iplug that has this??
RRokkenAudio
01-22-2010, 09:54 AM
Ok, that was a fail, lets try again:
Does anyone have any idea where I should turn to, some outside library, that I can start making Lines, Curves etc, with documentation, or any info at all on how to start doing dynamic guis?
~Rob.
Xenakios
01-22-2010, 10:48 AM
Ok, that was a fail, lets try again:
Does anyone have any idea where I should turn to, some outside library, that I can start making Lines, Curves etc, with documentation, or any info at all on how to start doing dynamic guis?
~Rob.
Forget external libraries and just use Lice with IPlug. It's very easy to draw some lines but you must figure out the math of lining out a filter's response curve yourself.
Here's a simple class that does custom drawing for an IPlug plugin using Lice :
// header file
class IDistributionGraph : public IControl
{
public:
IDistributionGraph(IPlugBase* pPlug, int x, int y,int width,int height, int paramIdx);
bool Draw(IGraphics* pGraphics);
bool IsDirty() { return true;}
private:
int m_width;
int m_height;
int m_xpos;
int m_ypos;
IPlugBase *m_pPlug;
};
// cpp file
IDistributionGraph::IDistributionGraph(IPlugBase *pPlug, int x, int y, int width, int height, int paramIdx)
: IControl(pPlug, &IRECT(x,y,width,height ))
{
OutputDebugString("dist graph ctor");
m_height=height;
m_width=width;
m_xpos=x;
m_ypos=y;
m_pPlug=pPlug;
}
bool IDistributionGraph::Draw(IGraphics* pGraphics)
{
//OutputDebugString("dist graph draw()");
IColor color(255,255,255,255);
//SetDirty();
double lowFreq= m_pPlug->GetParam(kLowFreq)->Value();
double hiFreq=m_pPlug->GetParam(kHighFreq)->Value();
double distr=m_pPlug->GetParam(kFilterFreqDistribution)->Value();
int numFilters=m_pPlug->GetParam(kNumFilters)->Int();
for (int i=0;i<numFilters;i++)
{
double filterfreqNorm=1.0/(numFilters-1)*i;
double shapedNormFreq=pow(filterfreqNorm,distr);
double freq=lowFreq+((hiFreq-lowFreq)*shapedNormFreq);
double xscaler=m_width/(20000.0-20.0);
double xcor=8+xscaler*freq;
pGraphics->DrawLine(&color,xcor,m_ypos+1,xcor,m_ypos+ m_height-2,0,true);
}
//xcor=8+xscaler*hiFreq;
//pGraphics->DrawLine(&color,xcor,m_ypos+1,xcor,m_ypos+ m_height-2);
return true;
}
That draws the graph within the red outline :
http://stash.reaper.fm/4552/xenrezon1.png
RRokkenAudio
01-22-2010, 11:10 AM
Thank you xenakios! Can't thank you enough.
~Rob.
Xenakios
01-22-2010, 11:35 AM
Thank you xenakios! Can't thank you enough.
~Rob.
I know the example isn't what you need but you seemed to be stuck with the "drawing lines" step. That's easy enough, the real difficulty will be coming up with the math for the filter response. (Unless you have some filter code that already provides that data for you. Of course you could also make a crude estimation of the response out of thin air for display purposes but anal retentive people would probably catch you had done that. ;) )
RRokkenAudio
01-22-2010, 11:51 AM
Where in LICE did you pull DrawLine from?
Xenakios
01-22-2010, 12:08 PM
Where in LICE did you pull DrawLine from?
Actually it's a bit complicated. You are provided the IGraphics pointer :
bool IDistributionGraph::Draw(IGraphics* pGraphics)
And you can then use for example the DrawLine() method of IGraphics. That in turn calls the Lice stuff internally. (As there is some initialization and book keeping that must be done when using Lice, so IGraphics abstracts that away. I believe IGraphics also used to have an OS dependent backend that was calling Windows and Mac OS-X native drawing APIs. Later Cockos Lice was added as the preferred backend.)
Using Lice directly with IPlug is a bit involved according to Schwa. (It's certainly possible though.) However you will probably have most of the necessary APIs in IGraphics to do your custom drawing. You can see what the supported drawing functions are in IGraphics.h.
RRokkenAudio
01-22-2010, 12:20 PM
ahh cool thanks, I won't look too much under the hood. Actually while typing: GetGUI()-> The quick text or whatever showed up,and I seen all the cool stuff you can do with iplug :)
BTW: For testing, I put:
bool IDistributionGraph::Draw(IGraphics* pGraphics)
{
IColor color(255,255,255,255);
pGraphics->DrawLine(&color,200,90,200,2+53,0,true);
return true;
}
Nothing showing up, prob because i dont understand all the arguments lol, But it didnt throw errors!
~Rob.
Xenakios
01-22-2010, 12:28 PM
ahh cool thanks, I won't look too much under the hood. Actually while typing: GetGUI()-> The quick text or whatever showed up,and I seen all the cool stuff you can do with iplug :)
BTW: For testing, I put:
bool IDistributionGraph::Draw(IGraphics* pGraphics)
{
IColor color(255,255,255,255);
pGraphics->DrawLine(&color,200,90,200,2+53,0,true);
return true;
}
Nothing showing up, prob because i dont understand all the arguments lol, But it didnt throw errors!
~Rob.
IDistributionGraph is a subclass of IControl, so it must be added as a control to the plugin like the usual sliders etc...(You must come up with a dummy plugin parameter if the control doesn't actually control any parameter of the audio processing.) The reason you would probably want your drawing to happen in IControl subclasses is that it's easier that way. Just implement the Draw() in the subclass, you are provided with the IGraphics object automatically and so on. Directly drawing with Lice on the plugin surface would be more involved.
RRokkenAudio
02-19-2010, 05:16 PM
BTW: anyone else have a screenie of thier iplug using a graph or line?
One thing with iplug, haven't seen it done yet.
Still can't figure out how to draw a line or any object to the screen, never minding all that class stuff:
IColor color(255,255,255,255);
pGraphics->DrawLine(&color,200,90,200,2+53,0,true);
Should draw something! right? I mean, theres a bunch of stuff in igraphics that can DRAW. Can't get a single one of them to do anything.
~Rob.
Xenakios
02-19-2010, 06:43 PM
Should draw something! right? I mean, theres a bunch of stuff in igraphics that can DRAW. Can't get a single one of them to do anything.
~Rob.
If anything will be drawn will depend on if you've set up all the stuff correctly before.
-Have you made your subclass of IControl?
-Have you instantiated that as an object correctly on the plugin?
-Have you confirmed your subclass's draw() method is actually being called?
-Are you trying to do your test drawing to the correct coordinates and with a color that will be visible?
Maybe the thing you're missing is that the Plugin window is not just a blank canvas you can draw on and expect things to stay there. It's really a collection of controls which are being told to redraw themselves all the time (when parameters change, or the window is deiconified etc). Even in areas where there are no real controls there is the background 'control' that is redrawn clobbering everything else.
That's why it's easiest to implement your drawing in the draw method of a fake control you make (derived from IControl), then you can be sure your draw routines will be called to redo your drawing at the correct times, so it appears that the stuff is always there on your plugin window.
junioreq
02-21-2010, 11:50 AM
Hmmm yeah, clears things up a little bit, still, I can see putting the code in Icontrol. h or whatever, but that other stuff, not quite too sure about, seeing as though to attach a control usually its just like:
pGraphics->AttachControl(new IKnobMultiControl(this, 312,48, kmakeup, &bitmap));
Isn't there a way to just do:
pGraphics->AttachControl(new FreqDrawLine(&color,200,90,200,2+53,0,true);
and be done with it?
hehe, Think i'm just gonna stay with that vintage look afterall ha
RRokkenAudio
03-19-2010, 01:06 AM
Haven't gotten this working, but can it do graphics like this:
http://www.hispasonic.com/images/articles/fruitywaveshaper.gif
~Rob.
onqel
03-19-2010, 08:44 AM
Yeah I believe it can..;)
You only need a few points, and interpolate between them.. of course there's some code to be written ;)
Here's what I made in 5 minutes changing 6 lines of code in the DistributionGraph example above..
http://dl.dropbox.com/u/1369729/misc/igraphic.PNG
and a little more "advanced", a scope:
http://dl.dropbox.com/u/1369729/misc/IPlugScope.dll
Soundbytes
03-19-2010, 09:00 AM
In case you develop on a mac you might want to have a look at the Filter Demo AU code example.
It seems to do exactly what you are looking for:
(you would of course have to wrap the supplied code into the IPlug/Lice classes but at least it seems to be a good starting point)
http://developer.apple.com/audio/images/demofilter.jpg
Source code is available from:
http://developer.apple.com/mac/library/samplecode/FilterDemo/index.html
Andreas
RRokkenAudio
03-19-2010, 10:55 AM
aww man, I gotta try to get this damn thing going!!! 5 mins! wtf lol..
~Rob.
onqel
03-21-2010, 04:22 AM
For the math of finding your filter-response you will find an example here:
http://www.musicdsp.org/archive.php?classid=2#108
junioreq
07-25-2010, 03:26 AM
How did you know what you needed here, to make this line up?
IDistributionGraph(IPlugBase* pPlug, int x, int y,int width,int height, int paramIdx);
RRokkenAudio
07-31-2010, 12:14 AM
Got it working and drawing last night. Now what will codes like that (musicdsp) put out? Does it output a few numbers that are then (problably not easily) applied to the draw arc? Like, I picture it like one of these for each filters, how would they connect or interact?
RRokkenAudio
08-28-2010, 08:46 PM
So, once you get the magnatude, what do you do with that? Use Iplug directly,or try to use lice?
DrawRadialLine, drawarce ?
Edit: perhaps it may be that you just draw pixel per pixel.... hmmm
~Rob.
bozmillar
10-29-2010, 02:48 PM
Got it working and drawing last night. Now what will codes like that (musicdsp) put out? Does it output a few numbers that are then (problably not easily) applied to the draw arc? Like, I picture it like one of these for each filters, how would they connect or interact?
ok, this is driving me nuts. Can you explain to me how you got it to draw. I've been at it all day and I'm not getting anywhere.
sstillwell
10-29-2010, 03:55 PM
For the math of finding your filter-response you will find an example here:
http://www.musicdsp.org/archive.php?classid=2#108
One thing to look out for...there's several different ways to state those equations, and some are better than others from a computing standpoint (even though they may be the same mathematically) They can generate extremely small numbers and either inflict you with rounding errors or with denormals.
Can't remember what I did offhand, but I do remember it took me a while with a fair amount of swearing.
Scott
junioreq
10-29-2010, 03:59 PM
I smoked my brain even trying to LOOK at the magnitude codes out there hahaa.
~Rob.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.