How do I loop playing a sound like a background music I want to put in chili's framework.
I used Sound.h and Sound.cpp
How do I loop a sound?
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: How do I loop a sound?
When you create a sound, the constructors have parameters that define where a sound should start and where it should end and enable looping.
Sound( const std::wstring& fileName,float loopStart,float loopEnd )
If you want to loop a sound that is 20 seconds or only 20 seconds of the sound
Sound bg_music = Sound{ L"music.wav", 0.f, 20.f };
Sound( const std::wstring& fileName,float loopStart,float loopEnd )
If you want to loop a sound that is 20 seconds or only 20 seconds of the sound
Sound bg_music = Sound{ L"music.wav", 0.f, 20.f };
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: How do I loop a sound?
make sure to use floats to get the loop in seconds, otherwise if you use ints they'll be converted to unsigned int and you'll be looping in samples ( 0 - 20 samples which wouldn't be more than a blip ).
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com