timidity/sdl_c.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 01 Jun 2013 22:30:04 -0700
changeset 627 438fb12df34f
parent 518 8bc9b5fd2aae
permissions -rw-r--r--
Updated iOS project to include OGG support directly
slouken@518
     1
/*
slouken@0
     2
    TiMidity -- Experimental MIDI to WAVE converter
slouken@0
     3
    Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
slouken@0
     4
slouken@0
     5
    This program is free software; you can redistribute it and/or modify
slouken@518
     6
    it under the terms of the Perl Artistic License, available in COPYING.
slouken@518
     7
 */
slouken@0
     8
slouken@0
     9
#include <stdio.h>
slouken@0
    10
#include <stdlib.h>
slouken@0
    11
#include <stdarg.h>
slouken@0
    12
slouken@0
    13
#include "config.h"
slouken@0
    14
#include "common.h"
slouken@0
    15
#include "output.h"
slouken@319
    16
#include "ctrlmode.h"
slouken@0
    17
#include "instrum.h"
slouken@0
    18
#include "playmidi.h"
slouken@0
    19
slouken@0
    20
static void ctl_refresh(void);
slouken@0
    21
static void ctl_total_time(int tt);
slouken@0
    22
static void ctl_master_volume(int mv);
slouken@0
    23
static void ctl_file_name(char *name);
slouken@0
    24
static void ctl_current_time(int ct);
slouken@0
    25
static void ctl_note(int v);
slouken@0
    26
static void ctl_program(int ch, int val);
slouken@0
    27
static void ctl_volume(int channel, int val);
slouken@0
    28
static void ctl_expression(int channel, int val);
slouken@0
    29
static void ctl_panning(int channel, int val);
slouken@0
    30
static void ctl_sustain(int channel, int val);
slouken@0
    31
static void ctl_pitch_bend(int channel, int val);
slouken@0
    32
static void ctl_reset(void);
slouken@0
    33
static int ctl_open(int using_stdin, int using_stdout);
slouken@0
    34
static void ctl_close(void);
slouken@0
    35
static int ctl_read(int32 *valp);
slouken@0
    36
static int cmsg(int type, int verbosity_level, char *fmt, ...);
slouken@0
    37
slouken@0
    38
/**********************************/
slouken@0
    39
/* export the interface functions */
slouken@0
    40
slouken@0
    41
#define ctl sdl_control_mode
slouken@0
    42
slouken@0
    43
ControlMode ctl= 
slouken@0
    44
{
slouken@0
    45
  "SDL interface", 's',
slouken@0
    46
  1,0,0,
slouken@0
    47
  ctl_open,NULL, ctl_close, ctl_read, cmsg,
slouken@0
    48
  ctl_refresh, ctl_reset, ctl_file_name, ctl_total_time, ctl_current_time, 
slouken@0
    49
  ctl_note, 
slouken@0
    50
  ctl_master_volume, ctl_program, ctl_volume, 
slouken@0
    51
  ctl_expression, ctl_panning, ctl_sustain, ctl_pitch_bend
slouken@0
    52
};
slouken@0
    53
slouken@0
    54
static int ctl_open(int using_stdin, int using_stdout)
slouken@0
    55
{
slouken@0
    56
  ctl.opened=1;
slouken@0
    57
  return 0;
slouken@0
    58
}
slouken@0
    59
slouken@0
    60
static void ctl_close(void)
slouken@0
    61
{ 
slouken@0
    62
  ctl.opened=0;
slouken@0
    63
}
slouken@0
    64
slouken@0
    65
static int ctl_read(int32 *valp)
slouken@0
    66
{
slouken@0
    67
  return RC_NONE;
slouken@0
    68
}
slouken@0
    69
slouken@0
    70
static int cmsg(int type, int verbosity_level, char *fmt, ...)
slouken@0
    71
{
slouken@245
    72
#ifdef GREGS_DEBUG
slouken@245
    73
  va_list ap;
slouken@245
    74
  int flag_newline = 1;
slouken@245
    75
  if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
slouken@245
    76
      ctl.verbosity<verbosity_level-1)
slouken@245
    77
    return 0;
slouken@245
    78
  if (*fmt == '~')
slouken@245
    79
    {
slouken@245
    80
      flag_newline = 0;
slouken@245
    81
      fmt++;
slouken@245
    82
    }
slouken@245
    83
  va_start(ap, fmt);
slouken@245
    84
  if (!ctl.opened)
slouken@245
    85
    {
slouken@245
    86
      vfprintf(stderr, fmt, ap);
slouken@245
    87
      if (flag_newline) fprintf(stderr, "\n");
slouken@245
    88
    }
slouken@245
    89
  else
slouken@245
    90
    {
slouken@245
    91
      vfprintf(stderr, fmt, ap);
slouken@245
    92
      if (flag_newline) fprintf(stderr, "\n");
slouken@245
    93
    }
slouken@245
    94
  va_end(ap);
slouken@245
    95
  if (!flag_newline) fflush(stderr);
slouken@245
    96
  return 0;
slouken@245
    97
#else
slouken@0
    98
  va_list ap;
slouken@0
    99
  if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
slouken@0
   100
      ctl.verbosity<verbosity_level)
slouken@0
   101
    return 0;
slouken@0
   102
  va_start(ap, fmt);
icculus@450
   103
  SDL_vsnprintf(timidity_error, TIMIDITY_ERROR_SIZE, fmt, ap);
slouken@0
   104
  va_end(ap);
slouken@0
   105
  return 0;
slouken@245
   106
#endif
slouken@0
   107
}
slouken@0
   108
slouken@0
   109
static void ctl_refresh(void) { }
slouken@0
   110
slouken@0
   111
static void ctl_total_time(int tt) {}
slouken@0
   112
slouken@0
   113
static void ctl_master_volume(int mv) {}
slouken@0
   114
slouken@0
   115
static void ctl_file_name(char *name) {}
slouken@0
   116
slouken@0
   117
static void ctl_current_time(int ct) {}
slouken@0
   118
slouken@0
   119
static void ctl_note(int v) {}
slouken@0
   120
slouken@0
   121
static void ctl_program(int ch, int val) {}
slouken@0
   122
slouken@0
   123
static void ctl_volume(int channel, int val) {}
slouken@0
   124
slouken@0
   125
static void ctl_expression(int channel, int val) {}
slouken@0
   126
slouken@0
   127
static void ctl_panning(int channel, int val) {}
slouken@0
   128
slouken@0
   129
static void ctl_sustain(int channel, int val) {}
slouken@0
   130
slouken@0
   131
static void ctl_pitch_bend(int channel, int val) {}
slouken@0
   132
slouken@0
   133
static void ctl_reset(void) {}