MIDI files in C(lccwin/WIN XP)

Discussion in 'C Programming' started by ravi, Jul 31, 2010.

  1. ravi

    ravi Guest

    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 ?
     
    ravi, Jul 31, 2010
    #1
    1. Advertising

  2. "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...
     
    BGB / cr88192, Jul 31, 2010
    #2
    1. Advertising

  3. ravi

    Bartc Guest

    "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
     
    Bartc, Aug 1, 2010
    #3
  4. On Jul 31, 10:58 pm, ravi <>

    > 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.
     
    Jean-Christophe, Aug 1, 2010
    #4
  5. ravi

    Dann Corbit Guest

    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.
     
    Dann Corbit, Aug 2, 2010
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugo Villeneuve

    Java MIDI output device to MIDI Yoke.

    Hugo Villeneuve, Jul 4, 2003, in forum: Java
    Replies:
    0
    Views:
    974
    Hugo Villeneuve
    Jul 4, 2003
  2. Gilly
    Replies:
    6
    Views:
    438
    Ken Starks
    May 4, 2008
  3. Asbjørn Bjørnstad
    Replies:
    0
    Views:
    451
    Asbjørn Bjørnstad
    Oct 9, 2008
  4. sandeep

    Status of lccwin

    sandeep, Feb 5, 2010, in forum: C Programming
    Replies:
    9
    Views:
    1,196
    Malcolm McLean
    Feb 8, 2010
  5. Krist
    Replies:
    6
    Views:
    782
    Arne Vajhøj
    May 7, 2010
Loading...

Share This Page