2019-07-30 00:29:23 +02:00
|
|
|
#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>
|
2019-07-30 00:29:23 +02:00
|
|
|
#include <filesystem>
|
2019-08-04 01:38:31 +02:00
|
|
|
#include <optional>
|
2019-07-30 00:29:23 +02:00
|
|
|
#include <string_view>
|
2019-08-04 01:38:31 +02:00
|
|
|
#include <absl/container/flat_hash_map.h>
|
|
|
|
|
#include <map>
|
2019-07-30 00:29:23 +02:00
|
|
|
|
|
|
|
|
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);
|
2019-07-30 00:29:23 +02:00
|
|
|
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;
|
2019-07-30 00:29:23 +02:00
|
|
|
};
|
|
|
|
|
}
|