From 5eb95871351d12cab2b3b6482136211f509009b1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 10 Mar 2017 22:26:02 +0100 Subject: [PATCH] - moved the various music format files into their own directory. --- src/CMakeLists.txt | 21 +-- src/sound/music_stream.cpp | 115 -------------- src/sound/{ => musicformats}/music_cd.cpp | 0 src/sound/{ => musicformats}/music_dumb.cpp | 40 +++-- src/sound/{ => musicformats}/music_gme.cpp | 0 .../{ => musicformats}/music_hmi_midiout.cpp | 0 .../{ => musicformats}/music_midistream.cpp | 0 .../{ => musicformats}/music_mus_midiout.cpp | 0 .../music_opl.cpp} | 33 ++++ .../{ => musicformats}/music_smf_midiout.cpp | 0 src/sound/musicformats/music_stream.cpp | 148 ++++++++++++++++++ .../{ => musicformats}/music_xmi_midiout.cpp | 0 src/sound/wildmidi/file_io.cpp | 2 +- 13 files changed, 220 insertions(+), 139 deletions(-) delete mode 100644 src/sound/music_stream.cpp rename src/sound/{ => musicformats}/music_cd.cpp (100%) rename src/sound/{ => musicformats}/music_dumb.cpp (95%) rename src/sound/{ => musicformats}/music_gme.cpp (100%) rename src/sound/{ => musicformats}/music_hmi_midiout.cpp (100%) rename src/sound/{ => musicformats}/music_midistream.cpp (100%) rename src/sound/{ => musicformats}/music_mus_midiout.cpp (100%) rename src/sound/{music_mus_opl.cpp => musicformats/music_opl.cpp} (57%) rename src/sound/{ => musicformats}/music_smf_midiout.cpp (100%) create mode 100644 src/sound/musicformats/music_stream.cpp rename src/sound/{ => musicformats}/music_xmi_midiout.cpp (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8b30f7198..46ee46e89 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -899,17 +899,7 @@ set( FASTMATH_SOURCES sound/i_music.cpp sound/i_sound.cpp sound/mpg123_decoder.cpp - sound/music_cd.cpp - sound/music_dumb.cpp - sound/music_gme.cpp - sound/music_mus_midiout.cpp - sound/music_smf_midiout.cpp - sound/music_hmi_midiout.cpp - sound/music_xmi_midiout.cpp - sound/music_midistream.cpp sound/music_midi_base.cpp - sound/music_mus_opl.cpp - sound/music_stream.cpp sound/oalsound.cpp sound/sndfile_decoder.cpp sound/mididevices/music_timiditypp_mididevice.cpp @@ -1245,6 +1235,16 @@ set (PCH_SOURCES sound/mididevices/music_softsynth_mididevice.cpp sound/mididevices/music_timidity_mididevice.cpp sound/mididevices/music_wildmidi_mididevice.cpp + sound/musicformats/music_cd.cpp + sound/musicformats/music_dumb.cpp + sound/musicformats/music_gme.cpp + sound/musicformats/music_mus_midiout.cpp + sound/musicformats/music_smf_midiout.cpp + sound/musicformats/music_hmi_midiout.cpp + sound/musicformats/music_xmi_midiout.cpp + sound/musicformats/music_midistream.cpp + sound/musicformats/music_opl.cpp + sound/musicformats/music_stream.cpp sound/oplsynth/fmopl.cpp sound/oplsynth/mlopl.cpp sound/oplsynth/mlopl_io.cpp @@ -1445,6 +1445,7 @@ source_group("Audio Files\\OPL Synth\\DOSBox" FILES sound/oplsynth/dosbox/opl.cp source_group("Audio Files\\Timidity" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/timidity/.+") source_group("Audio Files\\WildMidi" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/wildmidi/.+") source_group("Audio Files\\MIDI Devices" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/mididevices/.+") +source_group("Audio Files\\Music formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/musicformats/.+") source_group("External\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/math/.+") source_group("External\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/.+") source_group("External\\SFMT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sfmt/.+") diff --git a/src/sound/music_stream.cpp b/src/sound/music_stream.cpp deleted file mode 100644 index e0a99f06f..000000000 --- a/src/sound/music_stream.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "i_musicinterns.h" - -void StreamSong::Play (bool looping, int subsong) -{ - m_Status = STATE_Stopped; - m_Looping = looping; - - if (m_Stream->Play (m_Looping, 1)) - { - if (subsong != 0) - { - m_Stream->SetOrder (subsong); - } - m_Status = STATE_Playing; - } -} - -void StreamSong::Pause () -{ - if (m_Status == STATE_Playing && m_Stream != NULL) - { - if (m_Stream->SetPaused (true)) - m_Status = STATE_Paused; - } -} - -void StreamSong::Resume () -{ - if (m_Status == STATE_Paused && m_Stream != NULL) - { - if (m_Stream->SetPaused (false)) - m_Status = STATE_Playing; - } -} - -void StreamSong::Stop () -{ - if (m_Status != STATE_Stopped && m_Stream) - { - m_Stream->Stop (); - } - m_Status = STATE_Stopped; -} - -StreamSong::~StreamSong () -{ - Stop (); - if (m_Stream != NULL) - { - delete m_Stream; - m_Stream = NULL; - } -} - -StreamSong::StreamSong (FileReader *reader) -{ - m_Stream = GSnd->OpenStream (reader, SoundStream::Loop); -} - -StreamSong::StreamSong (const char *url) -{ - m_Stream = GSnd->OpenStream (url, SoundStream::Loop); -} - -bool StreamSong::IsPlaying () -{ - if (m_Status != STATE_Stopped) - { - if (m_Stream->IsEnded()) - { - Stop(); - return false; - } - return true; - } - return false; -} - -// -// StreamSong :: SetPosition -// -// Sets the position in ms. - -bool StreamSong::SetPosition(unsigned int pos) -{ - if (m_Stream != NULL) - { - return m_Stream->SetPosition(pos); - } - else - { - return false; - } -} - -bool StreamSong::SetSubsong(int subsong) -{ - if (m_Stream != NULL) - { - return m_Stream->SetOrder(subsong); - } - else - { - return false; - } -} - -FString StreamSong::GetStats() -{ - if (m_Stream != NULL) - { - return m_Stream->GetStats(); - } - return "No song loaded\n"; -} diff --git a/src/sound/music_cd.cpp b/src/sound/musicformats/music_cd.cpp similarity index 100% rename from src/sound/music_cd.cpp rename to src/sound/musicformats/music_cd.cpp diff --git a/src/sound/music_dumb.cpp b/src/sound/musicformats/music_dumb.cpp similarity index 95% rename from src/sound/music_dumb.cpp rename to src/sound/musicformats/music_dumb.cpp index dfe05f7b0..d688d1c2d 100644 --- a/src/sound/music_dumb.cpp +++ b/src/sound/musicformats/music_dumb.cpp @@ -3,20 +3,34 @@ ** Alternative module player, using a modified DUMB for decoding. ** Based on the Foobar2000 component foo_dumb, version 0.9.8.4. ** -** I tried doing this as an FMOD codec, but the built-in codecs -** take precedence over user-created ones, so this never saw any -** of the files. +**--------------------------------------------------------------------------- +** Copyright 2008 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. +**--------------------------------------------------------------------------- ** -** Note that if the replayer isn't fast enough to provide data -** for the stream in a timely manner, you'll hear random data at -** those points. I mention this because the debug version of DUMB -** is *MUCH, MUCH, MUCH* slower than the release version. If your -** processor only has a single core, you probably shouldn't even -** use the debug version of DUMB. Unfortunately, when I tried -** linking the debug build of ZDoom against a release build of DUMB, -** there were some files that would not load, even though they -** loaded fine when the DUMB build type matched the ZDoom build type. -** (Applies to Visual C++, GCC should be fine, I think.) */ // HEADER FILES ------------------------------------------------------------ diff --git a/src/sound/music_gme.cpp b/src/sound/musicformats/music_gme.cpp similarity index 100% rename from src/sound/music_gme.cpp rename to src/sound/musicformats/music_gme.cpp diff --git a/src/sound/music_hmi_midiout.cpp b/src/sound/musicformats/music_hmi_midiout.cpp similarity index 100% rename from src/sound/music_hmi_midiout.cpp rename to src/sound/musicformats/music_hmi_midiout.cpp diff --git a/src/sound/music_midistream.cpp b/src/sound/musicformats/music_midistream.cpp similarity index 100% rename from src/sound/music_midistream.cpp rename to src/sound/musicformats/music_midistream.cpp diff --git a/src/sound/music_mus_midiout.cpp b/src/sound/musicformats/music_mus_midiout.cpp similarity index 100% rename from src/sound/music_mus_midiout.cpp rename to src/sound/musicformats/music_mus_midiout.cpp diff --git a/src/sound/music_mus_opl.cpp b/src/sound/musicformats/music_opl.cpp similarity index 57% rename from src/sound/music_mus_opl.cpp rename to src/sound/musicformats/music_opl.cpp index 9150b70e5..85f4b815b 100644 --- a/src/sound/music_mus_opl.cpp +++ b/src/sound/musicformats/music_opl.cpp @@ -1,3 +1,36 @@ +/* +** music_opl.cpp +** Plays raw OPL formats +** +**--------------------------------------------------------------------------- +** Copyright 1998-2008 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. +**--------------------------------------------------------------------------- +*/ + #include "i_musicinterns.h" #include "oplsynth/muslib.h" #include "oplsynth/opl.h" diff --git a/src/sound/music_smf_midiout.cpp b/src/sound/musicformats/music_smf_midiout.cpp similarity index 100% rename from src/sound/music_smf_midiout.cpp rename to src/sound/musicformats/music_smf_midiout.cpp diff --git a/src/sound/musicformats/music_stream.cpp b/src/sound/musicformats/music_stream.cpp new file mode 100644 index 000000000..2e57bd31b --- /dev/null +++ b/src/sound/musicformats/music_stream.cpp @@ -0,0 +1,148 @@ +/* +** music_stream.cpp +** Wrapper around the sound system's streaming feature for music. +** +**--------------------------------------------------------------------------- +** Copyright 2008 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. +**--------------------------------------------------------------------------- +*/ + +#include "i_musicinterns.h" + +void StreamSong::Play (bool looping, int subsong) +{ + m_Status = STATE_Stopped; + m_Looping = looping; + + if (m_Stream->Play (m_Looping, 1)) + { + if (subsong != 0) + { + m_Stream->SetOrder (subsong); + } + m_Status = STATE_Playing; + } +} + +void StreamSong::Pause () +{ + if (m_Status == STATE_Playing && m_Stream != NULL) + { + if (m_Stream->SetPaused (true)) + m_Status = STATE_Paused; + } +} + +void StreamSong::Resume () +{ + if (m_Status == STATE_Paused && m_Stream != NULL) + { + if (m_Stream->SetPaused (false)) + m_Status = STATE_Playing; + } +} + +void StreamSong::Stop () +{ + if (m_Status != STATE_Stopped && m_Stream) + { + m_Stream->Stop (); + } + m_Status = STATE_Stopped; +} + +StreamSong::~StreamSong () +{ + Stop (); + if (m_Stream != NULL) + { + delete m_Stream; + m_Stream = NULL; + } +} + +StreamSong::StreamSong (FileReader *reader) +{ + m_Stream = GSnd->OpenStream (reader, SoundStream::Loop); +} + +StreamSong::StreamSong (const char *url) +{ + m_Stream = GSnd->OpenStream (url, SoundStream::Loop); +} + +bool StreamSong::IsPlaying () +{ + if (m_Status != STATE_Stopped) + { + if (m_Stream->IsEnded()) + { + Stop(); + return false; + } + return true; + } + return false; +} + +// +// StreamSong :: SetPosition +// +// Sets the position in ms. + +bool StreamSong::SetPosition(unsigned int pos) +{ + if (m_Stream != NULL) + { + return m_Stream->SetPosition(pos); + } + else + { + return false; + } +} + +bool StreamSong::SetSubsong(int subsong) +{ + if (m_Stream != NULL) + { + return m_Stream->SetOrder(subsong); + } + else + { + return false; + } +} + +FString StreamSong::GetStats() +{ + if (m_Stream != NULL) + { + return m_Stream->GetStats(); + } + return "No song loaded\n"; +} diff --git a/src/sound/music_xmi_midiout.cpp b/src/sound/musicformats/music_xmi_midiout.cpp similarity index 100% rename from src/sound/music_xmi_midiout.cpp rename to src/sound/musicformats/music_xmi_midiout.cpp diff --git a/src/sound/wildmidi/file_io.cpp b/src/sound/wildmidi/file_io.cpp index be34b4622..7dffff387 100644 --- a/src/sound/wildmidi/file_io.cpp +++ b/src/sound/wildmidi/file_io.cpp @@ -35,7 +35,7 @@ #include -#include "../files.h" +#include "files.h" #include "wm_error.h" #include "file_io.h" #include "pathexpander.h"