Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > MIDI files in C(lccwin/WIN XP)

Reply
Thread Tools

MIDI files in C(lccwin/WIN XP)

 
 
ravi
Guest
Posts: n/a
 
      07-31-2010
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 ?
 
Reply With Quote
 
 
 
 
BGB / cr88192
Guest
Posts: n/a
 
      07-31-2010

"ravi" <> wrote in message
news:i322pd$cl3$...
> 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...


 
Reply With Quote
 
 
 
 
Bartc
Guest
Posts: n/a
 
      08-01-2010

"ravi" <> wrote in message
news:i322pd$cl3$...
> 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.)

--
Bartc



 
Reply With Quote
 
Jean-Christophe
Guest
Posts: n/a
 
      08-01-2010
On Jul 31, 10:58 pm, ravi <nos...@nospam.com>

> 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.
 
Reply With Quote
 
Dann Corbit
Guest
Posts: n/a
 
      08-02-2010
In article <i322pd$cl3$>, says...
>
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Portable midi communication with external midi instruments? Asbjørn Bjørnstad Java 0 10-09-2008 03:03 PM
Real Time Midi File Playback - Reading and Writing midi at the sametime Gilly Python 6 05-04-2008 09:16 PM
D/L midi files launches a midi player I want the midi file Vlad Firefox 2 06-10-2005 02:25 AM
Can MIDI sequence files play on regular CD player? nickial Computer Support 3 09-11-2003 07:52 AM
Java MIDI output device to MIDI Yoke. Hugo Villeneuve Java 0 07-04-2003 10:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57