Skip to content

Commit

Permalink
Add RecordTemp
Browse files Browse the repository at this point in the history
  • Loading branch information
FangCunWuChang committed Nov 24, 2024
1 parent dc66269 commit 5a01dd7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/audioCore/AudioCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "misc/Renderer.h"
#include "misc/Device.h"
#include "misc/AudioLock.h"
#include "misc/RecordTemp.h"
#include "source/SourceManager.h"
#include "source/SourceIO.h"
#include "project/ProjectInfoData.h"
Expand Down Expand Up @@ -95,6 +96,7 @@ AudioCore::~AudioCore() {
PlayPosition::releaseInstance();
Plugin::releaseInstance();
ARADataIOThread::releaseInstance();
RecordTemp::releaseInstance();
SourceIO::releaseInstance();
SourceManager::releaseInstance();
UICallback::releaseInstance();
Expand Down
9 changes: 7 additions & 2 deletions src/audioCore/graph/SourceRecordProcessor.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include "SourceRecordProcessor.h"
#include "MainGraph.h"
#include "../misc/RecordTemp.h"
#include "../uiCallback/UICallback.h"

SourceRecordProcessor::SourceRecordProcessor(MainGraph* parent)
: parent(parent) {}
: parent(parent) {
[[maybe_unused]] auto recTemp = RecordTemp::getInstance();
}

SourceRecordProcessor::~SourceRecordProcessor() {}

Expand All @@ -20,8 +23,10 @@ void SourceRecordProcessor::processBlock(
auto playPosition = playHead->getPosition();
if (!playPosition->getIsPlaying() || !playPosition->getIsRecording()) { return; }
int timeInSamples = playPosition->getTimeInSamples().orFallback(0);
double timeInSeconds = playPosition->getTimeInSeconds().orFallback(0);

/** TODO Record Data Temp */
/** Record Data Temp */
RecordTemp::getInstance()->recordData(timeInSeconds, buffer, midiMessages);

/** TODO Callback */
/*if (trackIndexList.size() > 0 && buffer.getNumSamples() > 0) {
Expand Down
20 changes: 20 additions & 0 deletions src/audioCore/misc/RecordTemp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "RecordTemp.h"

void RecordTemp::recordData(double timeSec,
const juce::AudioBuffer<float>& buffer, const juce::MidiBuffer& midiMessages) {
/** TODO */
}

RecordTemp* RecordTemp::getInstance() {
return RecordTemp::instance
? RecordTemp::instance : (RecordTemp::instance = new RecordTemp());
}

void RecordTemp::releaseInstance() {
if (RecordTemp::instance) {
delete RecordTemp::instance;
RecordTemp::instance = nullptr;
}
}

RecordTemp* RecordTemp::instance = nullptr;
20 changes: 20 additions & 0 deletions src/audioCore/misc/RecordTemp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <JuceHeader.h>

class RecordTemp final : private juce::DeletedAtShutdown {
public:
RecordTemp() = default;

void recordData(double timeSec,
const juce::AudioBuffer<float>& buffer, const juce::MidiBuffer& midiMessages);

public:
static RecordTemp* getInstance();
static void releaseInstance();

private:
static RecordTemp* instance;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RecordTemp)
};

0 comments on commit 5a01dd7

Please sign in to comment.