[Scummvm-cvs-logs] CVS: scummvm/sound imuse.h,NONE,1.1 mididrv.h,NONE,1.1 mixer.cpp,NONE,1.1 mixer.h,NONE,1.1 imuse.cpp,1.21,1.22 mididrv.cpp,1.1,1.2 adlib.cpp,1.12,NONE gmidi.cpp,1.14,NONE gmidi.h,1.6,NONE

Ludvig Strigeus strigeus at users.sourceforge.net
Sun Apr 14 11:14:06 CEST 2002


Update of /cvsroot/scummvm/scummvm/sound
In directory usw-pr-cvs1:/tmp/cvs-serv31838/sound

Modified Files:
	imuse.cpp mididrv.cpp 
Added Files:
	imuse.h mididrv.h mixer.cpp mixer.h 
Removed Files:
	adlib.cpp gmidi.cpp gmidi.h 
Log Message:
wrote new mixer class,
cleaned up sound header files,
integrated mixer into scummvm & simon


--- NEW FILE: imuse.h ---

//WARNING: These is only the public interface to the IMUSE class
//This is safe as long as none of the methods are virtual,
//and as long as no variables are put here.
//Removing the private parts from the public class definition,
//means that the internals of IMuse can change without having to
//recompile all files that depend on this interface.
//Also, it probably decreases compile times, since the IMuse specific
//classes only will be parsed once (which is when imuse.cpp is compiled)


//If you change stuff here, you *MUST* change stuff in imuse.cpp as well

class IMuse {
public:
	/* making a dummy constructor means that this object will never be
	 * instanciated on its own */

public:
	enum {
		PROP_TEMPO_BASE = 1,
		PROP_MT32_EMULATE = 2,
	};

	void on_timer();
	void pause(bool paused);
	int terminate();
	int save_or_load(Serializer *ser, Scumm *scumm);
	int set_music_volume(uint vol);
	int get_music_volume();
	int set_master_volume(uint vol);
	int get_master_volume();
	bool start_sound(int sound);
	int stop_sound(int sound);
	int stop_all_sounds();
	int get_sound_status(int sound);
	int32 do_command(int a, int b, int c, int d, int e, int f, int g, int h);
	int clear_queue();
	void setBase(byte **base);
	uint32 property(int prop, uint32 value);

	static IMuse *create(OSystem *syst, MidiDriver *midi, SoundMixer *mixer);

	static IMuse *create_adlib(OSystem *syst, SoundMixer *mixer) { return create(syst, NULL, mixer); }
	static IMuse *create_midi(OSystem *syst, MidiDriver *midi) { return create(syst, midi, NULL); }
};

--- NEW FILE: mididrv.h ---
struct MidiEvent {
	uint32 delta;
	uint32 event;
};

/* Lowlevel Abstract Midi Driver Class */
class MidiDriver {
	
public:
	/* called whenever the midi driver is in streaming mode,
	 * and more midi commands need to be generated
	 * return 0 to tell the mididriver that the end of stream was reached
	 */
	typedef int StreamCallback(void *param, MidiEvent *ev, int num);
	

	/* open modes, pass one of those to open() */
	enum {
		MO_SIMPLE = 1,
		MO_STREAMING = 2,
	};

	/* Special events that can be inserted in a MidiEvent.
	 * event = (ME_xxx<<24) | <24-bit data associated with event>
	 */
	enum {
		ME_NONE  = 0,
		ME_TEMPO = 1,
	};

	/* error codes returned by open.
	 * can be converted to a string with get_error_name()
	 */
	enum {
		MERR_CANNOT_CONNECT = 1,
		MERR_STREAMING_NOT_AVAILABLE = 2,
		MERR_DEVICE_NOT_AVAILABLE = 3,
		MERR_ALREADY_OPEN = 4,
	};

	enum {
		PROP_TIMEDIV = 1,
	};

	
	/* destroy the midi object */
	virtual void destroy() = 0;

	/* open the midi driver.
	 * returns 0 if successful.
	 * otherwise an error code. */
	virtual int open(int mode) = 0;

	/* close the midi driver */
	virtual void close() = 0;

	/* output a packed midi command to the midi stream
	 * valid only if mode is MO_SIMPLE
	 */
	virtual void send(uint32 b) = 0;

