I have a 424 mb wav file, which I want to play, but it takes a lot of time to load, and it uses 425.6 mb of ram. Way too much ram for a dos format program. I want to load only a part of the song, then when it's almost at the final, load the second part, when the second part is played, remove from ram the first part, and etc. For this I should use 50 parts.
Here is the line of code:
PlaySound("../music/main.wav", NULL, SND_FILENAME|SND_LOOP|SND_ASYNC);
I mention that I need to run this in background, while the other commands do their roles.
How do I make PlaySound load only some parts of the song C++
219 Views Asked by TheRealOne78 At
1
There are 1 best solutions below
Related Questions in C++
- How to immediately apply DISPLAYCONFIG_SCALING display scaling mode with SetDisplayConfig and DISPLAYCONFIG_PATH_TARGET_INFO
- Why can't I use templates members in its specialization?
- How to fix "Access violation executing location" when using GLFW and GLAD
- Dynamic array of structures in C++/ cannot fill a dynamic array of doubles in structure from dynamic array of structures
- How do I apply the interface concept with the base-class in design?
- File refuses to compile std::erase() even if using -std=g++23
- How can I do a successful map when the number of elements to be mapped is not consistent in Thrust C++
- Can std::bit_cast be applied to an empty object?
- Unexpected inter-thread happens-before relationships from relaxed memory ordering
- How i can move element of dynamic vector in argument of function push_back for dynamic vector
- Brick Breaker Ball Bounce
- Thread-safe lock-free min where both operands can change c++
- Watchdog Timer Reset on ESP32 using Webservers
- How to solve compiler error: no matching function for call to 'dmhFS::dmhFS()' in my case?
- Conda CMAKE CXX Compiler error while compiling Pytorch
Related Questions in RAM
- Windows 64-bit: Do overlapped MMF windows mean more RAM consumption (doubling the RAM where the file views overlap)?
- Read/write data to DS1642
- Failed to use memory bits in fpga
- Is it better to pass a C++ object by reference than by value if it is in RAM?
- Stm32 Problem with reading from Flash memory (incorrect data)
- MariaDB not releasing RAM after jobs finish
- How to secure a Python project on Windows from domain administrators?
- Memory consumption of Parent & child process in Linux
- Simulation contradiction using the same Vivado block ram IP
- RAM crash executing procedure in Spyder
- Will the 16n prefetch in DDR5 affect the bandwidth of small-granularity memory accesses?
- How do I view individual memory blocks on my PC?
- pidstat output to file, once
- Get memory usage of this process C++ Win32
- how do I determine how much RAM a jupyter notebook has allocated and is using?
Related Questions in PLAYSOUND
- play .wav file using c language
- applicationDidEnterBackground, playSoundFileNamed Crash
- VC2013 Express unresolved link PlaySound
- PlaySound in C++ using CLion
- How to compile a c++ console application which uses the PlaySound function?
- Problem To Download playsound Module using pip
- playsound package to play sound in python
- Manage sounds on multiple open tabs react
- How to play the same sound every minute?
- How to calculate the dbHL in flutter?
- How do I make PlaySound load only some parts of the song C++
- Using PlaySound() in MASM, need a method to help run this in the background without the code waiting for the entire .wav sound file to finish
- Having a Problem playing .WAV files in java
- i am a beginner in python trying to use playsound module ,when run program ,it shows The specified device is not open or is not recognized by MCI
- Why does invoking the playsound module cause my script to crash?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
PlaySoundis a fairly high-level function, so it's tricky to get behavior like this. In particular, you will likely experience small silent gaps between playing back the different parts. So the best solution would be to go to a lower-level API that allows more sophisticated managing of sound playback buffers. OpenAL is a good library for doing this, the modern Windows native solution is WASAPI, which unfortunately is quite complicated to use.With
PlaySounditself, first adjust your program to load the.wavfile to memory and then useSND_MEMORYfor playing it from memory (example).Now, instead of loading the whole
.wavfile at once, you just load the header and as many soundframes as fill your buffer. You then create your own.wavheader for just those loaded samples and put it all in a contiguous buffer. You basically build your own, smaller.wavfile in memory. Then you callPlaySound(..., SND_MEMORY)on that buffer. Rinse and repeat for the remaining samples from the original file.Note that you will need your own
.wavfile format parser for this, but the file format is not that complicated, so hopefully this should not be too much of an issue.