Using JUCE gui elements without audioprocessor

Hello,

totally new here. My first of what may be a series of newbie questions. I’m just getting back into C++, after some time (last I tinkered with it was in undergrad where there basically wasn’t things such as classes and objects, that should date me!). I can write command line apps like mad…

So I am working on a exploratory plug in project with another audio pro friend. He’s the DSP math guy, I am trying to come up with a GUI for him - of course he uses a different API for the DSP core. So I came across juce, and am impressed (and a bit intimidated) and have been messing with the Jucer and Introjucer and can get some basic things going.

But I’ve started tinkering with trying to put some “juce” into his things (that are not templated in the Introjucer) and am completely stuck. I’m taking a methodical approach to it, so at this point I am just trying to get a basic editor window to pop up with a slider - figuring if I can get that to work I’ll move on to more difficult things. Here’s my question (illustrated by a code snippet, generated by Jucer and copied verbatim, which is how I’d like to generate the GUI).

[code]BlankWindow::BlankWindow ()
: slider (0)
{
addAndMakeVisible (slider = new Slider (“new slider”));
slider->setRange (0, 10, 0);
slider->setSliderStyle (Slider::LinearHorizontal);
slider->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
slider->addListener (this);

ETC…

[/code]

So I have made a class called BlankWindow that is of AudioProcessorEditor in the header file.

I get this error when I try to compile:

error C2512: ‘juce::AudioProcessorEditor’ : no appropriate default constructor available

I’m sure this is a silly question and I suspect that it demonstrates a fundamental lack of chops with c++ (sigh). Any guidance appreciated, and thanks for your patience.

Jim

The AudioProcessorEditor needs an AudioProcessor as a constructor param.
So you’ll need to pass it one…

//AudioProcessorEditor constructor
AudioProcessorEditor::AudioProcessorEditor (AudioProcessor* const owner_)

//
BlankWindow::BlankWindow (AudioProcessor* const owner_)
: AudioProcessorEditor(owner_),
  slider (0)
{
....
}

Here’s my changes:

[code]BlankWindow::BlankWindow (AudioProcessor* const owner_)
: AudioProcessorEditor(owner_),
slider (0)

{
addAndMakeVisible (slider = new Slider (“new slider”));
slider->setRange (0, 10, 0);
slider->setSliderStyle (Slider::LinearHorizontal);
slider->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
slider->addListener (this);

setSize (600, 400);

}

BlankWindow::~BlankWindow()
{

deleteAndZero (slider);

}

//ETC…
[/code]

[code]class BlankWindow : public AudioProcessorEditor,
public SliderListener
{
public:

 BlankWindow (AudioProcessor* const Owner_);

~BlankWindow();

void paint (Graphics& g);
void resized();
void sliderValueChanged (Slider* sliderThatWasMoved);

private:

Slider* slider;

};

//ETC…

[/code]

Errors (there are 52 - here’s a few copied)

BlankWindow.obj : error LNK2019: unresolved external symbol “public: virtual __thiscall juce::AudioProcessorEditor::~AudioProcessorEditor(void)” (??1AudioProcessorEditor@juce@@UAE@XZ) referenced in function __unwindfunclet$??0BlankWindow@@QAE@QAVAudioProcessor@juce@@@Z$0
BlankWindow.obj : error LNK2019: unresolved external symbol “public: void __thiscall juce::Component::setSize(int,int)” (?setSize@Component@juce@@QAEXHH@Z) referenced in function “public: __thiscall BlankWindow::BlankWindow(class juce::AudioProcessor * const)” (??0BlankWindow@@QAE@QAVAudioProcessor@juce@@@Z)
BlankWindow.obj : error LNK2019: unresolved external symbol “public: void __thiscall juce::Slider::addListener(class juce::Slider::Listener *)” (?addListener@Slider@juce@@QAEXPAVListener@12@@Z) referenced in function “public: __thiscall BlankWindow::BlankWindow(class juce::AudioProcessor * const)” (??0BlankWindow@@QAE@QAVAudioProcessor@juce@@@Z)
BlankWindow.obj : error LNK2019: unresolved external symbol “public: void __thiscall juce::Slider::setTextBoxStyle(enum juce::Slider::TextEntryBoxPosition,bool,int,int)” (?setTextBoxStyle@Slider@juce@@QAEXW4TextEntryBoxPosition@12@_NHH@Z) referenced in function “public: __thiscall BlankWindow::BlankWindow(class juce::AudioProcessor * const)” (??0BlankWindow@@QAE@QAVAudioProcessor@juce@@@Z)
BlankWindow.obj : error LNK2019: unresolved external symbol “public: void __thiscall juce::Slider::setSliderStyle(enum juce::Slider::SliderStyle)” (?setSliderStyle@Slider@juce@@QAEXW4SliderStyle@12@@Z) referenced in function “public: __thiscall BlankWindow::BlankWindow(class juce::AudioProcessor * const)” (??0BlankWindow@@QAE@QAVAudioProcessor@juce@@@Z)
BlankWindow.obj : error LNK2019: unresolved external symbol “public: void __thiscall juce::Slider::setRange(double,double,double)” (?setRange@Slider@juce@@QAEXNNN@Z) referenced in function “public: __thiscall BlankWindow::BlankWindow(class juce::AudioProcessor * const)” (??0BlankWindow@@QAE@QAVAudioProcessor@juce@@@Z)
BlankWindow.obj : error LNK2019: unresolved external symbol “public: __thiscall juce::String::~String(void)” (??1String@juce@@QAE@XZ) referenced in function “public: __thiscall BlankWindow::BlankWindow(class juce::AudioProcessor * const)” (??0BlankWindow@@QAE@QAVAudioProcessor@juce@@@Z)
BlankWindow.obj : error LNK2019: unresolved external symbol “public: void __thiscall juce::Component::addAndMakeVisible(class juce::Component *,int)” (?addAndMakeVisible@Component@juce@@QAEXPAV12@H@Z) referenced in function “public: __thiscall BlankWindow::BlankWindow(class juce::AudioProcessor * const)” (??0BlankWindow@@QAE@QAVAudioProcessor@juce@@@Z)
BlankWindow.obj : error LNK2019: unresolved external symbol "public: __t

UPDATE:

Apologies for my persistence… :?

I took a step back and built the PlugInEditor .cpp and .h files with the introjucer, included the introjucer generated appconfig.h and juceheader.h files in the project. VS2010 seems to find everything fine - but on build it throws the same errors as above, and:

[quote]The juce.h file is deprecated - please include each module’s header file directly, or preferably let the introjucer handle the inclusion of source code in your project.
Have you included your AppConfig.h file before including the JUCE headers?[/quote]

Note that I am not trying to call the editor window from the main plug in code yet, but that shouldn’t have anything to do with this?

I understand from reading on the forums that the Juce.h file may not be part of the Juce package in the future, but what’s odd is that the Juce.h file is NOT included anywhere in my project as far as VS finds. So I am wondering if it’s a VS thing. VERY flummoxed… Help?

Why not just use the AudioProcessor class and have your friend simply insert his DSP code into the processBlock() method. I don’t use JUCE to process audio, I use it to access the incoming stream which I then process with another API. If he’s using a C/C++ API then it might be far easier to do it this way.

Yes I think I am leaning that way.

But I’d sure like this to work as an option. If only to salve my irritation that it is not.

Seems_Like_It_Should

:slight_smile:

Well I gave up doing it the “hard way”

Just using Juce, and things work. More questions to come…