	/* set callback when more streams need to be generated.
	 * valid only when mode==MO_STREAMING
	 */
	virtual void set_stream_callback(void *param, StreamCallback *sc) = 0;

	/* Pause or resume streaming MIDI */
	virtual void pause(bool pause) = 0;


	/* Get or set a property */
	virtual uint32 property(int prop, uint32 param) = 0;

	/* retrieve a string representation of an error code */
	static const char *get_error_name(int error_code);
};



/* driver types */
enum {
	MD_AUTO = 0,
	MD_NULL = 1,
	MD_WINDOWS = 2,
	MD_TIMIDITY = 3,
	MD_SEQ = 4,
	MD_QTMUSIC = 5,
	MD_AMIDI = 6,
};


/* Factory functions => no need to include the specific classes
 * in this header => faster compile */
MidiDriver *MidiDriver_NULL_create();
MidiDriver *MidiDriver_WIN_create();
MidiDriver *MidiDriver_TIMIDITY_create();
MidiDriver *MidiDriver_SEQ_create();
MidiDriver *MidiDriver_QT_create();
MidiDriver *MidiDriver_AMIDI_create();

--- NEW FILE: mixer.cpp ---
#include "stdafx.h"
#include "scumm.h"
#include "cdmusic.h"

void SoundMixer::uninsert(Channel *chan) {

	for(int i=0; i!=NUM_CHANNELS; i++) {	
		if (_channels[i] == chan) {
			if (_handles[i]) {
				*_handles[i] = 0;
				_handles[i] = NULL;
			}
			_channels[i] = NULL;
			return;
		}
	}
	error("SoundMixer::channel_deleted chan not found");
}

void SoundMixer::insert(PlayingSoundHandle *handle, Channel *chan) {
	for(int i=0; i!=NUM_CHANNELS; i++) {
		if (_channels[i] == NULL) {
			_channels[i] = chan;
			_handles[i] = handle;
			if (handle)
				*handle = i + 1;
			return;
		}
	}
	
	warning("SoundMixer::insert out of mixer slots");
	chan->destroy();
}


void SoundMixer::play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags) {
	insert(handle, new Channel_RAW(this, sound, size, rate, flags));
}

void SoundMixer::mix(int16 *buf, uint len) {
	if (_premix_proc) {
		_premix_proc(_premix_param, buf, len);
	} else {
		/* no premixer available, zero the buf out */
		memset(buf, 0, len * sizeof(int16));
	}

	/* now mix all channels */
	for(int i=0; i!=NUM_CHANNELS; i++)
		if (_channels[i])
			_channels[i]->mix(buf, len);
}

void SoundMixer::on_generate_samples(void *s, byte *samples, int len) {
	((SoundMixer*)s)->mix((int16*)samples, len>>1);
}

void SoundMixer::bind_to_system(OSystem *syst) {
	_volume_table = (int16*)calloc(256*sizeof(int16),1);
		
	uint rate = (uint)syst->property(OSystem::PROP_GET_SAMPLE_RATE, 0);

	_output_rate = rate;
	
	if (rate == 0)
		error("OSystem returned invalid sample rate");
	
	syst->set_sound_proc(this, on_generate_samples, OSystem::SOUND_16BIT);
}

void SoundMixer::stop_all() {
	for(int i=0; i!=NUM_CHANNELS; i++)
		if (_channels[i])
			_channels[i]->destroy();
}

void SoundMixer::stop(PlayingSoundHandle psh) {
	if (psh && _channels[psh-1])
		_channels[psh-1]->destroy();
}


bool SoundMixer::has_active_channel() {
	for(int i=0; i!=NUM_CHANNELS; i++)
		if (_channels[i])
			return true;
	return false;
}

void SoundMixer::setup_premix(void *param, PremixProc *proc) {
	_premix_param = param;
	_premix_proc = proc;
}

void SoundMixer::set_volume(int volume) {
	for(int i=0; i!=256; i++)
		_volume_table[i] =((int8)i) * volume;
}


