~and471/ubuntu/maverick/frozen-bubble/fix-599809

« back to all changes in this revision

Viewing changes to SDL_mixer_patched/timidity/output.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette
  • Date: 2004-07-08 17:22:16 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040708172216-4e9erxuhsq7djmnd
Tags: 1.0.0-6
c_stuff/lib/FBLE.pm: fix to deal with new SDL_perl (closes: #257749).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
    output.c
21
 
    
22
 
    Audio output (to file / device) functions.
23
 
*/
24
 
 
25
 
#include "config.h"
26
 
#include "output.h"
27
 
#include "tables.h"
28
 
 
29
 
 
30
 
#ifdef SDL
31
 
extern PlayMode sdl_play_mode;
32
 
#define DEFAULT_PLAY_MODE &sdl_play_mode
33
 
#endif
34
 
 
35
 
PlayMode *play_mode_list[] = {
36
 
#ifdef DEFAULT_PLAY_MODE
37
 
  DEFAULT_PLAY_MODE,
38
 
#endif
39
 
  0
40
 
};
41
 
 
42
 
#ifdef DEFAULT_PLAY_MODE
43
 
  PlayMode *play_mode=DEFAULT_PLAY_MODE;
44
 
#endif
45
 
 
46
 
/*****************************************************************/
47
 
/* Some functions to convert signed 32-bit data to other formats */
48
 
 
49
 
void s32tos8(void *dp, int32 *lp, int32 c)
50
 
{
51
 
  int8 *cp=(int8 *)(dp);
52
 
  int32 l;
53
 
  while (c--)
54
 
    {
55
 
      l=(*lp++)>>(32-8-GUARD_BITS);
56
 
      if (l>127) l=127;
57
 
      else if (l<-128) l=-128;
58
 
      *cp++ = (int8) (l);
59
 
    }
60
 
}
61
 
 
62
 
void s32tou8(void *dp, int32 *lp, int32 c)
63
 
{
64
 
  uint8 *cp=(uint8 *)(dp);
65
 
  int32 l;
66
 
  while (c--)
67
 
    {
68
 
      l=(*lp++)>>(32-8-GUARD_BITS);
69
 
      if (l>127) l=127;
70
 
      else if (l<-128) l=-128;
71
 
      *cp++ = 0x80 ^ ((uint8) l);
72
 
    }
73
 
}
74
 
 
75
 
void s32tos16(void *dp, int32 *lp, int32 c)
76
 
{
77
 
  int16 *sp=(int16 *)(dp);
78
 
  int32 l;
79
 
  while (c--)
80
 
    {
81
 
      l=(*lp++)>>(32-16-GUARD_BITS);
82
 
      if (l > 32767) l=32767;
83
 
      else if (l<-32768) l=-32768;
84
 
      *sp++ = (int16)(l);
85
 
    }
86
 
}
87
 
 
88
 
void s32tou16(void *dp, int32 *lp, int32 c)
89
 
{
90
 
  uint16 *sp=(uint16 *)(dp);
91
 
  int32 l;
92
 
  while (c--)
93
 
    {
94
 
      l=(*lp++)>>(32-16-GUARD_BITS);
95
 
      if (l > 32767) l=32767;
96
 
      else if (l<-32768) l=-32768;
97
 
      *sp++ = 0x8000 ^ (uint16)(l);
98
 
    }
99
 
}
100
 
 
101
 
void s32tos16x(void *dp, int32 *lp, int32 c)
102
 
{
103
 
  int16 *sp=(int16 *)(dp);
104
 
  int32 l;
105
 
  while (c--)
106
 
    {
107
 
      l=(*lp++)>>(32-16-GUARD_BITS);
108
 
      if (l > 32767) l=32767;
109
 
      else if (l<-32768) l=-32768;
110
 
      *sp++ = XCHG_SHORT((int16)(l));
111
 
    }
112
 
}
113
 
 
114
 
void s32tou16x(void *dp, int32 *lp, int32 c)
115
 
{
116
 
  uint16 *sp=(uint16 *)(dp);
117
 
  int32 l;
118
 
  while (c--)
119
 
    {
120
 
      l=(*lp++)>>(32-16-GUARD_BITS);
121
 
      if (l > 32767) l=32767;
122
 
      else if (l<-32768) l=-32768;
123
 
      *sp++ = XCHG_SHORT(0x8000 ^ (uint16)(l));
124
 
    }
125
 
}
126
 
 
127
 
void s32toulaw(void *dp, int32 *lp, int32 c)
128
 
{
129
 
  uint8 *up=(uint8 *)(dp);
130
 
  int32 l;
131
 
  while (c--)
132
 
    {
133
 
      l=(*lp++)>>(32-13-GUARD_BITS);
134
 
      if (l > 4095) l=4095;
135
 
      else if (l<-4096) l=-4096;
136
 
      *up++ = _l2u[l];
137
 
    }
138
 
}