// doDraw
//---------------------------------------------------------------------------
void SoundView::doDraw(Surface &viewArea, Surface &clientArea)
{
    MenuTemplateView::doDraw(viewArea, clientArea);

    char strBuf[256];
    
    const int arrowButtonWidth = 16;
    
    iRect visualMeter;
    int   x               = optionsMeterStartX + arrowButtonWidth;
    int   y               = bodyTextRect.min.y + 15;
    int   yOffset         = 15;
    
    Surface tempSurface(optionsMeterWidth, 14, 1);
    
    // Sound Volume
    y += yOffset;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d %%", getSoundVolume());
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(clientArea, x, y);

    // Music Volume
    y += yOffset*3;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d %%", getMusicVolume());
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(clientArea, x, y);

    //clientArea.bltStringCenter("Not available for preview", Color::white);

} // end SoundView::doDraw
Beispiel #2
0
void EntityPigZombie::onUpdate() 
{
        moveSpeed = playerToAttack == null ? 0.5 : 0.95;
        if(randomSoundDelay > 0 && --randomSoundDelay == 0)
        {
            worldObj.playSoundAtEntity(this, "mob.zombiepig.zpigangry", getSoundVolume() * 2.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.2 + 1.0F) * 1.8);
        }
        super.onUpdate();
}
Beispiel #3
0
	void loadCustomSounds(const string& mPackName, const string& mPath)
	{
		for(auto filePath : getScan<Mode::Single, Type::File, Pick::ByExt>(mPath + "Sounds/", ".ogg"))
		{
			string fileName{getNameFromPath(filePath, mPath + "Sounds/", "")};
			assetManager.loadSound(mPackName + "_" + fileName, filePath);
			assetManager.getSound(mPackName + "_" + fileName).setVolume(getSoundVolume());
		}
	}
/**
 * Play sound once.
 * @param name sound name
 * @param distance mag2 distance
 */
void SDLSound::playAmbientSound(const char* name, long distance)
{
    Mix_Chunk *chunk = findChunk(name);
    if (chunk) {
        int oldVolume = Mix_VolumeChunk(chunk, getSoundVolume(distance));
        if (Mix_PlayChannel(-1, chunk, 0) == -1) {
            Mix_AllocateChannels(8 + Mix_AllocateChannels(-1));
            if (Mix_PlayChannel(-1, chunk, 0) == -1) {
                LOG (("Couldn't play sound '%s': %s", name, Mix_GetError()));
            }
        }
        Mix_VolumeChunk(chunk, oldVolume);
    }
}
Beispiel #5
0
	void loadSounds()
	{
		Json::Value soundsRoot = getJsonFileRoot("Sounds/sounds.json");

		for(Json::ValueIterator itr{soundsRoot.begin()}; itr != soundsRoot.end(); itr++)
		{
			SoundBuffer* soundBuffer{new SoundBuffer};
			soundBuffer->loadFromFile("Sounds/" + (*itr).asString());
			soundBufferPtrsMap.insert(make_pair(itr.key().asString(), soundBuffer));

			Sound* soundPtr{new Sound};
			soundPtr->setBuffer(*soundBuffer);
			soundPtr->setVolume(getSoundVolume());
			soundPtrsMap.insert(make_pair(itr.key().asString(), soundPtr));

		}
	}	
// doDraw
//---------------------------------------------------------------------------
void OptionsTemplateView::doDraw(Surface &viewArea, Surface &clientArea)
{
    checkBoxFullscreen->setState(GameConfig::video_fullscreen);
    checkBoxBlendSmoke->setState(GameConfig::video_blendsmoke);
    checkBoxDrawAllShadows->setState(GameConfig::video_shadows);

    MenuTemplateView::doDraw(viewArea, clientArea);

    Surface tempSurface(optionsMeterWidth, 14, 1);

    // Scroll Rate
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);

    char strBuf[256];
    const int arrowButtonWidth = 16;
    int   x               = bodyTextRect.min.x + optionsMeterStartX + arrowButtonWidth;
    int   y               = bodyTextRect.min.y ;
    int yOffset          =  17;

    y += yOffset*7;

    sprintf(strBuf, "%d %%", int((float(getScrollRate()) / 
                    float(gameconfig->scrollrate.getMax())) * 100.0f));
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(clientArea, x, y);
    y += yOffset*2;
    
    // Sound Volume
    y += yOffset*3;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d %%", getSoundVolume());
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(clientArea, x, y);

    // Music Volume
    y += yOffset*3;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d %%", getMusicVolume());
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(clientArea, x, y);
} // end VisualsView::doDraw
Beispiel #7
0
void TFI_KK_Sound ( byte* command , int CarType , int charge , int volume )
{
	byte str [ 5 ] ;
	int i;
	sprintf ( (  char * )str , "%d%04d" , getValue ( CarType , 0 , 9 ) , charge ) ;
	command [ 0 ] = 0xAA ;
	command [ 1 ] = 0x0A ;
	command [ 2 ] = 0x4A ;
	strncpy ((  char * )&command [ 3 ] , (  char * )str , 5 ) ;
	command [ 8 ] = getSoundVolume ( volume ) ;
	command [ 9 ] = 0xBB ;
	
	serial_write(LED_COM,command , TFI_KK_GetCommandLen( command )) ;

	for(i = 0;i<TFI_KK_GetCommandLen( command );i++ )
	{
		echoic("TFI=<%x>",command[i]);
	}
}
Beispiel #8
0
void SoundProcessor::process() {
#ifdef _FMOD_SOUND
	for(std::list<FMOD::Channel*>::iterator i = soundChannel.begin(); i!=soundChannel.end();)
	{
		bool is_playing = false;
		(*i)->isPlaying(&is_playing);
		if(!is_playing) {
			i = soundChannel.erase(i);
		}
		else ++i;
	}
	for(std::list<std::pair<Sound*, float> >::iterator i = soundsToPlay.begin(); i != soundsToPlay.end(); ++i)
		if((soundChannel.size() < getSoundChannels()))
		{
			FMOD::Channel* mychannel = NULL;
			soundEngine->playSound(FMOD_CHANNEL_FREE, i->first->getData(), 0, &mychannel);
			mychannel->setPan(i->second);
			mychannel->setVolume((float)(getSoundVolume()/100.0));
			soundChannel.push_back(mychannel);
		}
#elif _SDL_MIXER_SOUND
	for(std::list<std::pair<boost::shared_ptr<const Sound>, float> >::iterator i = soundsToPlay.begin(); i != soundsToPlay.end(); ++i)
		if((soundChannel.size() < soundConfiguration->getSoundChannels()))
		{
			int mychannel = -1;
			mychannel = Mix_PlayChannel(-1, i->first->getData(), 0);
			if(mychannel == -1) {
				std::ostringstream os;
				os << "ERROR (SoundProcessor::process()): " << Mix_GetError();
				throw SDLException(os.str());
			} else
			soundChannel.push_back(mychannel);
			int rightVolume = static_cast<int>(254.0 * i->second);
			Mix_SetPanning(mychannel, static_cast<Uint8>(254 - rightVolume), static_cast<Uint8>(rightVolume));
			// Mix_SetDistance TODO
			// int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance)  TODO
		}
#endif
		soundsToPlay.clear();
		// ------ END SOUND ENGINE -------
}
/**
 * Play sound once.
 * @param name sound name
 * @param distance mag2 distance
 */
void SDLSound::playAmbientSound(const char* name, long distance)
{
    SoundData *sdata = findChunk(name);
    if (sdata)
    {
        if ( sdata->last_played.isTimeOut() )
        {
            int oldVolume = Mix_VolumeChunk(sdata->getData(), getSoundVolume(distance));
            if (Mix_PlayChannel(-1, sdata->getData(), 0) == -1)
            {
                //LOG (("Couldn't play sound '%s': %s", name, Mix_GetError()));
            }
            Mix_VolumeChunk(sdata->getData(), oldVolume);
            sdata->last_played.reset();
        }
        else
        {
//            LOGGER.debug("Skipped ambient sound '%s' due to timeout", name);
        }
    }
}
Beispiel #10
0
int SDLAudio::getSoundVolume ( std::string filename )                         // Public version of getSoundVolume that takes filename as parameter and returns the volume as a percent
{
  Mix_Chunk* sound = assetCache.getSound( filename );
  return getSoundVolume(sound);
}
Beispiel #11
0
	void refreshVolumes()
	{
		for(const auto& pair : assetManager.getSounds()) pair.second->setVolume(getSoundVolume());
		for(const auto& pair : assetManager.getMusics()) pair.second->setVolume(getMusicVolume());
	}