3// SFML - Simple and Fast Multimedia Library 4// Copyright (C) 2007-2025 Laurent Gomila (laurent@sfml-dev.org) 6// This software is provided 'as-is', without any express or implied warranty. 7// In no event will the authors be held liable for any damages arising from the use of this software. 9// Permission is granted to anyone to use this software for any purpose, 10// including commercial applications, and to alter it and redistribute it freely, 11// subject to the following restrictions: 13// 1. The origin of this software must not be misrepresented; 14// you must not claim that you wrote the original software. 15// If you use this software in a product, an acknowledgment 16// in the product documentation would be appreciated but is not required. 18// 2. Altered source versions must be plainly marked as such, 19// and must not be misrepresented as being the original software. 21// 3. This notice may not be removed or altered from any source distribution. 66// Associated `Span` type 96explicitMusic(
const std::filesystem::path& filename);
119Music(
constvoid* data, std::size_t sizeInBytes);
304 std::optional<std::uint64_t>
onLoop() override;
315 [[nodiscard]] std::uint64_t timeToSamples(
Time position) const;
325 [[nodiscard]]
Time samplesToTime(std::uint64_t samples) const;
331 std::unique_ptr<Impl> m_impl;
Provide read access to sound files.
Abstract class for custom file input streams.
Music()
Default constructor.
void onSeek(Time timeOffset) override
Change the current playing position in the stream source.
std::optional< std::uint64_t > onLoop() override
Change the current playing position in the stream source to the loop offset.
Time getDuration() const
Get the total duration of the music.
bool openFromStream(InputStream &stream)
Open a music from an audio file in a custom stream.
Music(Music &&) noexcept
Move constructor.
bool onGetData(Chunk &data) override
Request a new chunk of audio samples from the stream source.
Music(const std::filesystem::path &filename)
Construct a music from an audio file.
bool openFromFile(const std::filesystem::path &filename)
Open a music from an audio file.
TimeSpan getLoopPoints() const
Get the positions of the of the sound's looping sequence.
Music(InputStream &stream)
Construct a music from an audio file in a custom stream.
Music(const void *data, std::size_t sizeInBytes)
Construct a music from an audio file in memory.
void setLoopPoints(TimeSpan timePoints)
Sets the beginning and duration of the sound's looping sequence using sf::Time
bool openFromMemory(const void *data, std::size_t sizeInBytes)
Open a music from an audio file in memory.
~Music() override
Destructor.
SoundStream(SoundStream &&) noexcept
Move constructor.
Structure defining a time range using the template type.
Structure defining a chunk of audio data to stream.