annotate src/console/gme.cxx @ 2450:ccfc52a92504

Remove debugging notice.
author William Pitcock <nenolod@atheme.org>
date Thu, 13 Mar 2008 16:42:02 -0500
parents 986f098da058
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
1 // Game_Music_Emu 0.5.2. http://www.slack.net/~ant/
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
2
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
3 #include "Music_Emu.h"
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
4
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
5 #if !GME_DISABLE_STEREO_DEPTH
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
6 #include "Effects_Buffer.h"
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
7 #endif
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
8 #include "blargg_endian.h"
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
9 #include <string.h>
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
10 #include <ctype.h>
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
11
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
12 /* Copyright (C) 2003-2006 Shay Green. This module is free software; you
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
13 can redistribute it and/or modify it under the terms of the GNU Lesser
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
14 General Public License as published by the Free Software Foundation; either
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
15 version 2.1 of the License, or (at your option) any later version. This
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
16 module is distributed in the hope that it will be useful, but WITHOUT ANY
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
18 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
19 details. You should have received a copy of the GNU Lesser General Public
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
20 License along with this module; if not, write to the Free Software Foundation,
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
21 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
22
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
23 #include "blargg_source.h"
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
24
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
25 #ifndef GME_TYPE_LIST
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
26
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
27 // Default list of all supported game music types (copy this to blargg_config.h
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
28 // if you want to modify it)
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
29 #define GME_TYPE_LIST \
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
30 gme_ay_type,\
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
31 gme_gbs_type,\
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
32 gme_gym_type,\
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
33 gme_hes_type,\
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
34 gme_kss_type,\
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
35 gme_nsf_type,\
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
36 gme_nsfe_type,\
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
37 gme_sap_type,\
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
38 gme_spc_type,\
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
39 gme_vgm_type,\
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
40 gme_vgz_type
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
41
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
42 #endif
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
43
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
44 static gme_type_t const gme_type_list_ [] = { GME_TYPE_LIST, 0 };
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
45
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
46 gme_type_t const* gme_type_list()
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
47 {
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
48 return gme_type_list_;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
49 }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
50
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
51 const char* gme_identify_header( void const* header )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
52 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
53 switch ( get_be32( header ) )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
54 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
55 case BLARGG_4CHAR('Z','X','A','Y'): return "AY";
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
56 case BLARGG_4CHAR('G','B','S',0x01): return "GBS";
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
57 case BLARGG_4CHAR('G','Y','M','X'): return "GYM";
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
58 case BLARGG_4CHAR('H','E','S','M'): return "HES";
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
59 case BLARGG_4CHAR('K','S','C','C'):
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
60 case BLARGG_4CHAR('K','S','S','X'): return "KSS";
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
61 case BLARGG_4CHAR('N','E','S','M'): return "NSF";
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
62 case BLARGG_4CHAR('N','S','F','E'): return "NSFE";
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
63 case BLARGG_4CHAR('S','A','P',0x0D): return "SAP";
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
64 case BLARGG_4CHAR('S','N','E','S'): return "SPC";
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
65 case BLARGG_4CHAR('V','g','m',' '): return "VGM";
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
66 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
67 return "";
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
68 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
69
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
70 static void to_uppercase( const char* in, int len, char* out )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
71 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
72 for ( int i = 0; i < len; i++ )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
73 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
74 if ( !(out [i] = toupper( in [i] )) )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
75 return;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
76 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
77 *out = 0; // extension too long
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
78 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
79
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
80 gme_type_t gme_identify_extension( const char* extension_ )
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
81 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
82 char const* end = strrchr( extension_, '.' );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
83 if ( end )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
84 extension_ = end + 1;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
85
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
86 char extension [6];
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
87 to_uppercase( extension_, sizeof extension, extension );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
88
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
89 for ( gme_type_t const* types = gme_type_list_; *types; types++ )
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
90 if ( !strcmp( extension, (*types)->extension_ ) )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
91 return *types;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
92 return 0;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
93 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
94
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
95 gme_err_t gme_identify_file( const char* path, gme_type_t* type_out )
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
96 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
97 *type_out = gme_identify_extension( path );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
98 // TODO: don't examine header if file has extension?
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
99 if ( !*type_out )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
100 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
101 char header [4];
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
102 GME_FILE_READER in;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
103 RETURN_ERR( in.open( path ) );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
104 RETURN_ERR( in.read( header, sizeof header ) );
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
105 *type_out = gme_identify_extension( gme_identify_header( header ) );
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
106 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
107 return 0;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
108 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
109
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
110 gme_err_t gme_open_data( void const* data, long size, Music_Emu** out, long sample_rate )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
111 {
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
112 require( (data || !size) && out );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
113 *out = 0;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
114
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
115 gme_type_t file_type = 0;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
116 if ( size >= 4 )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
117 file_type = gme_identify_extension( gme_identify_header( data ) );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
118 if ( !file_type )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
119 return gme_wrong_file_type;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
120
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
121 Music_Emu* emu = gme_new_emu( file_type, sample_rate );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
122 CHECK_ALLOC( emu );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
123
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
124 gme_err_t err = gme_load_data( emu, data, size );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
125
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
126 if ( err )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
127 delete emu;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
128 else
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
129 *out = emu;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
130
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
131 return err;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
132 }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
133
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
134 gme_err_t gme_open_file( const char* path, Music_Emu** out, long sample_rate )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
135 {
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
136 require( path && out );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
137 *out = 0;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
138
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
139 GME_FILE_READER in;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
140 RETURN_ERR( in.open( path ) );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
141
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
142 char header [4];
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
143 int header_size = 0;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
144
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
145 gme_type_t file_type = gme_identify_extension( path );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
146 if ( !file_type )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
147 {
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
148 header_size = sizeof header;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
149 RETURN_ERR( in.read( header, sizeof header ) );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
150 file_type = gme_identify_extension( gme_identify_header( header ) );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
151 }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
152 if ( !file_type )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
153 return gme_wrong_file_type;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
154
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
155 Music_Emu* emu = gme_new_emu( file_type, sample_rate );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
156 CHECK_ALLOC( emu );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
157
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
158 // optimization: avoids seeking/re-reading header
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
159 Remaining_Reader rem( header, header_size, &in );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
160 gme_err_t err = emu->load( rem );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
161 in.close();
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
162
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
163 if ( err )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
164 delete emu;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
165 else
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
166 *out = emu;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
167
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
168 return err;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
169 }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
170
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
171 Music_Emu* gme_new_emu( gme_type_t type, long rate )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
172 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
173 if ( type )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
174 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
175 if ( rate == gme_info_only )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
176 return type->new_info();
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
177
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
178 Music_Emu* me = type->new_emu();
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
179 if ( me )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
180 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
181 #if !GME_DISABLE_STEREO_DEPTH
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
182 if ( type->flags_ & 1 )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
183 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
184 me->effects_buffer = BLARGG_NEW Effects_Buffer;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
185 if ( me->effects_buffer )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
186 me->set_buffer( me->effects_buffer );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
187 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
188
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
189 if ( !(type->flags_ & 1) || me->effects_buffer )
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
190 #endif
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
191 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
192 if ( !me->set_sample_rate( rate ) )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
193 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
194 check( me->type() == type );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
195 return me;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
196 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
197 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
198 delete me;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
199 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
200 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
201 return 0;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
202 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
203
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
204 gme_err_t gme_load_file( Music_Emu* me, const char* path ) { return me->load_file( path ); }
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
205
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
206 gme_err_t gme_load_data( Music_Emu* me, void const* data, long size )
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
207 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
208 Mem_File_Reader in( data, size );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
209 return me->load( in );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
210 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
211
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
212 gme_err_t gme_load_custom( Music_Emu* me, gme_reader_t func, long size, void* data )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
213 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
214 Callback_Reader in( func, size, data );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
215 return me->load( in );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
216 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
217
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
218 void gme_delete( Music_Emu* me ) { delete me; }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
219
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
220 gme_type_t gme_type( Music_Emu const* me ) { return me->type(); }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
221
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
222 const char* gme_warning( Music_Emu* me ) { return me->warning(); }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
223
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
224 int gme_track_count( Music_Emu const* me ) { return me->track_count(); }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
225
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
226 const char* gme_track_info( Music_Emu const* me, track_info_t* out, int track )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
227 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
228 return me->track_info( out, track );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
229 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
230
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
231 void gme_set_stereo_depth( Music_Emu* me, double depth )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
232 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
233 #if !GME_DISABLE_STEREO_DEPTH
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
234 if ( me->effects_buffer )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
235 STATIC_CAST(Effects_Buffer*,me->effects_buffer)->set_depth( depth );
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
236 #endif
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
237 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
238
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
239 void* gme_user_data ( Music_Emu const* me ) { return me->user_data(); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
240 void gme_set_user_data ( Music_Emu* me, void* new_user_data ) { me->set_user_data( new_user_data ); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
241 void gme_set_user_cleanup(Music_Emu* me, gme_user_cleanup_t func ) { me->set_user_cleanup( func ); }
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff changeset
242
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
243 gme_err_t gme_start_track ( Music_Emu* me, int index ) { return me->start_track( index ); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
244 gme_err_t gme_play ( Music_Emu* me, long n, short* p ) { return me->play( n, p ); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
245 void gme_set_fade ( Music_Emu* me, long start_msec ) { me->set_fade( start_msec ); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
246 int gme_track_ended ( Music_Emu const* me ) { return me->track_ended(); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
247 long gme_tell ( Music_Emu const* me ) { return me->tell(); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
248 gme_err_t gme_seek ( Music_Emu* me, long msec ) { return me->seek( msec ); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
249 int gme_voice_count ( Music_Emu const* me ) { return me->voice_count(); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
250 void gme_ignore_silence ( Music_Emu* me, int disable ) { me->ignore_silence( disable != 0 ); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
251 void gme_set_tempo ( Music_Emu* me, double t ) { me->set_tempo( t ); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
252 void gme_mute_voice ( Music_Emu* me, int index, int mute ) { me->mute_voice( index, mute != 0 ); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
253 void gme_mute_voices ( Music_Emu* me, int mask ) { me->mute_voices( mask ); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
254 void gme_set_equalizer ( Music_Emu* me, gme_equalizer_t const* eq ) { me->set_equalizer( *eq ); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
255 gme_equalizer_t gme_equalizer( Music_Emu const* me ) { return me->equalizer(); }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
256 const char** gme_voice_names ( Music_Emu const* me ) { return me->voice_names(); }