RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
 
Post new topic Reply to topic  
View previous topic - View next topic  
Author Message
JimKurth
Monkey-Butler


Joined: 01 Apr 2007
Posts: 53
Location: Houston, TX

PostPosted: Sun Jul 01, 2007 5:00 am    Post subject: Loading and reading MIDI files help... [quote]

I've read Microsoft's article on MIDI files, and I also looked into programming resources (no source code) about the file type. I understand how to read them but I only have one question: How do you program this to be played for multiple tracks? Do you load the contents of the file into memory and just jump to location xxxx:xxxx to grab another track's info to be played simultaneously? That wouldn't be so bad with small files but larger complex 16-track MIDI files seem potential for problems.

From what I understand each track chunk extends from start to end of the file and then jumps to the next track chunk from start to end and so forth. I'm not understanding how to grab this data and send it to the sound device to retrieve incoming midi commands. Maybe I'm thinking in the wrong direction (usually am). If any one knows the concept of how to do this please share with me. Thanks.

James Kurth
james.kurth@hotmail.com
Back to top  
XMark
Guitar playin' black mage


Joined: 30 May 2002
Posts: 870
Location: New Westminster, BC, Canada

PostPosted: Tue Jul 03, 2007 10:48 pm    Post subject: [quote]

Which language are you programming in, and which library are you using for sound?

It sounds like you're trying to re-invent the wheel by programming your own MIDI loading and playing routine, which should not be necessary because there are many libraries available to handle the whole thing for you. For example, the Allegro library comes with midi loading and playing routines.
_________________
Mark Hall
Abstract Productions
I PLAYS THE MUSIC THAT MAKES THE PEOPLES FALL DOWN!
Back to top  
JimKurth
Monkey-Butler


Joined: 01 Apr 2007
Posts: 53
Location: Houston, TX

PostPosted: Wed Jul 04, 2007 2:23 am    Post subject: [quote]

Well, I guess you could say I'm trying to make my own routines. I'm doing it because I feel the best way to manipulate things and troubleshoot problems is if you write the code yourself. I am programming in QuickBASIC and I have looked at a MIDI load/playback program for Qbasic, however it only plays 1 track and doesn't account for ticks or duration. I'd use libraries but most people add in too much stuff and I only want to use routines that I will use and how to manipulate it. I've seen a C++ MIDI loading program and since I don't program in C++ (and as hard as I try to learn it, it always stumps me), I'm forced to write my own routines.

I do know the file structure and my first guess is to write a TSR or a program shell that runs simultaneously in the background that initializes the sound card, and sets up the MIDI, and then loops while the game is running, waiting for MIDI commands and/or sound samples. Then, in the game, make an array of 16 cells (1 per track) and have it store the starting byte of that track from the MIDI file. Next, prepare for durations with Track TIMERs and lastly, when the current timer has reached the track timer, send the next MIDI command to this background MIDI player.

Of course what I'm thinking about sounds very tough and complex and it is, especially since I'm using Qbasic and MASM. But anyway thanks for the post.

-Jim
Back to top  
Nodtveidt
Demon Hunter


Joined: 11 Nov 2002
Posts: 786
Location: Camuy, PR

PostPosted: Wed Jul 04, 2007 2:36 am    Post subject: [quote]

There's always QMIDI... :)
_________________
If you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows. - wallace
Back to top  
BDZ
Slightly Deformed Faerie Princess


Joined: 11 Jan 2007
Posts: 32
Location: Wisconsin

PostPosted: Wed Jul 04, 2007 3:15 pm    Post subject: [quote]

I've kind of been wanting to do the same thing as Jim Kurth here. Is there any other simple solution besides QMIDI?
Back to top  
JimKurth
Monkey-Butler


Joined: 01 Apr 2007
Posts: 53
Location: Houston, TX

PostPosted: Wed Jul 04, 2007 9:13 pm    Post subject: [quote]

BDZ,

I'm going to attempt to write a MIDI loader/player in Qbasic. I'll keep you informed of the progress. I'm not going to take forever on it. I'm sure reading the file won't be a problem. It's playback and keeping everything else running smoothly that is the problem. This will be a big challenge for me, but I'll try.

I've got a complete list of Interrupts/Ports and the Internet for resources on soundcard programming (Not going to write "You're soundcard isn't compatible with this program" routines. Just straight guts for general SoundBlaster soundcards)
Back to top  
DeveloperX
202192397