/* RAW mixer */
SoundMixer::Channel_RAW::Channel_RAW(SoundMixer *mixer, void *sound, uint32 size, uint rate, byte flags) {
	_mixer = mixer;
	_flags = flags;
	_ptr = sound;
	_pos = 0;
	_fp_pos = 0;
	_fp_speed = (1 << 16) * rate / mixer->_output_rate;

	/* adjust the magnitute to prevent division error */
	while (size & 0xFFFF0000)
		size >>= 1, rate >>= 1;

	_size = size * mixer->_output_rate / rate;
}

void SoundMixer::Channel_RAW::mix(int16 *data, uint len) {
	byte *s, *s_org = NULL;
	uint32 fp_pos;

	if (len > _size)
		len = _size;
	_size -= len;

	/* 
	 * simple support for fread() reading of samples
	 */
	if (_flags & FLAG_FILE) {
		/* determine how many samples to read from the file */
		uint num = len * _fp_speed >> 16;

		s_org = (byte*)malloc(num);
		if (s_org == NULL)
			error("Channel_RAW::mix out of memory");
		
		uint num_read = fread(s_org, 1, num, (FILE*)_ptr);
		if (num - num_read != 0)
			memset(s_org + num_read, 0x80, num - num_read);
				
		s = s_org;
		fp_pos = 0;
	} else {
		s = (byte*)_ptr + _pos;
		fp_pos = _fp_pos;
	}

	const uint32 fp_speed = _fp_speed;
	const int16 *vol_tab = _mixer->_volume_table;

	if (_flags & FLAG_UNSIGNED) {
		do {
			fp_pos += fp_speed;
			*data++ += vol_tab[*s ^ 0x80];
			s += fp_pos >> 16;
			fp_pos &= 0x0000FFFF;
		} while (--len);
	} else {
		do {
			fp_pos += fp_speed;
			*data++ += vol_tab[*s];
			s += fp_pos >> 16;
			fp_pos &= 0x0000FFFF;
		} while (--len);
	}

	_pos = s - (byte*) _ptr;
	_fp_pos = fp_pos;

	if (_flags & FLAG_FILE) {
		free(s_org);
	}

	if (!_size)
		destroy();
}

void SoundMixer::Channel_RAW::destroy() {
	if (_flags & FLAG_AUTOFREE)
		free(_ptr);
	_mixer->uninsert(this);
	delete this;
}


/* MP3 mixer goes here */

#if 0

#ifdef COMPRESSED_SOUND_FILE
void Scumm::playSfxSound_MP3(void *sound, uint32 size)
{
	MixerChannel *mc = allocateMixer();

	if (!mc) {
		warning("No mixer channel available");
		return;
	}

	mc->type = MIXER_MP3;
	mc->_sfx_sound = sound;

	mad_stream_init(&mc->sound_data.mp3.stream);



#ifdef _WIN32_WCE

	// 11 kHz on WinCE

	mad_stream_options((mad_stream *) & mc->sound_data.mp3.stream,
										 MAD_OPTION_HALFSAMPLERATE);

#endif


	mad_frame_init(&mc->sound_data.mp3.frame);
	mad_synth_init(&mc->sound_data.mp3.synth);
	mc->sound_data.mp3.position = 0;
	mc->sound_data.mp3.pos_in_frame = 0xFFFFFFFF;
	mc->sound_data.mp3.size = size;
	/* This variable is the number of samples to cut at the start of the MP3
	   file. This is needed to have lip-sync as the MP3 file have some miliseconds
	   of blank at the start (as, I suppose, the MP3 compression algorithm need to
	   have some silence at the start to really be efficient and to not distort
	   too much the start of the sample).

	   This value was found by experimenting out. If you recompress differently your
	   .SO3 file, you may have to change this value.

	   When using Lame, it seems that the sound starts to have some volume about 50 ms
	   from the start of the sound => we skip about 1024 samples.
	 */
	mc->sound_data.mp3.silence_cut = 1024;
}
#endif

#ifdef COMPRESSED_SOUND_FILE
static inline int scale_sample(mad_fixed_t sample)
{
	/* round */
	sample += (1L << (MAD_F_FRACBITS - 16));

	/* clip */
	if (sample >= MAD_F_ONE)
		sample = MAD_F_ONE - 1;
	else if (sample < -MAD_F_ONE)
		sample = -MAD_F_ONE;

	/* quantize and scale to not saturate when mixing a lot of channels */
	return sample >> (MAD_F_FRACBITS + 2 - 16);
}
#endif

