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();
|
||||||
|
|
||||||
|
|
|
@ -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,9 +250,7 @@ static Bit8u dro_opl3_enable[]={
|
||||||
};
|
};
|
||||||
|
|
||||||
void Hiopl::StartCapture(const char* filepath) {
|
void Hiopl::StartCapture(const char* filepath) {
|
||||||
if (NULL != captureHandle) {
|
Hiopl::master = this;
|
||||||
StopCapture();
|
|
||||||
} else {
|
|
||||||
lastWrite = -1;
|
lastWrite = -1;
|
||||||
captureLengthBytes = 0;
|
captureLengthBytes = 0;
|
||||||
captureStart = Time::currentTimeMillis();
|
captureStart = Time::currentTimeMillis();
|
||||||
|
@ -294,7 +298,6 @@ void Hiopl::StartCapture(const char* filepath) {
|
||||||
for (Bit8u i = 0xe0; i <= 0xf5; i++) {
|
for (Bit8u i = 0xe0; i <= 0xf5; i++) {
|
||||||
_CaptureRegWrite(i, regCache[i]);
|
_CaptureRegWrite(i, regCache[i]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void host_writed(Bit8u *off, Bit32u val) {
|
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);
|
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