Skip to content

Commit

Permalink
Starting to implement volume
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorbaraujo committed Jun 28, 2016
1 parent d7c92d9 commit 189e32d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions include/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ namespace ijengine {
void stop_audio();

void play_sound_effect(const string &path);

void set_audio_volume();
void set_sound_effect_volume();
}

namespace event {
Expand Down
8 changes: 4 additions & 4 deletions kernel/sdl2/sdl2kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ SDL2Kernel::play_audio_from_path(const string& path)
// printf("error: %s\n", Mix_GetError());
}

Mix_PlayMusic(audio, -1);
Mix_FadeInMusic(audio, -1, 2000);
}
}

Expand All @@ -289,11 +289,11 @@ SDL2Kernel::stop_audio()
void
SDL2Kernel::play_sound_effect(const string& path)
{
string sound_effect_path = audio_dir_path + "/effects/" + path;
Mix_Chunk *effect = Mix_LoadWAV(sound_effect_path.c_str());
//string sound_effect_path = audio_dir_path + "/effects/" + path;
Mix_Chunk *effect = Mix_LoadWAV(path.c_str());

if(not effect){
// printf("Failed to load sound effect\n");
printf("Failed to load sound effect\n");
}

Mix_PlayChannel(-1, effect, 0);
Expand Down
12 changes: 12 additions & 0 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ namespace ijengine
{
kernel->play_sound_effect(path);
}

void
set_audio_volume(int volume)
{
kernel->set_audio_volume(volume);
}

void
set_sound_effect_volume(int volume)
{
kernel->set_sound_effect_volume(volume);
}
}

namespace event
Expand Down
Binary file added test/res/effects/boom.wav
Binary file not shown.

0 comments on commit 189e32d

Please sign in to comment.