Mercurial > audlegacy-plugins
comparison src/console/Music_Emu.cxx @ 12:3da1b8942b8b trunk
[svn] - remove src/Input src/Output src/Effect src/General src/Visualization src/Container
author | nenolod |
---|---|
date | Mon, 18 Sep 2006 03:14:20 -0700 |
parents | src/Input/console/Music_Emu.cxx@13389e613d67 |
children | fb513e10174e |
comparison
equal
deleted
inserted
replaced
11:cff1d04026ae | 12:3da1b8942b8b |
---|---|
1 | |
2 // Game_Music_Emu 0.3.0. http://www.slack.net/~ant/ | |
3 | |
4 #include "Music_Emu.h" | |
5 | |
6 #include <string.h> | |
7 | |
8 /* Copyright (C) 2003-2006 Shay Green. This module is free software; you | |
9 can redistribute it and/or modify it under the terms of the GNU Lesser | |
10 General Public License as published by the Free Software Foundation; either | |
11 version 2.1 of the License, or (at your option) any later version. This | |
12 module is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
14 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for | |
15 more details. You should have received a copy of the GNU Lesser General | |
16 Public License along with this module; if not, write to the Free Software | |
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ | |
18 | |
19 #include BLARGG_SOURCE_BEGIN | |
20 | |
21 Music_Emu::equalizer_t const Music_Emu::tv_eq = { -8.0, 180 }; | |
22 | |
23 Music_Emu::Music_Emu() | |
24 { | |
25 equalizer_.treble = -1.0; | |
26 equalizer_.bass = 60; | |
27 sample_rate_ = 0; | |
28 voice_count_ = 0; | |
29 mute_mask_ = 0; | |
30 track_count_ = 0; | |
31 error_count_ = 0; | |
32 track_ended_ = false; | |
33 } | |
34 | |
35 Music_Emu::~Music_Emu() | |
36 { | |
37 } | |
38 | |
39 blargg_err_t Music_Emu::load_file( const char* path ) | |
40 { | |
41 Std_File_Reader in; | |
42 BLARGG_RETURN_ERR( in.open( path ) ); | |
43 return load( in ); | |
44 } | |
45 | |
46 void Music_Emu::skip( long count ) | |
47 { | |
48 const int buf_size = 1024; | |
49 sample_t buf [buf_size]; | |
50 | |
51 const long threshold = 30000; | |
52 if ( count > threshold ) | |
53 { | |
54 int saved_mute = mute_mask_; | |
55 mute_voices( ~0 ); | |
56 | |
57 while ( count > threshold / 2 ) | |
58 { | |
59 play( buf_size, buf ); | |
60 count -= buf_size; | |
61 } | |
62 | |
63 mute_voices( saved_mute ); | |
64 } | |
65 | |
66 while ( count ) | |
67 { | |
68 int n = buf_size; | |
69 if ( n > count ) | |
70 n = count; | |
71 count -= n; | |
72 play( n, buf ); | |
73 } | |
74 } | |
75 | |
76 const char** Music_Emu::voice_names() const | |
77 { | |
78 static const char* names [] = { | |
79 "Voice 1", "Voice 2", "Voice 3", "Voice 4", | |
80 "Voice 5", "Voice 6", "Voice 7", "Voice 8" | |
81 }; | |
82 return names; | |
83 } | |
84 |