📄 seq_info.c
字号:
/* * seq_info.c * Example program for /dev/sequencer. */#include <unistd.h>#include <stdlib.h>#include <stdio.h>#include <fcntl.h>#include <sys/types.h>#include <sys/ioctl.h>#include <sys/soundcard.h>/* return string given a MIDI device type */char *midi_device_type(int type){ switch (type) { case SNDCARD_ADLIB: return("Adlib"); case SNDCARD_SB: return("SoundBlaster"); case SNDCARD_PAS: return("ProAudioSpectrum"); case SNDCARD_GUS: return("GravisUltraSound"); case SNDCARD_MPU401: return("MPU401"); case SNDCARD_SB16: return("SoundBlaster16"); case SNDCARD_SB16MIDI: return("SoundBlaster16 MIDI"); case SNDCARD_UART6850: return("6850 UART"); case SNDCARD_GUS16: return("Gravis UltraSound 16"); case SNDCARD_MSS: return("Microsoft Sound System"); case SNDCARD_PSS: return("Personal Sound System"); case SNDCARD_SSCAPE: return("Ensoniq SoundScape");/* these require a more recent version of the sound driver */#if SOUND_VERSION >= 301 case SNDCARD_PSS_MPU: return("Personal Sound System + MPU"); case SNDCARD_PSS_MSS: return("Personal Sound System/Microsoft Sound System"); case SNDCARD_TRXPRO_MPU: return("MediaTrix Pro + MPU"); case SNDCARD_MAD16: return("MAD16"); case SNDCARD_MAD16_MPU: return("MAD16 + MPU"); case SNDCARD_CS4232: return("CS4232"); case SNDCARD_CS4232_MPU: return("CS4232 + MPU"); case SNDCARD_MAUI: return("Maui"); case SNDCARD_PSEUDO_MSS: return("Pseudo-MSS");#endif /* SOUND_VERSION >= 301 */#if SOUND_VERSION >= 350 case SNDCARD_GUSPNP: return ("Gravis UltraSound PlugNPlay");#endif /* SOUND_VERSION >= 301 */ default: return("unknown"); }}/* return string given a synthesizer device type */char *synth_device_type(int type){ switch (type) { case SYNTH_TYPE_FM: return("FM"); case SYNTH_TYPE_SAMPLE: return("Sampling"); case SYNTH_TYPE_MIDI: return("MIDI"); default: return("unknown"); }}/* return string given a synthesizer device subtype */char *synth_device_subtype(int type){ switch (type) { case FM_TYPE_ADLIB: return("Adlib"); case FM_TYPE_OPL3: return("OPL-3"); case SAMPLE_TYPE_GUS: return("GUS"); default: return("unknown"); }}int main(int argc, char *argv[]){ int i, status, numdevs; struct synth_info sinfo; struct midi_info minfo; int fd; /* file descriptor for /dev/sequencer */ char *device; /* name of device to report on */ /* get device name from command line or use default */ if (argc == 2) device = argv[1]; else device = "/dev/sequencer"; /* try to open device */ fd = open(device, O_WRONLY); if (fd == -1) { fprintf(stderr, "%s: unable to open `%s', ", argv[0], device); perror(""); return 1; } status = ioctl(fd, SNDCTL_SEQ_NRSYNTHS, &numdevs); if (status == -1) { perror("ioctl failed"); exit(1); } printf("%s:\n%d synthesizer device%s installed\n", device, numdevs, numdevs == 1 ? "" : "s"); for (i = 0 ; i < numdevs ; i++) { sinfo.device = i; status = ioctl(fd, SNDCTL_SYNTH_INFO, &sinfo); if (status == -1) { perror("ioctl failed"); exit(1); } printf("Device %d: `%s' type: `%s' subtype: `%s' voices: %d\n", i, sinfo.name, synth_device_type(sinfo.synth_type), synth_device_subtype(sinfo.synth_subtype), sinfo.nr_voices); } status = ioctl(fd, SNDCTL_SEQ_NRMIDIS, &numdevs); if (status == -1) { perror("ioctl failed"); exit(1); } printf("%d MIDI device%s installed\n", numdevs, numdevs == 1 ? "" : "s"); for (i = 0 ; i < numdevs ; i++) { minfo.device = i; status = ioctl(fd, SNDCTL_MIDI_INFO, &minfo); if (status == -1) { perror("ioctl failed"); exit(1); } printf("Device %d: `%s' type: `%s'\n", i, minfo.name, midi_device_type(minfo.dev_type)); } /* close file and exit */ close(fd); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -