AudioSignal& MusicComposer::operator()(const std::string& ent){
  string word = ent;
  char first = word.at(0);

  if(first == '*') {
    char second = word.at(1);
    switch(second) {
    case 't': changeTrack(ent);
      break;
    case 'l': return loadFile(ent);
      break;
    case 'e': echo(ent);
      break;
    case '~': smallDuration(ent);
      break;
    case '=': longDuration(ent);
      break;
    case '.': addAll();
      break;
    default : cout << "Oops!!!! There was an invalid character " << endl;
    }
  } else {
    music = readNotes(ent);
  }

return music;
}
Esempio n. 2
0
  Music::Music(std::string const &newTrack, SoundType newType, SoundState newState, bool newLoop)
    : track(newTrack), type(newType), state(newState), loop(newLoop)
  {
    setVolume(100);
    if (this->track.empty())
      {
	std::cerr << "Error : There is no music" << std::endl;
	return;
      }
    changeTrack(this->track);
    std::cout << "new music" << std::endl;
    if (this->state == PLAY)
      this->start();
  }
Esempio n. 3
0
void MainMenu::optionsMenuButtonClicked( CheckButton* button, int ){
    std::string buttonName = button->getName();
    if( buttonName == "BackgroundMusic"){
        getSound()->playSound("Click");
        getSound()->enableMusic( !getConfig()->musicEnabled );
    } else if( buttonName == "MusicVolumePlus"){
        int newVolume = getConfig()->musicVolume + 5;
        if( newVolume > 100 ){
           newVolume = 100;
        }
        if( getConfig()->musicVolume != newVolume ){
            getSound()->setMusicVolume( newVolume );
            getSound()->playSound("Click");
        }
    } else if( buttonName == "MusicVolumeMinus"){
        int newVolume = getConfig()->musicVolume -5;
        if( newVolume < 0 ){
           newVolume = 0;
        }
        if( getConfig()->musicVolume != newVolume ){
            getSound()->setMusicVolume( newVolume );
            getSound()->playSound("Click");
        }
    } else if( buttonName == "SoundFX"){
        getConfig()->soundEnabled = !getConfig()->soundEnabled;
        getSound()->playSound("Click");
    } else if( buttonName == "FXVolumePlus"){
        int newVolume = getConfig()->soundVolume + 5;
        if( newVolume > 100 ){
           newVolume = 100;
        }
        if( getConfig()->soundVolume != newVolume ){
            getSound()->setSoundVolume( newVolume );
            getSound()->playSound("Click");
        }
    } else if( buttonName == "FXVolumeMinus"){
        int newVolume = getConfig()->soundVolume - 5;
        if( newVolume < 0 ){
           newVolume = 0;
        }
        if( getConfig()->soundVolume != newVolume ){
            getSound()->setSoundVolume( newVolume );
            getSound()->playSound("Click");
        }
    } else if( buttonName == "ResolutionPrev"){
        changeResolution(false);
    } else if( buttonName == "ResolutionNext"){
        changeResolution(true);
    } else if( buttonName == "WorldLenPrev"){
        changeWorldLen(false);
    } else if( buttonName == "WorldLenNext"){
        changeWorldLen(true);
    } else if( buttonName == "LanguagePrev"){
        changeLanguage(false);
    } else if( buttonName == "LanguageNext"){
        changeLanguage(true);
    } else if( buttonName == "Fullscreen"){
        getSound()->playSound("Click");
        getConfig()->useFullScreen = !getConfig()->useFullScreen;
        getConfig()->save();
        if( getConfig()->restartOnChangeScreen )
        {
            quitState = RESTART;
            running = false;
        }
        else
        {
            //SDL_IGNORE to avoid forth and back jumping resolution
            SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE);
            initVideo( getConfig()->videoX, getConfig()->videoY);
            currentMenu->resize(getConfig()->videoX, getConfig()->videoY);
            SDL_EventState(SDL_VIDEORESIZE, SDL_ENABLE);
            loadOptionsMenu(); //in case resolution was changed while in fullscreen
        }
    } else if( buttonName == "TrackPrev"){
        changeTrack(false);
    } else if( buttonName == "TrackNext"){
        changeTrack(true);
    } else if( buttonName == "BinaryMode"){
        binary_mode = !binary_mode;
    } else if( buttonName == "SeedMode"){
        seed_compression = !seed_compression;
    } else {
        std::cerr << "MainMenu::optionsMenuButtonClicked " << buttonName << " unknown Button!\n";
    }
}