JUCE doesn’t have any built in stuff for VST hosting, does it?
I does not, I already asked Jules about it, and maybe will never have. But from what I found out doing my host its not to difficult to do with JUCE, you can look at this project as an example: http://www.adbe.org/juceforum/viewtopic.php?t=42
BTW I saw that you have a piano keyboard GUI in your project, I need one for my project, any chance of sharing the source code?
What did he say? It’d be a great thing to have. As for the code for the keyboard, I’ll post it when I get home.
short version of my question:
- I wonder if you plan to support some abstraction for hosting VSTs?
Answer:
- No - not publicly, anyway! I’m working on this but it won’t be open-source…
I guess we can assume its not logical to sell a host and give source code for others to easly build a competitor…anyway if you are not building a full fledged sequencer than being a VST host (I didn’t need any other format for my project) then its not very difficult to do
Look here for some more info: http://www.kvr-vst.com/forum/viewtopic.php?t=64592
int kWidth; //Width of the black keys
int curKey; //Highlighted key
//==============================================================================
void paint (Graphics& g)
{
g.setColour (Colours::white);
g.fillAll();
int bKeys[] = {1,3,6,8,10}; //The positions of the five black keys (in semitones)
if (!isBlack(curKey)) {
g.setColour (Colours::indianred);
g.fillRect(getPos(curKey,0)+1,0,kWidth*12/7,getHeight());
}
g.setColour(Colours::lightgrey);
for (int i=0; i<75; i++) {
g.drawLine(i*kWidth*12/7,0,i*kWidth*12/7,getHeight());
}
g.setColour(Colours::black);
for (int i=0; i<53; i++) {
g.fillRect((i/5)*kWidth*12+bKeys[i%5]*kWidth,0,kWidth,25);
}
g.setColour (Colours::lightgrey.withAlpha (0.7f));
if (isBlack(curKey)) {
g.setColour (Colours::indianred);
g.fillRect(curKey*kWidth,0,kWidth,25);
}
g.setColour (Colours::black.withAlpha (0.25f));
g.drawRect (0, 0, getWidth(), getHeight());
}
bool isBlack(int p) {
return p%12==1 || p%12==3 || p%12==6 || p%12==8 || p%12==10;
}
int getPos(int p, int side) {
if (isBlack(p)) {
p+=side;
}
int wKeys[] = {0,0,1,1,2,3,3,4,4,5,5,6};
return p/12*kWidth*12 + wKeys[p%12]*kWidth*12/7;
}
there’s the code for drawing the keyboard. the size for the component would be kWidth*128
wow I thought it will be larger code…thanks! If I use it I will probably put it in a class and extend it …any code for mouse clicks?
BTW I found this interesting article and code for keyboard (there is C# and C++ version):
Yeah, in my code it’s a class but most of it is specific to my program so I didn’t post it. As for mouse clicks, I didn’t need it for my program but it shouldn’t be too hard to do. If the y coordinate is less than 25 then the key is x/kWidth. If it’s greater then 25 then it’s a white key and play around with how to get it.