From d32b0ea4e4a75bf75e5c45b7820d233e408dffa3 Mon Sep 17 00:00:00 2001 From: Modnark <66146584+Modnark@users.noreply.github.com> Date: Tue, 11 Oct 2022 22:34:36 -0400 Subject: [PATCH] Add more sounds internally --- src/include/AudioPlayer.h | 3 +- src/include/Enum.h | 4 +- src/source/Application.cpp | 2 + src/source/AudioPlayer.cpp | 4 +- src/source/DataModelV2/DataModelInstance.cpp | 1 + src/source/DataModelV2/Instance.cpp | 3 -- src/source/DataModelV2/PartInstance.cpp | 52 +++++++++++++++++++- src/source/DataModelV2/SoundInstance.cpp | 1 + src/source/DataModelV2/SoundService.cpp | 2 + src/source/main.cpp | 2 - 10 files changed, 64 insertions(+), 10 deletions(-) diff --git a/src/include/AudioPlayer.h b/src/include/AudioPlayer.h index 7467064..7068099 100644 --- a/src/include/AudioPlayer.h +++ b/src/include/AudioPlayer.h @@ -6,6 +6,7 @@ class AudioPlayer public: AudioPlayer(void); ~AudioPlayer(void); - static void playSound(std::string); + static void init(); + static void playSound(std::string); }; diff --git a/src/include/Enum.h b/src/include/Enum.h index 0f4c2a1..0643d95 100644 --- a/src/include/Enum.h +++ b/src/include/Enum.h @@ -35,7 +35,9 @@ namespace Enum namespace Sound { enum Value { - NoSound = 0, Victory = 1, Boing = 2 + NoSound = 0, Victory = 1, Boing = 2, Bomb = 3, + Ping = 4, Break = 5, Splat = 6, Swoosh = 7, + Snap = 8, Page = 9 }; } } \ No newline at end of file diff --git a/src/source/Application.cpp b/src/source/Application.cpp index 5a7d908..1f31657 100644 --- a/src/source/Application.cpp +++ b/src/source/Application.cpp @@ -130,6 +130,8 @@ Application::Application(HWND parentWindow) : _propWindow(NULL) { //: GApp(setti return; } + AudioPlayer::init(); + _window = renderDevice->window(); _window->makeCurrent(); diff --git a/src/source/AudioPlayer.cpp b/src/source/AudioPlayer.cpp index 5c5e595..f23c280 100644 --- a/src/source/AudioPlayer.cpp +++ b/src/source/AudioPlayer.cpp @@ -4,7 +4,7 @@ #include #include #include -#define NUM_SOUNDS 10 +#define NUM_SOUNDS 32 static SDL_AudioSpec fmt; static bool initiated = false; @@ -23,7 +23,7 @@ void AudioPlayer::init() initiated = true; extern void mixaudio(void *unused, Uint8 *stream, int len); fmt.freq = 22050; - fmt.format = AUDIO_S16; + fmt.format = AUDIO_S16LSB; fmt.channels = 2; fmt.samples = 1024; /* A good value for games */ fmt.callback = mixaudio; diff --git a/src/source/DataModelV2/DataModelInstance.cpp b/src/source/DataModelV2/DataModelInstance.cpp index f4fc9f0..7eef1f9 100644 --- a/src/source/DataModelV2/DataModelInstance.cpp +++ b/src/source/DataModelV2/DataModelInstance.cpp @@ -32,6 +32,7 @@ DataModelInstance::DataModelInstance(void) _modY=0; workspace->setParent(this); level->setParent(this); + soundService->setParent(this); _loadedFileName="..//skooter.rbxm"; listicon = 5; diff --git a/src/source/DataModelV2/Instance.cpp b/src/source/DataModelV2/Instance.cpp index 4cb1279..98fceea 100644 --- a/src/source/DataModelV2/Instance.cpp +++ b/src/source/DataModelV2/Instance.cpp @@ -20,11 +20,8 @@ Instance::Instance(const Instance &oinst) className = oinst.className; canDelete = oinst.canDelete; listicon = oinst.listicon; - //setParent(oinst.parent); } - - void Instance::render(RenderDevice* rd) { for(size_t i = 0; i < children.size(); i++) diff --git a/src/source/DataModelV2/PartInstance.cpp b/src/source/DataModelV2/PartInstance.cpp index 8fb5837..0cb6dbf 100644 --- a/src/source/DataModelV2/PartInstance.cpp +++ b/src/source/DataModelV2/PartInstance.cpp @@ -476,6 +476,20 @@ static TCHAR* strSoundType(int option) return "Victory"; case Enum::Sound::Boing: return "Boing"; + case Enum::Sound::Splat: + return "Splat"; + case Enum::Sound::Snap: + return "Snap"; + case Enum::Sound::Bomb: + return "Bomb"; + case Enum::Sound::Break: + return "Break"; + case Enum::Sound::Ping: + return "Ping"; + case Enum::Sound::Swoosh: + return "Swoosh"; + case Enum::Sound::Page: + return "Page"; } return "NoSound"; } @@ -488,6 +502,21 @@ static Enum::Sound::Value EnumOnTouchSoundType(TCHAR* option) return Enum::Sound::Victory; if(strcmp("Boing", option) == 0) return Enum::Sound::Boing; + if(strcmp("Splat", option) == 0) + return Enum::Sound::Splat; + if(strcmp("Bomb", option) == 0) + return Enum::Sound::Bomb; + if(strcmp("Break", option) == 0) + return Enum::Sound::Break; + if(strcmp("Swoosh", option) == 0) + return Enum::Sound::Swoosh; + if(strcmp("Page", option) == 0) + return Enum::Sound::Page; + if(strcmp("Ping", option) == 0) + return Enum::Sound::Ping; + if(strcmp("Snap", option) == 0) + return Enum::Sound::Snap; + return Enum::Sound::NoSound; } @@ -530,6 +559,27 @@ void PartInstance::onTouch() case Enum::Sound::Boing: sndService->playSound(sndService->findFirstChild("Boing")); break; + case Enum::Sound::Break: + sndService->playSound(sndService->findFirstChild("Break")); + break; + case Enum::Sound::Snap: + sndService->playSound(sndService->findFirstChild("Snap")); + break; + case Enum::Sound::Bomb: + sndService->playSound(sndService->findFirstChild("Bomb")); + break; + case Enum::Sound::Splat: + sndService->playSound(sndService->findFirstChild("Splat")); + break; + case Enum::Sound::Page: + sndService->playSound(sndService->findFirstChild("Page")); + break; + case Enum::Sound::Ping: + sndService->playSound(sndService->findFirstChild("Ping")); + break; + case Enum::Sound::Swoosh: + sndService->playSound(sndService->findFirstChild("Swoosh")); + break; } } @@ -669,7 +719,7 @@ std::vector PartInstance::getProperties() "What sound plays when touched", (LPARAM)strSoundType(OnTouchSound), PIT_COMBO, - TEXT("NoSound\0Victory\0Boing\0") + TEXT("NoSound\0Victory\0Boing\0Break\0Snap\0Bomb\0Splat\0Page\0Ping\0Swoosh\0") )); sprintf_s(changeScoreTxt, "%d", changeScore); diff --git a/src/source/DataModelV2/SoundInstance.cpp b/src/source/DataModelV2/SoundInstance.cpp index 7f3072e..b53cc74 100644 --- a/src/source/DataModelV2/SoundInstance.cpp +++ b/src/source/DataModelV2/SoundInstance.cpp @@ -5,6 +5,7 @@ SoundInstance::SoundInstance() { name = "Sound"; className = "Sound"; + listicon = 8; soundVolume = 0.5; soundId = ""; diff --git a/src/source/DataModelV2/SoundService.cpp b/src/source/DataModelV2/SoundService.cpp index 46662d4..bd26307 100644 --- a/src/source/DataModelV2/SoundService.cpp +++ b/src/source/DataModelV2/SoundService.cpp @@ -8,6 +8,8 @@ SoundService::SoundService() name = "SoundService"; className = "SoundService"; musicVolume = 0.3f; + listicon = 8; + canDelete = false; // Create stock sounds SoundInstance* stockSound = new SoundInstance(); diff --git a/src/source/main.cpp b/src/source/main.cpp index 18a8bd3..856768b 100644 --- a/src/source/main.cpp +++ b/src/source/main.cpp @@ -159,8 +159,6 @@ int main(int argc, char** argv) { icc.dwICC = ICC_WIN95_CLASSES/*|ICC_COOL_CLASSES|ICC_DATE_CLASSES| ICC_PAGESCROLLER_CLASS|ICC_USEREX_CLASSES*/; InitCommonControlsEx(&icc); - - AudioPlayer::init(); HMODULE hThisInstance = GetModuleHandle(NULL); if (!createWindowClass("mainHWND",WndProc,hThisInstance))