2 * Initialization procedures for multimedia
4 * Copyright 1998 Luiz Otavio L. Zorzella
11 #include "multimedia.h"
18 extern int MODM_NUMDEVS
;
19 extern LPMIDIOUTCAPS16 midiDevices
[MAX_MIDIOUTDRV
];
23 /**************************************************************************
24 * unixToWindowsDeviceType [internal]
26 * return the Windows equivalent to a Unix Device Type
30 int unixToWindowsDeviceType(int type
)
32 /* MOD_MIDIPORT output port
33 * MOD_SYNTH generic internal synth
34 * MOD_SQSYNTH square wave internal synth
35 * MOD_FMSYNTH FM internal synth
36 * MOD_MAPPER MIDI mapper
39 /* FIXME Is this really the correct equivalence from UNIX to Windows Sound type */
42 case SYNTH_TYPE_FM
: return MOD_FMSYNTH
;
43 case SYNTH_TYPE_SAMPLE
: return MOD_SYNTH
;
44 case SYNTH_TYPE_MIDI
: return MOD_MIDIPORT
;
46 ERR(midi
, "Cannot determine the type of this midi device. Assuming FM Synth\n");
52 /**************************************************************************
53 * MultimediaInit [internal]
55 * Initializes the MIDI devices information variables
58 BOOL32
MULTIMEDIA_Init (void)
61 int i
, status
, numsynthdevs
=255, nummididevs
=255;
62 struct synth_info sinfo
;
63 struct midi_info minfo
;
64 int fd
; /* file descriptor for MIDI_DEV */
66 TRACE (midi
, "Initializing the MIDI variables.\n");
67 /* try to open device */
68 fd
= open(MIDI_DEV
, O_WRONLY
);
70 TRACE (midi
, "No soundcards founds: unable to open `%s'.\n", MIDI_DEV
);
74 /* find how many Synth devices are there in the system */
75 status
= ioctl(fd
, SNDCTL_SEQ_NRSYNTHS
, &numsynthdevs
);
77 if (numsynthdevs
> MAX_MIDIOUTDRV
) {
78 ERR (midi
, "MAX_MIDIOUTDRV was enough for the number of devices. Some FM devices will not be available.\n");
79 numsynthdevs
= MAX_MIDIOUTDRV
;
83 ERR (midi
, "ioctl failed.\n");
87 for (i
= 0 ; i
< numsynthdevs
; i
++) {
88 LPMIDIOUTCAPS16 tmplpCaps
;
91 status
= ioctl(fd
, SNDCTL_SYNTH_INFO
, &sinfo
);
93 ERR(midi
, "ioctl failed.\n");
97 tmplpCaps
= xmalloc (sizeof (MIDIOUTCAPS16
));
98 /* We also have the information sinfo.synth_subtype, not used here
101 /* Manufac ID. We do not have access to this with soundcard.h
102 * Does not seem to be a problem, because in mmsystem.h only
103 * Microsoft's ID is listed.
105 tmplpCaps
->wMid
= 0x00FF;
106 tmplpCaps
->wPid
= 0x0001; /* FIXME Product ID */
107 tmplpCaps
->vDriverVersion
= 0x001; /* Product Version. We simply say "1" */
108 strcpy(tmplpCaps
->szPname
, sinfo
.name
);
110 tmplpCaps
->wTechnology
= unixToWindowsDeviceType (sinfo
.synth_type
);
111 tmplpCaps
->wVoices
= sinfo
.nr_voices
;
113 /* FIXME Is it possible to know the maximum
114 * number of simultaneous notes of a soundcard ?
115 * I beleive we don't have this information, but
116 * it's probably equal or more than wVoices
118 tmplpCaps
->wNotes
= sinfo
.nr_voices
;
120 /* FIXME Do we have this information?
121 * Assuming the soundcards can handle
122 * MIDICAPS_VOLUME and MIDICAPS_LRVOLUME but
123 * not MIDICAPS_CACHE.
125 tmplpCaps
->dwSupport
= MIDICAPS_VOLUME
|MIDICAPS_LRVOLUME
;
127 midiDevices
[i
] = tmplpCaps
;
129 TRACE(midi
,"techn = %d voices=%d notes = %d support = %ld\n",tmplpCaps
->wTechnology
,tmplpCaps
->wVoices
,tmplpCaps
->wNotes
,tmplpCaps
->dwSupport
);
132 /* find how many MIDI devices are there in the system */
133 status
= ioctl(fd
, SNDCTL_SEQ_NRMIDIS
, &nummididevs
);
135 ERR(midi
, "ioctl failed.\n");
139 if (numsynthdevs
+ nummididevs
> MAX_MIDIOUTDRV
) {
140 ERR(midi
, "MAX_MIDIOUTDRV was enough for the number of devices. Some MIDI devices will not be available.\n");
141 nummididevs
= MAX_MIDIOUTDRV
- numsynthdevs
;
144 /* windows does not seem to diferentiate Synth from MIDI devices */
145 MODM_NUMDEVS
= numsynthdevs
+ nummididevs
;
147 for (i
= 0 ; i
< nummididevs
; i
++) {
148 LPMIDIOUTCAPS16 tmplpCaps
;
151 status
= ioctl(fd
, SNDCTL_MIDI_INFO
, &minfo
);
153 ERR(midi
, "ioctl failed.\n");
157 tmplpCaps
= xmalloc (sizeof (MIDIOUTCAPS16
));
158 /* This whole part is somewhat obscure to me. I'll keep trying to dig
159 info about it. If you happen to know, please tell us. The very descritive
160 minfo.dev_type was not used here.
162 tmplpCaps
->wMid
= 0x00FF; /* Manufac ID. We do not have access to this with soundcard.h
163 Does not seem to be a problem, because in mmsystem.h only
164 Microsoft's ID is listed */
165 tmplpCaps
->wPid
= 0x0001; /* FIXME Product ID */
166 tmplpCaps
->vDriverVersion
= 0x001; /* Product Version. We simply say "1" */
167 strcpy(tmplpCaps
->szPname
, minfo
.name
);
169 tmplpCaps
->wTechnology
= MOD_MIDIPORT
; /* FIXME Is this right? */
170 tmplpCaps
->wVoices
= 16; /* Does it make any difference? */
171 tmplpCaps
->wNotes
= 16; /* Does it make any difference? */
172 tmplpCaps
->dwSupport
= MIDICAPS_VOLUME
|MIDICAPS_LRVOLUME
; /* FIXME Does it make any difference? */
174 midiDevices
[numsynthdevs
+ i
] = tmplpCaps
;
176 TRACE(midi
,"techn = %d voices=%d notes = %d support = %ld\n",tmplpCaps
->wTechnology
,tmplpCaps
->wVoices
,tmplpCaps
->wNotes
,tmplpCaps
->dwSupport
);
179 /* close file and exit */
182 #endif /* HAVE_OSS */