3
TiMidity -- Experimental MIDI to WAVE converter
4
Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
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.
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.
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.
22
Audio output (to file / device) functions.
31
extern PlayMode sdl_play_mode;
32
#define DEFAULT_PLAY_MODE &sdl_play_mode
35
PlayMode *play_mode_list[] = {
36
#ifdef DEFAULT_PLAY_MODE
42
#ifdef DEFAULT_PLAY_MODE
43
PlayMode *play_mode=DEFAULT_PLAY_MODE;
46
/*****************************************************************/
47
/* Some functions to convert signed 32-bit data to other formats */
49
void s32tos8(void *dp, int32 *lp, int32 c)
51
int8 *cp=(int8 *)(dp);
55
l=(*lp++)>>(32-8-GUARD_BITS);
57
else if (l<-128) l=-128;
62
void s32tou8(void *dp, int32 *lp, int32 c)
64
uint8 *cp=(uint8 *)(dp);
68
l=(*lp++)>>(32-8-GUARD_BITS);
70
else if (l<-128) l=-128;
71
*cp++ = 0x80 ^ ((uint8) l);
75
void s32tos16(void *dp, int32 *lp, int32 c)
77
int16 *sp=(int16 *)(dp);
81
l=(*lp++)>>(32-16-GUARD_BITS);
82
if (l > 32767) l=32767;
83
else if (l<-32768) l=-32768;
88
void s32tou16(void *dp, int32 *lp, int32 c)
90
uint16 *sp=(uint16 *)(dp);
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);
101
void s32tos16x(void *dp, int32 *lp, int32 c)
103
int16 *sp=(int16 *)(dp);
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));
114
void s32tou16x(void *dp, int32 *lp, int32 c)
116
uint16 *sp=(uint16 *)(dp);
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));
127
void s32toulaw(void *dp, int32 *lp, int32 c)
129
uint8 *up=(uint8 *)(dp);
133
l=(*lp++)>>(32-13-GUARD_BITS);
134
if (l > 4095) l=4095;
135
else if (l<-4096) l=-4096;