Esempio n. 1
0
/*
 * Makes a new bank, put it on a file and makes it current bank
 */
int Bank::newbank(const char *newbankdirname)
{
    int  result;
    char tmpfilename[MAX_STRING_SIZE];
    char bankdir[MAX_STRING_SIZE];
    snprintf(bankdir, MAX_STRING_SIZE, "%s", config.cfg.bankRootDirList[0]);

    if(((bankdir[strlen(bankdir) - 1]) != '/')
       && ((bankdir[strlen(bankdir) - 1]) != '\\'))
        strncat(bankdir, "/", MAX_STRING_SIZE - strlen(bankdir) - 1 );
    ;
    strncat(bankdir, newbankdirname, MAX_STRING_SIZE - strlen(bankdir) - 1);
#ifdef OS_WINDOWS
    result = mkdir(bankdir);
#else
    result = mkdir(bankdir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#endif
    if(result < 0)
        return -1;

    snprintf(tmpfilename,
             MAX_STRING_SIZE,
             "%s/%s",
             bankdir,
             FORCE_BANK_DIR_FILE);
//    printf("%s\n",tmpfilename);
    FILE *tmpfile = fopen(tmpfilename, "w+");
    fclose(tmpfile);

    return loadbank(bankdir);
}
Esempio n. 2
0
Bank::Bank()
{
    ZERO(defaultinsname, PART_MAX_NAME_LEN);
    snprintf(defaultinsname, PART_MAX_NAME_LEN, "%s", " ");

    for(int i = 0; i < BANK_SIZE; i++) {
        ins[i].used     = false;
        ins[i].filename = NULL;
        ins[i].info.PADsynth_used = false;
    }
    dirname = NULL;
    clearbank();



    for(int i = 0; i < MAX_NUM_BANKS; i++) {
        banks[i].dir  = NULL;
        banks[i].name = NULL;
    }

    bankfiletitle = dirname;

    loadbank(config.cfg.currentBankDir);
}
Esempio n. 3
0
int
main (int argc, char **argv)
{

  int i;
  int lo_fd;
  fd_set rfds;
  struct timeval tv;
  int retval;
  int done = 0;
  int loadOK = 0;

  funcion = 0;
  gui.Pexit = 0 ;
  gui.Pexitprogram = 0;
  gui.ready = 0;
  gui.D_Vol_c = 0;
  gui.D_Tune_c = 0;
  gui.D_Portamento_c = 0;
  gui.D_LFO_Volume_c = 0;
  gui.D_LFO_Frequency_c = 0;
  gui.D_LFO_Delay_c = 0;
  gui.D_LFO_Wave_c = 0;
  gui.cop = 0;
  for (i = 0; i < 6; i++)
    {
      gui.D_Wave_c[i] = 0;
      gui.D_H_c[i] = 0;
      gui.D_HF_c[i] = 0;
      gui.D_OVol_c[i] = 0;
      gui.D_pLFO_c[i] = 0;
      gui.D_Attack_c[i] = 0;
      gui.D_Decay_c[i] = 0;
      gui.D_Sustain_c[i] = 0;
      gui.D_Release_c[i] = 0;
    }

  gui.D_Ftype_c = 0;
  gui.D_Fgain_c = 0;
  gui.D_Fcutoff_c = 0;
  gui.D_Fq_c = 0;
  gui.D_FLFO_c = 0;
  gui.D_FADSR_c = 0;
  gui.D_Fstages_c = 0;
  gui.D_Fvelocity_c = 0;
  gui.D_Algo_c = 0;


  New ();
  New_Bank ();
  char *url = argv[1];
  char *host = lo_url_get_hostname (url);
  char *port = lo_url_get_port (url);
  char *path = lo_url_get_path (url);
  char *label = argv[3];
  char *temp;


  pthread_create (&thr1, NULL, thread1, NULL);
  gui.ui_win->copy_label (argv[3]);
  gui.ui_win->show ();

  sprintf (gui.uBankFilename, "%s/Default.goomf", DATADIR);
  loadOK = loadbank (gui.uBankFilename);




  osc_server = 0;
  m_host = lo_address_new (host, port);

  osc_configure_path = osc_build_path (path, "/configure");
  osc_control_path = osc_build_path (path, "/control");
  osc_exiting_path = osc_build_path (path, "/exiting");
  osc_hide_path = osc_build_path (path, "/hide");
  osc_midi_path = osc_build_path (path, "/midi");
  osc_program_path = osc_build_path (path, "/program");
  osc_quit_path = osc_build_path (path, "/quit");
  osc_show_path = osc_build_path (path, "/show");
  osc_update_path = osc_build_path (path, "/update");

  osc_server = lo_server_new (NULL, osc_error);

  lo_server_add_method (osc_server, osc_configure_path, "ss",
			configure_handler, NULL);
  lo_server_add_method (osc_server, osc_control_path, "if", control_handler,
			NULL);
  lo_server_add_method (osc_server, osc_hide_path, "", hide_handler, NULL);
  lo_server_add_method (osc_server, osc_program_path, "ii", program_handler,
			NULL);
  lo_server_add_method (osc_server, osc_quit_path, "", quit_handler, NULL);
  lo_server_add_method (osc_server, osc_exiting_path, "", exiting_handler,
			NULL);
  lo_server_add_method (osc_server, osc_show_path, "", show_handler, NULL);
  lo_server_add_method (osc_server, NULL, NULL, debug_handler, NULL);

  temp = lo_server_get_url (osc_server);
  myurl = osc_build_path (temp, (strlen (path) > 1 ? path + 1 : path));
  lo_send (m_host, osc_update_path, "s", myurl);
  sleep (2);
  gui.d_osc_label->copy_label (myurl);
  gui.d_osc_label->redraw ();
  if (!loadOK)
    Send_laristra ();


  lo_fd = lo_server_get_socket_fd (osc_server);

  if (lo_fd > 0)
    {

      do
	{
	  FD_ZERO (&rfds);
	  FD_SET (lo_fd, &rfds);

	  retval = select (lo_fd + 1, &rfds, NULL, NULL, NULL);

	  if (retval == -1)
	    {
	      printf ("select() error\n");
	      exit (1);

	    }
	  else if (retval > 0)

	    {

	      if (FD_ISSET (0, &rfds))
		{
		  read_stdin ();
		}
	      if (FD_ISSET (lo_fd, &rfds))
		{
		  lo_server_recv_noblock (osc_server, 0);
		}
	    }


	}
      while (!done);

    }
  else
    {

      do
	{
	  FD_ZERO (&rfds);
	  FD_SET (0, &rfds);
	  tv.tv_sec = 0;
	  tv.tv_usec = 10000;

	  retval = select (1, &rfds, NULL, NULL, &tv);

	  if (retval == -1)
	    {

	      printf ("select() error\n");
	      exit (1);

	    }
	  else if (retval > 0 && FD_ISSET (0, &rfds))
	    {

	      read_stdin ();

	    }

	  lo_server_recv_noblock (osc_server, 0);



	}
      while (!done);

    }





  free (host);
  free (port);
  free (path);
  free (osc_configure_path);
  free (osc_control_path);
  free (osc_exiting_path);
  free (osc_hide_path);
  free (osc_midi_path);
  free (osc_program_path);
  free (osc_quit_path);
  free (osc_show_path);
  free (osc_update_path);
  free (myurl);


  return (0);





}
Esempio n. 4
0
void *
thread1 (void *arg)
{
  int i;
  while (gui.Pexitprogram == 0)
    {
      switch (gui.ready)
	{
	case 1:
	  i = loadbank (gui.uBankFilename);
	  if (!i)
	    Put_Loaded_Bank ();
	  break;
	case 2:
	  gui.Pname->value (Banco[(int) gui.PresetSelect->value ()].Name);
	  Put_Combi (gui.PresetSelect->value ());
	  Send_Values ();
	  Update_Main_Widgets ();
	  Update_Operator_Widgets (gui.op);
	  break;
	case 3:
	  savebank (gui.uBankFilename);
	  break;
	case 4:
	  New_Bank ();
	  Put_Loaded_Bank ();
	  break;
	case 5:
	  make_window_banks ();
	  break;
	case 6:
	  New ();
	  Send_Values ();
	  Update_Main_Widgets ();
	  Update_Operator_Widgets (gui.op);
	  gui.Pname->value ("");
	  break;
	}

      gui.ready = 0;

      switch (funcion)
	{
	case 1:
	  gui.ui_win->iconize ();
	  break;
	case 2:
	  gui.ui_win->show ();
	  break;
	}

      funcion = 0;

      if (gui.cop)
	{
	  Update_Operator_Widgets (gui.op);
	  gui.cop = 0;
	}
      if (gui.D_Vol_c)
	{
	  lo_send (m_host, osc_control_path, "if", 2, gui.D_Vol->value ());
	  master_volume = gui.D_Vol->value ();
	  gui.D_Vol_c = 0;
	}

      if (gui.D_Tune_c)
	{
	  lo_send (m_host, osc_control_path, "if", 3, gui.D_Tune->value ());
	  tune = gui.D_Tune->value ();
	  gui.D_Tune_c = 0;
	}

      if (gui.D_Portamento_c)
	{
	  lo_send (m_host, osc_control_path, "if", 4,
		   gui.D_Portamento->value ());
	  portamento = gui.D_Portamento->value ();
	  gui.D_Portamento_c = 0;
	}
      if (gui.D_LFO_Volume_c)
	{
	  lo_send (m_host, osc_control_path, "if", 5,
		   gui.D_LFO_Volume->value ());
	  LFO_Volume = gui.D_LFO_Volume->value ();
	  gui.D_LFO_Volume_c = 0;
	}
      if (gui.D_LFO_Frequency_c)
	{
	  lo_send (m_host, osc_control_path, "if", 6,
		   gui.D_LFO_Frequency->value ());
	  LFO_Frequency = gui.D_LFO_Frequency->value ();
	  gui.D_LFO_Frequency_c = 0;
	}
      if (gui.D_LFO_Delay_c)
	{
	  lo_send (m_host, osc_control_path, "if", 7,
		   gui.D_LFO_Delay->value ());
	  LFO_Delay = gui.D_LFO_Delay->value ();
	  gui.D_LFO_Delay_c = 0;
	}
      if (gui.D_LFO_Wave_c)
	{
	  lo_send (m_host, osc_control_path, "if", 8,
		   gui.D_LFO_Wave->value ());
	  LFO_Wave = (int) gui.D_LFO_Wave->value ();
	  gui.D_LFO_Wave_c = 0;
	}
      if (gui.D_Wave_c[gui.op])
	{
	  lo_send (m_host, osc_control_path, "if", 9 + gui.op,
		   gui.D_Wave->value ());
	  wave[gui.op] = (int) gui.D_Wave->value ();
	  gui.D_Wave_c[gui.op] = 0;
	}
      if (gui.D_H_c[gui.op])
	{
	  lo_send (m_host, osc_control_path, "if", 15 + gui.op,
		   gui.D_H->value ());
	  H[gui.op] = gui.D_H->value ();
	  gui.D_H_c[gui.op] = 0;
	}

      if (gui.D_HF_c[gui.op])
	{
	  lo_send (m_host, osc_control_path, "if", 21 + gui.op,
		   gui.D_HF->value ());
	  HF[gui.op] = gui.D_HF->value ();
	  gui.D_HF_c[gui.op] = 0;
	}

      if (gui.D_OVol_c[gui.op])
	{
	  lo_send (m_host, osc_control_path, "if", 27 + gui.op,
		   gui.D_OVol->value ());
	  Ovol[gui.op] = gui.D_OVol->value ();
	  gui.D_OVol_c[gui.op] = 0;
	}

      if (gui.D_Attack_c[gui.op])
	{
	  lo_send (m_host, osc_control_path, "if", 33 + gui.op,
		   gui.D_Attack->value ());
	  attack[gui.op] = gui.D_Attack->value ();
	  gui.D_Attack_c[gui.op] = 0;
	}

      if (gui.D_Decay_c[gui.op])
	{
	  lo_send (m_host, osc_control_path, "if", 39 + gui.op,
		   gui.D_Decay->value ());
	  decay[gui.op] = gui.D_Decay->value ();
	  gui.D_Decay_c[gui.op] = 0;
	}

      if (gui.D_Sustain_c[gui.op])
	{
	  lo_send (m_host, osc_control_path, "if", 45 + gui.op,
		   gui.D_Sustain->value ());
	  sustain[gui.op] = gui.D_Sustain->value ();
	  gui.D_Sustain_c[gui.op] = 0;
	}

      if (gui.D_Release_c[gui.op])
	{
	  lo_send (m_host, osc_control_path, "if", 51 + gui.op,
		   gui.D_Release->value ());
	  release[gui.op] = gui.D_Release->value ();
	  gui.D_Release_c[gui.op] = 0;
	}

      if (gui.D_pLFO_c[gui.op])
	{
	  lo_send (m_host, osc_control_path, "if", 57 + gui.op,
		   gui.D_pLFO->value ());
	  pLFO[gui.op] = gui.D_pLFO->value ();
	  gui.D_pLFO_c[gui.op] = 0;
	}

      if (gui.D_Ftype_c)
	{
	  lo_send (m_host, osc_control_path, "if", 63, gui.D_Ftype->value ());
	  Ftype = gui.D_Ftype->value ();
	  set_FilterType (Ftype);
	  gui.D_Ftype_c = 0;
	}

      if (gui.D_Fgain_c)
	{
	  lo_send (m_host, osc_control_path, "if", 64, gui.D_Fgain->value ());
	  Fgain = gui.D_Fgain->value ();
	  gui.D_Fgain_c = 0;
	}

      if (gui.D_Fcutoff_c)
	{
	  lo_send (m_host, osc_control_path, "if", 65,
		   gui.D_Fcutoff->value ());
	  Fcutoff = gui.D_Fcutoff->value ();
	  gui.D_Fcutoff_c = 0;
	}

      if (gui.D_Fq_c)
	{
	  lo_send (m_host, osc_control_path, "if", 66, gui.D_Fq->value ());
	  Fq = gui.D_Fq->value ();
	  gui.D_Fq_c = 0;
	}

      if (gui.D_FLFO_c)
	{
	  lo_send (m_host, osc_control_path, "if", 67, gui.D_FLFO->value ());
	  FLFO = gui.D_FLFO->value ();
	  gui.D_FLFO_c = 0;
	}

      if (gui.D_FADSR_c)
	{
	  lo_send (m_host, osc_control_path, "if", 68, gui.D_FADSR->value ());
	  FADSR = gui.D_FADSR->value ();
	  gui.D_FADSR_c = 0;
	}

      if (gui.D_Fstages_c)
	{
	  lo_send (m_host, osc_control_path, "if", 69,
		   gui.D_Fstages->value ());
	  Fstages = gui.D_Fstages->value ();
	  gui.D_Fstages_c = 0;
	}

      if (gui.D_Fvelocity_c)
	{
	  lo_send (m_host, osc_control_path, "if", 70,
		   (float) gui.D_Fvelocity->value ());
	  Fvelocity = gui.D_Fvelocity->value ();
	  gui.D_Fvelocity_c = 0;
	}

      if (gui.D_Algo_c)
        {
         lo_send (m_host, osc_control_path, "if", 71,
		   (float) gui.D_Algo->value ());
	  algo = gui.D_Algo->value ();
	  gui.D_Algo_c = 0;
        }

      if(gui.Pexit)
        {
         gui.Pexit=0;
         lo_send (m_host, osc_exiting_path, "");
         exit(0);
        } 

      Fl::wait ();
    }

  

};