Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions gameSource/LivingLifePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5776,7 +5776,7 @@ void LivingLifePage::handleAnimSound( int inObjectID, double inAge,



playSound( u,
playCryingSound( u,
getVectorFromCamera( inPosX, inPosY ) );

}
Expand Down Expand Up @@ -11464,8 +11464,9 @@ void LivingLifePage::draw( doublePair inViewCenter,
// make sure it can be heard, even
// if paused
setSoundLoudness( 1.0 );
float hungerLoudness = SettingsManager::getFloatSetting( "HungerLoudness", 1.0 );
playSoundSprite( mHungerSound,
getSoundEffectsLoudness(),
getSoundEffectsLoudness() * hungerLoudness,
// middle
0.5 );
}
Expand Down Expand Up @@ -22770,8 +22771,9 @@ void LivingLifePage::step() {
// make sure it can be heard
// even if paused
setSoundLoudness( 1.0 );
float hungerLoudness = SettingsManager::getFloatSetting( "HungerLoudness", 1.0 );
playSoundSprite( mHungerSound,
getSoundEffectsLoudness(),
getSoundEffectsLoudness() * hungerLoudness,
// middle
0.5 );
}
Expand Down
50 changes: 48 additions & 2 deletions gameSource/SettingsPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ SettingsPage::SettingsPage()
mTrippingEffectDisabledBox( 0, 168, 4 ),

// Sound
mCryingLoudnessSlider( mainFont, 0, 40, 4, 200, 30,
0.0, 1.0,
"CRYING LOUDNESS", true ),
mHungerLoudnessSlider( mainFont, 0, 40, 4, 200, 30,
0.0, 1.0,
"HUNGER LOUDNESS", true ),
mMusicLoudnessSlider( mainFont, 0, 40, 4, 200, 30,
0.0, 1.0,
translate( "musicLoudness" ), true ),
Expand Down Expand Up @@ -189,6 +195,10 @@ SettingsPage::SettingsPage()
mSoundEffectsLoudnessSlider.addActionListener( this );
addComponent( &mMusicLoudnessSlider );
mMusicLoudnessSlider.addActionListener( this );
addComponent( &mCryingLoudnessSlider );
mCryingLoudnessSlider.addActionListener( this );
addComponent( &mHungerLoudnessSlider );
mHungerLoudnessSlider.addActionListener( this );

// Screen
addComponent( &mTrippingEffectDisabledBox );
Expand Down Expand Up @@ -766,6 +776,36 @@ void SettingsPage::actionPerformed( GUIComponent *inTarget ) {
setMusicLoudness( mMusicLoudnessSlider.getValue(), true );
}
}
else if( inTarget == &mCryingLoudnessSlider ) {
setMusicLoudness( 0 );
mMusicStartTime = 0;

if( ! mCryingLoudnessSlider.isPointerDown() ) {
float cryingLoudness = mCryingLoudnessSlider.getValue();

setCryingLoudness( cryingLoudness );

SoundSpriteHandle mCryingSound = loadSoundSprite( "otherSounds", "cryingTest.aiff" );
playSoundSprite( mCryingSound,
getSoundEffectsLoudness() * cryingLoudness,
0.5 );
}
}
else if( inTarget == &mHungerLoudnessSlider ) {
setMusicLoudness( 0 );
mMusicStartTime = 0;

if( ! mHungerLoudnessSlider.isPointerDown() ) {
float hungerLoudness = mHungerLoudnessSlider.getValue();

SettingsManager::setSetting( "HungerLoudness", hungerLoudness );

SoundSpriteHandle mHungerSound = loadSoundSprite( "otherSounds", "hunger.aiff" );
playSoundSprite( mHungerSound,
getSoundEffectsLoudness() * hungerLoudness,
0.5 );
}
}
else if( inTarget == &mCopyButton ) {
char *address = mCustomServerAddressField.getText();

Expand Down Expand Up @@ -1350,6 +1390,8 @@ void SettingsPage::makeActive( char inFresh ) {

mMusicLoudnessSlider.setValue( musicLoudness );
mSoundEffectsLoudnessSlider.setValue( getSoundEffectsLoudness() );
mCryingLoudnessSlider.setValue( getCryingLoudness() );
mHungerLoudnessSlider.setValue( SettingsManager::getFloatSetting( "HungerLoudness", 1.0 ) );
setMusicLoudness( 0 );
mMusicStartTime = 0;

Expand Down Expand Up @@ -1420,8 +1462,10 @@ void SettingsPage::updatePage() {
mCursorModeSet->setPosition( 0, 0 );
mCursorScaleSlider.setPosition( -80, -lineSpacing * 3 );

mMusicLoudnessSlider.setPosition( 0, lineSpacing / 2 );
mSoundEffectsLoudnessSlider.setPosition( 0, - lineSpacing / 2 );
mMusicLoudnessSlider.setPosition( 0, lineSpacing * 2 );
mSoundEffectsLoudnessSlider.setPosition( 0, lineSpacing );
mCryingLoudnessSlider.setPosition( 0, - lineSpacing );
mHungerLoudnessSlider.setPosition( 0, - lineSpacing * 2 );

mTargetFrameRateField.setPosition( 5, lineSpacing );
mVsyncBox.setPosition( 0, 0 );
Expand Down Expand Up @@ -1476,6 +1520,8 @@ void SettingsPage::updatePage() {

mMusicLoudnessSlider.setVisible( mPage == 3 );
mSoundEffectsLoudnessSlider.setVisible( mPage == 3 );
mCryingLoudnessSlider.setVisible( mPage == 3 );
mHungerLoudnessSlider.setVisible( mPage == 3 );

#ifdef USE_DISCORD
mEnableDiscordRichPresence.setVisible(mPage == 4);
Expand Down
2 changes: 2 additions & 0 deletions gameSource/SettingsPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class SettingsPage : public GamePage, public ActionListener {
// Sound
ValueSlider mMusicLoudnessSlider;
ValueSlider mSoundEffectsLoudnessSlider;
ValueSlider mCryingLoudnessSlider;
ValueSlider mHungerLoudnessSlider;

#ifdef USE_DISCORD
// Discord
Expand Down
Binary file added gameSource/otherSounds/cryingTest.aiff
Binary file not shown.
1 change: 1 addition & 0 deletions gameSource/settings/cryingLoudness.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0
1 change: 1 addition & 0 deletions gameSource/settings/hungerLoudness.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0
28 changes: 28 additions & 0 deletions gameSource/soundBank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ int getMaxSoundID() {
}


static double cryingLoudness = 1.0;

void setCryingLoudness( double inLoudness ) {
cryingLoudness = inLoudness;

SettingsManager::setSetting( "cryingLoudness",
(float)cryingLoudness );
}

double getCryingLoudness() {
return cryingLoudness;
}


static int16_t *readAIFFFile( File *inFile, int *outNumSamples ) {
int numBytes;
Expand Down Expand Up @@ -374,6 +387,9 @@ int initSoundBankStart( char *outRebuildingCache ) {

soundEffectsLoudness =
SettingsManager::getFloatSetting( "soundEffectsLoudness", 1.0 );

cryingLoudness =
SettingsManager::getFloatSetting( "cryingLoudness", 1.0 );

soundEffectsOff = SettingsManager::getIntSetting( "soundEffectsOff", 0 );

Expand Down Expand Up @@ -1134,6 +1150,18 @@ void playSound( SoundUsage inUsage,
}


void playCryingSound( SoundUsage inUsage,
doublePair inVectorFromCameraToSoundSource ) {
//set new soundEffectsLoudness temporarily to soften sound of baby cries
double tempSoundEffectsLoudness = soundEffectsLoudness;
soundEffectsLoudness *= cryingLoudness;

playSound( inUsage, inVectorFromCameraToSoundSource );

soundEffectsLoudness = tempSoundEffectsLoudness; //revert changes
}



void playSound( SoundSpriteHandle inSoundSprite,
double inVolumeTweak,
Expand Down
8 changes: 8 additions & 0 deletions gameSource/soundBank.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ void setSoundEffectsLoudness( double inLoudness );

double getSoundEffectsLoudness();

// defaults to 1.0
void setCryingLoudness( double inLoudness );

double getCryingLoudness();

// defaults to on
void setSoundEffectsOff( char inOff );

Expand All @@ -96,6 +101,9 @@ void playSound( SoundUsage inUsage,
void playSound( SoundUsage inUsage,
doublePair inVectorFromCameraToSoundSource );

void playCryingSound( SoundUsage inUsage,
doublePair inVectorFromCameraToSoundSource );


// leverage stereo positioning code on a raw sound sprite
// still offer a volume tweak on top of stereo positioning
Expand Down