aboutsummaryrefslogtreecommitdiff
path: root/backends/midi/mt32/mt32.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2004-11-06 01:41:32 +0000
committerEugene Sandulenko2004-11-06 01:41:32 +0000
commit805b21181ab7138da6960ade703b25716120fc29 (patch)
tree8a8b04662d7e25f0b6d3675452cd50fc589b5ee6 /backends/midi/mt32/mt32.cpp
parentab7c30e4ed59004f311fd068746d1537c9da5f50 (diff)
downloadscummvm-rg350-805b21181ab7138da6960ade703b25716120fc29.tar.gz
scummvm-rg350-805b21181ab7138da6960ade703b25716120fc29.tar.bz2
scummvm-rg350-805b21181ab7138da6960ade703b25716120fc29.zip
Major MT-32 emu overhaul based on KingGuppy's code.
o added configure option o mi2 intro doesn't freeze anymore and has no sound glitches o missing instruments in many titles are fixed o numerous memory overwrite bugs are fixed o code is cleaned a lot and splitted into many smaller files o mt32.cpp went to backends/midi o synced with upstream code o reverberation fixed * don't complain about File class wrapper :) * all custom types are back * #pragmas are to do * maybe some indentation is wrong too I prefer smaller commits, but this thing came in one piece. svn-id: r15715
Diffstat (limited to 'backends/midi/mt32/mt32.cpp')
-rw-r--r--backends/midi/mt32/mt32.cpp156
1 files changed, 0 insertions, 156 deletions
diff --git a/backends/midi/mt32/mt32.cpp b/backends/midi/mt32/mt32.cpp
deleted file mode 100644
index 9faaa923ad..0000000000
--- a/backends/midi/mt32/mt32.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2004 The ScummVM project
- *
- * YM2612 tone generation code written by Tomoaki Hayasaka.
- * Used under the terms of the GNU General Public License.
- * Adpated to ScummVM by Jamieson Christian.
- *
- * 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 "backends/midi/emumidi.h"
-
-#include "common/util.h"
-#include "common/file.h"
-
-#include "backends/midi/mt32/synth.h"
-
-class MidiDriver_MT32 : public MidiDriver_Emulated {
-private:
- CSynthMT32 *_synth;
-
- int _outputRate;
-
-protected:
- void generate_samples(int16 *buf, int len);
-
-public:
- MidiDriver_MT32(SoundMixer *mixer, const char *path);
- virtual ~MidiDriver_MT32();
-
- int open();
- void close();
- void send(uint32 b);
- uint32 property(int prop, uint32 param) { return 0; }
-
- void setPitchBendRange(byte channel, uint range) { }
- void sysEx(byte *msg, uint16 length);
-
- MidiChannel *allocateChannel() { return 0; }
- MidiChannel *getPercussionChannel() { return 0; }
-
-
- // AudioStream API
- bool isStereo() const { return true; }
- int getRate() const { return _outputRate; }
-};
-
-
-////////////////////////////////////////
-//
-// MidiDriver_MT32
-//
-////////////////////////////////////////
-
-
-MidiDriver_MT32::MidiDriver_MT32(SoundMixer *mixer, const char *path)
- : MidiDriver_Emulated(mixer) {
- File fp;
-
- _synth = new CSynthMT32();
- File::addDefaultDirectory(path);
-
- _baseFreq = 1000;
-
- fp.open("waveforms.raw");
-
- if(!fp.isOpen()) {
- error("Unable to open waveforms.raw");
- }
-
- switch(fp.size()) {
- case 1410000:
- _outputRate = 32000;
- break;
- case 1944040:
- _outputRate = 44100;
- break;
- default:
- error("MT-32: Unknown waveforms.raw file sample rate");
- }
- fp.close();
-}
-
-MidiDriver_MT32::~MidiDriver_MT32() {
- delete _synth;
-}
-
-int MidiDriver_MT32::open() {
- SynthProperties prop;
-
- if (_isOpen)
- return MERR_ALREADY_OPEN;
-
- MidiDriver_Emulated::open();
-
- prop.SampleRate = getRate(); // 32000;
- prop.UseReverb = true;
- prop.UseDefault = true;
- //prop.RevType = 0;
- //prop.RevTime = 5;
- //prop.RevLevel = 3;
-
- _synth->ClassicOpen(prop);
-
- _mixer->setupPremix(this);
-
- return 0;
-}
-
-void MidiDriver_MT32::send(uint32 b) {
- _synth->PlayMsg(b);
-}
-
-void MidiDriver_MT32::sysEx(byte *msg, uint16 length) {
- _synth->PlaySysex(msg, length);
-}
-
-void MidiDriver_MT32::close() {
- if (!_isOpen)
- return;
- _isOpen = false;
-
- // Detach the premix callback handler
- _mixer->setupPremix(0);
-
- _synth->Close();
-}
-
-void MidiDriver_MT32::generate_samples(int16 *data, int len) {
- _synth->MT32_CallBack((uint8 *)data, len, _mixer->getMusicVolume());
-}
-
-
-////////////////////////////////////////
-//
-// MidiDriver_MT32 factory
-//
-////////////////////////////////////////
-
-MidiDriver *MidiDriver_MT32_create(SoundMixer *mixer, const char *path) {
- return new MidiDriver_MT32(mixer, path);
-}