I do not know enough about C++ to figure this out and no amount of interweb searching has helped. Here's the problem, Codelite has generated this (with some additions from me).
Code: Select all
// Define the MainApp
class MainApp : public wxApp
{
public:
MainApp()
{
}
virtual ~MainApp()
{
}
wxSingleInstanceChecker* m_checker;
virtual bool OnInit()
{
// Add the common image handlers
//midiin = 0;
m_checker = new wxSingleInstanceChecker;
if(m_checker->IsAnotherRunning()) {
delete m_checker; // OnExit() won't be called if we return false
m_checker = NULL;
return false;
}
wxImage::AddHandler(new wxPNGHandler);
wxImage::AddHandler(new wxJPEGHandler);
MainFrame* mainFrame = new MainFrame(NULL);
SetTopWindow(mainFrame);
mainFrame->Show(true);
return true;
}
virtual int OnExit()
{
delete m_checker;
m_checker = NULL;
return 0;
}
};
DECLARE_APP(MainApp)
IMPLEMENT_APP(MainApp)
Code: Select all
// cmidiin.cpp
#include <iostream>
#include <cstdlib>
#include "RtMidi.h"
void mycallback( double deltatime, std::vector< unsigned char > *message, void *userData )
{
unsigned int nBytes = message->size();
for ( unsigned int i=0; i<nBytes; i++ )
std::cout << "Byte " << i << " = " << (int)message->at(i) << ", ";
if ( nBytes > 0 )
std::cout << "stamp = " << deltatime << std::endl;
}
int main()
{
RtMidiIn *midiin = new RtMidiIn();
// Check available ports.
unsigned int nPorts = midiin->getPortCount();
if ( nPorts == 0 ) {
std::cout << "No ports available!\n";
goto cleanup;
}
midiin->openPort( 0 );
// Set our callback function. This should be done immediately after
// opening the port to avoid having incoming messages written to the
// queue.
midiin->setCallback( &mycallback );
// Don't ignore sysex, timing, or active sensing messages.
midiin->ignoreTypes( false, false, false );
std::cout << "\nReading MIDI input ... press <enter> to quit.\n";
char input;
std::cin.get(input);
// Clean up
cleanup:
delete midiin;
return 0;
}
Code: Select all
void mycallback( double deltatime, std::vector< unsigned char > *message, void *userData )
I have tried putting that at the top of my file, it compiles fine, but causes (I think) a segment fault?
Any clues as to how I should emulate the sample layout given that there is no main in the generated file?
I imagine this is not a codelite issue at all, but I'm lumbered with what it has generated and do not know how to get round this.
Thanks.