/[pcsx2_0.9.7]/trunk/plugins/spu2-x/src/Linux/Config.cpp
ViewVC logotype

Contents of /trunk/plugins/spu2-x/src/Linux/Config.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 290 - (show annotations) (download)
Sat Dec 25 02:51:30 2010 UTC (9 years, 6 months ago) by william
File size: 9574 byte(s)
Auto Commited Import of: pcsx2-0.9.7-DEBUG (upstream: v0.9.7.4139 local: v0.9.7.283-latest) in ./trunk
1 /* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
2 * Developed and maintained by the Pcsx2 Development Team.
3 *
4 * Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz]
5 *
6 * SPU2-X is free software: you can redistribute it and/or modify it under the terms
7 * of the GNU Lesser General Public License as published by the Free Software Found-
8 * ation, either version 3 of the License, or (at your option) any later version.
9 *
10 * SPU2-X is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with SPU2-X. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "Global.h"
19 #include "Dialogs.h"
20 #include "Config.h"
21
22 #ifdef PCSX2_DEVBUILD
23 static const int LATENCY_MAX = 3000;
24 #else
25 static const int LATENCY_MAX = 750;
26 #endif
27
28 static const int LATENCY_MIN = 40;
29
30 int AutoDMAPlayRate[2] = {0,0};
31
32 // Default settings.
33
34 // MIXING
35 int Interpolation = 1;
36 /* values:
37 0: no interpolation (use nearest)
38 1. linear interpolation
39 2. cubic interpolation
40 3. hermite interpolation
41 4. catmull-rom interpolation
42 */
43
44 bool EffectsDisabled = false;
45 int ReverbBoost = 0;
46 bool postprocess_filter_enabled = 1;
47
48 // OUTPUT
49 u32 OutputModule = 0;
50 int SndOutLatencyMS = 300;
51 int SynchMode = 0; // Time Stretch, Async or Disabled
52
53 /*****************************************************************************/
54
55 void ReadSettings()
56 {
57 // For some reason this can be called before we know what ini file we're writing to.
58 // Lets not try to read it if that happens.
59 if (!pathSet)
60 {
61 FileLog("Read called without the path set.\n");
62 return;
63 }
64
65 Interpolation = CfgReadInt( L"MIXING",L"Interpolation", 1 );
66 EffectsDisabled = CfgReadBool( L"MIXING", L"Disable_Effects", false );
67 ReverbBoost = CfgReadInt( L"MIXING",L"Reverb_Boost", 0 );
68
69 wxString temp;
70 CfgReadStr( L"OUTPUT", L"Output_Module", temp, PortaudioOut->GetIdent() );
71 OutputModule = FindOutputModuleById( temp.c_str() );// find the driver index of this module
72
73 SndOutLatencyMS = CfgReadInt(L"OUTPUT",L"Latency", 300);
74 SynchMode = CfgReadInt( L"OUTPUT", L"Synch_Mode", 0);
75
76 PortaudioOut->ReadSettings();
77 SoundtouchCfg::ReadSettings();
78 DebugConfig::ReadSettings();
79
80 // Sanity Checks
81 // -------------
82
83 Clampify( SndOutLatencyMS, LATENCY_MIN, LATENCY_MAX );
84
85 WriteSettings();
86 spuConfig->Flush();
87 }
88
89 /*****************************************************************************/
90
91 void WriteSettings()
92 {
93 if (!pathSet)
94 {
95 FileLog("Write called without the path set.\n");
96 return;
97 }
98
99 CfgWriteInt(L"MIXING",L"Interpolation",Interpolation);
100 CfgWriteBool(L"MIXING",L"Disable_Effects",EffectsDisabled);
101 CfgWriteInt(L"MIXING",L"Reverb_Boost",ReverbBoost);
102
103 CfgWriteStr(L"OUTPUT",L"Output_Module", mods[OutputModule]->GetIdent() );
104 CfgWriteInt(L"OUTPUT",L"Latency", SndOutLatencyMS);
105 CfgWriteInt(L"OUTPUT",L"Synch_Mode", SynchMode);
106
107 PortaudioOut->WriteSettings();
108 SoundtouchCfg::WriteSettings();
109 DebugConfig::WriteSettings();
110 }
111
112 void advanced_dialog()
113 {
114 SoundtouchCfg::DisplayDialog();
115 }
116
117 void debug_dialog()
118 {
119 DebugConfig::DisplayDialog();
120 }
121
122 void DisplayDialog()
123 {
124 int return_value;
125
126 GtkWidget *dialog;
127 GtkWidget *main_frame, *main_box;
128
129 GtkWidget *mixing_frame, *mixing_box;
130 GtkWidget *int_label, *int_box;
131 GtkWidget *effects_check;
132 GtkWidget *reverb_label, *reverb_box;
133 GtkWidget *debug_check;
134 GtkWidget *debug_button;
135
136 GtkWidget *output_frame, *output_box;
137 GtkWidget *mod_label, *mod_box;
138 GtkWidget *latency_label, *latency_slide;
139 GtkWidget *sync_label, *sync_box;
140 GtkWidget *advanced_button;
141
142 /* Create the widgets */
143 dialog = gtk_dialog_new_with_buttons (
144 "Spu2-X Config",
145 NULL, /* parent window*/
146 (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
147 GTK_STOCK_OK,
148 GTK_RESPONSE_ACCEPT,
149 GTK_STOCK_CANCEL,
150 GTK_RESPONSE_REJECT,
151 NULL);
152
153 int_label = gtk_label_new ("Interpolation:");
154 int_box = gtk_combo_box_new_text ();
155 gtk_combo_box_append_text(GTK_COMBO_BOX(int_box), "0 - Nearest (fastest/bad quality)");
156 gtk_combo_box_append_text(GTK_COMBO_BOX(int_box), "1 - Linear (simple/nice)");
157 gtk_combo_box_append_text(GTK_COMBO_BOX(int_box), "2 - Cubic (slower/good highs)");
158 gtk_combo_box_append_text(GTK_COMBO_BOX(int_box), "3 - Hermite (slower/better highs)");
159 gtk_combo_box_append_text(GTK_COMBO_BOX(int_box), "4 - Catmull-Rom (slow/hq)");
160 gtk_combo_box_set_active(GTK_COMBO_BOX(int_box), Interpolation);
161
162 effects_check = gtk_check_button_new_with_label("Disable Effects Processing");
163
164 reverb_label = gtk_label_new ("Reverb Boost Factor:");
165 reverb_box = gtk_combo_box_new_text ();
166 gtk_combo_box_append_text(GTK_COMBO_BOX(reverb_box), "1X - Normal Reverb Volume");
167 gtk_combo_box_append_text(GTK_COMBO_BOX(reverb_box), "2X - Reverb Volume x 2");
168 gtk_combo_box_append_text(GTK_COMBO_BOX(reverb_box), "4X - Reverb Volume x 4");
169 gtk_combo_box_append_text(GTK_COMBO_BOX(reverb_box), "8X - Reverb Volume x 8");
170 gtk_combo_box_set_active(GTK_COMBO_BOX(reverb_box), ReverbBoost);
171
172 debug_check = gtk_check_button_new_with_label("Enable Debug Options");
173 debug_button = gtk_button_new_with_label("Debug...");
174
175 mod_label = gtk_label_new ("Module:");
176 mod_box = gtk_combo_box_new_text ();
177 gtk_combo_box_append_text(GTK_COMBO_BOX(mod_box), "0 - No Sound (emulate SPU2 only)");
178 gtk_combo_box_append_text(GTK_COMBO_BOX(mod_box), "1 - PortAudio (cross-platform)");
179 //gtk_combo_box_append_text(GTK_COMBO_BOX(mod_box), "2 - Alsa (probably doesn't work)");
180 gtk_combo_box_set_active(GTK_COMBO_BOX(mod_box), OutputModule);
181
182 latency_label = gtk_label_new ("Latency:");
183 latency_slide = gtk_hscale_new_with_range(LATENCY_MIN, LATENCY_MAX, 5);
184 gtk_range_set_value(GTK_RANGE(latency_slide), SndOutLatencyMS);
185
186 sync_label = gtk_label_new ("Synchronization Mode:");
187 sync_box = gtk_combo_box_new_text ();
188 gtk_combo_box_append_text(GTK_COMBO_BOX(sync_box), "TimeStretch (Recommended)");
189 gtk_combo_box_append_text(GTK_COMBO_BOX(sync_box), "Async Mix (Breaks some games!)");
190 gtk_combo_box_append_text(GTK_COMBO_BOX(sync_box), "None (Audio can skip.)");
191 gtk_combo_box_set_active(GTK_COMBO_BOX(sync_box), SynchMode);
192
193 advanced_button = gtk_button_new_with_label("Advanced...");
194
195 main_box = gtk_hbox_new(false, 5);
196 main_frame = gtk_frame_new ("Spu2-X Config");
197 gtk_container_add (GTK_CONTAINER(main_frame), main_box);
198
199 mixing_box = gtk_vbox_new(false, 5);
200 mixing_frame = gtk_frame_new ("Mixing Settings:");
201 gtk_container_add (GTK_CONTAINER(mixing_frame), mixing_box);
202
203 output_box = gtk_vbox_new(false, 5);
204 output_frame = gtk_frame_new ("Output Settings:");
205 gtk_container_add (GTK_CONTAINER(output_frame), output_box);
206
207 gtk_container_add(GTK_CONTAINER(mixing_box), int_label);
208 gtk_container_add(GTK_CONTAINER(mixing_box), int_box);
209 gtk_container_add(GTK_CONTAINER(mixing_box), reverb_label);
210 gtk_container_add(GTK_CONTAINER(mixing_box), reverb_box);
211 gtk_container_add(GTK_CONTAINER(mixing_box), effects_check);
212 gtk_container_add(GTK_CONTAINER(mixing_box), debug_check);
213 gtk_container_add(GTK_CONTAINER(mixing_box), debug_button);
214
215 gtk_container_add(GTK_CONTAINER(output_box), mod_label);
216 gtk_container_add(GTK_CONTAINER(output_box), mod_box);
217 gtk_container_add(GTK_CONTAINER(output_box), sync_label);
218 gtk_container_add(GTK_CONTAINER(output_box), sync_box);
219 gtk_container_add(GTK_CONTAINER(output_box), latency_label);
220 gtk_container_add(GTK_CONTAINER(output_box), latency_slide);
221 gtk_container_add(GTK_CONTAINER(output_box), advanced_button);
222
223 gtk_container_add(GTK_CONTAINER(main_box), mixing_frame);
224 gtk_container_add(GTK_CONTAINER(main_box), output_frame);
225
226 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(effects_check), EffectsDisabled);
227 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(debug_check), DebugEnabled);
228
229 gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame);
230 gtk_widget_show_all (dialog);
231
232 g_signal_connect_swapped(GTK_OBJECT (advanced_button), "clicked", G_CALLBACK(advanced_dialog), advanced_button);
233 g_signal_connect_swapped(GTK_OBJECT (debug_button), "clicked", G_CALLBACK(debug_dialog), debug_button);
234
235 return_value = gtk_dialog_run (GTK_DIALOG (dialog));
236
237 if (return_value == GTK_RESPONSE_ACCEPT)
238 {
239 DebugEnabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(debug_check));
240 if (gtk_combo_box_get_active(GTK_COMBO_BOX(int_box)) != -1)
241 Interpolation = gtk_combo_box_get_active(GTK_COMBO_BOX(int_box));
242
243 EffectsDisabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(effects_check));
244
245 if (gtk_combo_box_get_active(GTK_COMBO_BOX(reverb_box)) != -1)
246 ReverbBoost = gtk_combo_box_get_active(GTK_COMBO_BOX(reverb_box));
247
248 if (gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box)) != -1)
249 OutputModule = gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box));
250
251 SndOutLatencyMS = gtk_range_get_value(GTK_RANGE(latency_slide));
252
253 if (gtk_combo_box_get_active(GTK_COMBO_BOX(sync_box)) != -1)
254 SynchMode = gtk_combo_box_get_active(GTK_COMBO_BOX(sync_box));
255 }
256
257 gtk_widget_destroy (dialog);
258 }
259
260 void configure()
261 {
262 initIni();
263 ReadSettings();
264 DisplayDialog();
265 WriteSettings();
266 delete spuConfig;
267 spuConfig = NULL;
268 }

  ViewVC Help
Powered by ViewVC 1.1.22