osci-render/Source/audio/ShapeSound.cpp

44 wiersze
1.0 KiB
C++
Czysty Zwykły widok Historia

2023-08-28 21:06:21 +00:00
#include "ShapeSound.h"
2024-05-11 22:10:54 +00:00
ShapeSound::ShapeSound(OscirenderAudioProcessor &p, std::shared_ptr<FileParser> parser) : parser(parser) {
2023-08-28 21:06:21 +00:00
if (parser->isSample()) {
2024-05-11 22:10:54 +00:00
producer = std::make_unique<FrameProducer>(*this, std::make_shared<FileParser>(p));
2023-08-28 21:06:21 +00:00
} else {
producer = std::make_unique<FrameProducer>(*this, parser);
}
producer->startThread();
}
2023-09-10 16:43:37 +00:00
ShapeSound::ShapeSound() {}
ShapeSound::~ShapeSound() {
frames.kill();
2023-09-10 16:43:37 +00:00
if (producer != nullptr) {
producer->stopThread(1000);
}
}
2023-08-28 21:06:21 +00:00
bool ShapeSound::appliesToNote(int note) {
return true;
}
bool ShapeSound::appliesToChannel(int channel) {
return true;
}
void ShapeSound::addFrame(std::vector<std::unique_ptr<Shape>>& frame, bool force) {
if (force) {
frames.push(std::move(frame));
} else {
frames.try_push(std::move(frame));
}
2023-08-28 21:06:21 +00:00
}
double ShapeSound::updateFrame(std::vector<std::unique_ptr<Shape>>& frame) {
if (frames.try_pop(frame)) {
frameLength = Shape::totalLength(frame);
2023-08-28 21:06:21 +00:00
}
return frameLength;
}