void MixerChannel::mix(int16 * data, uint32 len)
{
	if (!_sfx_sound)
		return;

#ifdef COMPRESSED_SOUND_FILE
	if (type == MIXER_STANDARD) {
#endif
		int8 *s;
		uint32 fp_pos, fp_speed;

		if (len > sound_data.standard._sfx_size)
			len = sound_data.standard._sfx_size;
		sound_data.standard._sfx_size -= len;

		s = (int8 *) _sfx_sound + sound_data.standard._sfx_pos;
		fp_pos = sound_data.standard._sfx_fp_pos;
		fp_speed = sound_data.standard._sfx_fp_speed;

		do {
			fp_pos += fp_speed;
			*data++ += (*s << 6);
			s += fp_pos >> 16;
			fp_pos &= 0x0000FFFF;
		} while (--len);

		sound_data.standard._sfx_pos = s - (int8 *) _sfx_sound;
		sound_data.standard._sfx_fp_speed = fp_speed;
		sound_data.standard._sfx_fp_pos = fp_pos;

		if (!sound_data.standard._sfx_size)
			clear();
#ifdef COMPRESSED_SOUND_FILE
	} else {
		if (type == MIXER_MP3) {
			mad_fixed_t const *ch;
			while (1) {
				ch =
					sound_data.mp3.synth.pcm.samples[0] + sound_data.mp3.pos_in_frame;
				while ((sound_data.mp3.pos_in_frame < sound_data.mp3.synth.pcm.length)
							 && (len > 0)) {
					if (sound_data.mp3.silence_cut > 0) {
						sound_data.mp3.silence_cut--;
					} else {
						*data++ += scale_sample(*ch++);
						len--;
					}
					sound_data.mp3.pos_in_frame++;
				}
				if (len == 0)
					return;

				if (sound_data.mp3.position >= sound_data.mp3.size) {
					clear();
					return;
				}

				mad_stream_buffer(&sound_data.mp3.stream,
													((unsigned char *)_sfx_sound) +
													sound_data.mp3.position,
													sound_data.mp3.size + MAD_BUFFER_GUARD -
													sound_data.mp3.position);

				if (mad_frame_decode(&sound_data.mp3.frame, &sound_data.mp3.stream) ==
						-1) {
					/* End of audio... */
					if (sound_data.mp3.stream.error == MAD_ERROR_BUFLEN) {
						clear();
						return;
					} else if (!MAD_RECOVERABLE(sound_data.mp3.stream.error)) {
						error("MAD frame decode error !");
					}
				}
				mad_synth_frame(&sound_data.mp3.synth, &sound_data.mp3.frame);
				sound_data.mp3.pos_in_frame = 0;
				sound_data.mp3.position =
					(unsigned char *)sound_data.mp3.stream.next_frame -
					(unsigned char *)_sfx_sound;
			}
		} else if (type == MIXER_MP3_CDMUSIC) {
			mad_fixed_t const *ch;
			mad_timer_t frame_duration;
			static long last_pos = 0;

			if (!sound_data.mp3_cdmusic.playing)
				return;

			while (1) {

				// See if we just skipped
				if (ftell(sound_data.mp3_cdmusic.file) != last_pos) {
					int skip_loop;

					// Read the new data
					memset(_sfx_sound, 0,
								 sound_data.mp3_cdmusic.buffer_size + MAD_BUFFER_GUARD);
					sound_data.mp3_cdmusic.size =
						fread(_sfx_sound, 1, sound_data.mp3_cdmusic.buffer_size,
									sound_data.mp3_cdmusic.file);
					if (!sound_data.mp3_cdmusic.size) {
						sound_data.mp3_cdmusic.playing = false;
						return;
					}
					last_pos = ftell(sound_data.mp3_cdmusic.file);
					// Resync
					mad_stream_buffer(&sound_data.mp3_cdmusic.stream,
														(unsigned char *)_sfx_sound,
														sound_data.mp3_cdmusic.size);
					skip_loop = 2;
					while (skip_loop != 0) {
						if (mad_frame_decode(&sound_data.mp3_cdmusic.frame,
																 &sound_data.mp3_cdmusic.stream) == 0) {
							/* Do not decrease duration - see if it's a problem */
							skip_loop--;
							if (skip_loop == 0) {
								mad_synth_frame(&sound_data.mp3_cdmusic.synth,
																&sound_data.mp3_cdmusic.frame);
							}
						} else {
							if (!MAD_RECOVERABLE(sound_data.mp3_cdmusic.stream.error)) {
								debug(1, "Unrecoverable error while skipping !");
								sound_data.mp3_cdmusic.playing = false;
								return;
							}
						}
					}
					// We are supposed to be in synch
					mad_frame_mute(&sound_data.mp3_cdmusic.frame);
					mad_synth_mute(&sound_data.mp3_cdmusic.synth);
					// Resume decoding
					if (mad_frame_decode(&sound_data.mp3_cdmusic.frame,
															 &sound_data.mp3_cdmusic.stream) == 0) {
						sound_data.mp3_cdmusic.position =
							(unsigned char *)sound_data.mp3_cdmusic.stream.next_frame -
							(unsigned char *)_sfx_sound;
						sound_data.mp3_cdmusic.pos_in_frame = 0;
					} else {
						sound_data.mp3_cdmusic.playing = false;
						return;
					}
				}
				// Get samples, play samples ... 

				ch = sound_data.mp3_cdmusic.synth.pcm.samples[0] +
					sound_data.mp3_cdmusic.pos_in_frame;
				while ((sound_data.mp3_cdmusic.pos_in_frame <
								sound_data.mp3_cdmusic.synth.pcm.length) && (len > 0)) {
					*data++ += scale_sample(*ch++);
					len--;
					sound_data.mp3_cdmusic.pos_in_frame++;
				}
				if (len == 0) {
					return;
				}
				// See if we have finished
				// May be incorrect to check the size at the end of a frame but I suppose
				// they are short enough :)   

				frame_duration = sound_data.mp3_cdmusic.frame.header.duration;

				mad_timer_negate(&frame_duration);
				mad_timer_add(&sound_data.mp3_cdmusic.duration, frame_duration);
				if (mad_timer_compare(sound_data.mp3_cdmusic.duration, mad_timer_zero)
						< 0) {
					sound_data.mp3_cdmusic.playing = false;
				}

				if (mad_frame_decode(&sound_data.mp3_cdmusic.frame,
														 &sound_data.mp3_cdmusic.stream) == -1) {

					if (sound_data.mp3_cdmusic.stream.error == MAD_ERROR_BUFLEN) {
						int not_decoded;

						if (!sound_data.mp3_cdmusic.stream.next_frame) {
							memset(_sfx_sound, 0,
										 sound_data.mp3_cdmusic.buffer_size + MAD_BUFFER_GUARD);
							sound_data.mp3_cdmusic.size =
								fread(_sfx_sound, 1, sound_data.mp3_cdmusic.buffer_size,
											sound_data.mp3_cdmusic.file);
							sound_data.mp3_cdmusic.position = 0;
							not_decoded = 0;
						} else {
							not_decoded = sound_data.mp3_cdmusic.stream.bufend -
								sound_data.mp3_cdmusic.stream.next_frame;
							memcpy(_sfx_sound, sound_data.mp3_cdmusic.stream.next_frame,
										 not_decoded);

							sound_data.mp3_cdmusic.size =
								fread((unsigned char *)_sfx_sound + not_decoded, 1,
											sound_data.mp3_cdmusic.buffer_size - not_decoded,
											sound_data.mp3_cdmusic.file);
						}
						last_pos = ftell(sound_data.mp3_cdmusic.file);
						sound_data.mp3_cdmusic.stream.error = MAD_ERROR_NONE;
						// Restream
						mad_stream_buffer(&sound_data.mp3_cdmusic.stream,
															(unsigned char *)_sfx_sound,
															sound_data.mp3_cdmusic.size + not_decoded);
						if (mad_frame_decode
								(&sound_data.mp3_cdmusic.frame,
								 &sound_data.mp3_cdmusic.stream) == -1) {
							debug(1, "Error decoding after restream %d !",
										sound_data.mp3.stream.error);
						}
					} else if (!MAD_RECOVERABLE(sound_data.mp3.stream.error)) {
						error("MAD frame decode error in MP3 CDMUSIC !");
					}
				}

				mad_synth_frame(&sound_data.mp3_cdmusic.synth,
												&sound_data.mp3_cdmusic.frame);
				sound_data.mp3_cdmusic.pos_in_frame = 0;
				sound_data.mp3_cdmusic.position =
					(unsigned char *)sound_data.mp3_cdmusic.stream.next_frame -
					(unsigned char *)_sfx_sound;
			}
		}
	}
#endif
}

