0 Members and 1 Guest are viewing this topic.
// Load a sound effect to play...sf::SoundBuffer Buffer;if (!Buffer.LoadFromFile("data/sound/Click.wav")) return EXIT_FAILURE;sf::Sound Sound;Sound.SetBuffer(Buffer); // Buffer is a sf::SoundBuffer//...Sound.Play();
It's most likely the time it takes to load the media from the hard drive. If you load the sound ahead of when you need it, it should play immediately.
// Load a sound effect to play...sf::SoundBuffer Buffer;if (!Buffer.LoadFromFile("data/sound/Click.wav")) return EXIT_FAILURE;sf::Sound Sound;Sound.SetBuffer(Buffer); // Buffer is a sf::SoundBuffer//=============================================================================================== while (visuals->App.IsOpened()) { visuals->MilliSeconds = visuals->MyClock.GetElapsedTime(); visuals->NextFrameMS = visuals->MilliSeconds + .01815; visuals->FramesPerSecond++; if (visuals->MilliSeconds >= visuals->NextSecond) { visuals->FPS_Array[visuals->FPS_ArrayIndex] = visuals->FramesPerSecond; visuals->FramesPerSecond = 0; visuals->NextSecond = visuals->MyClock.GetElapsedTime() + 1; visuals->FPS_ArrayIndex++; if (visuals->FPS_ArrayIndex > 9) visuals->FPS_ArrayIndex = 0; } // Process events sf::Event Event; while (visuals->App.GetEvent(Event)) { // Close window : exit if (Event.Type == sf::Event::Closed) visuals->App.Close(); if (Event.Type == sf::Event::KeyPressed) { if (Event.Key.Code == sf::Key::Space) if (visuals->ScreenStatus == DisplayScreenForWhile) {//============================================= Sound.Play(); //<-PLAY SOUND HERE (User pressed [Spacebar]...//============================================= visuals->ScreenStatusCounter = 1000; } } } if (visuals->ScreenToDisplay == SFMLInformationScreen) DisplaySFMLInformationScreen(); else if (visuals->ScreenToDisplay == SilentHeroProductionsScreen) DisplaySilentHeroProductionsScreen(); else if (visuals->ScreenToDisplay == TitleScreen) DisplayTitleScreen(); uint16_t total = 0; for (uint16_t index = 0; index < 10; index++) { total = total + visuals->FPS_Array[index]; } total = total / 10; sprintf(visuals->VariableText, "%d", total); visuals->DrawTextOnScreenBuffer(visuals->VariableText, 22, sf::Color(0, 255, 0, 255), sf::Color(0, 0, 0, 255), true, 10, 10, TextLeft); visuals->DisplayScreenBufferOnScreen(); visuals->MilliSeconds = visuals->MyClock.GetElapsedTime(); if (visuals->NextFrameMS > visuals->MilliSeconds) sf::Sleep(visuals->NextFrameMS - visuals->MilliSeconds); }//=============================================================================================== visuals->UnloadFontsFromMemory(); visuals->UnloadAllBMPsFromMemory();//delete Buffer; delete visuals; return EXIT_SUCCESS;}// A 100% By JeZ+Lee and mattmatteh of Silent Hero Productions(R)...
Have you tried the latest sources from SVN?
Do you mean the "delay" is a known problem, and that it is already solved ?