2024-08-22 15:59:21 +00:00
|
|
|
#pragma once
|
2024-10-23 11:44:31 +00:00
|
|
|
#include "../shape/OsciPoint.h"
|
2024-08-22 15:59:21 +00:00
|
|
|
#include <JuceHeader.h>
|
|
|
|
|
2025-01-05 15:55:53 +00:00
|
|
|
class CommonAudioProcessor;
|
2024-08-22 15:59:21 +00:00
|
|
|
class WavParser {
|
|
|
|
public:
|
2025-01-07 17:51:08 +00:00
|
|
|
WavParser(CommonAudioProcessor& p);
|
2024-08-22 15:59:21 +00:00
|
|
|
~WavParser();
|
|
|
|
|
2024-10-23 11:44:31 +00:00
|
|
|
OsciPoint getSample();
|
2024-08-22 15:59:21 +00:00
|
|
|
|
2025-01-06 18:27:23 +00:00
|
|
|
void setProgress(double progress);
|
|
|
|
void setPaused(bool paused);
|
|
|
|
bool isPaused();
|
|
|
|
void setLooping(bool looping);
|
|
|
|
bool isLooping();
|
2025-01-07 17:51:08 +00:00
|
|
|
bool parse(std::unique_ptr<juce::InputStream> stream);
|
|
|
|
void close();
|
|
|
|
bool isInitialised();
|
2025-01-06 18:27:23 +00:00
|
|
|
|
|
|
|
std::function<void(double)> onProgress;
|
|
|
|
|
2024-08-22 15:59:21 +00:00
|
|
|
private:
|
|
|
|
void setSampleRate(double sampleRate);
|
|
|
|
|
2025-01-07 17:51:08 +00:00
|
|
|
std::atomic<bool> initialised = false;
|
|
|
|
juce::AudioFormatReaderSource* afSource = nullptr;
|
|
|
|
std::atomic<bool> looping = true;
|
|
|
|
std::unique_ptr<juce::ResamplingAudioSource> source = nullptr;
|
2024-08-22 15:59:21 +00:00
|
|
|
juce::AudioBuffer<float> audioBuffer;
|
2025-01-07 17:51:08 +00:00
|
|
|
std::atomic<long> totalSamples;
|
|
|
|
std::atomic<long> counter = 0;
|
2025-01-06 18:27:23 +00:00
|
|
|
std::atomic<double> currentSample = 0;
|
|
|
|
std::atomic<bool> paused = false;
|
2024-08-22 15:59:21 +00:00
|
|
|
int fileSampleRate;
|
|
|
|
int currentSampleRate;
|
2025-01-05 15:55:53 +00:00
|
|
|
CommonAudioProcessor& audioProcessor;
|
2024-10-23 11:44:31 +00:00
|
|
|
};
|