sdl_c.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. TiMidity -- Experimental MIDI to WAVE converter
  3. Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. sdl_c.c
  16. Minimal control mode -- no interaction, just stores messages.
  17. */
  18. #include "../../neo/idlib/precompiled.h"
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <stdarg.h>
  22. #include <string.h>
  23. #include "config.h"
  24. #include "common.h"
  25. #include "output.h"
  26. #include "controls.h"
  27. #include "instrum.h"
  28. #include "playmidi.h"
  29. static void ctl_refresh(void);
  30. static void ctl_total_time(int tt);
  31. static void ctl_master_volume(int mv);
  32. static void ctl_file_name(char *name);
  33. static void ctl_current_time(int ct);
  34. static void ctl_note(int v);
  35. static void ctl_program(int ch, int val);
  36. static void ctl_volume(int channel, int val);
  37. static void ctl_expression(int channel, int val);
  38. static void ctl_panning(int channel, int val);
  39. static void ctl_sustain(int channel, int val);
  40. static void ctl_pitch_bend(int channel, int val);
  41. static void ctl_reset(void);
  42. static int ctl_open(int using_stdin, int using_stdout);
  43. static void ctl_close(void);
  44. static int ctl_read(int *valp);
  45. static int cmsg(int type, int verbosity_level, char *fmt, ...);
  46. #ifdef _DEBUG
  47. #define safeOutputDebug(x) printf( "%s", x )
  48. #else
  49. #define safeOutputDebug(x)
  50. #endif
  51. /**********************************/
  52. /* export the interface functions */
  53. #define ctl sdl_control_mode
  54. ControlMode ctl=
  55. {
  56. "SDL interface", 's',
  57. 1,0,0,
  58. ctl_open,NULL, ctl_close, ctl_read, cmsg,
  59. ctl_refresh, ctl_reset, ctl_file_name, ctl_total_time, ctl_current_time,
  60. ctl_note,
  61. ctl_master_volume, ctl_program, ctl_volume,
  62. ctl_expression, ctl_panning, ctl_sustain, ctl_pitch_bend
  63. };
  64. static int ctl_open(int using_stdin, int using_stdout)
  65. {
  66. ctl.opened=1;
  67. return 0;
  68. }
  69. static void ctl_close(void)
  70. {
  71. ctl.opened=0;
  72. }
  73. static int ctl_read(int *valp)
  74. {
  75. return RC_NO_RETURN_VALUE;
  76. }
  77. extern void SendDebugMsg(const char*);
  78. extern bool debugOutput;
  79. static int cmsg(int type, int verbosity_level, char *fmt, ...)
  80. {
  81. #ifdef _DEBUG
  82. va_list ap;
  83. va_start(ap, fmt);
  84. idStr::vsnPrintf(timidity_error, TIMIDITY_ERROR_MAX_CHARS - 1, fmt, ap);
  85. va_end(ap);
  86. strcat( timidity_error, "\n" );
  87. if ( debugOutput && verbosity_level <= VERB_VERBOSE ) {
  88. safeOutputDebug( timidity_error );
  89. }
  90. #endif
  91. return 0;
  92. }
  93. static void ctl_refresh(void) { }
  94. static void ctl_total_time(int tt) {}
  95. static void ctl_master_volume(int mv) {}
  96. static void ctl_file_name(char *name) {}
  97. static void ctl_current_time(int ct) {}
  98. static void ctl_note(int v) {}
  99. static void ctl_program(int ch, int val) {}
  100. static void ctl_volume(int channel, int val) {}
  101. static void ctl_expression(int channel, int val) {}
  102. static void ctl_panning(int channel, int val) {}
  103. static void ctl_sustain(int channel, int val) {}
  104. static void ctl_pitch_bend(int channel, int val) {}
  105. static void ctl_reset(void) {}