diff options
author | Simon Howard | 2006-07-22 16:43:12 +0000 |
---|---|---|
committer | Simon Howard | 2006-07-22 16:43:12 +0000 |
commit | 87c062c1d4f7788620183f36b7239cdf28c4d2d1 (patch) | |
tree | 8c0981396399bc26b4ec8da010edb825af04f5db /src/i_sound.c | |
parent | 6b9f3748cf561254f085fa83ada80cb5ba9b3946 (diff) | |
download | chocolate-doom-87c062c1d4f7788620183f36b7239cdf28c4d2d1.tar.gz chocolate-doom-87c062c1d4f7788620183f36b7239cdf28c4d2d1.tar.bz2 chocolate-doom-87c062c1d4f7788620183f36b7239cdf28c4d2d1.zip |
New mus -> mid conversion code thanks to Ben Ryves <benryves@benryves.com>
This plays back a lot of music closer to Vanilla Doom - eg. tnt.wad map02
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 566
Diffstat (limited to 'src/i_sound.c')
-rw-r--r-- | src/i_sound.c | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/src/i_sound.c b/src/i_sound.c index 0ef92b22..a2008862 100644 --- a/src/i_sound.c +++ b/src/i_sound.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: i_sound.c 473 2006-05-03 18:54:08Z fraggle $ +// $Id: i_sound.c 566 2006-07-22 16:43:12Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -128,7 +128,7 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: i_sound.c 473 2006-05-03 18:54:08Z fraggle $"; +rcsid[] = "$Id: i_sound.c 566 2006-07-22 16:43:12Z fraggle $"; #include <stdio.h> #include <stdlib.h> @@ -139,7 +139,8 @@ rcsid[] = "$Id: i_sound.c 473 2006-05-03 18:54:08Z fraggle $"; #include <unistd.h> #endif -#include "mmus2mid.h" +#include "memio.h" +#include "mus2mid.h" #include "z_zone.h" #include "i_system.h" @@ -687,40 +688,26 @@ static boolean IsMus(byte *mem, int len) static boolean ConvertMus(byte *musdata, int len, char *filename) { - MIDI *mididata; - UBYTE *mid; - int midlen; - boolean result; + MEMFILE *instream; + MEMFILE *outstream; + void *outbuf; + size_t outbuf_len; + int result; - // Convert from mus to midi - // Bits here came from PrBoom - - mididata = Z_Malloc(sizeof(MIDI), PU_STATIC, 0); - mmus2mid(musdata, mididata, 89, 0); - - if (MIDIToMidi(mididata, &mid, &midlen)) - { - // Error occurred + instream = mem_fopen_read(musdata, len); + outstream = mem_fopen_write(); - fprintf(stderr, "Error converting MUS lump.\n"); + result = mus2mid(instream, outstream); - result = false; - } - else + if (result == 0) { - // Write midi data to disk - - M_WriteFile(filename, mid, midlen); - - // Clean up - - free(mid); - free_mididata(mididata); + mem_get_buf(outstream, &outbuf, &outbuf_len); - result = true; + M_WriteFile(filename, outbuf, outbuf_len); } - Z_Free(mididata); + mem_fclose(instream); + mem_fclose(outstream); return result; } |