void MixerChannel::clear()
{
	free(_sfx_sound);
	_sfx_sound = NULL;

#ifdef COMPRESSED_SOUND_FILE
	if (type == MIXER_MP3) {
		mad_synth_finish(&sound_data.mp3.synth);
		mad_frame_finish(&sound_data.mp3.frame);
		mad_stream_finish(&sound_data.mp3.stream);
	}
#endif
}

#endif



--- NEW FILE: mixer.h ---
#ifndef _mixer_h_included
#define _mixer_h_included

typedef uint32 PlayingSoundHandle;

class SoundMixer {
private:	
	class Channel {
	public:
		virtual void mix(int16 *data, uint len) = 0;
		virtual void destroy() = 0;
	};

	class Channel_RAW : public Channel {
		SoundMixer *_mixer;
		void *_ptr;
		uint32 _pos;
		uint32 _size;
		uint32 _fp_speed;
		uint32 _fp_pos;
		byte _flags;
		

	public:
		void mix(int16 *data, uint len);
		void destroy();

		Channel_RAW(SoundMixer *mixer, void *sound, uint32 size, uint rate, byte flags);
	};

#ifdef COMPRESSED_SOUND_FILE

	class Channel_RAW : public Channel {
		SoundMixer *_mixer;

	public:
		void mix(int16 *data, uint len);
		void destroy();

