PageRenderTime 39ms CodeModel.GetById 13ms app.highlight 21ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  3    TiMidity -- Experimental MIDI to WAVE converter
  4    Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
  5
  6    This program is free software; you can redistribute it and/or modify
  7    it under the terms of the GNU General Public License as published by
  8    the Free Software Foundation; either version 2 of the License, or
  9    (at your option) any later version.
 10
 11    This program is distributed in the hope that it will be useful,
 12    but WITHOUT ANY WARRANTY; without even the implied warranty of
 13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14    GNU General Public License for more details.
 15
 16    You should have received a copy of the GNU General Public License
 17    along with this program; if not, write to the Free Software
 18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 19
 20    sdl_c.c
 21    Minimal control mode -- no interaction, just stores messages.
 22    */
 23
 24#include <stdio.h>
 25#include <stdlib.h>
 26#include <stdarg.h>
 27
 28#include "config.h"
 29#include "common.h"
 30#include "output.h"
 31#include "ctrlmode.h"
 32#include "instrum.h"
 33#include "playmidi.h"
 34
 35static void ctl_refresh(void);
 36static void ctl_total_time(int tt);
 37static void ctl_master_volume(int mv);
 38static void ctl_file_name(char *name);
 39static void ctl_current_time(int ct);
 40static void ctl_note(int v);
 41static void ctl_program(int ch, int val);
 42static void ctl_volume(int channel, int val);
 43static void ctl_expression(int channel, int val);
 44static void ctl_panning(int channel, int val);
 45static void ctl_sustain(int channel, int val);
 46static void ctl_pitch_bend(int channel, int val);
 47static void ctl_reset(void);
 48static int ctl_open(int using_stdin, int using_stdout);
 49static void ctl_close(void);
 50static int ctl_read(int32 *valp);
 51static int cmsg(int type, int verbosity_level, char *fmt, ...);
 52
 53/**********************************/
 54/* export the interface functions */
 55
 56#define ctl sdl_control_mode
 57
 58ControlMode ctl= 
 59{
 60  "SDL interface", 's',
 61  1,0,0,
 62  ctl_open,NULL, ctl_close, ctl_read, cmsg,
 63  ctl_refresh, ctl_reset, ctl_file_name, ctl_total_time, ctl_current_time, 
 64  ctl_note, 
 65  ctl_master_volume, ctl_program, ctl_volume, 
 66  ctl_expression, ctl_panning, ctl_sustain, ctl_pitch_bend
 67};
 68
 69static int ctl_open(int using_stdin, int using_stdout)
 70{
 71  ctl.opened=1;
 72  return 0;
 73}
 74
 75static void ctl_close(void)
 76{ 
 77  ctl.opened=0;
 78}
 79
 80static int ctl_read(int32 *valp)
 81{
 82  return RC_NONE;
 83}
 84
 85static int cmsg(int type, int verbosity_level, char *fmt, ...)
 86{
 87#ifdef GREGS_DEBUG
 88  va_list ap;
 89  int flag_newline = 1;
 90  if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
 91      ctl.verbosity<verbosity_level-1)
 92    return 0;
 93  if (*fmt == '~')
 94    {
 95      flag_newline = 0;
 96      fmt++;
 97    }
 98  va_start(ap, fmt);
 99  if (!ctl.opened)
100    {
101      vfprintf(stderr, fmt, ap);
102      if (flag_newline) fprintf(stderr, "\n");
103    }
104  else
105    {
106      vfprintf(stderr, fmt, ap);
107      if (flag_newline) fprintf(stderr, "\n");
108    }
109  va_end(ap);
110  if (!flag_newline) fflush(stderr);
111  return 0;
112#else
113  va_list ap;
114  if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
115      ctl.verbosity<verbosity_level)
116    return 0;
117  va_start(ap, fmt);
118  SDL_vsnprintf(timidity_error, TIMIDITY_ERROR_SIZE, fmt, ap);
119  va_end(ap);
120  return 0;
121#endif
122}
123
124static void ctl_refresh(void) { }
125
126static void ctl_total_time(int tt) {}
127
128static void ctl_master_volume(int mv) {}
129
130static void ctl_file_name(char *name) {}
131
132static void ctl_current_time(int ct) {}
133
134static void ctl_note(int v) {}
135
136static void ctl_program(int ch, int val) {}
137
138static void ctl_volume(int channel, int val) {}
139
140static void ctl_expression(int channel, int val) {}
141
142static void ctl_panning(int channel, int val) {}
143
144static void ctl_sustain(int channel, int val) {}
145
146static void ctl_pitch_bend(int channel, int val) {}
147
148static void ctl_reset(void) {}