Mercurial > audlegacy
comparison Plugins/Input/modplug/gui/main.cpp @ 278:37316876ef6e trunk
[svn] Use modplug instead of mikmod. Supports more formats & compressed files.
author | chainsaw |
---|---|
date | Sat, 10 Dec 2005 14:31:13 -0800 |
parents | |
children | 9d393eabf984 |
comparison
equal
deleted
inserted
replaced
277:0cf2cc6d0fe5 | 278:37316876ef6e |
---|---|
1 /* | |
2 * Initial main.c file generated by Glade. Edit as required. | |
3 * Glade will not overwrite this file. | |
4 */ | |
5 | |
6 #ifdef HAVE_CONFIG_H | |
7 # include <config.h> | |
8 #endif | |
9 | |
10 #include <gtk/gtk.h> | |
11 #include <libintl.h> | |
12 | |
13 #include "interface.h" | |
14 #include "support.h" | |
15 #include "main.h" | |
16 | |
17 #include <sstream> | |
18 //open() | |
19 #include <sys/types.h> | |
20 #include <sys/stat.h> | |
21 #include <fcntl.h> | |
22 //mmap() | |
23 #include <unistd.h> | |
24 #include <sys/mman.h> | |
25 #include <fstream> | |
26 | |
27 #include "../stddefs.h" | |
28 #include <libmodplug/stdafx.h> | |
29 #include <libmodplug/sndfile.h> | |
30 #include "../archive/open.h" | |
31 | |
32 #define MAX_MESSAGE_LENGTH 4000 | |
33 | |
34 GtkWidget *AboutWin = NULL; | |
35 GtkWidget *ConfigWin = NULL; | |
36 GtkWidget *InfoWin = NULL; | |
37 | |
38 void ShowAboutWindow() | |
39 { | |
40 if(!AboutWin) | |
41 AboutWin = create_About(); | |
42 gtk_widget_show(AboutWin); | |
43 } | |
44 | |
45 void ShowConfigureWindow(const ModplugXMMS::Settings& aProps) | |
46 { | |
47 if(!ConfigWin) | |
48 ConfigWin = create_Config(); | |
49 | |
50 if(aProps.mBits == 8) | |
51 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "bit8"), TRUE); | |
52 else | |
53 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "bit16"), TRUE); | |
54 | |
55 if(aProps.mFrequency == 11025) | |
56 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "samp11"), TRUE); | |
57 else if (aProps.mFrequency == 22050) | |
58 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "samp22"), TRUE); | |
59 else | |
60 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "samp44"), TRUE); | |
61 | |
62 if(aProps.mChannels == 1) | |
63 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "mono"), TRUE); | |
64 else | |
65 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "stereo"), TRUE); | |
66 | |
67 if(aProps.mResamplingMode == 0) | |
68 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "resampNearest"), TRUE); | |
69 else if(aProps.mResamplingMode == 1) | |
70 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "resampLinear"), TRUE); | |
71 else if(aProps.mResamplingMode == 2) | |
72 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "resampSpline"), TRUE); | |
73 else | |
74 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "resampPolyphase"), TRUE); | |
75 | |
76 if(aProps.mNoiseReduction) | |
77 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxNR"), TRUE); | |
78 else | |
79 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxNR"), FALSE); | |
80 | |
81 if(aProps.mFastinfo) | |
82 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxFastInfo"), TRUE); | |
83 else | |
84 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxFastInfo"), FALSE); | |
85 | |
86 if(aProps.mUseFilename) | |
87 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxUseFilename"), TRUE); | |
88 else | |
89 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxUseFilename"), FALSE); | |
90 | |
91 if(aProps.mReverb) | |
92 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxReverb"), TRUE); | |
93 else | |
94 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxReverb"), FALSE); | |
95 | |
96 if(aProps.mMegabass) | |
97 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxBassBoost"), TRUE); | |
98 else | |
99 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxBassBoost"), FALSE); | |
100 | |
101 if(aProps.mSurround) | |
102 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxSurround"), TRUE); | |
103 else | |
104 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxSurround"), FALSE); | |
105 | |
106 if(aProps.mPreamp) | |
107 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxPreamp"), TRUE); | |
108 else | |
109 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxPreamp"), FALSE); | |
110 | |
111 gtk_adjustment_set_value(gtk_range_get_adjustment((GtkRange*)lookup_widget(ConfigWin, "fxReverbDepth")), aProps.mReverbDepth); | |
112 gtk_adjustment_set_value(gtk_range_get_adjustment((GtkRange*)lookup_widget(ConfigWin, "fxReverbDelay")), aProps.mReverbDelay); | |
113 gtk_adjustment_set_value(gtk_range_get_adjustment((GtkRange*)lookup_widget(ConfigWin, "fxBassAmount")), aProps.mBassAmount); | |
114 gtk_adjustment_set_value(gtk_range_get_adjustment((GtkRange*)lookup_widget(ConfigWin, "fxBassRange")), aProps.mBassRange); | |
115 gtk_adjustment_set_value(gtk_range_get_adjustment((GtkRange*)lookup_widget(ConfigWin, "fxSurroundDepth")), aProps.mSurroundDepth); | |
116 gtk_adjustment_set_value(gtk_range_get_adjustment((GtkRange*)lookup_widget(ConfigWin, "fxSurroundDelay")), aProps.mSurroundDelay); | |
117 gtk_adjustment_set_value(gtk_range_get_adjustment((GtkRange*)lookup_widget(ConfigWin, "fxPreampLevel")), aProps.mPreampLevel); | |
118 | |
119 if(aProps.mLoopCount < 0) | |
120 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxLoopForever"), TRUE); | |
121 else if(aProps.mLoopCount == 0) | |
122 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxNoLoop"), TRUE); | |
123 else | |
124 { | |
125 gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(ConfigWin, "fxLoopFinite"), TRUE); | |
126 gtk_adjustment_set_value(gtk_spin_button_get_adjustment( | |
127 (GtkSpinButton*)lookup_widget(ConfigWin, "fxLoopCount")), aProps.mLoopCount); | |
128 } | |
129 | |
130 gtk_widget_show(ConfigWin); | |
131 } | |
132 | |
133 void ShowInfoWindow(const string& aFilename) | |
134 { | |
135 if(!InfoWin) | |
136 InfoWin = create_Info(); | |
137 | |
138 uint32 lSongTime, lNumSamples, lNumInstruments, i; | |
139 string lInfo; | |
140 char lBuffer[33]; | |
141 stringstream lStrStream(ios::out); //C++ replacement for sprintf() | |
142 | |
143 CSoundFile* lSoundFile; | |
144 | |
145 Archive* lArchive; | |
146 string lShortFN; | |
147 uint32 lPos; | |
148 | |
149 lPos = aFilename.find_last_of('/') + 1; | |
150 lShortFN = aFilename.substr(lPos); | |
151 | |
152 //open and mmap the file | |
153 lArchive = OpenArchive(aFilename); | |
154 if(lArchive->Size() == 0) | |
155 { | |
156 delete lArchive; | |
157 return; | |
158 } | |
159 | |
160 lSoundFile = new CSoundFile; | |
161 lSoundFile->Create((uchar*)lArchive->Map(), lArchive->Size()); | |
162 | |
163 lInfo = lShortFN; | |
164 lInfo += '\n'; | |
165 lInfo += lSoundFile->GetTitle(); | |
166 lInfo += '\n'; | |
167 | |
168 switch(lSoundFile->GetType()) | |
169 { | |
170 case MOD_TYPE_MOD: | |
171 lInfo+= "ProTracker"; | |
172 break; | |
173 case MOD_TYPE_S3M: | |
174 lInfo+= "Scream Tracker 3"; | |
175 break; | |
176 case MOD_TYPE_XM: | |
177 lInfo+= "Fast Tracker 2"; | |
178 break; | |
179 case MOD_TYPE_IT: | |
180 lInfo+= "Impulse Tracker"; | |
181 break; | |
182 case MOD_TYPE_MED: | |
183 lInfo+= "OctaMed"; | |
184 break; | |
185 case MOD_TYPE_MTM: | |
186 lInfo+= "MTM"; | |
187 break; | |
188 case MOD_TYPE_669: | |
189 lInfo+= "669 Composer / UNIS 669"; | |
190 break; | |
191 case MOD_TYPE_ULT: | |
192 lInfo+= "ULT"; | |
193 break; | |
194 case MOD_TYPE_STM: | |
195 lInfo+= "Scream Tracker"; | |
196 break; | |
197 case MOD_TYPE_FAR: | |
198 lInfo+= "Farandole"; | |
199 break; | |
200 case MOD_TYPE_AMF: | |
201 lInfo+= "ASYLUM Music Format"; | |
202 break; | |
203 case MOD_TYPE_AMS: | |
204 lInfo+= "AMS module"; | |
205 break; | |
206 case MOD_TYPE_DSM: | |
207 lInfo+= "DSIK Internal Format"; | |
208 break; | |
209 case MOD_TYPE_MDL: | |
210 lInfo+= "DigiTracker"; | |
211 break; | |
212 case MOD_TYPE_OKT: | |
213 lInfo+= "Oktalyzer"; | |
214 break; | |
215 case MOD_TYPE_DMF: | |
216 lInfo+= "Delusion Digital Music Fileformat (X-Tracker)"; | |
217 break; | |
218 case MOD_TYPE_PTM: | |
219 lInfo+= "PolyTracker"; | |
220 break; | |
221 case MOD_TYPE_DBM: | |
222 lInfo+= "DigiBooster Pro"; | |
223 break; | |
224 case MOD_TYPE_MT2: | |
225 lInfo+= "MT2"; | |
226 break; | |
227 case MOD_TYPE_AMF0: | |
228 lInfo+= "AMF0"; | |
229 break; | |
230 case MOD_TYPE_PSM: | |
231 lInfo+= "PSM"; | |
232 break; | |
233 default: | |
234 lInfo+= "Unknown"; | |
235 break; | |
236 } | |
237 lInfo += '\n'; | |
238 | |
239 lSongTime = lSoundFile->GetSongTime(); | |
240 lStrStream.clear(); | |
241 lStrStream << (int)(lSongTime / 60) << ":"; | |
242 if(lSongTime % 60 < 10) //single digit for seconds? | |
243 lStrStream << '0'; //yes, so add a 0. | |
244 lStrStream << (int)(lSongTime % 60); | |
245 | |
246 lStrStream << '\n'; | |
247 | |
248 lStrStream << (int)lSoundFile->GetMusicSpeed() << '\n'; | |
249 lStrStream << (int)lSoundFile->GetMusicTempo() << '\n'; | |
250 lStrStream << (int)(lNumSamples = lSoundFile->GetNumSamples()) << '\n'; | |
251 lStrStream << (int)(lNumInstruments = lSoundFile->GetNumInstruments()); | |
252 lStrStream << '\n'; | |
253 lStrStream << (int)(lSoundFile->GetNumPatterns()) << '\n'; | |
254 lStrStream << (int)lSoundFile->GetNumChannels(); | |
255 lInfo += lStrStream.str(); | |
256 | |
257 gtk_label_set_text((GtkLabel*)lookup_widget(InfoWin, "info_general"), lInfo.c_str()); | |
258 | |
259 lInfo = ""; | |
260 for(i = 0; i < lNumSamples; i++) | |
261 { | |
262 lSoundFile->GetSampleName(i, lBuffer); | |
263 lInfo += lBuffer; | |
264 lInfo += '\n'; | |
265 } | |
266 gtk_label_set_text((GtkLabel*)lookup_widget(InfoWin, "info_samples"), lInfo.c_str()); | |
267 | |
268 lInfo = ""; | |
269 for(i = 0; i < lNumInstruments; i++) | |
270 { | |
271 lSoundFile->GetInstrumentName(i, lBuffer); | |
272 lInfo += lBuffer; | |
273 lInfo += '\n'; | |
274 } | |
275 gtk_label_set_text((GtkLabel*)lookup_widget(InfoWin, "info_instruments"), lInfo.c_str()); | |
276 | |
277 char message[MAX_MESSAGE_LENGTH]; | |
278 static int length = 0; | |
279 | |
280 //textbox = (GtkLabel*)lookup_widget(InfoWin, "info_message"); | |
281 //gtk_text_backward_delete(textbox, length); | |
282 length = lSoundFile->GetSongComments(message, MAX_MESSAGE_LENGTH, 80); | |
283 if (length != 0) { | |
284 gtk_label_set_text((GtkLabel*)lookup_widget(InfoWin, "info_message"), message); | |
285 } | |
286 | |
287 //unload the file | |
288 lSoundFile->Destroy(); | |
289 delete lSoundFile; | |
290 delete lArchive; | |
291 | |
292 gtk_widget_show(InfoWin); | |
293 } |