Skip to content

Commit

Permalink
Refactor AmbientSound (#2688)
Browse files Browse the repository at this point in the history
Implements new SoundObject object that is hearable in entire Sector. It is possible to change it's volume and looping sound play interval. Attempts to fix the long-broken AmbientSound.

Co-authored-by: Rusty-Box <carstenwirtz@​live.de
  • Loading branch information
mrkubax10 authored Jan 4, 2024
1 parent 78b13f7 commit 6788eb0
Show file tree
Hide file tree
Showing 17 changed files with 625 additions and 203 deletions.
Binary file modified data/images/engine/editor/music.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 3 additions & 6 deletions data/images/engine/editor/objects.stoi
Original file line number Diff line number Diff line change
Expand Up @@ -356,24 +356,21 @@
(object
(class "particles-ghosts")
(icon "images/engine/editor/ghostparticles.png"))



;; +-- This should be disabled, as it probably won't support multiple textures
;; | per config object.
;; v ~ Semphris
(object
(class "particles-custom")
(icon "images/engine/editor/particle.png"))



(object
(class "particles-custom-file")
(icon "images/engine/editor/particle_file.png"))
(object
(class "textscroller")
(icon "images/engine/editor/textscroller.png"))
(object
(class "sound-object")
(icon "images/engine/editor/sound.png"))
)

(objectgroup
Expand Down
Binary file added data/images/engine/editor/sound.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/audio/dummy_sound_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DummySoundSource final : public SoundSource
is_playing = true;
}

virtual void stop() override
virtual void stop(bool) override
{
is_playing = false;
}
Expand Down
5 changes: 3 additions & 2 deletions src/audio/openal_sound_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ OpenALSoundSource::~OpenALSoundSource()
}

void
OpenALSoundSource::stop()
OpenALSoundSource::stop(bool unload_buffer)
{
#ifdef WIN32
// See commit 417a8e7a8c599bfc2dceaec7b6f64ac865318ef1
alSourceRewindv(1, &m_source); // Stops the source
#else
alSourceStop(m_source);
#endif
alSourcei(m_source, AL_BUFFER, AL_NONE);
if (unload_buffer)
alSourcei(m_source, AL_BUFFER, AL_NONE);
try
{
SoundManager::check_al_error("Problem stopping audio source: ");
Expand Down
2 changes: 1 addition & 1 deletion src/audio/openal_sound_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OpenALSoundSource : public SoundSource
~OpenALSoundSource() override;

virtual void play() override;
virtual void stop() override;
virtual void stop(bool unload_buffer = true) override;
virtual bool playing() const override;

virtual void set_looping(bool looping) override;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/sound_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SoundSource
virtual ~SoundSource() {}

virtual void play() = 0;
virtual void stop() = 0;
virtual void stop(bool unload_buffer = true) = 0;
virtual bool playing() const = 0;

virtual void set_looping(bool looping) = 0;
Expand Down
Loading

0 comments on commit 6788eb0

Please sign in to comment.