85class AudioFileManager {
87 bool operator()(
String*
const& lhs,
String*
const& rhs)
const {
return strcasecmp(lhs->get(), rhs->get()) < 0; }
93 deluge::fast_map<String*, Sample*, StringLessThan> sampleFiles;
94 deluge::fast_map<String*, WaveTable*, StringLessThan> wavetableFiles;
97 std::expected<AudioFile*, Error> getAudioFileFromFilename(
String& fileName,
bool mayReadCard,
98 FilePointer* filePointer, AudioFileType type,
99 bool makeWaveTableWorkAtAllCosts =
false);
100 bool loadCluster(
Cluster& cluster, int32_t minNumReasonsAfter = 0);
101 void loadAnyEnqueuedClusters(int32_t maxNum = 128,
bool mayProcessUserActionsBetween =
false);
102 void removeReasonFromCluster(
Cluster& cluster,
char const* errorCode,
bool deletingSong =
false);
106 std::expected<void, Error> setupAlternateAudioFilePath(
String& newPath, int32_t dirPathLength,
String& oldPath);
107 std::expected<void, Error> setupAlternateAudioFileDir(
String& newPath,
char const* rootDir,
108 String& songFilenameWithoutExtension);
109 bool loadingQueueHasAnyLowestPriorityElements();
113 AudioRecordingFolder folder, uint32_t* getNumber,
const char* channelName,
115 void deleteAnyTempRecordedSamplesFromMemory();
117 void releaseFile(
Sample& sample);
119 bool releaseSampleAtFilePath(
String& filePath);
122 void thingBeginningLoading(ThingType newThingType);
123 void thingFinishedLoading();
125 void setCardRead() { cardReadOnce =
true; }
126 void setCardEjected() { cardEjected =
true; }
128 ClusterPriorityQueue loadingQueue;
130 Cluster* clusterBeingLoaded;
131 int32_t minNumReasonsForClusterBeingLoaded;
134 String alternateAudioFileLoadPath;
135 AlternateLoadDirStatus alternateLoadDirStatus = AlternateLoadDirStatus::NONE_SET;
136 ThingType thingTypeBeingLoaded = ThingType::NONE;
137 DIR alternateLoadDir;
139 std::array<int32_t, kNumAudioRecordingFolders> highestUsedAudioRecordingNumber;
140 std::bitset<kNumAudioRecordingFolders> highestUsedAudioRecordingNumberNeedsReChecking;
141 void firstCardRead();
144 bool cardReadOnce{
false};
146 bool cardDisabled =
false;
148 uint32_t clusterSizeAtBoot{0};
150 void cardReinserted();
151 int32_t readBytes(
char* buffer, int32_t num, int32_t* byteIndexWithinCluster, Cluster** currentCluster,
152 uint32_t* currentClusterIndex, uint32_t fileSize, Sample* sample);
153 int32_t loadAiff(Sample* newSample, uint32_t fileSize, Cluster** currentCluster, uint32_t* currentClusterIndex);
154 int32_t loadWav(Sample* newSample, uint32_t fileSize, Cluster** currentCluster, uint32_t* currentClusterIndex);
Error getUnusedAudioRecordingFilePath(String &filePath, String *tempFilePathForRecording, AudioRecordingFolder folder, uint32_t *getNumber, const char *channelName, String *songName)
Definition audio_file_manager.cpp:224