2
0
Fork 0

Begin work on communication of recording state between instances using static variables.

This commit is contained in:
bruce 2014-11-03 18:16:59 +09:00
parent abb5a05218
commit 76206997f8
5 changed files with 78 additions and 61 deletions

View file

@ -27,7 +27,7 @@
void PluginGui::updateFromParameters()
{
emulatorSlider->setValue(processor->getEnumParameter("Emulator"), juce::NotificationType::dontSendNotification);
setRecordButtonState(processor->isRecording());
setRecordButtonState(processor->isThisInstanceRecording());
sineImageButton->setToggleState(false, false);
halfsineImageButton->setToggleState(false, false);
@ -1498,7 +1498,7 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked)
{
//[UserButtonCode_recordButton] -- add your button handler code here..
recordButton->setToggleState(false, false);
if (!processor->isRecording()) {
if (!processor->isAnyInstanceRecording()) {
WildcardFileFilter wildcardFilter ("*.dro", String::empty, "DRO files");
FileBrowserComponent browser (FileBrowserComponent::saveMode,
File::nonexistent,

View file

@ -136,10 +136,14 @@ JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
available_channels.push_back(i);
}
bool JuceOplvstiAudioProcessor::isRecording() {
bool JuceOplvstiAudioProcessor::isThisInstanceRecording() {
return NULL != recordingFile;
}
bool JuceOplvstiAudioProcessor::isAnyInstanceRecording() {
return Opl->IsAnInstanceRecording();
}
void JuceOplvstiAudioProcessor::startRecording(File *outputFile) {
recordingFile = outputFile;
Opl->StartCapture(outputFile->getFullPathName().toUTF8());

View file

@ -26,7 +26,8 @@ public:
void applyPitchBend();
~JuceOplvstiAudioProcessor();
bool isRecording();
bool isThisInstanceRecording();
bool isAnyInstanceRecording();
void startRecording(File *outputFile);
void stopRecording();

View file

@ -5,9 +5,15 @@
// A wrapper around the DOSBox and ZDoom OPL emulators.
// Used by the first recording instance to claim master status
Hiopl* Hiopl::master = NULL;
bool Hiopl::IsAnInstanceRecording() {
return NULL != Hiopl::master;
}
Hiopl::Hiopl(int buflen, Emulator emulator) {
captureHandle = NULL;
StopCapture();
InitCaptureVariables();
adlib = new DBOPL::Handler();
zdoom = JavaOPLCreate(false);
@ -244,9 +250,7 @@ static Bit8u dro_opl3_enable[]={
};
void Hiopl::StartCapture(const char* filepath) {
if (NULL != captureHandle) {
StopCapture();
} else {
Hiopl::master = this;
lastWrite = -1;
captureLengthBytes = 0;
captureStart = Time::currentTimeMillis();
@ -294,7 +298,6 @@ void Hiopl::StartCapture(const char* filepath) {
for (Bit8u i = 0xe0; i <= 0xf5; i++) {
_CaptureRegWrite(i, regCache[i]);
}
}
}
INLINE void host_writed(Bit8u *off, Bit32u val) {
@ -304,9 +307,18 @@ INLINE void host_writed(Bit8u *off, Bit32u val) {
off[3]=(Bit8u)(val >> 24);
};
void Hiopl::InitCaptureVariables() {
captureHandle = NULL;
captureLengthBytes = 0;
lastWrite = -1;
captureStart = -1;
}
void Hiopl::StopCapture() {
if (NULL != captureHandle) {
Bit32u lengthMilliseconds = (Bit32u)(3000 + Time::currentTimeMillis() - captureStart);
Bit16u finalDelay = (Bit16u)(Time::currentTimeMillis() - lastWrite);
_CaptureDelay(finalDelay);
Bit32u lengthMilliseconds = (Bit32u)(finalDelay + Time::currentTimeMillis() - captureStart);
host_writed(&dro_header[0x0c], lengthMilliseconds);
host_writed(&dro_header[0x10], captureLengthBytes);
//if (opl.raw.opl3 && opl.raw.dualopl2) host_writed(&dro_header[0x14],0x1);
@ -317,10 +329,7 @@ void Hiopl::StopCapture() {
fwrite(dro_header, 1, sizeof(dro_header), captureHandle);
fclose(captureHandle);
}
captureHandle = NULL;
captureLengthBytes = 0;
lastWrite = -1;
captureStart = -1;
InitCaptureVariables();
}
void Hiopl::_CaptureDelay(Bit16u delayMs) {

View file

@ -58,6 +58,8 @@ class Hiopl {
void _WriteReg(Bit32u reg, Bit8u value, Bit8u mask=0x0);
void _ClearRegBits(Bit32u reg, Bit8u mask);
void InitCaptureVariables();
bool IsAnInstanceRecording();
void StartCapture(const char* filepath);
void StopCapture();
@ -79,6 +81,7 @@ class Hiopl {
std::map<int, int> _op1offset;
std::map<int, int> _op2offset;
static Hiopl* master;
FILE* captureHandle;
Bit64s captureStart;
Bit64s lastWrite;