⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timidity.c

📁 MIDI解码程序(用VC编写)
💻 C
📖 第 1 页 / 共 5 页
字号:
/*    TiMidity++ -- MIDI to WAVE converter and player    Copyright (C) 1999-2004 Masanao Izumo <iz@onicos.co.jp>    Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#ifdef HAVE_CONFIG_H#include "config.h"#endif /* HAVE_CONFIG_H */#include <stdio.h>#ifdef STDC_HEADERS#include <stdlib.h>#include <ctype.h>#include <stddef.h>#endif#ifndef NO_STRING_H#include <string.h>#else#include <strings.h>#endif#ifdef __W32__#include <windows.h>#include <io.h>#include <shlobj.h>#endif#ifdef HAVE_UNISTD_H#include <unistd.h>#endif /* HAVE_UNISTD_H */#ifdef HAVE_SYS_STAT_H#include <sys/stat.h>#endif /* NAVE_SYS_STAT_H */#include <fcntl.h> /* for open */#ifdef HAVE_STDBOOL_H#include <stdbool.h>#endif#ifndef __bool_true_false_are_defined# ifdef bool#  undef bool# endif# ifdef ture#  undef ture# endif# ifdef false#  undef false# endif# define bool int# define false ((bool)0)# define true (!false)# define __bool_true_false_are_defined true#endif /* C99 _Bool hack */#ifdef BORLANDC_EXCEPTION#include <excpt.h>#endif /* BORLANDC_EXCEPTION */#include <signal.h>#if defined(__FreeBSD__) && !defined(__alpha__)#include <floatingpoint.h> /* For FP exceptions */#endif#if defined(__NetBSD__) || defined(__OpenBSD__)#include <ieeefp.h> /* For FP exceptions */#endif#include "interface.h"#include "timidity.h"#include "utils/tmdy_getopt.h"#include "common.h"#include "instrum.h"#include "playmidi.h"#include "readmidi.h"#include "output.h"#include "controls.h"#include "tables.h"#include "miditrace.h"#include "reverb.h"#ifdef SUPPORT_SOUNDSPEC#include "soundspec.h"#endif /* SUPPORT_SOUNDSPEC */#include "resample.h"#include "recache.h"#include "arc.h"#include "strtab.h"#include "wrd.h"#define DEFINE_GLOBALS#include "mid.defs"#include "aq.h"#include "mix.h"#include "unimod.h"#include "quantity.h"#ifdef IA_W32GUI#include "w32g.h"#include "w32g_utl.h"#endif#ifndef __GNUC__#define __attribute__(x) /* ignore */#endif/* option enums */enum {	TIM_OPT_FIRST = 256,	/* first entry */	TIM_OPT_VOLUME = TIM_OPT_FIRST,	TIM_OPT_DRUM_POWER,	TIM_OPT_VOLUME_COMP,	TIM_OPT_ANTI_ALIAS,	TIM_OPT_BUFFER_FRAGS,	TIM_OPT_CONTROL_RATIO,	TIM_OPT_CONFIG_FILE,	TIM_OPT_DRUM_CHANNEL,	TIM_OPT_IFACE_PATH,	TIM_OPT_EXT,	TIM_OPT_MOD_WHEEL,	TIM_OPT_PORTAMENTO,	TIM_OPT_VIBRATO,	TIM_OPT_CH_PRESS,	TIM_OPT_MOD_ENV,	TIM_OPT_TRACE_TEXT,	TIM_OPT_OVERLAP,	TIM_OPT_TEMPER_CTRL,	TIM_OPT_DEFAULT_MID,	TIM_OPT_SYSTEM_MID,	TIM_OPT_DEFAULT_BANK,	TIM_OPT_FORCE_BANK,	TIM_OPT_DEFAULT_PGM,	TIM_OPT_FORCE_PGM,	TIM_OPT_DELAY,	TIM_OPT_CHORUS,	TIM_OPT_REVERB,	TIM_OPT_VOICE_LPF,	TIM_OPT_NS,	TIM_OPT_RESAMPLE,	TIM_OPT_EVIL,	TIM_OPT_FAST_PAN,	TIM_OPT_FAST_DECAY,	TIM_OPT_SPECTROGRAM,	TIM_OPT_KEYSIG,	TIM_OPT_HELP,	TIM_OPT_INTERFACE,	TIM_OPT_VERBOSE,	TIM_OPT_QUIET,	TIM_OPT_TRACE,	TIM_OPT_LOOP,	TIM_OPT_RANDOM,	TIM_OPT_SORT,	TIM_OPT_BACKGROUND,	TIM_OPT_RT_PRIO,	TIM_OPT_SEQ_PORTS,	TIM_OPT_REALTIME_LOAD,	TIM_OPT_ADJUST_KEY,	TIM_OPT_VOICE_QUEUE,	TIM_OPT_PATCH_PATH,	TIM_OPT_PCM_FILE,	TIM_OPT_DECAY_TIME,	TIM_OPT_INTERPOLATION,	TIM_OPT_OUTPUT_MODE,	TIM_OPT_OUTPUT_STEREO,	TIM_OPT_OUTPUT_SIGNED,	TIM_OPT_OUTPUT_BITWIDTH,	TIM_OPT_OUTPUT_FORMAT,	TIM_OPT_OUTPUT_SWAB,	TIM_OPT_FLAC_VERIFY,	TIM_OPT_FLAC_PADDING,	TIM_OPT_FLAC_COMPLEVEL,	TIM_OPT_FLAC_OGGFLAC,	TIM_OPT_SPEEX_QUALITY,	TIM_OPT_SPEEX_VBR,	TIM_OPT_SPEEX_ABR,	TIM_OPT_SPEEX_VAD,	TIM_OPT_SPEEX_DTX,	TIM_OPT_SPEEX_COMPLEXITY,	TIM_OPT_SPEEX_NFRAMES,	TIM_OPT_OUTPUT_FILE,	TIM_OPT_PATCH_FILE,	TIM_OPT_POLYPHONY,	TIM_OPT_POLY_REDUCE,	TIM_OPT_MUTE,	TIM_OPT_TEMPER_MUTE,	TIM_OPT_AUDIO_BUFFER,	TIM_OPT_CACHE_SIZE,	TIM_OPT_SAMPLE_FREQ,	TIM_OPT_ADJUST_TEMPO,	TIM_OPT_CHARSET,	TIM_OPT_UNLOAD_INST,	TIM_OPT_VOLUME_CURVE,	TIM_OPT_VERSION,	TIM_OPT_WRD,	TIM_OPT_RCPCV_DLL,	TIM_OPT_CONFIG_STR,	TIM_OPT_FREQ_TABLE,	TIM_OPT_PURE_INT,	TIM_OPT_MODULE,	/* last entry */	TIM_OPT_LAST = TIM_OPT_PURE_INT};static const char *optcommands =		"4A:aB:b:C:c:D:d:E:eFfg:H:hI:i:jK:k:L:M:m:N:"		"O:o:P:p:Q:q:R:S:s:T:t:UV:vW:"#ifdef __W32__		"w:"#endif		"x:Z:";		/* Only GJlnruXYyz are remain... */static const struct option longopts[] = {	{ "volume",                 required_argument, NULL, TIM_OPT_VOLUME },	{ "drum-power",             required_argument, NULL, TIM_OPT_DRUM_POWER },	{ "no-volume-compensation", no_argument,       NULL, TIM_OPT_DRUM_POWER },	{ "volume-compensation",    optional_argument, NULL, TIM_OPT_VOLUME_COMP },	{ "no-anti-alias",          no_argument,       NULL, TIM_OPT_ANTI_ALIAS },	{ "anti-alias",             optional_argument, NULL, TIM_OPT_ANTI_ALIAS },	{ "buffer-fragments",       required_argument, NULL, TIM_OPT_BUFFER_FRAGS },	{ "control-ratio",          required_argument, NULL, TIM_OPT_CONTROL_RATIO },	{ "config-file",            required_argument, NULL, TIM_OPT_CONFIG_FILE },	{ "drum-channel",           required_argument, NULL, TIM_OPT_DRUM_CHANNEL },	{ "interface-path",         required_argument, NULL, TIM_OPT_IFACE_PATH },	{ "ext",                    required_argument, NULL, TIM_OPT_EXT },	{ "no-mod-wheel",           no_argument,       NULL, TIM_OPT_MOD_WHEEL },	{ "mod-wheel",              optional_argument, NULL, TIM_OPT_MOD_WHEEL },	{ "no-portamento",          no_argument,       NULL, TIM_OPT_PORTAMENTO },	{ "portamento",             optional_argument, NULL, TIM_OPT_PORTAMENTO },	{ "no-vibrato",             no_argument,       NULL, TIM_OPT_VIBRATO },	{ "vibrato",                optional_argument, NULL, TIM_OPT_VIBRATO },	{ "no-ch-pressure",         no_argument,       NULL, TIM_OPT_CH_PRESS },	{ "ch-pressure",            optional_argument, NULL, TIM_OPT_CH_PRESS },	{ "no-mod-envelope",        no_argument,       NULL, TIM_OPT_MOD_ENV },	{ "mod-envelope",           optional_argument, NULL, TIM_OPT_MOD_ENV },	{ "no-trace-text-meta",     no_argument,       NULL, TIM_OPT_TRACE_TEXT },	{ "trace-text-meta",        optional_argument, NULL, TIM_OPT_TRACE_TEXT },	{ "no-overlap-voice",       no_argument,       NULL, TIM_OPT_OVERLAP },	{ "overlap-voice",          optional_argument, NULL, TIM_OPT_OVERLAP },	{ "no-temper-control",      no_argument,       NULL, TIM_OPT_TEMPER_CTRL },	{ "temper-control",         optional_argument, NULL, TIM_OPT_TEMPER_CTRL },	{ "default-mid",            required_argument, NULL, TIM_OPT_DEFAULT_MID },	{ "system-mid",             required_argument, NULL, TIM_OPT_SYSTEM_MID },	{ "default-bank",           required_argument, NULL, TIM_OPT_DEFAULT_BANK },	{ "force-bank",             required_argument, NULL, TIM_OPT_FORCE_BANK },	{ "default-program",        required_argument, NULL, TIM_OPT_DEFAULT_PGM },	{ "force-program",          required_argument, NULL, TIM_OPT_FORCE_PGM },	{ "delay",                  required_argument, NULL, TIM_OPT_DELAY },	{ "chorus",                 required_argument, NULL, TIM_OPT_CHORUS },	{ "reverb",                 required_argument, NULL, TIM_OPT_REVERB },	{ "voice-lpf",              required_argument, NULL, TIM_OPT_VOICE_LPF },	{ "noise-shaping",          required_argument, NULL, TIM_OPT_NS },#ifndef FIXED_RESAMPLATION	{ "resample",               required_argument, NULL, TIM_OPT_RESAMPLE },#endif	{ "evil",                   required_argument, NULL, TIM_OPT_EVIL },	{ "no-fast-panning",        no_argument,       NULL, TIM_OPT_FAST_PAN },	{ "fast-panning",           optional_argument, NULL, TIM_OPT_FAST_PAN },	{ "no-fast-decay",          no_argument,       NULL, TIM_OPT_FAST_DECAY },	{ "fast-decay",             optional_argument, NULL, TIM_OPT_FAST_DECAY },	{ "spectrogram",            required_argument, NULL, TIM_OPT_SPECTROGRAM },	{ "force-keysig",           required_argument, NULL, TIM_OPT_KEYSIG },	{ "help",                   optional_argument, NULL, TIM_OPT_HELP },	{ "interface",              required_argument, NULL, TIM_OPT_INTERFACE },	{ "verbose",                optional_argument, NULL, TIM_OPT_VERBOSE },	{ "quiet",                  optional_argument, NULL, TIM_OPT_QUIET },	{ "no-trace",               no_argument,       NULL, TIM_OPT_TRACE },	{ "trace",                  optional_argument, NULL, TIM_OPT_TRACE },	{ "no-loop",                no_argument,       NULL, TIM_OPT_LOOP },	{ "loop",                   optional_argument, NULL, TIM_OPT_LOOP },	{ "no-random",              no_argument,       NULL, TIM_OPT_RANDOM },	{ "random",                 optional_argument, NULL, TIM_OPT_RANDOM },	{ "no-sort",                no_argument,       NULL, TIM_OPT_SORT },	{ "sort",                   optional_argument, NULL, TIM_OPT_SORT },#ifdef IA_ALSASEQ	{ "no-background",          no_argument,       NULL, TIM_OPT_BACKGROUND },	{ "background",             optional_argument, NULL, TIM_OPT_BACKGROUND },	{ "realtime-priority",      required_argument, NULL, TIM_OPT_RT_PRIO },	{ "sequencer-ports",        required_argument, NULL, TIM_OPT_SEQ_PORTS },#endif	{ "no-realtime-load",       no_argument,       NULL, TIM_OPT_REALTIME_LOAD },	{ "realtime-load",          optional_argument, NULL, TIM_OPT_REALTIME_LOAD },	{ "adjust-key",             required_argument, NULL, TIM_OPT_ADJUST_KEY },	{ "voice-queue",            required_argument, NULL, TIM_OPT_VOICE_QUEUE },	{ "patch-path",             required_argument, NULL, TIM_OPT_PATCH_PATH },	{ "pcm-file",               required_argument, NULL, TIM_OPT_PCM_FILE },	{ "decay-time",             required_argument, NULL, TIM_OPT_DECAY_TIME },	{ "interpolation",          required_argument, NULL, TIM_OPT_INTERPOLATION },	{ "output-mode",            required_argument, NULL, TIM_OPT_OUTPUT_MODE },	{ "output-stereo",          no_argument,       NULL, TIM_OPT_OUTPUT_STEREO },	{ "output-mono",            no_argument,       NULL, TIM_OPT_OUTPUT_STEREO },	{ "output-signed",          no_argument,       NULL, TIM_OPT_OUTPUT_SIGNED },	{ "output-unsigned",        no_argument,       NULL, TIM_OPT_OUTPUT_SIGNED },	{ "output-16bit",           no_argument,       NULL, TIM_OPT_OUTPUT_BITWIDTH },	{ "output-24bit",           no_argument,       NULL, TIM_OPT_OUTPUT_BITWIDTH },	{ "output-8bit",            no_argument,       NULL, TIM_OPT_OUTPUT_BITWIDTH },	{ "output-linear",          no_argument,       NULL, TIM_OPT_OUTPUT_FORMAT },	{ "output-ulaw",            no_argument,       NULL, TIM_OPT_OUTPUT_FORMAT },	{ "output-alaw",            no_argument,       NULL, TIM_OPT_OUTPUT_FORMAT },	{ "no-output-swab",         no_argument,       NULL, TIM_OPT_OUTPUT_SWAB },	{ "output-swab",            optional_argument, NULL, TIM_OPT_OUTPUT_SWAB },#ifdef AU_FLAC	{ "flac-verify",            no_argument,       NULL, TIM_OPT_FLAC_VERIFY },	{ "flac-padding",           required_argument, NULL, TIM_OPT_FLAC_PADDING },	{ "flac-complevel",         required_argument, NULL, TIM_OPT_FLAC_COMPLEVEL },#ifdef AU_OGGFLAC	{ "oggflac",                no_argument,       NULL, TIM_OPT_FLAC_OGGFLAC },#endif /* AU_OGGFLAC */#endif /* AU_FLAC */#ifdef AU_SPEEX	{ "speex-quality",          required_argument, NULL, TIM_OPT_SPEEX_QUALITY },	{ "speex-vbr",              no_argument,       NULL, TIM_OPT_SPEEX_VBR },	{ "speex-abr",              required_argument, NULL, TIM_OPT_SPEEX_ABR },	{ "speex-vad",              no_argument,       NULL, TIM_OPT_SPEEX_VAD },	{ "speex-dtx",              no_argument,       NULL, TIM_OPT_SPEEX_DTX },	{ "speex-complexity",       required_argument, NULL, TIM_OPT_SPEEX_COMPLEXITY },	{ "speex-nframes",          required_argument, NULL, TIM_OPT_SPEEX_NFRAMES },#endif /* AU_SPEEX */	{ "output-file",            required_argument, NULL, TIM_OPT_OUTPUT_FILE },	{ "patch-file",             required_argument, NULL, TIM_OPT_PATCH_FILE },	{ "polyphony",              required_argument, NULL, TIM_OPT_POLYPHONY },	{ "no-polyphony-reduction", no_argument,       NULL, TIM_OPT_POLY_REDUCE },	{ "polyphony-reduction",    optional_argument, NULL, TIM_OPT_POLY_REDUCE },	{ "mute",                   required_argument, NULL, TIM_OPT_MUTE },	{ "temper-mute",            required_argument, NULL, TIM_OPT_TEMPER_MUTE },	{ "audio-buffer",           required_argument, NULL, TIM_OPT_AUDIO_BUFFER },	{ "cache-size",             required_argument, NULL, TIM_OPT_CACHE_SIZE },	{ "sampling-freq",          required_argument, NULL, TIM_OPT_SAMPLE_FREQ },	{ "adjust-tempo",           required_argument, NULL, TIM_OPT_ADJUST_TEMPO },	{ "output-charset",         required_argument, NULL, TIM_OPT_CHARSET },	{ "no-unload-instruments",  no_argument,       NULL, TIM_OPT_UNLOAD_INST },	{ "unload-instruments",     optional_argument, NULL, TIM_OPT_UNLOAD_INST },	{ "volume-curve",           required_argument, NULL, TIM_OPT_VOLUME_CURVE },	{ "version",                no_argument,       NULL, TIM_OPT_VERSION },	{ "wrd",                    required_argument, NULL, TIM_OPT_WRD },#ifdef __W32__	{ "rcpcv-dll",              required_argument, NULL, TIM_OPT_RCPCV_DLL },#endif	{ "config-string",          required_argument, NULL, TIM_OPT_CONFIG_STR },	{ "freq-table",             required_argument, NULL, TIM_OPT_FREQ_TABLE },	{ "pure-intonation",        optional_argument, NULL, TIM_OPT_PURE_INT },	{ "module",                 required_argument, NULL, TIM_OPT_MODULE },	{ NULL,                     no_argument,       NULL, '\0'     }};#define INTERACTIVE_INTERFACE_IDS "kmqagrwAWP"/* main interfaces (To be used another main) */#if defined(main) || defined(ANOTHER_MAIN) || defined ( IA_W32GUI ) || defined ( IA_W32G_SYN )#define MAIN_INTERFACE#else#define MAIN_INTERFACE static#endif /* main */MAIN_INTERFACE void timidity_start_initialize(void);MAIN_INTERFACE int timidity_pre_load_configuration(void);MAIN_INTERFACE int timidity_post_load_configuration(void);MAIN_INTERFACE void timidity_init_player(void);MAIN_INTERFACE int timidity_play_main(int nfiles, char **files);MAIN_INTERFACE int got_a_configuration;char *wrdt_open_opts = NULL;char *opt_aq_max_buff = NULL,     *opt_aq_fill_buff = NULL;void timidity_init_aq_buff(void);int opt_control_ratio = 0; /* Save -C option */int set_extension_modes(char *);int set_ctl(char *);int set_play_mode(char *);int set_wrd(char *);MAIN_INTERFACE int set_tim_opt_short(int, char *);MAIN_INTERFACE int set_tim_opt_long(int, char *, int);static inline int parse_opt_A(const char *);static inline int parse_opt_drum_power(const char *);static inline int parse_opt_volume_comp(const char *);static inline int parse_opt_a(const char *);static inline int parse_opt_B(const char *);static inline int parse_opt_C(const char *);static inline int parse_opt_c(char *);static inline int parse_opt_D(const char *);static inline int parse_opt_d(const char *);static inline int parse_opt_E(char *);static inline int parse_opt_mod_wheel(const char *);static inline int parse_opt_portamento(const char *);static inline int parse_opt_vibrato(const char *);static inline int parse_opt_ch_pressure(const char *);static inline int parse_opt_mod_env(const char *);static inline int parse_opt_trace_text(const char *);static inline int parse_opt_overlap_voice(const char *);static inline int parse_opt_temper_control(const char *);static inline int parse_opt_default_mid(char *);static inline int parse_opt_system_mid(char *);static inline int parse_opt_default_bank(const char *);static inline int parse_opt_force_bank(const char *);static inline int parse_opt_default_program(const char *);static inline int parse_opt_force_program(const char *);static inline int set_default_program(int);static inline int parse_opt_delay(const char *);static inline int parse_opt_chorus(const char *);static inline int parse_opt_reverb(const char *);static inline int parse_opt_voice_lpf(const char *);static inline int parse_opt_noise_shaping(const char *);static inline int parse_opt_resample(const char *);static inline int parse_opt_e(const char *);static inline int parse_opt_F(const char *);static inline int parse_opt_f(const char *);static inline int parse_opt_g(const char *);static inline int parse_opt_H(const char *);__attribute__((noreturn))static inline int parse_opt_h(const char *);#ifdef IA_DYNAMICstatic inline void list_dyna_interface(FILE *, char *, char *);static inline char *dynamic_interface_info(int);char *dynamic_interface_module(int);#endifstatic inline int parse_opt_i(const char *);static inline int parse_opt_verbose(const char *);static inline int parse_opt_quiet(const char *);static inline int parse_opt_trace(const char *);static inline int parse_opt_loop(const char *);static inline int parse_opt_random(const char *);static inline int parse_opt_sort(const char *);#ifdef IA_ALSASEQstatic inline int parse_opt_background(const char *);static inline int parse_opt_rt_prio(const char *);static inline int parse_opt_seq_ports(const char *);#endifstatic inline int parse_opt_j(const char *);static inline int parse_opt_K(const char *);static inline int parse_opt_k(const char *);static inline int parse_opt_L(char *);static inline int parse_opt_M(const char *);static inline int parse_opt_m(const char *);static inline int parse_opt_N(const char *);static inline int parse_opt_O(const char *);static inline int parse_opt_output_stereo(const char *);static inline int parse_opt_output_signed(const char *);static inline int parse_opt_output_bitwidth(const char *);static inline int parse_opt_output_format(const char *);static inline int parse_opt_output_swab(const char *);#ifdef AU_FLACstatic inline int parse_opt_flac_verify(const char *);static inline int parse_opt_flac_padding(const char *);static inline int parse_opt_flac_complevel(const char *);#ifdef AU_OGGFLACstatic inline int parse_opt_flac_oggflac(const char *);#endif /* AU_OGGFLAC */#endif /* AU_FLAC */#ifdef AU_SPEEXstatic inline int parse_opt_speex_quality(const char *);static inline int parse_opt_speex_vbr(const char *);static inline int parse_opt_speex_abr(const char *);static inline int parse_opt_speex_vad(const char *);static inline int parse_opt_speex_dtx(const char *);static inline int parse_opt_speex_complexity(const char *);static inline int parse_opt_speex_nframes(const char *);#endif /* AU_SPEEX */static inline int parse_opt_o(char *);static inline int parse_opt_P(const char *);static inline int parse_opt_p(const char *);static inline int parse_opt_p1(const char *);static inline int parse_opt_Q(const char *);static inline int parse_opt_Q1(const char *);static inline int parse_opt_q(const char *);static inline int parse_opt_R(const char *);static inline int parse_opt_S(const char *);static inline int parse_opt_s(const char *);static inline int parse_opt_T(const char *);static inline int parse_opt_t(const char *);static inline int parse_opt_U(const char *);static inline int parse_opt_volume_curve(char *);__attribute__((noreturn))static inline int parse_opt_v(const char *);static inline int parse_opt_W(char *);#ifdef __W32__static inline int parse_opt_w(const char *);#endifstatic inline int parse_opt_x(char *);static inline void expand_escape_string(char *);static inline int parse_opt_Z(char *);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -