📄 wildmidi_lib.c
字号:
tmp_patch->amp = 1024; tmp_patch->note = 0; } else { if (tmp_patch->next != NULL) { while (tmp_patch->next != NULL) { if (tmp_patch->next->patchid == patchid) break; tmp_patch = tmp_patch->next; } if (tmp_patch->next == NULL) { tmp_patch->next = malloc (sizeof(struct _patch)); if (tmp_patch->next == NULL) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, NULL, 0); WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_LOAD, config_file, 0); WM_FreePatches(); if (config_dir != NULL) free (config_dir); free (line_buffer); free (config_buffer); return -1; } tmp_patch = tmp_patch->next; tmp_patch->patchid = patchid; tmp_patch->filename = NULL; tmp_patch->amp = 1024; tmp_patch->note = 0; tmp_patch->next = NULL; tmp_patch->first_sample = NULL; tmp_patch->loaded = 0; tmp_patch->inuse_count = 0; } else { tmp_patch = tmp_patch->next; free (tmp_patch->filename); tmp_patch->filename = NULL; tmp_patch->amp = 1024; tmp_patch->note = 0; } } else { tmp_patch->next = malloc (sizeof(struct _patch)); if (tmp_patch->next == NULL) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, NULL, errno); WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_LOAD, config_file, 0); WM_FreePatches(); if (config_dir != NULL) free (config_dir); free (line_buffer); free (config_buffer); return -1; } tmp_patch = tmp_patch->next; tmp_patch->patchid = patchid; tmp_patch->filename = NULL; tmp_patch->amp = 1024; tmp_patch->note = 0; tmp_patch->next = NULL; tmp_patch->first_sample = NULL; tmp_patch->loaded = 0; tmp_patch->inuse_count = 0; } } } chr_ptr = strchr(line_buffer,' ') + 1; if (chr_ptr == NULL) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, "(syntax error in patch line)", 0); WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_LOAD, config_file, 0); WM_FreePatches(); if (config_dir != NULL) free (config_dir); free (line_buffer); free (config_buffer); return -1; } line_ptr = chr_ptr - line_buffer; chr_ptr = strchr(&line_buffer[line_ptr],' '); if (chr_ptr != NULL) { *chr_ptr = '\0'; } if (strncasecmp(&line_buffer[(line_ptr + strlen(&line_buffer[line_ptr]) - 5)], ".pat", 4) != 0) { if (config_dir != NULL) { tmp_patch->filename = malloc(strlen(config_dir) + strlen(&line_buffer[line_ptr]) + 5); if (tmp_patch->filename == NULL) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, NULL, 0); WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_LOAD, config_file, 0); WM_FreePatches(); if (config_dir != NULL) free (config_dir); free (line_buffer); free (config_buffer); return -1; } strcpy(tmp_patch->filename, config_dir); strcat(tmp_patch->filename, &line_buffer[line_ptr]); } else { tmp_patch->filename = malloc(strlen(&line_buffer[line_ptr]) + 5); if (tmp_patch->filename == NULL) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, NULL, 0); WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_LOAD, config_file, 0); WM_FreePatches(); free (line_buffer); free (config_buffer); return -1; } strcpy(tmp_patch->filename, &line_buffer[line_ptr]); } strcat(tmp_patch->filename, ".pat"); } else { if (config_dir != NULL) { tmp_patch->filename = malloc(strlen(config_dir) + strlen(&line_buffer[line_ptr]) + 1); if (tmp_patch->filename == NULL) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, NULL, 0); WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_LOAD, config_file, 0); WM_FreePatches(); if (config_dir != NULL) free (config_dir); free (line_buffer); free (config_buffer); return -1; } strcpy(tmp_patch->filename, config_dir); strcat(tmp_patch->filename, &line_buffer[line_ptr]); } else { tmp_patch->filename = malloc(strlen(&line_buffer[line_ptr]) + 1); if (tmp_patch->filename == NULL) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, NULL, 0); WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_LOAD, config_file, 0); WM_FreePatches(); free (line_buffer); free (config_buffer); return -1; } strcpy(tmp_patch->filename, &line_buffer[line_ptr]); } } tmp_patch->env[0].set = 0x00; tmp_patch->env[1].set = 0x00; tmp_patch->env[2].set = 0x00; tmp_patch->env[3].set = 0x00; tmp_patch->env[4].set = 0x00; tmp_patch->env[5].set = 0x00; tmp_patch->keep = 0; tmp_patch->remove = 0; if (chr_ptr != NULL) { line_ptr = chr_ptr - line_buffer + 1; chr_ptr = strstr(&line_buffer[line_ptr], "amp="); if (chr_ptr != NULL) { if (!isdigit(chr_ptr[4])) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, "(syntax error in patch line)", 0); } else { tmp_patch->amp = ((atoi(&chr_ptr[4]) << 10) / 100); } } chr_ptr = strstr(&line_buffer[line_ptr], "note="); if (chr_ptr != NULL) { if (!isdigit(chr_ptr[5])) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, "(syntax error in patch line)", 0); } else { tmp_patch->note = atoi(&chr_ptr[5]); } } chr_ptr = strstr(&line_buffer[line_ptr], "keep=loop"); if (chr_ptr != NULL) { tmp_patch->keep |= SAMPLE_LOOP; } chr_ptr = strstr(&line_buffer[line_ptr], "keep=env"); if (chr_ptr != NULL) { tmp_patch->keep |= SAMPLE_ENVELOPE; } chr_ptr = strstr(&line_buffer[line_ptr], "remove=sustain"); if (chr_ptr != NULL) { tmp_patch->remove |= SAMPLE_SUSTAIN; } chr_ptr = strstr(&line_buffer[line_ptr], "env_time0="); if (chr_ptr != NULL) { if (!isdigit(chr_ptr[10])) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, "(syntax error in patch line)", 0); } else { tmp_patch->env[0].time = atof(&chr_ptr[10]); if ((tmp_patch->env[0].time > 45000.0) || (tmp_patch->env[0].time < 1.47)) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, "(range error in patch line)", 0); tmp_patch->env[0].set &= 0xFE; } else { tmp_patch->env[0].set |= 0x01; } } } chr_ptr = strstr(&line_buffer[line_ptr], "env_time1="); if (chr_ptr != NULL) { if (!isdigit(chr_ptr[10])) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, "(syntax error in patch line)", 0); } else { tmp_patch->env[1].time = atof(&chr_ptr[10]); if ((tmp_patch->env[1].time > 45000.0) || (tmp_patch->env[1].time < 1.47)) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, "(range error in patch line)", 0); tmp_patch->env[1].set &= 0xFE; } else { tmp_patch->env[1].set |= 0x01; } } } chr_ptr = strstr(&line_buffer[line_ptr], "env_time2="); if (chr_ptr != NULL) { if (!isdigit(chr_ptr[10])) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, "(syntax error in patch line)", 0); } else { tmp_patch->env[2].time = atof(&chr_ptr[10]); if ((tmp_patch->env[2].time > 45000.0) || (tmp_patch->env[2].time < 1.47)) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, "(range error in patch line)", 0); tmp_patch->env[2].set &= 0xFE; } else { tmp_patch->env[2].set |= 0x01; } } } chr_ptr = strstr(&line_buffer[line_ptr], "env_time3="); if (chr_ptr != NULL) { if (!isdigit(chr_ptr[10])) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, "(syntax error in patch line)", 0); } else { tmp_patch->env[3].time = atof(&chr_ptr[10]); if ((tmp_patch->env[3].time > 45000.0) || (tmp_patch->env[3].time < 1.47)) { WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_INVALID, "(range error in patch line)", 0); tmp_patch->env[3].set &= 0xFE; } else { tmp_patch->env[3].set |= 0x01; } } } chr_ptr = strstr(&line_buffer[line_p
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -