Movatterモバイル変換


[0]ホーム

URL:


Loading...
Searching...
No Matches
InputSoundFile.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
33
34#include <filesystem>
35#include <memory>
36#include <vector>
37
38#include <cstddef>
39#include <cstdint>
40
41
42namespacesf
43{
44classTime;
45classInputStream;
46
52{
53public:
61InputSoundFile() =default;
62
79explicitInputSoundFile(const std::filesystem::path& filename);
80
93InputSoundFile(constvoid* data, std::size_t sizeInBytes);
94
107
124 [[nodiscard]]boolopenFromFile(const std::filesystem::path& filename);
125
138 [[nodiscard]]boolopenFromMemory(constvoid* data, std::size_t sizeInBytes);
139
151 [[nodiscard]]boolopenFromStream(InputStream& stream);
152
159 [[nodiscard]] std::uint64_tgetSampleCount()const;
160
167 [[nodiscard]]unsignedintgetChannelCount()const;
168
175 [[nodiscard]]unsignedintgetSampleRate()const;
176
188 [[nodiscard]]const std::vector<SoundChannel>&getChannelMap()const;
189
199 [[nodiscard]]TimegetDuration()const;
200
207 [[nodiscard]]TimegetTimeOffset()const;
208
215 [[nodiscard]] std::uint64_tgetSampleOffset()const;
216
234voidseek(std::uint64_t sampleOffset);
235
248voidseek(Time timeOffset);
249
259 [[nodiscard]] std::uint64_tread(std::int16_t* samples, std::uint64_t maxCount);
260
265voidclose();
266
267private:
272structSFML_AUDIO_API StreamDeleter
273 {
274 StreamDeleter(bool theOwned);
275
276// To accept ownership transfer from usual std::unique_ptr<T>
277template <typename T>
278 StreamDeleter(const std::default_delete<T>&);
279
280void operator()(InputStream* ptr)const;
281
282bool owned{true};
283 };
284
286// Member data
288 std::unique_ptr<SoundFileReader> m_reader;
289 std::unique_ptr<InputStream, StreamDeleter> m_stream{nullptr,false};
290 std::uint64_t m_sampleOffset{};
291 std::uint64_t m_sampleCount{};
292unsignedint m_sampleRate{};
293 std::vector<SoundChannel> m_channelMap;
294};
295
296}// namespace sf
297
298
#define SFML_AUDIO_API
InputSoundFile(const std::filesystem::path &filename)
Construct a sound file from the disk for reading.
bool openFromStream(InputStream &stream)
Open a sound file from a custom stream for reading.
InputSoundFile(const void *data, std::size_t sizeInBytes)
Construct a sound file in memory for reading.
bool openFromFile(const std::filesystem::path &filename)
Open a sound file from the disk for reading.
bool openFromMemory(const void *data, std::size_t sizeInBytes)
Open a sound file in memory for reading.
unsigned int getChannelCount() const
Get the number of channels used by the sound.
std::uint64_t getSampleCount() const
Get the total number of audio samples in the file.
InputSoundFile()=default
Default constructor.
unsigned int getSampleRate() const
Get the sample rate of the sound.
std::uint64_t getSampleOffset() const
Get the read offset of the file in samples.
void seek(Time timeOffset)
Change the current read position to the given time offset.
InputSoundFile(InputStream &stream)
Construct a sound file from a custom stream for reading.
Time getDuration() const
Get the total duration of the sound file.
const std::vector< SoundChannel > & getChannelMap() const
Get the map of position in sample frame to sound channel.
std::uint64_t read(std::int16_t *samples, std::uint64_t maxCount)
Read audio samples from the open file.
Time getTimeOffset() const
Get the read offset of the file in time.
void close()
Close the current file.
void seek(std::uint64_t sampleOffset)
Change the current read position to the given sample offset.
Abstract class for custom file input streams.
Represents a time value.
DefinitionTime.hpp:42

[8]ページ先頭

©2009-2025 Movatter.jp