Movatterモバイル変換


[0]ホーム

URL:


Loading...
Searching...
No Matches
SoundStream.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2025 Laurent Gomila (laurent@sfml-dev.org)
5//
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.
8//
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:
12//
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.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#pragma once
26
28// Headers
30#include <SFML/Audio/Export.hpp>
31
34
35#include <SFML/System/Time.hpp>
36
37#include <memory>
38#include <optional>
39#include <vector>
40
41#include <cstddef>
42#include <cstdint>
43
44
45namespacesf
46{
52{
53public:
58structChunk
59 {
60const std::int16_t*samples{};
61 std::size_tsampleCount{};
62 };
63
68~SoundStream()override;
69
75
80SoundStream& operator=(SoundStream&&) noexcept;
81
94voidplay() override;
95
105voidpause() override;
106
117voidstop() override;
118
127 [[nodiscard]]unsignedintgetChannelCount() const;
128
138 [[nodiscard]]unsignedintgetSampleRate() const;
139
149 [[nodiscard]] std::vector<SoundChannel>getChannelMap() const;
150
157 [[nodiscard]]StatusgetStatus() const override;
158
172voidsetPlayingOffset(Time timeOffset);
173
182 [[nodiscard]]TimegetPlayingOffset() const;
183
197voidsetLooping(bool loop);
198
207 [[nodiscard]]boolisLooping() const;
208
218voidsetEffectProcessor(EffectProcessor effectProcessor) override;
219
220protected:
228
244voidinitialize(unsignedint channelCount,unsignedint sampleRate, const std::vector<SoundChannel>& channelMap);
245
263 [[nodiscard]] virtualboolonGetData(Chunk& data) = 0;
264
274 virtualvoidonSeek(Time timeOffset) = 0;
275
286 virtual std::optional<std::uint64_t>onLoop();
287
288private:
295 [[nodiscard]]void* getSound() const override;
296
298// Member data
300 struct Impl;
301 std::unique_ptr<Impl> m_impl;
302};
303
304}// namespace sf
305
306
#define SFML_AUDIO_API
SoundSource(const SoundSource &)=default
Copy constructor.
std::function< void(const float *inputFrames, unsigned int &inputFrameCount, float *outputFrames, unsigned int &outputFrameCount, unsigned int frameChannelCount)> EffectProcessor
Callable that is provided with sound data for processing.
Status
Enumeration of the sound source states.
void setLooping(bool loop)
Set whether or not the stream should loop after reaching the end.
std::vector< SoundChannel > getChannelMap() const
Get the map of position in sample frame to sound channel.
SoundStream(SoundStream &&) noexcept
Move constructor.
unsigned int getChannelCount() const
Return the number of channels of the stream.
void pause() override
Pause the audio stream.
void initialize(unsigned int channelCount, unsigned int sampleRate, const std::vector< SoundChannel > &channelMap)
Define the audio stream parameters.
bool isLooping() const
Tell whether or not the stream is in loop mode.
Status getStatus() const override
Get the current status of the stream (stopped, paused, playing)
void setEffectProcessor(EffectProcessor effectProcessor) override
Set the effect processor to be applied to the sound.
void stop() override
Stop playing the audio stream.
unsigned int getSampleRate() const
Get the stream sample rate of the stream.
virtual void onSeek(Time timeOffset)=0
Change the current playing position in the stream source.
virtual bool onGetData(Chunk &data)=0
Request a new chunk of audio samples from the stream source.
virtual std::optional< std::uint64_t > onLoop()
Change the current playing position in the stream source to the beginning of the loop.
~SoundStream() override
Destructor.
Time getPlayingOffset() const
Get the current playing position of the stream.
void play() override
Start or resume playing the audio stream.
void setPlayingOffset(Time timeOffset)
Change the current playing position of the stream.
Represents a time value.
DefinitionTime.hpp:42
SoundChannel
Types of sound channels that can be read/written from sound buffers/files.
Structure defining a chunk of audio data to stream.
const std::int16_t * samples
Pointer to the audio samples.
std::size_t sampleCount
Number of samples pointed by Samples.

[8]ページ先頭

©2009-2025 Movatter.jp