10 #include "w32g_pref.h"
13 //
\83G
\83\89\81[
\89ñ
\94ð
\97p (w32g_c.c, w32g_i.c, w32g_ut2.c
\93\99\82Ì
\91ã
\91Ö
14 int PlayerLanguage = LANGUAGE_JAPANESE; //LANGUAGE_ENGLISH;
15 int IniFileAutoSave = 1;
19 char *PlaylistHistoryFile;
20 char *MidiFileOpenDir;
21 char *ConfigFileOpenDir;
22 char *PlaylistFileOpenDir;
24 BOOL PosSizeSave = TRUE;
27 int AutoloadPlaylist = 0;
28 int AutosavePlaylist = 0;
29 int SeachDirRecursive = 0;
30 int DocWndIndependent = 0;
31 int DocWndAutoPopup = 0;
33 int PlayerThreadPriority;
34 int MidiPlayerThreadPriority;
35 int MainThreadPriority;
36 int GUIThreadPriority;
37 int TracerThreadPriority;
38 int WrdThreadPriority;
40 int InitMinimizeFlag = 0;
41 int main_panel_update_time = 10;
42 int DebugWndStartFlag = 1;
43 int ConsoleWndStartFlag = 0;
44 int ListWndStartFlag = 0;
45 int TracerWndStartFlag = 0;
46 int DocWndStartFlag = 0;
47 int WrdWndStartFlag = 0;
48 int SoundSpecWndStartFlag = 0;
50 int ConsoleWndFlag = 1;
52 int TracerWndFlag = 0;
55 int SoundSpecWndFlag = 0;
58 char *w32g_output_dir = NULL;
59 int w32g_auto_output_mode = 0;
60 int w32g_lock_open_file = 0;
61 WRDTracer w32g_wrdt_mode;
63 int playlist_max_ini = 1;
64 int ConsoleClearFlag = 0;
66 extern char *opt_reduce_voice_threshold;
67 extern char *opt_reduce_quality_threshold;
68 extern char *opt_reduce_polyphony_threshold;
80 HWND hSoundSpecWnd = 0;
81 HWND hDebugEditWnd = 0;
87 HANDLE hMainThread = 0;
88 HANDLE hPlayerThread = 0;
89 HANDLE hMainThreadInfo = 0;
90 DWORD dwMainThreadID = 0;
92 void TracerWndApplyQuietChannel(ChannelBitMask quietchannels_){}
93 void w32g_restart(void){}
94 void w32g_send_rc(int rc, ptr_size_t value){}
95 void w32g_i_init(void){}
96 void w32g_ext_control_main_thread(int rc, ptr_size_t value){}
99 static int ctl_open(int using_stdin, int using_stdout){}
100 static void ctl_close(void){}
101 static int ctl_pass_playing_list(int number_of_files, char *list_of_files[]){}
102 static void ctl_event(CtlEvent *e){}
103 static int ctl_read(ptr_size_t *valp){}
104 static int cmsg(int type, int verbosity_level, char *fmt, ...){}
105 #define ctl w32gui_control_mode
106 #define CTL_STATUS_UPDATE -98
109 "Win32 GUI interface", 'w',
112 CTLF_AUTOSTART | CTLF_DRAG_START,
115 ctl_pass_playing_list,
123 //
\82±
\82±
\82©
\82çsetup
\82Ì
\83\81\83C
\83\93\95\94\95ª
125 char IniPath[FILEPATH_MAX] = "";
128 // w32_utl.c
\82Å
\8eg
\97p
129 void get_ini_path(char *ini)
132 strcpy(ini, (const char *)&IniPath);
135 // timidity_start_initialize()
136 void config_gui_start_initialize(void)
139 static int drums[] = DEFAULT_DRUMCHANNELS;
140 static int is_first = 1;
142 #if defined(__FreeBSD__) && !defined(__alpha__)
144 #elif defined(__NetBSD__) || defined(__OpenBSD__)
147 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
149 fpsetmask(fpexp & ~(FP_X_INV|FP_X_DZ));
151 if(!output_text_code)
152 output_text_code = safe_strdup(OUTPUT_TEXT_CODE);
154 opt_aq_max_buff = safe_strdup("5.0");
155 if(!opt_aq_fill_buff)
156 opt_aq_fill_buff = safe_strdup("100%");
157 if(!opt_reduce_voice_threshold)
158 opt_reduce_voice_threshold = safe_strdup("75%");
159 if(!opt_reduce_quality_threshold)
160 opt_reduce_quality_threshold = safe_strdup("99%");
161 if(!opt_reduce_polyphony_threshold)
162 opt_reduce_polyphony_threshold = safe_strdup("85%");
164 /* Check the byte order */
172 fprintf(stderr, "Byte order is miss configured.\n");
175 for(i = 0; i < MAX_CHANNELS; i++)
176 memset(&(channel[i]), 0, sizeof(Channel));
177 CLEAR_CHANNELMASK(quietchannels);
178 CLEAR_CHANNELMASK(default_drumchannels);
179 for(i = 0; drums[i] > 0; i++)
180 SET_CHANNELMASK(default_drumchannels, drums[i] - 1);
181 #if MAX_CHANNELS > 16
182 for(i = 16; i < MAX_CHANNELS; i++)
183 if(IS_SET_CHANNELMASK(default_drumchannels, i & 0xF))
184 SET_CHANNELMASK(default_drumchannels, i);
186 if(program_name == NULL)
187 program_name = "TiMidity";
188 uudecode_unquote_html = 1;
189 for(i = 0; i < MAX_CHANNELS; i++){
190 default_program[i] = DEFAULT_PROGRAM;
191 special_program[i] = -1;
192 memset(channel[i].drums, 0, sizeof(channel[i].drums));
194 if(play_mode == NULL)
195 play_mode = &null_play_mode;
198 // void timidity_init_player()
199 void config_gui_init_player(void)
201 // initialize_resampler_coeffs();
202 /* Allocate voice[] */
205 // voice = (Voice*) safe_calloc(max_voices, sizeof(Voice));
206 //memset(voice, 0, sizeof(voice));
207 /* Set play mode parameters */
208 if(opt_output_rate != 0)
209 play_mode->rate = opt_output_rate;
210 else if(play_mode->rate == 0)
211 play_mode->rate = DEFAULT_RATE;
213 COPY_CHANNELMASK(drumchannels, default_drumchannels);
214 COPY_CHANNELMASK(drumchannel_mask, default_drumchannel_mask);
215 if(opt_buffer_fragments != -1)
217 if(play_mode->flag & PF_BUFF_FRAGM_OPT)
218 play_mode->extra_param[0] = opt_buffer_fragments;
221 opt_buffer_fragments = 64;
222 if(opt_audio_buffer_bits != -1)
223 audio_buffer_bits = opt_audio_buffer_bits;
225 opt_audio_buffer_bits = audio_buffer_bits;
227 if(opt_compute_buffer_bits != -128)
228 compute_buffer_bits = opt_compute_buffer_bits;
230 opt_compute_buffer_bits = compute_buffer_bits;
231 init_output(); // div_playmode_rate
236 void config_gui_main(void)
239 timdrvOverrideSFSettingLoad();
240 #if defined(VST_LOADER_ENABLE)
241 if (hVSTHost == NULL) {
242 // ini
\82Ì
\83f
\83B
\83\8c\83N
\83g
\83\8a\82É
\82 \82é timvstwrap.dll
244 char WrapPath[FILEPATH_MAX] = "";
245 for(i = 0; i < FILEPATH_MAX; i++){
246 if(IniPath[i] == '\0')
248 else if(IniPath[i] == '\\')
253 for(i = 0; i < last; i++){
254 WrapPath[j++] = IniPath[i];
258 strcat(WrapPath, "\\timvstwrap_x64.dll\0");
260 strcat(WrapPath, "\\timvstwrap.dll\0");
264 hVSTHost = LoadLibrary(WrapPath);
265 if (hVSTHost == NULL){
267 hVSTHost = LoadLibrary("timvstwrap_x64.dll");
269 hVSTHost = LoadLibrary("timvstwrap.dll");
272 if (hVSTHost != NULL) {
273 ((vst_open)GetProcAddress(hVSTHost, "vstOpen"))();
277 // timidity_start_initialize()
278 config_gui_start_initialize();
279 timidity_post_load_configuration();
280 config_gui_init_player();
284 void config_gui_main_close(void)
288 safe_free(play_mode->name);
289 play_mode->name = NULL;
290 #ifdef SUPPORT_SOCKET
291 safe_free(url_user_agent);
292 url_user_agent = NULL;
293 safe_free(url_http_proxy_host);
294 url_http_proxy_host = NULL;
295 safe_free(url_ftp_proxy_host);
296 url_ftp_proxy_host = NULL;
297 safe_free(user_mailaddr);
298 user_mailaddr = NULL;
301 safe_free(dynamic_lib_root);
302 dynamic_lib_root = NULL;
304 safe_free(pcm_alternate_file);
305 pcm_alternate_file = NULL;
306 safe_free(opt_output_name);
307 opt_output_name = NULL;
308 safe_free(opt_aq_max_buff);
309 opt_aq_max_buff = NULL;
310 safe_free(opt_aq_fill_buff);
311 opt_aq_fill_buff = NULL;
312 safe_free(opt_reduce_voice_threshold);
313 opt_reduce_voice_threshold = NULL;
314 safe_free(opt_reduce_quality_threshold);
315 opt_reduce_quality_threshold = NULL;
316 safe_free(opt_reduce_polyphony_threshold);
317 opt_reduce_polyphony_threshold = NULL;
318 safe_free(output_text_code);
319 output_text_code = NULL;
320 safe_free(wrdt_open_opts);
321 wrdt_open_opts = NULL;
332 free_global_mblock();
334 //free_reverb_buffer();
335 free_effect_buffers();
340 uninitialize_resampler_coeffs();
341 for (i = 0; i < MAX_CHANNELS; i++)
343 #ifdef VST_LOADER_ENABLE
344 if (hVSTHost != NULL) {
345 ((vst_close)GetProcAddress(hVSTHost,"vstClose"))();
346 FreeLibrary(hVSTHost);
352 HINSTANCE hInst = NULL;
353 HWND hConfigWnd = NULL;
355 void set_config_hwnd(HWND hwnd)
362 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
366 #if defined(TIMIDITY_LEAK_CHECK)
367 _CrtSetDbgFlag(CRTDEBUGFLAGS);
370 hIcon = (HICON *)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_TIMIDITY), IMAGE_ICON, 16, 16, 0);
371 if ( hConfigWnd != NULL ) {
372 DestroyWindow ( hConfigWnd );
376 PrefWndCreate(NULL, 0); // set hConfigWnd
378 SendMessage(hConfigWnd, WM_SETICON,FALSE, (LPARAM)hIcon);
379 { // Set the title of the main window again.
381 SendMessage( hConfigWnd, WM_GETTEXT, (WPARAM)255, (LPARAM)buffer);
382 SendMessage( hConfigWnd, WM_SETTEXT, (WPARAM)0, (LPARAM)buffer);
386 ShowWindow(hConfigWnd, nCmdShow);
387 UpdateWindow(hConfigWnd);
391 int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
393 static int init_flg = 0;
402 char buffer[FILEPATH_MAX] = {0};
403 GetWindowsDirectory(buffer, FILEPATH_MAX - 1);
404 if (IS_PATH_SEP(buffer[strlen(buffer) - 1]))
405 buffer[strlen(buffer) - 1] = 0;
406 strlcat(buffer, "\\", FILEPATH_MAX);
407 strlcat(buffer, "timdrv_soundfont.ini", FILEPATH_MAX);
408 strncpy(IniPath, buffer, FILEPATH_MAX);
410 if (!InitInstance (hInstance, nCmdShow)) // Create Window
412 hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CONFIG_GUI));
413 while (GetMessage(&msg, NULL, 0, 0)){ // message loop
414 if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)){
415 TranslateMessage(&msg);
416 DispatchMessage(&msg);
419 return (int) msg.wParam;