bool SoundHandler::LoadFromFile(const typeAssetID theAssetID, sf::SoundBuffer& theAsset) { // Start with a return result of false bool anResult = false; // Retrieve the filename for this asset std::string anFilename = GetFilename(theAssetID); // Was a valid filename found? then attempt to load the asset from anFilename if(anFilename.length() > 0) { // Load the asset from a file #if (SFML_VERSION_MAJOR < 2) anResult = theAsset.LoadFromFile(anFilename); #else anResult = theAsset.loadFromFile(anFilename); #endif } else { ELOG() << "SoundHandler::LoadFromFile(" << theAssetID << ") No filename provided!" << std::endl; } // Return anResult of true if successful, false otherwise return anResult; }
bool SoundHandler::LoadFromMemory(const typeAssetID theAssetID, sf::SoundBuffer& theAsset) { // Start with a return result of false bool anResult = false; // TODO: Retrieve the const char* pointer to load data from const char* anData = NULL; // TODO: Retrieve the size in bytes of the font to load from memory size_t anDataSize = 0; // Try to obtain the font from the memory location specified if(NULL != anData && anDataSize > 0) { // Load the image from the memory location specified #if (SFML_VERSION_MAJOR < 2) anResult = theAsset.LoadFromMemory(anData, anDataSize); #else anResult = theAsset.loadFromMemory(anData, anDataSize); #endif } else { ELOG() << "SoundHandler::LoadFromMemory(" << theAssetID << ") Bad memory location or size!" << std::endl; } // Return anResult of true if successful, false otherwise return anResult; }
int InitGL() // All Setup For OpenGL goes here { glShadeModel(GL_SMOOTH); // Enables Smooth Shading glClearColor(0.0, 0.0, 0.0, 1.0); glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // The Type Of Depth Test To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculation glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // Uses default lighting parameters glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glEnable(GL_NORMALIZE); glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); glEnable(GL_LIGHT1); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); // and now some init I need to do for other stuff ilInit(); /* Initialization of DevIL */ // mouse stuff pointer = toGLTexture("./dati/models/textures/mirino.png"); lastx = middleX; lasty = middleY; relativeX = 0.0; relativeY = 0.0; glutWarpPointer(middleX, middleY); // put the cursor in the middle of the screen //for the menu InitMenu(); // for the text t3dInit(); // for the skybox initSkybox(); // for the blend initAssets(); // for the sounds if (!sound_hit.loadFromFile("./dati/audio/hit.wav")) return -1; if (!sound_miss.loadFromFile("./dati/audio/miss.wav")) return -1; if (!sound_youreempty.loadFromFile("./dati/audio/youreempty.wav")) return -1; if (!sound_ohno.loadFromFile("./dati/audio/ohno.wav")) return -1; music.setLoop(true); if (!music.openFromFile("./dati/audio/Rango_Theme.ogg")) return -1; music.play(); return TRUE; // Initialization Went OK }
void SoundFX::Initialize() { attack1_snd.loadFromFile("./Resources/Sounds/Battle/Player_attack1.wav"); attack_sounds[0].setBuffer(attack1_snd); attack2_snd.loadFromFile("./Resources/Sounds/Battle/Player_attack2.wav"); attack_sounds[1].setBuffer(attack2_snd); attack3_snd.loadFromFile("./Resources/Sounds/Battle/Player_attack3.wav"); attack_sounds[2].setBuffer(attack3_snd); hit1_snd.loadFromFile("./Resources/Sounds/Battle/Player_hit1.wav"); hit_sounds[0].setBuffer(hit1_snd); hit2_snd.loadFromFile("./Resources/Sounds/Battle/Player_hit2.wav"); hit_sounds[1].setBuffer(hit2_snd); miss1_snd.loadFromFile("./Resources/Sounds/Battle/Player_miss1.wav"); hit_sounds[0].setBuffer(miss1_snd); miss2_snd.loadFromFile("./Resources/Sounds/Battle/Player_miss2.wav"); hit_sounds[1].setBuffer(miss2_snd); burp1_snd.loadFromFile("./Resources/Sounds/Battle/Player_burp1.wav"); burp2_snd.loadFromFile("./Resources/Sounds/Battle/Player_burp2.wav"); burp3_snd.loadFromFile("./Resources/Sounds/Battle/Player_burp3.wav"); burp_sounds[0].setBuffer(burp1_snd); burp_sounds[1].setBuffer(burp2_snd); burp_sounds[2].setBuffer(burp3_snd); }
void MyStream::load(const sf::SoundBuffer& buffer) { // extract the audio samples from the sound buffer to our own container m_samples.assign(buffer.getSamples(), buffer.getSamples() + buffer.getSampleCount()); // reset the current playing position m_currentSample = 0; // initialize the base class initialize(buffer.getChannelCount(), buffer.getSampleRate()); }
virtual void init() { dt=0; select_switch = 0.2; if (!standard_font.loadFromFile("fonts/Unique.ttf")) { // error... } // darken = sf::RectangleShape(sf::Vector2f(800,400)); //sfx if (!buffer.loadFromFile("sfx/Blip 007.wav")) { //error } blip.setBuffer(buffer); if(!title.loadFromFile("gfx/title.png"))std::cout<<"Error"<<std::endl; t**s.setTexture(title); t**s.setOrigin(50,8); t**s.setScale(sf::Vector2f(3,3)); t**s.setPosition(400,100); sf::FloatRect tempt ; for(int i =0 ; i<4;i++) { selector[i].setFont(standard_font); selector[i].setCharacterSize(28); // dla centrowania obiektow tempt = selector[i].getGlobalBounds(); selector[i].setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2)); selector[i].setPosition(350,150+30*i); } selector[0].setString("Start game"); selector[1].setString("Info"); selector[2].setString("Highscores"); selector[3].setString("Exit"); selector[0].setColor(sf::Color(0,127,127)); timer.restart(); };
void rawGenerator::playStream() { if (sw == 0){ if (!Buffer.loadFromSamples(waveOut, SAMPLES, 1, 44100)) { std::cerr << "Loading failed!" << std::endl; //return 1; } std::cout << "Sound 1" << std::endl; sw = 0; } Sound.setBuffer(Buffer); //Sound.setLoop(true); Sound.play(); }
bool SoundManager::load(Path name, sf::SoundBuffer & dst) { if (name.str().find(internal_path) == 0) { return true; } else { DataManager::Paths paths = app->data.paths(Path("sounds") + name); paths.push_back(name); bool success = false; for (int i = 0; i < paths.size() && !success; i++) { success = dst.loadFromFile(paths[i].c_str()); } if (success) { LOG(DEBUG, "loaded sound '%s'", name.c_str()); } else { LOG(WARNING, "unable to find sound '%s'", name.c_str()); } return success; } }
bool SoundHandler::loadFromFile(const typeAssetID assetID, sf::SoundBuffer& asset) { // Start with a return result of false bool succ = false; // Retrieve the filename for this asset std::string anFilename = assetID; // Was a valid filename found? then attempt to load the asset from anFilename if(anFilename.length() > 0) { // Load the asset from a file succ = asset.loadFromFile(anFilename); } else { ELOG() << "SoundHandler::loadFromFile(" << assetID << ") No filename provided!" << std::endl; } // Return anResult of true if successful, false otherwise return succ; }
void AudioSource::setSoundBuffer(sf::SoundBuffer& sb) { XY_WARNING(m_mode != Mode::Cached, "setting this sound buffer will have no effect on streaming audio!"); m_sound.setBuffer(sb); m_duration = sb.getDuration().asSeconds(); }
void chargerSound(sf::SoundBuffer& buffer, std::string filePath) { if(!buffer.loadFromFile(filePath)) std::cerr << "Erreur durant chargement du son " << filePath << std::endl; }
void load(const sf::SoundBuffer& buffer) { m_samples.assign(buffer.getSamples(), buffer.getSamples() + buffer.getSampleCount()); m_currentSample = 0; initialize(buffer.getChannelCount(), buffer.getSampleRate()); }