Пример #1
0
int main(void)
{
    init_ports();
    init_osc();
    startup(); // setup sequence
    TMR0_init(); // will use for 15 min timer

    int i;
    while(1)// main loop
    {
        while(!detect);// main loop, program spends majority here, detect active low

        for(i=5; i !=0; i--) // to separate beginning of trigger sequence
        {
            delayUs(50000);
        }
        trigger(); // take picture
        for(i=10; i !=0; i--) // delay after picture
        {
            delayUs(50000);
        }
    }

    return (EXIT_SUCCESS);
}
Пример #2
0
void init(){
	init_osc();
	__builtin_write_OSCCONL(OSCCON & ~(0x40));	// Débloquage des RPIN et RPOR
    io_init();
    PWM1_init ();
    QEI_init ();
    UART_init();
	__builtin_write_OSCCONL(OSCCON | 0x40);		// Rebloquage des RPIN et RPOR
}
Пример #3
0
int main(int argc, char** argv) {

  byte_t output;
  int j;
  int note;
  int c;

  while ( (c=getopt(argc, argv, "d")) != -1 )
	switch (c) {
	case 'd': debug = 1; break;
	default: abort();
	}
		  
  if ( optind == argc )
	die ("usage: midigen [-d] midinote");


  print_prologoue(N, SR);

  note = atoi ( argv[optind++]);

  calculate_frequencies();
  init_osc();

  for ( j = 0; j< 16; j++)
	channel_volume[j] = 0.7;

  oscillators[0].t = 0;
  oscillators[0].note = note;
  oscillators[0].velocity = 127;
  oscillators[0].channel = 0;
  oscillators[0].freq = frequencies_rad[note]/SR;

  if (debug) fprintf(stderr, "midigen: playing note: i:%-3i f:%5.2f\n", 
					 note, frequencies_hz[note]);

  while ( 1 ) {

	// calculate output
	output = 128;

	output += process_osc(oscillators);

	// write output
	fwrite(&output, 1, 1, stdout);
  }

  print_epilogue();

  return 0;
}
Пример #4
0
int
main ( int argc, char **argv )
{
    set_traps();

    sigset_t mask;

    sigemptyset( &mask );
    sigaddset( &mask, SIGCHLD );

    sigprocmask(SIG_BLOCK, &mask, NULL );

    signal_fd = signalfd( -1, &mask, SFD_NONBLOCK );

    nsm_proxy = new NSM_Proxy();

    init_osc( NULL );

    const char *nsm_url = getenv( "NSM_URL" );

    if ( nsm_url )
    {
        announce( nsm_url, APP_TITLE, argv[0] );
    }
    else
    {
        fprintf( stderr, "Could not register as NSM client.\n" );
        exit(1);
    }


    struct signalfd_siginfo fdsi;

    /* listen for sigchld signals and process OSC messages forever */
    for ( ;; )
    {
        ssize_t s = read(signal_fd, &fdsi, sizeof(struct signalfd_siginfo));
        
        if (s == sizeof(struct signalfd_siginfo))
        {
            if (fdsi.ssi_signo == SIGCHLD)
                handle_sigchld();
        }
        
        lo_server_recv_noblock( losrv, 500 );

        if ( die_now )
            die();
    }
} 
Пример #5
0
void init()
{
    #ifndef SIMU
    TRISBbits.TRISB5 = 0;//output
    LATBbits.LATB5 = 1;
	/*TRISBbits.TRISB3 = 0;//output
    LATBbits.LATB3 = 1;//valeur de la sortie
	TRISBbits.TRISB2 = 0;//output
    LATBbits.LATB2 = 0;//valeur de la sortie*/
    #endif
	init_osc();
	UART_init();
	my_malloc_init();

}
Пример #6
0
int main(void)
{
    init_ports();
    init_osc();

    while(1)// main loop
    {
            modulate = 1;
            NOP4; NOP4; NOP2;
            modulate = 0;
            NOP4; NOP4; NOP2;
    }

    return (EXIT_SUCCESS);
}
Пример #7
0
static rtems_task gui_task(rtems_task_argument argument)
{
	init_fb_mtk(sysconfig_get_autostart_mode() == SC_AUTOSTART_FILE);
	sysconfig_set_mtk_language();
	sysconfig_set_mtk_wallpaper();
	init_input();
	input_add_callback(mtk_input);
	init_shortcuts();
	init_osc();
	init_messagebox();
	init_performance();
	init_renderer();
	init_cp();
	init_keyboard();
	init_ir();
	init_audio();
	init_midi();
	init_oscsettings();
	init_dmxspy();
	init_dmxdesk();
	init_dmx();
	init_videoin();
	init_rsswall();
	init_patcheditor();
	init_monitor();
	init_firstpatch();
	init_filemanager();
#ifdef WITH_PDF
	init_pdfreader();
#endif
	init_sysettings();
	init_about();
	init_flash();
	init_shutdown();

	cp_autostart();
	
	if(sysconfig_is_rescue())
		messagebox("Rescue mode", "You have booted in rescue mode.\n"
			"Your system will function as usual, using back-up software.\n"
			"From there, you can update the main software or perform\nother actions to fix the problem.\n");

	/* FIXME: work around "black screen" bug in MTK */
	mtk_cmd(1, "screen.refresh()");
	
	input_eventloop();
}
Пример #8
0
void init() {

    // Défaut toutes les pattes sont en entrée sauf PCD et PGC (qui sont concervés)
    TRISA = 0xFFFF;
    TRISB = TRISB | 0xFFFC;

    init_osc();
    //__builtin_write_OSCCONL(OSCCON & ~(0x40));    // Débloquage des RPIN et RPOR
    initDebug();
    UART_init_asser();
    UART_init_xbee();
 //   initSharp();
    initTimer();
    initTimerEvite();
    initPWM();
    //__builtin_write_OSCCONL(OSCCON | 0x40);        // Rebloquage des RPIN et RPOR
}
Пример #9
0
// tag::oscdump[]
int main(int argc, char **argv)
{
    if(argc == 3 && !strcmp(argv[1], "--dump-oscdoc")) {
        std::ofstream file(argv[2], std::ofstream::out);
        rtosc::OscDocFormatter formatter{&ports, "rtosc-tutorial",
            "http://example.com/", "http://example.com/",
                "John", "Smith"};
        file << formatter;
        file.close();
    }
    // end::oscdump[]


    middleware_init();
	const char *client_name = "rtosc-tutorial";
	jack_options_t options = JackNullOption;
	jack_status_t status;

	client = jack_client_open(client_name, options, &status, NULL);
	if(!client)
        return 1;

	jack_set_process_callback(client, process, 0);
	//jack_on_shutdown(client, jack_shutdown, 0);

    Fs = jack_get_sample_rate(client);

	port = jack_port_register (client, "out",
					  JACK_DEFAULT_AUDIO_TYPE,
					  JackPortIsOutput, 0);
    josc = jack_port_register(client, "osc",
                      JACK_DEFAULT_OSC_TYPE,
                      JackPortIsInput, 0);

    //Setup
    init_osc(&osc);
    init_seq(&seq);
    init_lfo(&lfo);
    init_lpf(&filter);

	jack_activate(client);

    while(1)
        middleware_tick();
}
Пример #10
0
int main (int argc, char**argv) {
  int osc_port=0;
  void *pa = allocPreamp();
  initPreamp(pa, NULL);

  int c;
  const char *optstring = "hi:o:O:p:V";
  struct option long_options[] = {
    { "help",      no_argument,       0, 'h' },
    { "input",     no_argument,       0, 'i' },
    { "output",    no_argument,       0, 'o' },
    { "parameter", required_argument, 0, 'p' },
    { "version",   no_argument,       0, 'V' },
    { 0, 0, 0, 0 }
  };

  while ((c = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) {
    switch (c) {
      case 'h':
	usage("jboverdrive", 0);
	return (0);
	break;
      case 'i':
	jack_inport_name=optarg;
	break;
      case 'o':
	jack_outport_name=optarg;
	break;
      case 'O':
	osc_port=atoi(optarg);
	break;
      case 'p':
	{
	  int ok=0;
	  char *t = strchr(optarg, '=');
	  if (t) {
	    *t='\0';
	    if (!strcasecmp(optarg, "bias"))       {ok=1; p_bias     =pp(t+1);}
	    if (!strcasecmp(optarg, "feedback"))   {ok=1; p_feedback =pp(t+1);}
	    if (!strcasecmp(optarg, "sagtobias"))  {ok=1; p_sagtobias=pp(t+1);}
	    if (!strcasecmp(optarg, "postfeed"))   {ok=1; p_postfeed =pp(t+1);}
	    if (!strcasecmp(optarg, "globfeed"))   {ok=1; p_globfeed =pp(t+1);}
	    if (!strcasecmp(optarg, "gainin"))     {ok=1; p_gainin   =pp(t+1);}
	    if (!strcasecmp(optarg, "gainout"))    {ok=1; p_gainout  =pp(t+1);}
	    *t='=';
	  }
	  if (!ok) {
	    fprintf(stderr, "invalid parameter '%s' given.\n", optarg);
	  }
	}
	break;
      case 'V':
	printf ("%s %s\n\n", "jboverdrive", VERSION);
	printf(
"Copyright (C) 2003-2004 Fredrik Kilander <*****@*****.**>\n"
"Copyright (C) 2012 Robin Gareus <*****@*****.**>\n"
"\n"
"This is free software; see the source for copying conditions.  There is NO\n"
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
);
	return(0);
      default:
	fprintf(stderr, "invalid argument.\n");
	usage("jboverdrive", 1);
    }
  }

  if (osc_port) {
#ifdef HAVE_LIBLO
    if (init_osc(osc_port)) osc_port=0;
#else
    fprintf(stderr, "This version has not been compiled with liblo.\nOSC is not available.\n");
#endif
  }

  j_client = jack_client_open ("b_overdrive", JackNullOption, NULL);
  if (!j_client) {
    fprintf(stderr, "could not connect to jack.\n");
    return(1);
  }

  j_input_port = jack_port_register (j_client, "in", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
  j_output_port = jack_port_register (j_client, "out", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);

  if (!j_output_port || !j_input_port) {
    fprintf(stderr, "no more jack ports available.\n");
    jack_client_close (j_client);
    return(1);
  }

  jack_on_shutdown (j_client, jack_shutdown_callback, NULL);
  jack_set_process_callback(j_client,jack_audio_callback, pa);

#ifndef _WIN32
  signal (SIGHUP, catchsig);
  signal (SIGINT, catchsig);
#endif

  fctl_biased     (pa, p_bias);
  fctl_biased_fb  (pa, p_feedback);
  fctl_sagtoBias  (pa, p_sagtobias);
  fctl_biased_fb2 (pa, p_postfeed);
  fctl_biased_gfb (pa, p_globfeed);
  fsetInputGain   (pa, p_gainin);
  fsetOutputGain  (pa, p_gainout);

  jack_activate(j_client);
  connect_jack_ports();

  while (j_client) {
    // TODO interaction; allow to change parameters
    // via terminal I/O
    sleep (1);
  }

#ifdef HAVE_LIBLO
  if (osc_port) {
    shutdown_osc();
  }
#endif

  freePreamp(pa);
  return (0);
}
Пример #11
0
int main(int argc, char** argv)
{
  if (argc == 1)
  {
    print_help(argv[0]);
    exit(1);
  }
  
//     printf("argv: %s %s %s %s %s %i\n", argv[0], argv[1], argv[2], argv[3], argv[4], argc );


  // FIXME: We don't need video, but without it SDL will fail to work in SDL_WaitEvent()
  if(SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
  {
    fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
    exit(1);
  }
  else
  {
    atexit(SDL_Quit);

    if (argc == 2 && (strcmp(argv[1], "--help") == 0 ||
                      strcmp(argv[1], "-h") == 0))
    {
      print_help(argv[0]);
    }
    if (argc == 2 && (strcmp(argv[1], "--version") == 0))
    {
      printf("sdl2osc 0.1.0\n");
      exit(EXIT_SUCCESS);
    }
    else if (argc == 2 && (strcmp(argv[1], "--list") == 0 ||
                           (strcmp(argv[1], "-l") == 0)))
    {
      int num_joysticks = SDL_NumJoysticks();
      if (num_joysticks == 0)
      {
        printf("No joysticks were found\n");
      }
      else
      {
	int joy_idx;
        printf("Found %d joystick(s)\n\n", num_joysticks);
        for(joy_idx = 0; joy_idx < num_joysticks; ++joy_idx)
        {
          SDL_Joystick* joy = SDL_JoystickOpen(joy_idx);
          if (!joy)
          {
            fprintf(stderr, "Unable to open joystick %d\n", joy_idx);
          }
          else
          {
            print_joystick_info(joy_idx, joy);
            SDL_JoystickClose(joy);
          }
        }
      }
    }
    else if (argc == 3 && (strcmp(argv[1], "--event") == 0 ||
                           strcmp(argv[1], "-e") == 0))
    {
      int joy_idx;
      if (!str2int(argv[2], &joy_idx))
      {
        fprintf(stderr, "Error: JOYSTICKNUM argument must be a number, but was '%s'\n", argv[2]);
        exit(1);
      }

      SDL_Joystick* joy = SDL_JoystickOpen(joy_idx);
      if (!joy)
      {
        fprintf(stderr, "Unable to open joystick %d\n", joy_idx);
      }
      else
      {
        print_joystick_info(joy_idx, joy);

        printf("Entering joystick test loop, press Ctrl-c to exit\n");
        int quit = 0;
        SDL_Event event;

        while(!quit && SDL_WaitEvent(&event))
        {
          switch(event.type)
          {
            case SDL_JOYAXISMOTION:
              printf("SDL_JOYAXISMOTION: joystick: %d axis: %d value: %d\n",
                     event.jaxis.which, event.jaxis.axis, event.jaxis.value);
              break;

            case SDL_JOYBUTTONDOWN:
              printf("SDL_JOYBUTTONUP: joystick: %d button: %d state: %d\n",
                     event.jbutton.which, event.jbutton.button, event.jbutton.state);
              break;
            case SDL_JOYBUTTONUP:
              printf("SDL_JOYBUTTONDOWN: joystick: %d button: %d state: %d\n",
                     event.jbutton.which, event.jbutton.button, event.jbutton.state);
              break;

            case SDL_JOYHATMOTION:
              printf("SDL_JOYHATMOTION: joystick: %d hat: %d value: %d\n",
                     event.jhat.which, event.jhat.hat, event.jhat.value);
              break;

            case SDL_JOYBALLMOTION:
              printf("SDL_JOYBALLMOTION: joystick: %d ball: %d x: %d y: %d\n",
                     event.jball.which, event.jball.ball, event.jball.xrel, event.jball.yrel);
              break;

            case SDL_QUIT:
              quit = 1;
              printf("Recieved interrupt, exiting\n");
              break;

            default:
              fprintf(stderr, "Error: Unhandled event type: %d\n", event.type);
          }
        }
        SDL_JoystickClose(joy);

      }
      fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
    }
    else if (argc == 2 && (strcmp(argv[1], "--osc") == 0 ||
                           strcmp(argv[1], "-o") == 0))
    {
      int joy_idx;
//       if (!str2int(argv[2], &joy_idx))
//       {
//         fprintf(stderr, "Error: JOYSTICKNUM argument must be a number, but was '%s'\n", argv[2]);
//         exit(1);
//       }
      
      char *port = "57151";
      char *outport = "57120";
      char *ip = "127.0.0.1";

      
      if ( argc == 5 )
	{
	ip = argv[4];
	port = argv[3];
	outport = argv[2];
	}
      else if ( argc == 4 )
	{
	port = argv[3];
	outport = argv[2];
	}
      else if ( argc == 3 )
	{
	outport = argv[2];
	}
  
      init_osc( ip, outport, port );

//       SDL_Joystick* joy = SDL_JoystickOpen(joy_idx);
//       if (!joy)
//       {
//         fprintf(stderr, "Unable to open joystick %d\n", joy_idx);
//       }
//       else
//       {
//         print_joystick_info(joy_idx, joy);

        printf("Entering joystick test loop, press Ctrl-c to exit\n");
//         int quit = 0;
        SDL_Event event;
        lo_timetag lo_now = LO_TT_IMMEDIATE;
        
        while(!done && SDL_WaitEvent(&event))
        {
          switch(event.type)
          {
            case SDL_JOYAXISMOTION:
	      lo_send_from( t, s, lo_now, "/joystick/axis", "iii", event.jaxis.which, event.jaxis.axis, event.jaxis.value );
//               printf("SDL_JOYAXISMOTION: joystick: %d axis: %d value: %d\n",
//                      event.jaxis.which, event.jaxis.axis, event.jaxis.value);
              break;
            case SDL_JOYBUTTONDOWN:
	      lo_send_from( t, s, lo_now, "/joystick/button", "iii", event.jbutton.which, event.jbutton.button, event.jbutton.state );
//               printf("SDL_JOYBUTTONUP: joystick: %d button: %d state: %d\n",
//                      event.jbutton.which, event.jbutton.button, event.jbutton.state);
              break;
            case SDL_JOYBUTTONUP:
	      lo_send_from( t, s, lo_now, "/joystick/button", "iii", event.jbutton.which, event.jbutton.button, event.jbutton.state );
//               printf("SDL_JOYBUTTONDOWN: joystick: %d button: %d state: %d\n",
//                      event.jbutton.which, event.jbutton.button, event.jbutton.state);
              break;

            case SDL_JOYHATMOTION:
	      lo_send_from( t, s, lo_now, "/joystick/hat", "iii", event.jhat.which, event.jhat.hat, event.jhat.value );
//               printf("SDL_JOYHATMOTION: joystick: %d hat: %d value: %d\n",
//                      event.jhat.which, event.jhat.hat, event.jhat.value);
              break;

            case SDL_JOYBALLMOTION:
	      lo_send_from( t, s, lo_now, "/joystick/ball", "iii", event.jball.which, event.jball.ball, event.jball.xrel, event.jball.yrel );
//               printf("SDL_JOYBALLMOTION: joystick: %d ball: %d x: %d y: %d\n",
//                      event.jball.which, event.jball.ball, event.jball.xrel, event.jball.yrel);
              break;

            case SDL_QUIT:
              done = 1;
              printf("Received interrupt, exiting\n");
              break;

            default:
              fprintf(stderr, "Error: Unhandled event type: %d\n", event.type);
          }
	}
//         SDL_JoystickClose(joy);
	  close_all_joysticks();
	  
	  lo_send_from( t, s, lo_now, "/sdl2osc/quit", "s", "nothing more to do, quitting" );
	  lo_server_thread_free( st );
	  lo_address_free( t );

//        }
//       fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
    }
    else
    {
      fprintf(stderr, "%s: unknown arguments\n", argv[0]);
      fprintf(stderr, "Try '%s --help' for more informations\n", argv[0]);
    }
  }
}
Пример #12
0
int setup(void){

  int i, cnt = 5000;
  tl_class *class_list;

  // initialize globals ... rethink this
  tl_set_samplerate(44100);
  tl_set_block_len(64);

  set_g_lvl_stck(init_lvl_stck());
  set_g_ctl_head(init_ctl(TL_HEAD_CTL));

  // TODO: attach these to modules, I can't see
  // any reason not to do this and automate this whole process
  ctl_l_freq = init_ctl(TL_LIN_CTL);
  ctl_r_freq = init_ctl(TL_LIN_CTL);

  ctl_l_freq->is_verbose = 0;
  ctl_r_freq->is_verbose = 0;

  ctl_l_amp = init_ctl(TL_LIN_CTL);
  ctl_r_amp = init_ctl(TL_LIN_CTL);

  ctl_l_amp->is_verbose = 1;
  ctl_r_amp->is_verbose = 1;

  install_onto_ctl_list(get_g_ctl_head(), ctl_l_freq);
  install_onto_ctl_list(get_g_ctl_head(), ctl_r_freq);
  install_onto_ctl_list(get_g_ctl_head(), ctl_l_amp);
  install_onto_ctl_list(get_g_ctl_head(), ctl_r_amp);

  // initialize portaudio
  pa_initialize(0,0,2,2,.25);

  // setup the modules
  dac = (tl_dac *)tl_init_dac(2,1);
  // dac will initialize the global output buffer
  tbl_l = (tl_table *)tl_init_table(1000, 1);
  tbl_r = (tl_table *)tl_init_table(1000, 1);
  lkup_l = (tl_lookup *)tl_init_lookup(1);
  lkup_r = (tl_lookup *)tl_init_lookup(1);

  osc_l = init_osc(tbl_l, lkup_l, ctl_l_freq->outlet, ctl_l_amp->outlet);
  osc_r = init_osc(tbl_r, lkup_r, ctl_r_freq->outlet, ctl_r_amp->outlet);


  // this part needs to be done explicitly
  // first, register the ctls
  set_ctl_kr(ctl_l_freq, &l_freq_val);
  set_ctl_kr(ctl_r_freq, &r_freq_val);
  set_ctl_kr(ctl_l_amp, &l_amp_val);
  set_ctl_kr(ctl_r_amp, &r_amp_val);

  // now register the classes
  set_g_class_head(init_class());

  tl_install_class(get_g_class_head(), (void *)osc_l, osc_l->dsp_func, osc_l->kill_func);
  tl_install_class(get_g_class_head(), (void *)osc_r, osc_r->dsp_func, osc_r->kill_func);
  tl_install_class(get_g_class_head(), (void *)dac, dac->dsp_func, dac->kill_func);

  // connect to the dac
  dac->inlets[0] = osc_l->tbl->outlets[0];
  dac->inlets[1] = osc_r->tbl->outlets[0];

  return 0;

}