reepblue Posted October 14, 2023 Share Posted October 14, 2023 Pausing/Resuming speakers aren't working as expected. #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); camera->Listen(); //Create a light auto light = CreateBoxLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); //Create a box auto box = CreateBox(world); box->SetColor(0, 0, 1); //Sound auto sound = LoadSound("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Sound/notification.wav"); auto speaker = CreateSpeaker(sound); speaker->SetPosition(box->GetPosition(true)); speaker->SetRange(10); auto speakerloop = CreateSpeaker(sound); speakerloop->SetPosition(box->GetPosition(true)); speakerloop->SetRange(10); speakerloop->SetLooping(true); auto speakerstate = speaker->GetState(); auto speakerloopstate = speakerloop->GetState(); bool paused = false; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { // P Plays the normal non-looping speaker if (window->KeyHit(KEY_P)) { speaker->Play(); } // L Plays the looping speaker if (window->KeyHit(KEY_L)) { speakerloop->Play(); } // Space pauses both speakers if (window->KeyHit(KEY_SPACE)) { if (!paused) { speaker->Pause(); speakerloop->Pause(); paused = true; } else { speaker->Resume(); speakerloop->Resume(); paused = false; } } // Report the state if (speaker->GetState() != speakerstate) { Print("Normal Speaker state at: " + String(speaker->GetState())); speakerstate = speaker->GetState(); } if (speakerloop->GetState() != speakerloopstate) { Print("Looping Speaker state at: " + String(speakerloop->GetState())); speakerloopstate = speakerloop->GetState(); } //Move and turn with the arrow keys - best experienced with headphones if (window->KeyDown(KEY_UP)) camera->Move(0, 0, 0.1); if (window->KeyDown(KEY_DOWN)) camera->Move(0, 0, -0.1); if (window->KeyDown(KEY_LEFT)) camera->Turn(0, -1, 0); if (window->KeyDown(KEY_RIGHT)) camera->Turn(0, 1, -0); world->Update(); world->Render(framebuffer); } return 0; } Right now, I have to do this hack in my project. void GameSpeaker::Pause() { if (speaker) { if (speaker->GetState() == SPEAKER_PLAYING) { pausetime = speaker->GetTime(); speaker->Pause(); } } } void GameSpeaker::Resume() { if (speaker) { if (speaker->GetState() == SPEAKER_PAUSED || pausetime > 0) { speaker->SetTime(pausetime); speaker->Play(); pausetime = 0; } } } Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Solution Josh Posted October 14, 2023 Solution Share Posted October 14, 2023 I believe this is fixed now. (Update is available.) Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
reepblue Posted October 14, 2023 Author Share Posted October 14, 2023 Diffrent problem, but related. When the sound is resumed, it starts from the beginning. Replace the sound with the one attached. radio_dreamlandloop_mono.zip Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Josh Posted October 16, 2023 Share Posted October 16, 2023 I am changing the system to use OpenAL's own pause / play functionality. I had some weird stuff in there to try to accomodate the sound source limits we had with hardware OpenAL but I don't think that is an issue anymore since it is all being done on the CPU now. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.