MIDI files in C(lccwin/WIN XP)

R

ravi

Hi Can anybody tell me you to play MIDI file through a C program ?

i am using lccwin for WinXP

Decoding the midi file and then play it by directly interfacing with
speakers using inportb() function in conio.h or sound() function in
dos.h.

is it possible or not and if possible then HOW TO DECODE MIDI FILE ?
 
B

BGB / cr88192

ravi said:
Hi Can anybody tell me you to play MIDI file through a C program ?

i am using lccwin for WinXP

Decoding the midi file and then play it by directly interfacing with
speakers using inportb() function in conio.h or sound() function in
dos.h.

is it possible or not and if possible then HOW TO DECODE MIDI FILE ?

going off-topic here...

this is really not a good group for this question (non-standard,
non-portable, ...).

this is also not a question with any simple or easy answer.


in MS-DOS, you essentially have to write a driver for whatever sound HW
happens to be in the system.
for DOS apps in Windows, one has to target whichever HW Windows is faking
(typically, a SoundBlaster), but this is only in 9x and 32-bit XP. DOSBox is
another target.

in this case, the SB HW (or faked SB HW), allows MIDI playback, so it is
mostly a matter of feeding the command-stream to the HW. if you want to go
the driver-writing route, go look up info on the particular HW yourself...

however, none of this will work in an actual Windows app.


Windows provides some of its own facilities, which can be used.
typically, these just synthesize the music in SW, and use waveform playback.

(MIDI is unrelated to waveform audio, and is actually a command-language
which depends on a fair amount of external data and logic, and so it takes
writing or using a synthesizer to get it into a playable form).

to make an analogy: MIDI tells the notes one would play on a piano, but
unless one supplies said piano, there is really nothing to hear from it...
(much like a rock-band trying to make their music via air-guitar...).


Linux generally involves using libraries (such as Timidity), which can also
be used on Windows (however, one has to provide them oneself, as they are
NOT part of the OS).

or, if one really wants to, they can write their own synthesizer, but how to
get the sound to the sound HW remains an OS-specific issue...
 
B

Bartc

ravi said:
Hi Can anybody tell me you to play MIDI file through a C program ?

i am using lccwin for WinXP

Decoding the midi file and then play it by directly interfacing with
speakers using inportb() function in conio.h or sound() function in
dos.h.

is it possible or not and if possible then HOW TO DECODE MIDI FILE ?

Google for 'midi file format'.

Decoding the file will give you a series of notes (eg. pitch, duration,
volume), over a timeframe, and possibly across several channels, each for a
separate instrument.

But you will need to do some work trying to get anything pleasant sounding
if you have just a simple interface to the speakers, such as this:

#include <windows.h> /* for lccwin32 */

int main(void)
{
Beep(1000,400);
Beep(2000,400);
Beep(3000,400);
}

(Note that WinXP will anyway have available APIs for playing midi notes
properly.)
 
J

Jean-Christophe

Can anybody tell me you to play MIDI file through a C program ?
is it possible or not and if possible then HOW TO DECODE MIDI FILE ?

To encode/decode MIDI from/to WAVE you should write a simple
function implementing MIDI format available everywhere, i.e:
http://www.sonicspot.com/guide/midifiles.html

Check MMREG.H which supports MIDI format for various hardware :

#define MM_MIDI_MAPPER 1 /* Midi Mapper */
#define MM_SNDBLST_MIDIOUT 3 /* Sound Blaster MIDI output port */
#define MM_SNDBLST_MIDIIN 4 /* Sound Blaster MIDI input port */
#define MM_MPU401_MIDIOUT 10 /* MPU 401 compatible MIDI output port
*/
#define MM_MPU401_MIDIIN 11 /* MPU 401 compatible MIDI input port
*/
#define MM_MSFT_GENERIC_MIDIIN 25 /* MS Vanilla driver MIDI in */
#define MM_MSFT_GENERIC_MIDIOUT 26 /* MS Vanilla driver MIDI
external out */
#define MM_MSFT_GENERIC_MIDISYNTH 27 /* MS Vanilla driver MIDI
synthesizer */
#define MM_WSS_SB16_MIDIIN 41 /* Sound Blaster 16 midi-in */
#define MM_WSS_SB16_MIDIOUT 42 /* Sound Blaster 16 midi out */
#define MM_WSS_SBPRO_MIDIIN 49 /* Sound Blaster Pro midi in */
#define MM_WSS_SBPRO_MIDIOUT 50 /* Sound Blaster Pro midi out */
#define MM_MSFT_SB16_MIDIIN 62 /* Sound Blaster 16 midi-in */
#define MM_MSFT_SB16_MIDIOUT 63 /* Sound Blaster 16 midi out */
#define MM_MSFT_SBPRO_MIDIIN 70 /* Sound Blaster Pro midi in */
#define MM_MSFT_SBPRO_MIDIOUT 71 /* Sound Blaster Pro midi out */
#define MM_MSFT_WDMAUDIO_MIDIOUT 102 /* Generic id for WDM Audio
drivers */
#define MM_MSFT_WDMAUDIO_MIDIIN 103 /* Generic id for WDM Audio
drivers */

.... etc ... lot of them.
 
D

Dann Corbit

Hi Can anybody tell me you to play MIDI file through a C program ?

i am using lccwin for WinXP

Decoding the midi file and then play it by directly interfacing with
speakers using inportb() function in conio.h or sound() function in
dos.h.

is it possible or not and if possible then HOW TO DECODE MIDI FILE ?

Take a look at sourceforge.
Type in "midi" for the keyword.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top