diff options
author | Jamieson Christian | 2003-05-19 00:50:30 +0000 |
---|---|---|
committer | Jamieson Christian | 2003-05-19 00:50:30 +0000 |
commit | 40ce9cdcc34492dc9972fd6c3c111756f8c9fba8 (patch) | |
tree | b57df5c8f21a2d3d5c55db394cddd2020f4c7498 /sound | |
parent | 3b7270a9c65854edb0faaa7270feab5a04c2c63f (diff) | |
download | scummvm-rg350-40ce9cdcc34492dc9972fd6c3c111756f8c9fba8.tar.gz scummvm-rg350-40ce9cdcc34492dc9972fd6c3c111756f8c9fba8.tar.bz2 scummvm-rg350-40ce9cdcc34492dc9972fd6c3c111756f8c9fba8.zip |
MidiStreamer goes away, replaced by MidiParser
svn-id: r7663
Diffstat (limited to 'sound')
-rw-r--r-- | sound/midistreamer.cpp | 125 | ||||
-rw-r--r-- | sound/midistreamer.h | 77 | ||||
-rw-r--r-- | sound/module.mk | 1 |
3 files changed, 0 insertions, 203 deletions
diff --git a/sound/midistreamer.cpp b/sound/midistreamer.cpp deleted file mode 100644 index de5c677ab5..0000000000 --- a/sound/midistreamer.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2003 The ScummVM project - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Header$ - * - */ - -// #include "stdafx.h" -#include "midistreamer.h" -#include "common/util.h" - -MidiStreamer::MidiStreamer (MidiDriver *target) : - _target (target), - _stream_proc (0), - _stream_param (0), - _isOpen (false), - _paused (false), - _event_count (0), - _event_index (0), - _tempo (500000), // 120 BPM = 500,000 microseconds between each beat - _ticks_per_beat (96), - _delay (0) -{ } - -void MidiStreamer::set_stream_callback (void *param, StreamCallback *sc) { - _stream_param = param; - _stream_proc = sc; - - if (_isOpen) { - _event_count = _stream_proc (_stream_param, _events, ARRAYSIZE (_events)); - _event_index = 0; - } -} - -void MidiStreamer::timer_thread (void *param) { - ((MidiStreamer *) param)->on_timer(); -} - -void MidiStreamer::on_timer() { - if (_paused || !_stream_proc) - return; - - _delay += _driver_tempo; - while (true) { - if (_event_index >= _event_count) { - _event_count = _stream_proc (_stream_param, _events, ARRAYSIZE (_events)); - _event_index = 0; - } - - if (!_event_count) - return; - - MidiEvent *ev = &_events [_event_index]; - if (_delay < _tempo * (long) ev->delta / (long) _ticks_per_beat) - return; - _delay -= _tempo * ev->delta / _ticks_per_beat; - if ((ev->event >> 24) != ME_TEMPO) { - _target->send (ev->event); - } else { - _tempo = ev->event & 0xFFFFFF; - } - - ++_event_index; - } // end while -} - -int MidiStreamer::open() { - if (_isOpen) - close(); - - int res = _target->open(); - if (res && res != MidiDriver::MERR_ALREADY_OPEN) - return res; - - _event_index = _event_count = _delay = 0; - _isOpen = true; - _paused = false; - - _driver_tempo = _target->getBaseTempo() / 500; - - _target->setTimerCallback (this, &timer_thread); - return 0; -} - -void MidiStreamer::close() { - if (!_isOpen) - return; - - _target->setTimerCallback (NULL, NULL); - - // Turn off all notes on all channels, - // just to catch anything still playing. - int i; - for (i = 0; i < 16; ++i) - _target->send ((0x7B << 8) | 0xB0 | i); - - _isOpen = false; - _paused = true; -} - -uint32 MidiStreamer::property (int prop, uint32 param) { - switch (prop) { - - // 16-bit time division according to standard midi specification - case MidiDriver::PROP_TIMEDIV: - _ticks_per_beat = (uint16)param; - return 1; - } - - return 0; -} diff --git a/sound/midistreamer.h b/sound/midistreamer.h deleted file mode 100644 index 1356dd98fe..0000000000 --- a/sound/midistreamer.h +++ /dev/null @@ -1,77 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2001-2003 The ScummVM project - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Header$ - * - */ - -#ifndef INCLUDED_MIDISTREAMER -#define INCLUDED_MIDISTREAMER - -class MidiStreamer; - -#include "mididrv.h" - -struct MidiEvent { - uint32 delta; - uint32 event; -}; - -class MidiStreamer { -public: - // Called whenever more MIDI commands need to be generated. - // Return 0 to tell MidiStreamer that end of stream was reached. - typedef int StreamCallback (void *param, MidiEvent *ev, int num); - - // 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 - }; - -private: - MidiDriver *_target; - StreamCallback *_stream_proc; - void *_stream_param; - bool _isOpen; - bool _paused; - - MidiEvent _events[64]; - int _event_count; - int _event_index; - - long _driver_tempo; - long _tempo; - uint16 _ticks_per_beat; - long _delay; - - static void timer_thread (void *param); - void on_timer(); - -public: - MidiStreamer (MidiDriver *target); - - int open(); - void close(); - void send(uint32 b) { if (_isOpen) _target->send (b); } - uint32 property(int prop, uint32 param); - void pause(bool p) { _paused = p; } - void set_stream_callback(void *param, StreamCallback *sc); -}; - -#endif diff --git a/sound/module.mk b/sound/module.mk index a14678afb5..9f49440b71 100644 --- a/sound/module.mk +++ b/sound/module.mk @@ -4,7 +4,6 @@ MODULE_OBJS = \ sound/fmopl.o \ sound/midiparser_smf.o \ sound/midiparser_xmidi.o \ - sound/midistreamer.o \ sound/mixer.o \ sound/mpu401.o |