From 6d78ff3469b8eedbf597ae811c9d89a18b10b407 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Oct 2010 13:49:33 +0000 Subject: [PATCH] - Backported GZDoom revisions 1018-1019: Fixed spelling of "pseudo" because it bugged me too much. ;) SVN r2880 (trunk) --- src/CMakeLists.txt | 2 +- src/sound/i_musicinterns.h | 14 +- src/sound/music_pseudo_mididevice.cpp | 260 ++++++++++++++++++++++++++ src/timidity/sf2.h | 2 +- zdoom.vcproj | 2 +- 5 files changed, 270 insertions(+), 10 deletions(-) create mode 100644 src/sound/music_pseudo_mididevice.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40f5772e76..298fe16a6a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -838,7 +838,7 @@ add_executable( zdoom WIN32 sound/music_softsynth_mididevice.cpp sound/music_timidity_mididevice.cpp sound/music_win_mididevice.cpp - sound/music_psuedo_mididevice.cpp + sound/music_pseudo_mididevice.cpp textures/automaptexture.cpp textures/bitmap.cpp textures/buildtexture.cpp diff --git a/src/sound/i_musicinterns.h b/src/sound/i_musicinterns.h index bf0bfaa14e..62a9f37103 100644 --- a/src/sound/i_musicinterns.h +++ b/src/sound/i_musicinterns.h @@ -143,13 +143,13 @@ protected: }; #endif -// Base class for psuedo-MIDI devices --------------------------------------- +// Base class for pseudo-MIDI devices --------------------------------------- -class PsuedoMIDIDevice : public MIDIDevice +class PseudoMIDIDevice : public MIDIDevice { public: - PsuedoMIDIDevice(); - ~PsuedoMIDIDevice(); + PseudoMIDIDevice(); + ~PseudoMIDIDevice(); void Close(); bool IsOpen() const; @@ -169,9 +169,9 @@ protected: bool bLooping; }; -// FMOD psuedo-MIDI device -------------------------------------------------- +// FMOD pseudo-MIDI device -------------------------------------------------- -class FMODMIDIDevice : public PsuedoMIDIDevice +class FMODMIDIDevice : public PseudoMIDIDevice { public: int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata); @@ -180,7 +180,7 @@ public: // MIDI file played with TiMidity++ and possibly streamed through FMOD ------ -class TimidityPPMIDIDevice : public PsuedoMIDIDevice +class TimidityPPMIDIDevice : public PseudoMIDIDevice { public: TimidityPPMIDIDevice(); diff --git a/src/sound/music_pseudo_mididevice.cpp b/src/sound/music_pseudo_mididevice.cpp new file mode 100644 index 0000000000..129be8f4cb --- /dev/null +++ b/src/sound/music_pseudo_mididevice.cpp @@ -0,0 +1,260 @@ +/* +** music_pseudo_mididevice.cpp +** Common base class for pseudo MIDI devices. +** +**--------------------------------------------------------------------------- +** Copyright 2008-2010 Randy Heit +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +// HEADER FILES ------------------------------------------------------------ + +#include "i_musicinterns.h" +#include "templates.h" +#include "doomdef.h" +#include "m_swap.h" + +// MACROS ------------------------------------------------------------------ + +// TYPES ------------------------------------------------------------------- + +// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- + +// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- + +// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- + +// EXTERNAL DATA DECLARATIONS ---------------------------------------------- + +// PRIVATE DATA DEFINITIONS ------------------------------------------------ + +// PUBLIC DATA DEFINITIONS ------------------------------------------------- + +// CODE -------------------------------------------------------------------- + +//========================================================================== +// +// PseudoMIDIDevice Constructor +// +//========================================================================== + +PseudoMIDIDevice::PseudoMIDIDevice() +{ + Stream = NULL; + Started = false; + bLooping = true; +} + +//========================================================================== +// +// PseudoMIDIDevice Destructor +// +//========================================================================== + +PseudoMIDIDevice::~PseudoMIDIDevice() +{ + Close(); +} + +//========================================================================== +// +// PseudoMIDIDevice :: Close +// +//========================================================================== + +void PseudoMIDIDevice::Close() +{ + if (Stream != NULL) + { + delete Stream; + Stream = NULL; + } + Started = false; +} + +//========================================================================== +// +// PseudoMIDIDevice :: IsOpen +// +//========================================================================== + +bool PseudoMIDIDevice::IsOpen() const +{ + return Stream != NULL; +} + +//========================================================================== +// +// PseudoMIDIDevice :: GetTechnology +// +//========================================================================== + +int PseudoMIDIDevice::GetTechnology() const +{ + return MOD_MIDIPORT; +} + +//========================================================================== +// +// PseudoMIDIDevice :: Resume +// +//========================================================================== + +int PseudoMIDIDevice::Resume() +{ + if (!Started) + { + if (Stream->Play(bLooping, 1)) + { + Started = true; + return 0; + } + return 1; + } + return 0; +} + +//========================================================================== +// +// PseudoMIDIDevice :: Stop +// +//========================================================================== + +void PseudoMIDIDevice::Stop() +{ + if (Started) + { + Stream->Stop(); + Started = false; + } +} + +//========================================================================== +// +// PseudoMIDIDevice :: Pause +// +//========================================================================== + +bool PseudoMIDIDevice::Pause(bool paused) +{ + if (Stream != NULL) + { + return Stream->SetPaused(paused); + } + return true; +} + +//========================================================================== +// +// PseudoMIDIDevice :: StreamOutSync +// +//========================================================================== + +int PseudoMIDIDevice::StreamOutSync(MIDIHDR *header) +{ + assert(0); + return 0; +} + +//========================================================================== +// +// PseudoMIDIDevice :: StreamOut +// +//========================================================================== + +int PseudoMIDIDevice::StreamOut(MIDIHDR *header) +{ + assert(0); + return 0; +} + +//========================================================================== +// +// PseudoMIDIDevice :: SetTempo +// +//========================================================================== + +int PseudoMIDIDevice::SetTempo(int tempo) +{ + return 0; +} + +//========================================================================== +// +// PseudoMIDIDevice :: SetTimeDiv +// +//========================================================================== + +int PseudoMIDIDevice::SetTimeDiv(int timediv) +{ + return 0; +} + +//========================================================================== +// +// PseudoMIDIDevice :: GetStats +// +//========================================================================== + +FString PseudoMIDIDevice::GetStats() +{ + if (Stream != NULL) + { + return Stream->GetStats(); + } + return "Pseudo MIDI device not open"; +} + + +//========================================================================== +// +// FMODMIDIDevice :: Open +// +//========================================================================== + +int FMODMIDIDevice::Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata) +{ + return 0; +} + +//========================================================================== +// +// FMODMIDIDevice :: Preprocess +// +// Create a standard MIDI file and stream it. +// +//========================================================================== + +bool FMODMIDIDevice::Preprocess(MIDIStreamer *song, bool looping) +{ + TArray midi; + + song->CreateSMF(midi); + Stream = GSnd->OpenStream((char *)&midi[0], looping ? SoundStream::Loop : 0, -1, midi.Size()); + return false; +} diff --git a/src/timidity/sf2.h b/src/timidity/sf2.h index 0036923dae..224bf6058a 100644 --- a/src/timidity/sf2.h +++ b/src/timidity/sf2.h @@ -162,7 +162,7 @@ struct SFModList enum { - SFMod_One = 0, // Psuedo-controller that always has the value 1 + SFMod_One = 0, // Pseudo-controller that always has the value 1 SFMod_NoteVelocity = 2, SFMod_KeyNumber = 3, SFMod_PolyPressure = 10, diff --git a/zdoom.vcproj b/zdoom.vcproj index 9986f70b92..05c7e012b9 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -5498,7 +5498,7 @@ >