I've searched a lot, without luck particularly on which encoding to load a .OGG file on. I'm trying to add a audio file in .ogg format, and have no idea what the problem is.
Here's my steps on adding .OGG audio files to the project:
I firstly add it to the audio assets in the project. When I open the .OGG file, I get an warning/error:
What encoding should i load an .OGG file in, if this is important?
- I tried to just pick an encoding that didn't give me the warning, whitch was 'ISO-8859-1'. Note that i tried with other encodings, such as UTF-8, UTF-16, UTF-32, US-ASCII without any effect.
Here is a picture of the .OGG file in UTF-8 encoding (default):
- I use SFML to load the sound files in a class i chose to call Sound:
Sound.cpp:
#include "Sound.h"
Sound::Sound() {
const std::string pathToProject = "C:\\Users\\User\\projectName";
exSongbuffer.loadFromFile(pathToProject + "\\projectContainer\\Assets\\Sounds\\ExampleSound.ogg");
exampleSong.setBuffer(exSongbuffer);
}
Sound.h:
#include <SFML/Audio/Sound.hpp>
#include <SFML/Audio/SoundBuffer.hpp>
class Sound {
public:
Sound();
sf::Sound ExampleSound;
sf::SoundBuffer exSoundBuffer;
}
Configuration.h:
class Configuration {
public:
Sound* sound = new Sound();
}
Machine.cpp:
StateMachine::StateMachine() {
auto* sound = new Sound();
config.sound = sound;
sound->menuSong.play();
}
main.cpp:
int main() {
StateMachine stateMachine;
while (stateMachine.run()) { // run() just runs the program until the user exits.
}
}