/project/jni/sdl_mixer/timidity/sdl_c.c

https://github.com/aichunyu/FFPlayer · C · 148 lines · 101 code · 23 blank · 24 comment · 12 complexity · 85d9b8dbd641b60b720154b23d0b8825 MD5 · raw file

  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 <stdio.h>
  19. #include <stdlib.h>
  20. #include <stdarg.h>
  21. #include "config.h"
  22. #include "common.h"
  23. #include "output.h"
  24. #include "ctrlmode.h"
  25. #include "instrum.h"
  26. #include "playmidi.h"
  27. static void ctl_refresh(void);
  28. static void ctl_total_time(int tt);
  29. static void ctl_master_volume(int mv);
  30. static void ctl_file_name(char *name);
  31. static void ctl_current_time(int ct);
  32. static void ctl_note(int v);
  33. static void ctl_program(int ch, int val);
  34. static void ctl_volume(int channel, int val);
  35. static void ctl_expression(int channel, int val);
  36. static void ctl_panning(int channel, int val);
  37. static void ctl_sustain(int channel, int val);
  38. static void ctl_pitch_bend(int channel, int val);
  39. static void ctl_reset(void);
  40. static int ctl_open(int using_stdin, int using_stdout);
  41. static void ctl_close(void);
  42. static int ctl_read(int32 *valp);
  43. static int cmsg(int type, int verbosity_level, char *fmt, ...);
  44. /**********************************/
  45. /* export the interface functions */
  46. #define ctl sdl_control_mode
  47. ControlMode ctl=
  48. {
  49. "SDL interface", 's',
  50. 1,0,0,
  51. ctl_open,NULL, ctl_close, ctl_read, cmsg,
  52. ctl_refresh, ctl_reset, ctl_file_name, ctl_total_time, ctl_current_time,
  53. ctl_note,
  54. ctl_master_volume, ctl_program, ctl_volume,
  55. ctl_expression, ctl_panning, ctl_sustain, ctl_pitch_bend
  56. };
  57. static int ctl_open(int using_stdin, int using_stdout)
  58. {
  59. ctl.opened=1;
  60. return 0;
  61. }
  62. static void ctl_close(void)
  63. {
  64. ctl.opened=0;
  65. }
  66. static int ctl_read(int32 *valp)
  67. {
  68. return RC_NONE;
  69. }
  70. static int cmsg(int type, int verbosity_level, char *fmt, ...)
  71. {
  72. #ifdef GREGS_DEBUG
  73. va_list ap;
  74. int flag_newline = 1;
  75. if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
  76. ctl.verbosity<verbosity_level-1)
  77. return 0;
  78. if (*fmt == '~')
  79. {
  80. flag_newline = 0;
  81. fmt++;
  82. }
  83. va_start(ap, fmt);
  84. if (!ctl.opened)
  85. {
  86. vfprintf(stderr, fmt, ap);
  87. if (flag_newline) fprintf(stderr, "\n");
  88. }
  89. else
  90. {
  91. vfprintf(stderr, fmt, ap);
  92. if (flag_newline) fprintf(stderr, "\n");
  93. }
  94. va_end(ap);
  95. if (!flag_newline) fflush(stderr);
  96. return 0;
  97. #else
  98. va_list ap;
  99. if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
  100. ctl.verbosity<verbosity_level)
  101. return 0;
  102. va_start(ap, fmt);
  103. SDL_vsnprintf(timidity_error, TIMIDITY_ERROR_SIZE, fmt, ap);
  104. va_end(ap);
  105. return 0;
  106. #endif
  107. }
  108. static void ctl_refresh(void) { }
  109. static void ctl_total_time(int tt) {}
  110. static void ctl_master_volume(int mv) {}
  111. static void ctl_file_name(char *name) {}
  112. static void ctl_current_time(int ct) {}
  113. static void ctl_note(int v) {}
  114. static void ctl_program(int ch, int val) {}
  115. static void ctl_volume(int channel, int val) {}
  116. static void ctl_expression(int channel, int val) {}
  117. static void ctl_panning(int channel, int val) {}
  118. static void ctl_sustain(int channel, int val) {}
  119. static void ctl_pitch_bend(int channel, int val) {}
  120. static void ctl_reset(void) {}