		Channel_MP3(SoundMixer *mixer, void *sound, uint rate);
	};

#endif

	static void on_generate_samples(void *s, byte *samples, int len);

public:
	typedef void PremixProc(void *param, int16 *data, uint len);

	uint _output_rate;

	int16 *_volume_table;

	enum {
		NUM_CHANNELS = 16,
	};

	void *_premix_param;
	PremixProc *_premix_proc;

	Channel *_channels[NUM_CHANNELS];
	PlayingSoundHandle *_handles[NUM_CHANNELS];
	
	void insert(PlayingSoundHandle *handle, Channel *chan);
	void uninsert(Channel *chan);

	/* start playing a raw sound */
	enum {
		FLAG_AUTOFREE = 1,
		FLAG_UNSIGNED = 2, /* unsigned samples */
		FLAG_FILE = 4,		 /* sound is a FILE * that's read from */
	};
	void play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags);

	/* Premix procedure, useful when using fmopl adlib */
	void setup_premix(void *param, PremixProc *proc);

	/* mix */
	void mix(int16 *buf, uint len);

	/* stop all currently playing sounds */
	void stop_all();

	/* stop playing a specific sound */
	void stop(PlayingSoundHandle psh);

	/* is any channel active? */
	bool has_active_channel();

	/* bind to the OSystem object => mixer will be
	 * invoked automatically when samples need
	 * to be generated */
	void bind_to_system(OSystem *syst);

	/* set the volume, 0-256 */
	void set_volume(int volume);

};


struct MP3OffsetTable {	/* Compressed Sound (.SO3) */
	int org_offset;
	int new_offset;
	int num_tags;
	int compressed_size;
};



#if 0
typedef enum {			/* Mixer types */
  MIXER_STANDARD,
  MIXER_MP3,
  MIXER_MP3_CDMUSIC
} MixerType;

struct MixerChannel {	/* Mixer Channel */
	void *_sfx_sound;
	MixerType type;
	union {
	  struct {
	    uint32 _sfx_pos;
	    uint32 _sfx_size;
	    uint32 _sfx_fp_speed;
	    uint32 _sfx_fp_pos;
	  } standard;
#ifdef COMPRESSED_SOUND_FILE
	  struct {
	    struct mad_stream stream;
	    struct mad_frame frame;
	    struct mad_synth synth;
	    uint32 silence_cut;
	    uint32 pos_in_frame;
	    uint32 position;
	    uint32 size;
	  } mp3;
	  struct {
            struct mad_stream stream;
            struct mad_frame frame;
            struct mad_synth synth;
            uint32 pos_in_frame;
            uint32 position;
            uint32 size;
            uint32 buffer_size;
            mad_timer_t duration;
            bool   playing;
            FILE   *file;
          } mp3_cdmusic;
#endif
	} sound_data;
	void mix(int16 *data, uint32 len);
	void clear();
};
#endif


