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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 290 - (show annotations) (download)
Sat Dec 25 02:51:30 2010 UTC (9 years ago) by william
File size: 4945 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 * This library is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by the Free
8 * Software Foundation; either version 2.1 of the the License, or (at your
9 * option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License along
17 * with this library; if not, write to the Free Software Foundation, Inc., 59
18 * Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22 #include "Global.h"
23 #include "Dialogs.h"
24 #include "Config.h"
25 #include "soundtouch/SoundTouch.h"
26
27 namespace SoundtouchCfg
28 {
29 void ClampValues()
30 {
31 Clampify( SequenceLenMS, SequenceLen_Min, SequenceLen_Max );
32 Clampify( SeekWindowMS, SeekWindow_Min, SeekWindow_Max );
33 Clampify( OverlapMS, Overlap_Min, Overlap_Max );
34 }
35
36 void ApplySettings( soundtouch::SoundTouch& sndtouch )
37 {
38 sndtouch.setSetting( SETTING_SEQUENCE_MS, SequenceLenMS );
39 sndtouch.setSetting( SETTING_SEEKWINDOW_MS, SeekWindowMS );
40 sndtouch.setSetting( SETTING_OVERLAP_MS, OverlapMS );
41 }
42
43 void ReadSettings()
44 {
45 SequenceLenMS = CfgReadInt( L"SOUNDTOUCH", L"SequenceLengthMS", 30 );
46 SeekWindowMS = CfgReadInt( L"SOUNDTOUCH", L"SeekWindowMS", 20 );
47 OverlapMS = CfgReadInt( L"SOUNDTOUCH", L"OverlapMS", 10 );
48
49 ClampValues();
50 WriteSettings();
51 }
52
53 void WriteSettings()
54 {
55 CfgWriteInt( L"SOUNDTOUCH", L"SequenceLengthMS", SequenceLenMS );
56 CfgWriteInt( L"SOUNDTOUCH", L"SeekWindowMS", SeekWindowMS );
57 CfgWriteInt( L"SOUNDTOUCH", L"OverlapMS", OverlapMS );
58 }
59
60 static GtkWidget *seq_label, *seek_label, *over_label;
61 static GtkWidget *seq_slide, *seek_slide, *over_slide;
62
63 void restore_defaults()
64 {
65 gtk_range_set_value(GTK_RANGE(seq_slide), 30);
66 gtk_range_set_value(GTK_RANGE(seek_slide), 20);
67 gtk_range_set_value(GTK_RANGE(over_slide), 10);
68 }
69
70 void DisplayDialog()
71 {
72 int return_value;
73 GtkWidget *dialog, *main_label, *main_frame, *main_box;
74 GtkWidget *default_button;
75
76 ReadSettings();
77
78 /* Create the widgets */
79 dialog = gtk_dialog_new_with_buttons (
80 "Advanced Settings",
81 NULL, /* parent window*/
82 (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
83 GTK_STOCK_OK,
84 GTK_RESPONSE_ACCEPT,
85 GTK_STOCK_CANCEL,
86 GTK_RESPONSE_REJECT,
87 NULL);
88
89 main_label = gtk_label_new ("These are advanced configuration options fine tuning time stretching behavior. Larger values are better for slowdown, while smaller values are better for speedup (more then 60 fps.). All options are in microseconds.");
90 gtk_label_set_line_wrap (GTK_LABEL(main_label), true);
91
92 default_button = gtk_button_new_with_label("Reset to Defaults");
93
94 seq_label = gtk_label_new("Sequence Length");
95 seq_slide = gtk_hscale_new_with_range(SequenceLen_Min, SequenceLen_Max, 2);
96 gtk_range_set_value(GTK_RANGE(seq_slide), SequenceLenMS);
97
98 seek_label = gtk_label_new("Seek Window Size");
99 seek_slide = gtk_hscale_new_with_range(SeekWindow_Min, SeekWindow_Max, 1);
100 gtk_range_set_value(GTK_RANGE(seek_slide), SeekWindowMS);
101
102 over_label = gtk_label_new("Overlap");
103 over_slide = gtk_hscale_new_with_range(Overlap_Min, Overlap_Max, 1);
104 gtk_range_set_value(GTK_RANGE(over_slide), OverlapMS);
105
106 main_box = gtk_vbox_new(false, 5);
107 main_frame = gtk_frame_new ("Spu2-X Config");
108
109 gtk_container_add(GTK_CONTAINER (main_box), default_button);
110 gtk_container_add(GTK_CONTAINER (main_box), seq_label);
111 gtk_container_add(GTK_CONTAINER (main_box), seq_slide);
112 gtk_container_add(GTK_CONTAINER (main_box), seek_label);
113 gtk_container_add(GTK_CONTAINER (main_box), seek_slide);
114 gtk_container_add(GTK_CONTAINER (main_box), over_label);
115 gtk_container_add(GTK_CONTAINER (main_box), over_slide);
116 gtk_container_add(GTK_CONTAINER(main_frame), main_box);
117
118 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_label);
119 gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame);
120 gtk_widget_show_all (dialog);
121
122 g_signal_connect_swapped(GTK_OBJECT (default_button), "clicked", G_CALLBACK(restore_defaults), default_button);
123
124 return_value = gtk_dialog_run (GTK_DIALOG (dialog));
125
126 if (return_value == GTK_RESPONSE_ACCEPT)
127 {
128 SequenceLenMS = gtk_range_get_value(GTK_RANGE(seq_slide));;
129 SeekWindowMS = gtk_range_get_value(GTK_RANGE(seek_slide));;
130 OverlapMS = gtk_range_get_value(GTK_RANGE(over_slide));;
131 }
132
133 gtk_widget_destroy (dialog);
134
135 WriteSettings();
136 }
137 }

  ViewVC Help
Powered by ViewVC 1.1.22