Begin work on communication of recording state between instances using static variables.
This commit is contained in:
parent
abb5a05218
commit
76206997f8
5 changed files with 78 additions and 61 deletions
|
@ -27,7 +27,7 @@
|
||||||
void PluginGui::updateFromParameters()
|
void PluginGui::updateFromParameters()
|
||||||
{
|
{
|
||||||
emulatorSlider->setValue(processor->getEnumParameter("Emulator"), juce::NotificationType::dontSendNotification);
|
emulatorSlider->setValue(processor->getEnumParameter("Emulator"), juce::NotificationType::dontSendNotification);
|
||||||
setRecordButtonState(processor->isRecording());
|
setRecordButtonState(processor->isThisInstanceRecording());
|
||||||
|
|
||||||
sineImageButton->setToggleState(false, false);
|
sineImageButton->setToggleState(false, false);
|
||||||
halfsineImageButton->setToggleState(false, false);
|
halfsineImageButton->setToggleState(false, false);
|
||||||
|
@ -1498,7 +1498,7 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked)
|
||||||
{
|
{
|
||||||
//[UserButtonCode_recordButton] -- add your button handler code here..
|
//[UserButtonCode_recordButton] -- add your button handler code here..
|
||||||
recordButton->setToggleState(false, false);
|
recordButton->setToggleState(false, false);
|
||||||
if (!processor->isRecording()) {
|
if (!processor->isAnyInstanceRecording()) {
|
||||||
WildcardFileFilter wildcardFilter ("*.dro", String::empty, "DRO files");
|
WildcardFileFilter wildcardFilter ("*.dro", String::empty, "DRO files");
|
||||||
FileBrowserComponent browser (FileBrowserComponent::saveMode,
|
FileBrowserComponent browser (FileBrowserComponent::saveMode,
|
||||||
File::nonexistent,
|
File::nonexistent,
|
||||||
|
|
|
@ -136,10 +136,14 @@ JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
|
||||||
available_channels.push_back(i);
|
available_channels.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JuceOplvstiAudioProcessor::isRecording() {
|
bool JuceOplvstiAudioProcessor::isThisInstanceRecording() {
|
||||||
return NULL != recordingFile;
|
return NULL != recordingFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JuceOplvstiAudioProcessor::isAnyInstanceRecording() {
|
||||||
|
return Opl->IsAnInstanceRecording();
|
||||||
|
}
|
||||||
|
|
||||||
void JuceOplvstiAudioProcessor::startRecording(File *outputFile) {
|
void JuceOplvstiAudioProcessor::startRecording(File *outputFile) {
|
||||||
recordingFile = outputFile;
|
recordingFile = outputFile;
|
||||||
Opl->StartCapture(outputFile->getFullPathName().toUTF8());
|
Opl->StartCapture(outputFile->getFullPathName().toUTF8());
|
||||||
|
|
|
@ -26,7 +26,8 @@ public:
|
||||||
void applyPitchBend();
|
void applyPitchBend();
|
||||||
~JuceOplvstiAudioProcessor();
|
~JuceOplvstiAudioProcessor();
|
||||||
|
|
||||||
bool isRecording();
|
bool isThisInstanceRecording();
|
||||||
|
bool isAnyInstanceRecording();
|
||||||
void startRecording(File *outputFile);
|
void startRecording(File *outputFile);
|
||||||
void stopRecording();
|
void stopRecording();
|
||||||
|
|
||||||
|
|
123
Source/hiopl.cpp
123
Source/hiopl.cpp
|
@ -5,9 +5,15 @@
|
||||||
|
|
||||||
// A wrapper around the DOSBox and ZDoom OPL emulators.
|
// 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) {
|
Hiopl::Hiopl(int buflen, Emulator emulator) {
|
||||||
captureHandle = NULL;
|
InitCaptureVariables();
|
||||||
StopCapture();
|
|
||||||
|
|
||||||
adlib = new DBOPL::Handler();
|
adlib = new DBOPL::Handler();
|
||||||
zdoom = JavaOPLCreate(false);
|
zdoom = JavaOPLCreate(false);
|
||||||
|
@ -244,56 +250,53 @@ static Bit8u dro_opl3_enable[]={
|
||||||
};
|
};
|
||||||
|
|
||||||
void Hiopl::StartCapture(const char* filepath) {
|
void Hiopl::StartCapture(const char* filepath) {
|
||||||
if (NULL != captureHandle) {
|
Hiopl::master = this;
|
||||||
StopCapture();
|
lastWrite = -1;
|
||||||
} else {
|
captureLengthBytes = 0;
|
||||||
lastWrite = -1;
|
captureStart = Time::currentTimeMillis();
|
||||||
captureLengthBytes = 0;
|
captureHandle = fopen(filepath, "wb");
|
||||||
captureStart = Time::currentTimeMillis();
|
fwrite(dro_header, 1, sizeof(dro_header), captureHandle);
|
||||||
captureHandle = fopen(filepath, "wb");
|
for (int i = 0; i <= 0xff; i++) {
|
||||||
fwrite(dro_header, 1, sizeof(dro_header), captureHandle);
|
_CaptureRegWrite(i, 0);
|
||||||
for (int i = 0; i <= 0xff; i++) {
|
}
|
||||||
_CaptureRegWrite(i, 0);
|
//_CaptureRegWrite(0x1, 0x20);
|
||||||
}
|
/*
|
||||||
//_CaptureRegWrite(0x1, 0x20);
|
for (int ch = 1; ch <= CHANNELS; ch++) {
|
||||||
/*
|
int offset1 = this->_GetOffset(ch, 1);
|
||||||
for (int ch = 1; ch <= CHANNELS; ch++) {
|
int offset2 = this->_GetOffset(ch, 2);
|
||||||
int offset1 = this->_GetOffset(ch, 1);
|
int offset0 = this->_GetOffset(ch);
|
||||||
int offset2 = this->_GetOffset(ch, 2);
|
_CaptureRegWrite(0x20 + offset1, regCache[0x20 + offset1]);
|
||||||
int offset0 = this->_GetOffset(ch);
|
_CaptureRegWrite(0x20 + offset2, regCache[0x20 + offset2]);
|
||||||
_CaptureRegWrite(0x20 + offset1, regCache[0x20 + offset1]);
|
_CaptureRegWrite(0x40 + offset1, regCache[0x40 + offset1]);
|
||||||
_CaptureRegWrite(0x20 + offset2, regCache[0x20 + offset2]);
|
_CaptureRegWrite(0x40 + offset2, regCache[0x40 + offset2]);
|
||||||
_CaptureRegWrite(0x40 + offset1, regCache[0x40 + offset1]);
|
_CaptureRegWrite(0x60 + offset1, regCache[0x60 + offset1]);
|
||||||
_CaptureRegWrite(0x40 + offset2, regCache[0x40 + offset2]);
|
_CaptureRegWrite(0x60 + offset2, regCache[0x60 + offset2]);
|
||||||
_CaptureRegWrite(0x60 + offset1, regCache[0x60 + offset1]);
|
_CaptureRegWrite(0x80 + offset1, regCache[0x80 + offset1]);
|
||||||
_CaptureRegWrite(0x60 + offset2, regCache[0x60 + offset2]);
|
_CaptureRegWrite(0x80 + offset2, regCache[0x80 + offset2]);
|
||||||
_CaptureRegWrite(0x80 + offset1, regCache[0x80 + offset1]);
|
_CaptureRegWrite(0xe0 + offset1, regCache[0xe0 + offset1]);
|
||||||
_CaptureRegWrite(0x80 + offset2, regCache[0x80 + offset2]);
|
_CaptureRegWrite(0xe0 + offset2, regCache[0xe0 + offset2]);
|
||||||
_CaptureRegWrite(0xe0 + offset1, regCache[0xe0 + offset1]);
|
_CaptureRegWrite(0xc0 + offset0, regCache[0xc0 + offset0]);
|
||||||
_CaptureRegWrite(0xe0 + offset2, regCache[0xe0 + offset2]);
|
}
|
||||||
_CaptureRegWrite(0xc0 + offset0, regCache[0xc0 + offset0]);
|
*/
|
||||||
}
|
_CaptureOpl3Enable();
|
||||||
*/
|
for (Bit8u i = 0x20; i <= 0x35; i++) {
|
||||||
_CaptureOpl3Enable();
|
_CaptureRegWrite(i, regCache[i]);
|
||||||
for (Bit8u i = 0x20; i <= 0x35; i++) {
|
}
|
||||||
_CaptureRegWrite(i, regCache[i]);
|
for (Bit8u i = 0x40; i <= 0x55; i++) {
|
||||||
}
|
_CaptureRegWrite(i, regCache[i]);
|
||||||
for (Bit8u i = 0x40; i <= 0x55; i++) {
|
}
|
||||||
_CaptureRegWrite(i, regCache[i]);
|
for (Bit8u i = 0x60; i <= 0x75; i++) {
|
||||||
}
|
_CaptureRegWrite(i, regCache[i]);
|
||||||
for (Bit8u i = 0x60; i <= 0x75; i++) {
|
}
|
||||||
_CaptureRegWrite(i, regCache[i]);
|
for (Bit8u i = 0x80; i <= 0x95; i++) {
|
||||||
}
|
_CaptureRegWrite(i, regCache[i]);
|
||||||
for (Bit8u i = 0x80; i <= 0x95; i++) {
|
}
|
||||||
_CaptureRegWrite(i, regCache[i]);
|
_CaptureRegWrite(0xbd, regCache[0xbd]);
|
||||||
}
|
for (Bit8u i = 0xc0; i <= 0xc8; i++) {
|
||||||
_CaptureRegWrite(0xbd, regCache[0xbd]);
|
_CaptureRegWrite(i, regCache[i] | 0x30); // enable L + R channels
|
||||||
for (Bit8u i = 0xc0; i <= 0xc8; i++) {
|
}
|
||||||
_CaptureRegWrite(i, regCache[i] | 0x30); // enable L + R channels
|
for (Bit8u i = 0xe0; i <= 0xf5; i++) {
|
||||||
}
|
_CaptureRegWrite(i, regCache[i]);
|
||||||
for (Bit8u i = 0xe0; i <= 0xf5; i++) {
|
|
||||||
_CaptureRegWrite(i, regCache[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,9 +307,18 @@ INLINE void host_writed(Bit8u *off, Bit32u val) {
|
||||||
off[3]=(Bit8u)(val >> 24);
|
off[3]=(Bit8u)(val >> 24);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void Hiopl::InitCaptureVariables() {
|
||||||
|
captureHandle = NULL;
|
||||||
|
captureLengthBytes = 0;
|
||||||
|
lastWrite = -1;
|
||||||
|
captureStart = -1;
|
||||||
|
}
|
||||||
|
|
||||||
void Hiopl::StopCapture() {
|
void Hiopl::StopCapture() {
|
||||||
if (NULL != captureHandle) {
|
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[0x0c], lengthMilliseconds);
|
||||||
host_writed(&dro_header[0x10], captureLengthBytes);
|
host_writed(&dro_header[0x10], captureLengthBytes);
|
||||||
//if (opl.raw.opl3 && opl.raw.dualopl2) host_writed(&dro_header[0x14],0x1);
|
//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);
|
fwrite(dro_header, 1, sizeof(dro_header), captureHandle);
|
||||||
fclose(captureHandle);
|
fclose(captureHandle);
|
||||||
}
|
}
|
||||||
captureHandle = NULL;
|
InitCaptureVariables();
|
||||||
captureLengthBytes = 0;
|
|
||||||
lastWrite = -1;
|
|
||||||
captureStart = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hiopl::_CaptureDelay(Bit16u delayMs) {
|
void Hiopl::_CaptureDelay(Bit16u delayMs) {
|
||||||
|
|
|
@ -58,6 +58,8 @@ class Hiopl {
|
||||||
void _WriteReg(Bit32u reg, Bit8u value, Bit8u mask=0x0);
|
void _WriteReg(Bit32u reg, Bit8u value, Bit8u mask=0x0);
|
||||||
void _ClearRegBits(Bit32u reg, Bit8u mask);
|
void _ClearRegBits(Bit32u reg, Bit8u mask);
|
||||||
|
|
||||||
|
void InitCaptureVariables();
|
||||||
|
bool IsAnInstanceRecording();
|
||||||
void StartCapture(const char* filepath);
|
void StartCapture(const char* filepath);
|
||||||
void StopCapture();
|
void StopCapture();
|
||||||
|
|
||||||
|
@ -79,6 +81,7 @@ class Hiopl {
|
||||||
std::map<int, int> _op1offset;
|
std::map<int, int> _op1offset;
|
||||||
std::map<int, int> _op2offset;
|
std::map<int, int> _op2offset;
|
||||||
|
|
||||||
|
static Hiopl* master;
|
||||||
FILE* captureHandle;
|
FILE* captureHandle;
|
||||||
Bit64s captureStart;
|
Bit64s captureStart;
|
||||||
Bit64s lastWrite;
|
Bit64s lastWrite;
|
||||||
|
|
Loading…
Reference in a new issue