File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ class LIBSCRATCHCPP_EXPORT Sound : public Asset
2525 int sampleCount () const ;
2626 void setSampleCount (int newSampleCount);
2727
28+ virtual void setVolume (double volume);
29+
2830 virtual void start ();
2931 virtual void stop ();
3032
Original file line number Diff line number Diff line change @@ -39,6 +39,12 @@ void Sound::setSampleCount(int newSampleCount)
3939 impl->sampleCount = newSampleCount;
4040}
4141
42+ /* ! Sets the volume percentage of the sound. */
43+ void Sound::setVolume (double volume)
44+ {
45+ impl->player ->setVolume (volume / 100 );
46+ }
47+
4248/* ! Starts the playback of the sound. */
4349void Sound::start ()
4450{
Original file line number Diff line number Diff line change @@ -64,6 +64,14 @@ TEST_F(SoundTest, ProcessData)
6464 sound.setData (3 , dataPtr);
6565}
6666
67+ TEST_F (SoundTest, SetVolume)
68+ {
69+ Sound sound (" sound1" , " a" , " wav" );
70+
71+ EXPECT_CALL (*m_player, setVolume (0.5604 ));
72+ sound.setVolume (56.04 );
73+ }
74+
6775TEST_F (SoundTest, Start)
6876{
6977 Sound sound (" sound1" , " a" , " wav" );
You can’t perform that action at this time.
0 commit comments