#endif /* _mixer_h_included */

Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/imuse.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** imuse.cpp	13 Apr 2002 18:31:45 -0000	1.21
--- imuse.cpp	14 Apr 2002 18:13:08 -0000	1.22
***************
*** 21,26 ****
  
  #include "stdafx.h"
- 
  #include "scumm.h"
  
  int num_mix;
--- 21,27 ----
  
  #include "stdafx.h"
  #include "scumm.h"
[...2873 lines suppressed...]
+ 			midiProgram(mc->_chan, part->_program);
+ 		}
+ 	}
+ 
+ 	if (what & pcChorus)
+ 		midiChorus(mc->_chan, part->_effect_level);
+ }
+ 
+ 
+ void IMuseGM::part_off(Part *part)
+ {
+ 	MidiChannelGM *mc = part->_mc->gm();
+ 	if (mc) {
+ 		part->_mc = NULL;
+ 		mc->_part = NULL;
+ 		memset(mc->_actives, 0, sizeof(mc->_actives));
+ 		midiSilence(mc->_chan);
+ 	}
+ }
+ 

Index: mididrv.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mididrv.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** mididrv.cpp	13 Apr 2002 18:34:11 -0000	1.1
--- mididrv.cpp	14 Apr 2002 18:13:08 -0000	1.2
***************
*** 31,39 ****
  #endif
  
- 
  #include "stdafx.h"
  #include "scumm.h"
! #include "gmidi.h"
! 
  
  #ifdef WIN32
--- 31,37 ----
  #endif
  
  #include "stdafx.h"
  #include "scumm.h"
! #include "mididrv.h"
  
  #ifdef WIN32
***************
*** 327,333 ****
  
  
- 
- 
- 
  void MidiDriver::midiInit()
  {
--- 325,328 ----
***************
*** 687,689 ****
  		("Music not enabled - MIDI support selected with no MIDI driver available. Try Adlib");
  }
! #endif
\ No newline at end of file
--- 682,731 ----
  		("Music not enabled - MIDI support selected with no MIDI driver available. Try Adlib");
  }
! 
! 
! 
! /* old header stuff.. */
! /* General Midi header file */
! #define SEQ_MIDIPUTC    5
! #define SPECIAL_CHANNEL 9
! #define DEVICE_NUM 0
! 
! 
! 
! #ifdef __APPLE__CW
! 	#include <QuickTimeComponents.h>
! 	#include "QuickTimeMusic.h"
! 
! 	NoteAllocator qtNoteAllocator;
! 	NoteChannel qtNoteChannel[16];
! 	NoteRequest simpleNoteRequest;
! #endif
! 
! #ifdef WIN32
! 	#include <winsock.h>
! #elif defined(UNIX)
! 	#include <sys/time.h>
! 	#include <unistd.h>
! 	#include <sys/types.h>
! 	#include <sys/socket.h>
! 	#include <netinet/in.h>
! 	#include <netdb.h>
! 	#include <stdio.h>
! 	#include <stdlib.h>
! 	#include <string.h>
! #endif
! 
! #ifdef __MORPHOS__
! 	#include <exec/types.h>
! 	#include <devices/amidi.h>
! 
! 	#define NO_PPCINLINE_STDARG
! 	#define NO_PPCINLINE_VARARGS
! 	#include <clib/alib_protos.h>
! 	#include <proto/exec.h>
! 	#undef CMD_INVALID
! 
! 	extern struct IOMidiRequest *ScummMidiRequest;
! #endif
! 
! #endif /* 0 */
\ No newline at end of file

--- adlib.cpp DELETED ---

--- gmidi.cpp DELETED ---

--- gmidi.h DELETED ---





More information about the Scummvm-git-logs mailing list