Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.1KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2010 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. // #include <lo/lo.h>
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <OSC/Endpoint.H>
  22. #include <ctype.h>
  23. #include <string.h>
  24. #include <time.h>
  25. #include <unistd.h>
  26. static bool got_response = false;
  27. /************************/
  28. /* OSC Message Handlers */
  29. /************************/
  30. static int osc_reply ( const char *path, const char *types, lo_arg **argv, int argc, lo_message, void * )
  31. {
  32. // OSCDMSG();
  33. printf( "%s : ", path );
  34. for ( int i = 0; i < argc; ++i )
  35. {
  36. switch ( types[i] )
  37. {
  38. case 's':
  39. printf( "\"%s\" ", &argv[i]->s );
  40. break;
  41. case 'f':
  42. printf( "%f ", argv[i]->f );
  43. break;
  44. case 'i':
  45. printf( "%i ", argv[i]->i );
  46. break;
  47. }
  48. }
  49. printf( "\n" );
  50. got_response = true;
  51. return 0;
  52. }
  53. int main(int argc, char *argv[])
  54. {
  55. OSC::Endpoint s;
  56. s.init( LO_UDP );
  57. s.add_method( NULL, NULL, osc_reply, 0, "");
  58. std::list<OSC::OSC_Value> args;
  59. for ( int i = 3; i < argc; ++i )
  60. {
  61. const char *s = argv[i];
  62. if ( strspn( s, "+-0123456789" ) == strlen( s ) )
  63. {
  64. args.push_back( OSC::OSC_Int( atol( s ) ) );
  65. }
  66. else if ( strspn( s, ".+-0123456789" ) == strlen( s ) )
  67. args.push_back( OSC::OSC_Float( atof( s ) ) );
  68. else
  69. {
  70. args.push_back( OSC::OSC_String( s ) );
  71. }
  72. }
  73. lo_address t = lo_address_new_from_url( argv[1] );
  74. fprintf( stderr, "Sending to %s\n", argv[1] );
  75. s.send( t, argv[2], args );
  76. printf( "Waiting for reply...\n" );
  77. while ( ! got_response )
  78. s.wait( 1000 * 30 );
  79. return 0;
  80. }