SFML community forums
Help => Audio => Topic started by: herbertbahia on July 22, 2020, 04:14:51 pm
-
::)
hello friends i need your help, i'm a c ++ student i need to embed a song in my sfml algorithm. I need an example how I do this, and if possible some software to transform music of different formats into an array. I am very grateful
-
Pretty sure I gave you a program to do this already :P
https://en.sfml-dev.org/forums/index.php?topic=27411.msg173876#msg173876
Just to clarify specifically, you can store the sound or music file in the program in the same way that you can store image files. Then, you can load (images/sounds) or stream (music) from them directly using loadFromMemory (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1SoundBuffer.php#af8cfa5599739a7edae69c5cba273d33f) and openFromMemory (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Music.php#ae93b21bcf28ff0b5fec458039111386e).
Note that the memory with a music file must stay available for as long as the sf::Music uses it (in the same way the file on disk would need to stay available).
-
I put the array there in the code but I don't know how I should call the function and the parameters I think is different from the image, I tried in several ways some give error in the compilation others lock my ide and close, but I'm happy to know that that program too will serve. I need an example. :'(
-
The array is just the storage of the file in memory. You would need to use the access the array as memory. You will normally be able to just use the array itself as a pointer to memory. If the memory requires different value type, you can change it in that header file.
What do you have so far? What isn't working? Show it and I'll have a look.
-
they were configurable errors, thank you for your attention, if more questions arise I will create a new topic