Joined: 04 May 2003
Posts: 1626
Location: Decatur, IL, USA

PostPosted: Thu Jul 05, 2007 4:48 am    Post subject: [quote]

JimKurth wrote:
BDZ,

I'm going to attempt to write a MIDI loader/player in Qbasic. I'll keep you informed of the progress. I'm not going to take forever on it. I'm sure reading the file won't be a problem. It's playback and keeping everything else running smoothly that is the problem. This will be a big challenge for me, but I'll try.

I've got a complete list of Interrupts/Ports and the Internet for resources on soundcard programming (Not going to write "You're soundcard isn't compatible with this program" routines. Just straight guts for general SoundBlaster soundcards)


Tip: Get FreeBASIC. Your QB code will be easily ported over.
And FB has an interface with Allegro to utilize MIDIS, WAVS, and PCX, BMP images. As well as a slew of other things out the box.

If you're stubborn and want to really write a QB MIDI lib; then God-speed. I've attempted that same thing; After more than 256KB of code (...thats quite a lot of lines of code...) and still nothing really usable; I gave up.

I cannot stress enough my support of moving to FB & Allegro before you get too far into your project.

I'd be happy to help you port your code. Just let me know.
Drop me an email here: ccpsceo@gmail.com
Goodnight....
_________________
Principal Software Architect
Rambling Indie Games, LLC

See my professional portfolio
Back to top  
JimKurth
Monkey-Butler


Joined: 01 Apr 2007
Posts: 53
Location: Houston, TX

PostPosted: Thu Jul 05, 2007 5:36 am    Post subject: [quote]

DeveloperX:

I appreciate your input and after thinking things through, I think I just may port this to C++ (somehow, I don't know yet) using MS-VC++ Express and Allegro. I can get some good speed with QB right now (without any ASM code) graphics wise and I think I'll stick with 320x200x32-bit cuz all my graphics are designed for it and I like that style. I do understand some C and I studied it but trying VC++ was completely different (felt like I was instructed to chop down a tree and I was given a fish for a saw). I found a nice C++ Game Programming site that teaches C++ and lessons on Allegro (where is that link...? Oh here: http://www.cppgameprogramming.com/cgi/nav.cgi?page=allegbasics) So, i'll check that out. I do have the guts in Qbasic and flowcharts for some other modules/engines on paper, so porting over wouldn't be hard (no need to start from scratch). I really need sound and music in my game though. It's too powerful to be left out (for any type of media). I'll quit the Qbasic MIDI quest. I did find out how to program the SB and send info to it, and I do have a site telling me the complete layout of a .MID file. Maybe now I can have flicker-free video clips (i was double-buffering a 4-frame walking motion but it went so fast that you saw the flickering problem I guess). I'll post up the file soon... somewhere with a demo of it and the base to create these video files in QB. Anyway, Thanks for the input. BTW, I have played Xenogears and thought the graphics were nice but I wasn't fond of the battle style (i'm just used to old turn-based FF-style cuz that's what I grew up with). Right now, I don't use tiles at all. Only pre-developed images for my towns/buildings/worlds/etc and an array-based movement map to determine where the player can move.

Another good option to moving to C++/Allegro is Joystick commands. I spent a week researching USB PnP codes to receive input from my current gamepad, but beats me how to get it done. All I know is the company and model memory address (xxxx:xxxx).

Well, gotta get to work on my demo cd. Applied for a sound position at TimeGate Studios in Houston and they want a demo cd from me. So, back to work on it. Anybody play their games and enjoy them? They made Kohan series and the FEAR expansion pack.
Back to top  
DeveloperX
202192397


Joined: 04 May 2003
Posts: 1626
Location: Decatur, IL, USA

PostPosted: Thu Jul 05, 2007 6:00 pm    Post subject: [quote]

I've got Allegro & C++ tutorials on my site as well
Please, check em out. :)

http://www.ccpssolutions.com/index.php?pageID=community/articles.php&c=C

and

http://www.ccpssolutions.com/agps/

Goodluck.
_________________
Principal Software Architect
Rambling Indie Games, LLC

See my professional portfolio
Back to top  
Post new topic Reply to topic Page 1 of 1 All times are GMT
 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum