sfizz/sources/FilePool.h

34 lines
1.1 KiB
C
Raw Normal View History

#pragma once
2019-08-03 18:14:58 +02:00
#include "StereoBuffer.h"
2019-08-04 01:38:31 +02:00
#include "Defaults.h"
#include <sndfile.hh>
#include <filesystem>
2019-08-04 01:38:31 +02:00
#include <optional>
#include <string_view>
2019-08-04 01:38:31 +02:00
#include <absl/container/flat_hash_map.h>
#include <map>
namespace sfz
{
class FilePool
{
public:
FilePool() = default;
2019-08-05 00:38:24 +02:00
void setRootDirectory(const std::filesystem::path& directory) { rootDirectory = directory; }
size_t getNumPreloadedSamples() { return preloadedData.size(); }
2019-08-04 01:38:31 +02:00
struct FileInformation
{
uint32_t end { Default::sampleEndRange.getEnd() };
uint32_t loopBegin { Default::loopRange.getStart() };
uint32_t loopEnd { Default::loopRange.getEnd() };
std::shared_ptr<StereoBuffer<float>> preloadedData;
};
2019-08-05 00:38:24 +02:00
std::optional<FileInformation> getFileInformation(std::string_view filename);
private:
std::filesystem::path rootDirectory;
2019-08-04 01:38:31 +02:00
Buffer<float> tempReadBuffer { config::preloadSize * 2 };
// std::map<std::string_view, std::shared_ptr<StereoBuffer<float>>> preloadedData;
absl::flat_hash_map<std::string_view, std::shared_ptr<StereoBuffer<float>>> preloadedData;
};
}