📄 w32g_utl.c
字号:
extern int set_play_mode(char *cp);extern int set_tim_opt(int c, char *optarg);extern int set_ctl(char *cp);extern int set_wrd(char *w);#if defined(__W32__) && defined(SMFCONV)extern int opt_rcpcv_dll;#endif /* SMFCONV */extern char *wrdt_open_opts;static int is_device_output_ID(int id){ return id == 'd' || id == 'n' || id == 'e';}#ifdef IA_W32G_SYNextern int w32g_syn_id_port[];extern int syn_AutoStart;extern DWORD processPriority;extern DWORD syn_ThreadPriority;extern int w32g_syn_port_num;extern int volatile stream_max_compute;#endifvoidApplySettingTiMidity(SETTING_TIMIDITY *st){ int i; char buffer[INI_MAXLEN]; /* Player must be stopped. * DANGER to apply settings while playing. */ amplification = SetValue(st->amplification, 0, MAX_AMPLIFICATION); antialiasing_allowed = SetFlag(st->antialiasing_allowed); if(st->buffer_fragments == -1) opt_buffer_fragments = -1; else opt_buffer_fragments = SetValue(st->buffer_fragments, 3, 1000); default_drumchannels = st->default_drumchannels; default_drumchannel_mask = st->default_drumchannel_mask; opt_modulation_wheel = SetFlag(st->opt_modulation_wheel); opt_portamento = SetFlag(st->opt_portamento); opt_nrpn_vibrato = SetFlag(st->opt_nrpn_vibrato); opt_channel_pressure = SetFlag(st->opt_channel_pressure); opt_trace_text_meta_event = SetFlag(st->opt_trace_text_meta_event); opt_overlap_voice_allow = SetFlag(st->opt_overlap_voice_allow); opt_default_mid = st->opt_default_mid; default_tonebank = st->default_tonebank; special_tonebank = st->special_tonebank; effect_lr_mode = st->effect_lr_mode; effect_lr_delay_msec = st->effect_lr_delay_msec; opt_reverb_control = st->opt_reverb_control; opt_chorus_control = st->opt_chorus_control; opt_surround_chorus = st->opt_surround_chorus; noise_sharp_type = st->noise_sharp_type; opt_evil_mode = st->opt_evil_mode; opt_tva_attack = st->opt_tva_attack; opt_tva_decay = st->opt_tva_decay; opt_tva_release = st->opt_tva_release; opt_delay_control = st->opt_delay_control; opt_default_module = st->opt_default_module; opt_lpf_def = st->opt_lpf_def; opt_drum_effect = st->opt_drum_effect; opt_modulation_envelope = st->opt_modulation_envelope; opt_pan_delay = st->opt_pan_delay; opt_eq_control = st->opt_eq_control; opt_insertion_effect = st->opt_insertion_effect; adjust_panning_immediately = SetFlag(st->adjust_panning_immediately); fast_decay = SetFlag(st->fast_decay);#ifdef SUPPORT_SOUNDSPEC view_soundspec_flag = SetFlag(st->view_soundspec_flag); spectrigram_update_sec = st->spectrigram_update_sec;#endif for(i = 0; i < MAX_CHANNELS; i++) default_program[i] = st->default_program[i]; set_ctl(st->opt_ctl); opt_realtime_playing = SetFlag(st->opt_realtime_playing); reduce_voice_threshold = st->reduce_voice_threshold; set_play_mode(st->opt_playmode); strncpy(OutputName,st->OutputName,MAXPATH);#if 0 if(OutputName[0] && !is_device_output_ID(play_mode->id_character)) play_mode->name = strdup(OutputName); // 儊儌儕儕乕僋偡傞偐側丠 偼偢偡偲偩傔偩偟丅#else if(OutputName[0] && !is_device_output_ID(play_mode->id_character)) play_mode->name = OutputName;#endif strncpy(w32g_output_dir,st->OutputDirName,MAXPATH); w32g_output_dir[MAXPATH-1] = '\0'; w32g_auto_output_mode = st->auto_output_mode; opt_output_rate = st->output_rate; if(st->output_rate) play_mode->rate = SetValue(st->output_rate, MIN_OUTPUT_RATE, MAX_OUTPUT_RATE); else if(play_mode->rate == 0) play_mode->rate = DEFAULT_RATE; voices = st->voices; auto_reduce_polyphony = st->auto_reduce_polyphony; quietchannels = st->quietchannels; temper_type_mute = st->temper_type_mute; if(opt_aq_max_buff) free(opt_aq_max_buff); if(opt_aq_fill_buff) free(opt_aq_fill_buff); strcpy(buffer, st->opt_qsize); opt_aq_max_buff = buffer; opt_aq_fill_buff = strchr(opt_aq_max_buff, '/'); *opt_aq_fill_buff++ = '\0'; opt_aq_max_buff = safe_strdup(opt_aq_max_buff); opt_aq_fill_buff = safe_strdup(opt_aq_fill_buff); modify_release = SetValue(st->modify_release, 0, MAX_MREL); allocate_cache_size = st->allocate_cache_size; key_adjust = st->key_adjust; opt_force_keysig = st->opt_force_keysig; opt_pure_intonation = st->opt_pure_intonation; opt_init_keysig = st->opt_init_keysig; if(output_text_code) free(output_text_code); output_text_code = safe_strdup(st->output_text_code); free_instruments_afterwards = st->free_instruments_afterwards; set_wrd(st->opt_wrd);#if defined(__W32__) && defined(SMFCONV) opt_rcpcv_dll = st->opt_rcpcv_dll;#endif /* SMFCONV */ opt_control_ratio = st->control_ratio; if(opt_control_ratio) control_ratio = SetValue(opt_control_ratio, 1, MAX_CONTROL_RATIO); else { control_ratio = play_mode->rate / CONTROLS_PER_SECOND; control_ratio = SetValue(control_ratio, 1, MAX_CONTROL_RATIO); } opt_drum_power = SetValue(st->opt_drum_power, 0, MAX_AMPLIFICATION); opt_amp_compensation = st->opt_amp_compensation; data_block_bits = st->data_block_bits; data_block_num = st->data_block_num;#ifdef IA_W32G_SYN for ( i = 0; i < MAX_PORT; i ++ ) { w32g_syn_id_port[i] = st->SynIDPort[i]; } syn_AutoStart = st->syn_AutoStart; processPriority = st->processPriority; syn_ThreadPriority = st->syn_ThreadPriority; w32g_syn_port_num = st->SynPortNum; stream_max_compute = st->SynShTime;#endif}voidSaveSettingTiMidity(SETTING_TIMIDITY *st){ int i, j; st->amplification = SetValue(amplification, 0, MAX_AMPLIFICATION); st->antialiasing_allowed = SetFlag(antialiasing_allowed); st->buffer_fragments = opt_buffer_fragments; st->control_ratio = SetValue(opt_control_ratio, 0, MAX_CONTROL_RATIO); st->default_drumchannels = default_drumchannels; st->default_drumchannel_mask = default_drumchannel_mask; st->opt_modulation_wheel = SetFlag(opt_modulation_wheel); st->opt_portamento = SetFlag(opt_portamento); st->opt_nrpn_vibrato = SetFlag(opt_nrpn_vibrato); st->opt_channel_pressure = SetFlag(opt_channel_pressure); st->opt_trace_text_meta_event = SetFlag(opt_trace_text_meta_event); st->opt_overlap_voice_allow = SetFlag(opt_overlap_voice_allow); st->opt_default_mid = opt_default_mid; st->default_tonebank = default_tonebank; st->special_tonebank = special_tonebank; st->effect_lr_mode = effect_lr_mode; st->effect_lr_delay_msec = effect_lr_delay_msec; st->opt_reverb_control = opt_reverb_control; st->opt_chorus_control = opt_chorus_control; st->opt_surround_chorus = opt_surround_chorus; st->opt_tva_attack = opt_tva_attack; st->opt_tva_decay = opt_tva_decay; st->opt_tva_release = opt_tva_release; st->opt_delay_control = opt_delay_control; st->opt_default_module = opt_default_module; st->opt_lpf_def = opt_lpf_def; st->opt_drum_effect = opt_drum_effect; st->opt_modulation_envelope = opt_modulation_envelope; st->opt_pan_delay = opt_pan_delay; st->opt_eq_control = opt_eq_control; st->opt_insertion_effect = opt_insertion_effect; st->noise_sharp_type = noise_sharp_type; st->opt_evil_mode = SetFlag(opt_evil_mode); st->adjust_panning_immediately = SetFlag(adjust_panning_immediately); st->fast_decay = SetFlag(fast_decay);#ifdef SUPPORT_SOUNDSPEC st->view_soundspec_flag = SetFlag(view_soundspec_flag); st->spectrigram_update_sec = spectrigram_update_sec;#endif for(i = 0; i < MAX_CHANNELS; i++) { if(def_instr_name[0]) st->default_program[i] = SPECIAL_PROGRAM; else st->default_program[i] = default_program[i]; } j = 0; st->opt_ctl[j++] = ctl->id_character; for(i = 1; i < ctl->verbosity; i++) st->opt_ctl[j++] = 'v'; for(i = 1; i > ctl->verbosity; i--) st->opt_ctl[j++] = 'q'; if(ctl->trace_playing) st->opt_ctl[j++] = 't'; if(ctl->flags & CTLF_LIST_LOOP) st->opt_ctl[j++] = 'l'; if(ctl->flags & CTLF_LIST_RANDOM) st->opt_ctl[j++] = 'r'; if(ctl->flags & CTLF_LIST_SORT) st->opt_ctl[j++] = 's'; if(ctl->flags & CTLF_AUTOSTART) st->opt_ctl[j++] = 'a'; if(ctl->flags & CTLF_AUTOEXIT) st->opt_ctl[j++] = 'x'; if(ctl->flags & CTLF_DRAG_START) st->opt_ctl[j++] = 'd'; if(ctl->flags & CTLF_AUTOUNIQ) st->opt_ctl[j++] = 'u'; if(ctl->flags & CTLF_AUTOREFINE) st->opt_ctl[j++] = 'R'; if(ctl->flags & CTLF_NOT_CONTINUE) st->opt_ctl[j++] = 'C'; st->opt_ctl[j] = '\0'; st->opt_realtime_playing = SetFlag(opt_realtime_playing); st->reduce_voice_threshold = reduce_voice_threshold; j = 0; st->opt_playmode[j++] = play_mode->id_character; st->opt_playmode[j++] = ((play_mode->encoding & PE_MONO) ? 'M' : 'S'); st->opt_playmode[j++] = ((play_mode->encoding & PE_SIGNED) ? 's' : 'u'); if (play_mode->encoding & PE_24BIT) {st->opt_playmode[j++] = '2';} else if (play_mode->encoding & PE_16BIT) {st->opt_playmode[j++] = '1';} else {st->opt_playmode[j++] = '8';} if(play_mode->encoding & PE_ULAW) st->opt_playmode[j++] = 'U'; else if(play_mode->encoding & PE_ALAW) st->opt_playmode[j++] = 'A'; else st->opt_playmode[j++] = 'l'; if(play_mode->encoding & PE_BYTESWAP) st->opt_playmode[j++] = 'x'; st->opt_playmode[j] = '\0'; strncpy(st->OutputName,OutputName,sizeof(st->OutputName)-1); strncpy(st->OutputDirName,w32g_output_dir,MAXPATH); st->OutputDirName[MAXPATH-1] = '\0'; st->auto_output_mode = w32g_auto_output_mode; st->voices = voices; st->auto_reduce_polyphony = auto_reduce_polyphony; st->quietchannels = quietchannels; st->temper_type_mute = temper_type_mute; snprintf(st->opt_qsize,sizeof(st->opt_qsize),"%s/%s", opt_aq_max_buff,opt_aq_fill_buff); st->modify_release = SetValue(modify_release, 0, MAX_MREL); st->allocate_cache_size = allocate_cache_size; st->opt_drum_power = SetValue(opt_drum_power, 0, MAX_AMPLIFICATION); st->opt_amp_compensation = opt_amp_compensation; st->key_adjust = key_adjust; st->opt_force_keysig = opt_force_keysig; st->opt_pure_intonation = opt_pure_intonation; st->opt_init_keysig = opt_init_keysig; st->output_rate = opt_output_rate; if(st->output_rate == 0) { st->output_rate = play_mode->rate; if(st->output_rate == 0) st->output_rate = DEFAULT_RATE; } st->output_rate = SetValue(st->output_rate,MIN_OUTPUT_RATE,MAX_OUTPUT_RATE); strncpy(st->output_text_code,output_text_code,sizeof(st->output_text_code)-1); st->free_instruments_afterwards = free_instruments_afterwards; st->opt_wrd[0] = wrdt->id; if(wrdt_open_opts) strncpy(st->opt_wrd + 1, wrdt_open_opts, sizeof(st->opt_wrd) - 2); else st->opt_wrd[1] = '\0';#if defined(__W32__) && defined(SMFCONV) st->opt_rcpcv_dll = opt_rcpcv_dll;#endif /* SMFCONV */ st->data_block_bits = data_block_bits; st->data_block_num = data_block_num;#ifdef IA_W32G_SYN for ( i = 0; i < MAX_PORT; i ++ ) { st->SynIDPort[i] = w32g_syn_id_port[i]; } st->syn_AutoStart = syn_AutoStart; st->processPriority = processPriority; st->syn_ThreadPriority = syn_ThreadPriority; st->SynPortNum = w32g_syn_port_num; st->SynShTime = stream_max_compute;#endif}//****************************************************************************/// ini & configstatic char S_IniFile[MAXPATH + 32];static char S_timidity_window_inifile[MAXPATH + 32];static char S_timidity_output_inifile[MAXPATH + 32];static char S_ConfigFile[MAXPATH + 32];static char S_PlaylistFile[MAXPATH + 32];static char S_PlaylistHistoryFile[MAXPATH + 32];static char S_MidiFileOpenDir[MAXPATH + 32];static char S_ConfigFileOpenDir[MAXPATH + 32];static char S_PlaylistFileOpenDir[MAXPATH + 32];static char S_DocFileExt[256];static char S_OutputName[MAXPATH + 32];static char *OutputName;static char S_w32g_output_dir[1024 + 32];static char S_SystemFont[256];static char S_PlayerFont[256];static char S_WrdFont[256];static char S_DocFont[256];static char S_ListFont[256];static char S_TracerFont[256];static char *SystemFont = S_SystemFont;char *PlayerFont = S_PlayerFont;static char *WrdFont = S_WrdFont;static char *DocFont = S_DocFont;static char *ListFont = S_ListFont;static char *TracerFont = S_TracerFont;//static HFONT hSystemFont = 0;//static HFONT hPlayerFont = 0;//static HFONT hWrdFont = 0;//static HFONT hDocFont = 0;//static HFONT hListFont = 0;//static HFONT hTracerFont = 0;static int SystemFontSize = 9;static int PlayerFontSize = 16;static int WrdFontSize = 16;static int DocFontSize = 16;static int ListFontSize = 16;static int TracerFontSize = 16;#define DEFAULT_DOCFILEEXT "doc;txt;hed"SETTING_PLAYER *sp_default, *sp_current, *sp_temp;SETTING_TIMIDITY *st_default, *st_current, *st_temp;char *timidity_window_inifile;char *timidity_output_inifile;#ifdef AU_GOGOextern int gogo_ConfigDialogInfoInit(void);extern int gogo_ConfigDialogInfoSaveINI(void);extern int gogo_ConfigDialogInfoLoadINI(void);#endif#ifdef AU_VORBISextern int vorbis_ConfigDialogInfoInit(void);extern int vorbis_ConfigDialogInfoSaveINI(void);extern int vorbis_ConfigDialogInfoLoadINI(void);#endifvoid w32g_initialize(void){ char buffer[MAXPATH + 1024]; char *p; hInst = GetModuleHandle(0); IniFile = S_IniFile; ConfigFile = S_ConfigFile; PlaylistFile = S_PlaylistFile; PlaylistHistoryFile = S_PlaylistHistoryFile; MidiFileOpenDir = S_MidiFileOpenDir; ConfigFileOpenDir = S_ConfigFileOpenDir; PlaylistFileOpenDir = S_PlaylistFileOpenDir; DocFileExt = S_DocFileExt; OutputName = S_OutputName; w32g_output_dir = S_w32g_output_dir; IniFile[0] = '\0'; ConfigFile[0] = '\0'; PlaylistFile[0] = '\0'; PlaylistHistoryFile[0] = '\0'; MidiFileOpenDir[0] = '\0'; ConfigFileOpenDir[0] = '\0'; PlaylistFileOpenDir[0] = '\0'; OutputName[0] = '\0'; w32g_output_dir[0] = '\0'; strcpy(DocFileExt,DEFAULT_DOCFILEEXT); strcpy(SystemFont,"俵俽 柧挬"); strcpy(PlayerFont,"俵俽 柧挬"); strcpy(WrdFont,"俵俽 柧挬"); strcpy(DocFont,"俵俽 柧挬"); strcpy(ListFont,"俵俽 柧挬"); strcpy(TracerFont,"俵俽 柧挬"); if(GetModuleFileName(hInst, buffer, MAXPATH)) { if((p = pathsep_strrchr(buffer)) != NULL) { p++; *p = '\0'; } else { buffer[0] = '.'; buffer[1] = PATH_SEP; buffer[2] = '\0'; } } else { buffer[0] = '.'; buffer[1] = PATH_SEP; buffer[2] = '\0'; } // timpp32g.ini strncpy(IniFile, buffer, MAXPATH); IniFile[MAXPATH] = '\0'; strcat(IniFile,"timpp32g.ini"); // timidity_window.ini timidity_window_inifile = S_timidity_window_inifile; strncpy(timidity_window_inifile, buffer, 200); timidity_window_inifile[200] = '\0'; strcat(timidity_window_inifile,"timidity_window.ini"); // timidity_output.ini timidity_output_inifile = S_timidity_output_inifile; strncpy(timidity_output_inifile, buffer, 200); timidity_output_inifile[200] = '\0'; strcat(timidity_output_inifile,"timidity_output.ini"); // default playlist strncpy(DefaultPlaylistPath, buffer, 200); DefaultPlaylistPath[200] = '\0'; strcat(DefaultPlaylistPath,DefaultPlaylistName); // st_default = (SETTING_TIMIDITY *)safe_malloc(sizeof(SETTING_TIMIDITY)); sp_default = (SETTING_PLAYER *)safe_malloc(sizeof(SETTING_PLAYER)); st_current = (SETTING_TIMIDITY *)safe_malloc(sizeof(SETTING_TIMIDITY)); sp_current = (SETTING_PLAYER *)safe_malloc(sizeof(SETTING_PLAYER)); st_temp = (SETTING_TIMIDITY *)safe_malloc(sizeof(SETTING_TIMIDITY)); sp_temp = (SETTING_PLAYER *)safe_malloc(sizeof(SETTING_PLAYER)); { DWORD dwRes;#ifdef AU_GOGO gogo_ConfigDialogInfoInit();#endif#ifdef AU_VORBIS vorbis_ConfigDialogInfoInit();#endif dwRes = GetFileAttributes(timidity_output_inifile); if(dwRes==0xFFFFFFFF || dwRes & FILE_ATTRIBUTE_DIRECTORY){#ifdef AU_GOGO gogo_ConfigDialogInfoSaveINI();#endif#ifdef AU_VORBIS vorbis_ConfigDialogInfoSaveINI();#endif } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -