
// Lew Hill II
// MidiVizApp
// main.cpp
//----------------------------------------

#include <MidiVizApp.h>

// --- Lib Stuff --- //
#include <vrj/Kernel/Kernel.h>


using namespace vrj;

int main(int argc, char* argv[])
{
   // Allocate the kernel object and the application object
   Kernel* kernel = Kernel::instance();           // Get the kernel
   MidiVizApp* application = new MidiVizApp();          // Instantiate an instance of the app

   // IF not args passed to the program
   //    Display usage information and exit
   if (argc <= 3)
   {
      std::cout << "\n\n";
      std::cout << "Usage: " << argv[0] << " <midiport> <audioport> vjconfigfile[0] vjconfigfile[1] ... vjconfigfile[n]" << std::endl;
      exit(1);
   }

   // Load any config files specified on the command line
   for( int i = 3; i < argc; ++i )
   {
      kernel->loadConfigFile(argv[i]);
   }

   application->setMidiPort(atol(argv[1]));
   application->setAudioPort(atol(argv[2]));

   // Start the kernel running
   kernel->start();

   // Give the kernel an application to execute
   kernel->setApplication(application);

   // Keep thread alive and waiting
   kernel->waitForKernelStop();

   application->finalize();
   //cout << "Begin Delete application" << endl;
   //   delete application;
   //cout << "End Delete application" << endl;
   return 0;
}

