Skip to content

Commit

Permalink
Fix #378 operator clipboard data is now os text based
Browse files Browse the repository at this point in the history
  • Loading branch information
asb2m10 committed Sep 29, 2024
1 parent ffada60 commit bb5e23e
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 20 deletions.
2 changes: 0 additions & 2 deletions Documentation/Keybindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
| CTRL+G | Focus on global group |
| CTRL+L | Open cartridge manager |
| CTRL+P | Open parameter dialog |
| CTRL+C | Copy current context on clipboard as hexa |
| CTRL+V | Paste context from clipboard content |
| SHIFT+UP or SHIFT+DOWN | On sliders, it steps 10 % |
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Changelog
* UI Refresh
* Accessibility implementation (including keyboard shortcuts)
* Mono/Poly parameter is now a plugin parameter
* Copy/paste operator values are now text based (and system wide)
* Fix Apple Logic startup issue

#### Version 0.9.7
Expand Down
6 changes: 4 additions & 2 deletions Source/OperatorEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,11 @@ void OperatorEditor::mouseDown(const MouseEvent &event) {
if ( event.mods.isPopupMenu()) {
PopupMenu popup;

bool hasClipboard = DexedClipboard().isOperatorData();

popup.addItem(1, "Copy Operator Values");
popup.addItem(2, "Paste Envelope Values", processor->hasClipboardContent());
popup.addItem(3, "Paste Operator Values", processor->hasClipboardContent());
popup.addItem(2, "Paste Envelope Values", hasClipboard);
popup.addItem(3, "Paste Operator Values", hasClipboard);
popup.addSeparator();
popup.addItem(4, "Send current program to DX7");

Expand Down
21 changes: 12 additions & 9 deletions Source/PluginData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,25 @@ void DexedAudioProcessor::resetToInitVoice() {
}

void DexedAudioProcessor::copyToClipboard(int srcOp) {
memcpy(clipboard, data, 161);
clipboardContent = srcOp;
DexedClipboard clipboard(data + (srcOp *21), 21);
clipboard.write(String("Program: '") + getProgramName(getCurrentProgram()) + "' operator: " + String(6-srcOp));
}

void DexedAudioProcessor::pasteOpFromClipboard(int destOp) {
memcpy(data+(destOp*21), clipboard+(clipboardContent*21), 21);
DexedClipboard clipboard;

jassert(clipboard.isOperatorData());

memcpy(data+(destOp*21), clipboard.getRawData(), 21);
triggerAsyncUpdate();
}

void DexedAudioProcessor::pasteEnvFromClipboard(int destOp) {
memcpy(data+(destOp*21), clipboard+(clipboardContent*21), 8);
DexedClipboard clipboard;

jassert(clipboard.isOperatorData());

memcpy(data+(destOp*21), clipboard.getRawData(), 8);
triggerAsyncUpdate();
}

Expand Down Expand Up @@ -301,11 +309,6 @@ void DexedAudioProcessor::sendSysexCartridge(File cart) {
sysexComm.send(MidiMessage(syx_data, sz));
}


bool DexedAudioProcessor::hasClipboardContent() {
return clipboardContent != -1;
}

//==============================================================================
void DexedAudioProcessor::getStateInformation(MemoryBlock& destData) {
// You should use this method to store your parameters in the memory block.
Expand Down
58 changes: 58 additions & 0 deletions Source/PluginData.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,62 @@ class Cartridge {
void packProgram(uint8_t *src, int idx, String name, char *opSwitch);
};

class DexedClipboard {
// In the future complete sysex will be supported
uint8_t content[SYSEX_SIZE];
int size = 0;
public:
DexedClipboard() {
String text = SystemClipboard::getTextFromClipboard();
// For now we only support operator clipboard
if ( text.length() < (21*2) ) {
TRACE("Clipboard is empty or too small");
return;
}

CharPointer_UTF8 t = text.getCharPointer();
for(int i=0;i<21;i++) {
int high = CharacterFunctions::getHexDigitValue(t.getAndAdvance());
if ( high == -1 ) {
TRACE("Malformed clipboard data");
return;
}

int low = CharacterFunctions::getHexDigitValue(t.getAndAdvance());
if ( low == -1 ) {
TRACE("Malformed clipboard data");
return;
}

content[i] = (high << 4) + low;
}
size = 21;
}

DexedClipboard(const uint8_t *data, int s) {
size = s;
memcpy(content, data, size);
}

bool isOperatorData() {
if ( size == 21 )
return true;
else
return false;
}

uint8_t *getRawData() {
return content;
}

void write(String description) {
String clipboardValue = String::toHexString(content, size, 0);
if ( description.isNotEmpty() ) {
clipboardValue.append("\n; ", 3);
clipboardValue.append(description, 1024);
}
SystemClipboard::copyTextToClipboard(clipboardValue);
}
};

#endif // PLUGINDATA_H_INCLUDED
2 changes: 0 additions & 2 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ DexedAudioProcessor::DexedAudioProcessor()
setCurrentProgram(0);
nextMidi = NULL;
midiMsg = NULL;

clipboardContent = -1;

mtsClient = NULL;
mtsClient = MTS_RegisterClient();
Expand Down
6 changes: 1 addition & 5 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ class DexedAudioProcessor : public AudioProcessor, public AsyncUpdater, public
FmCore engineMsfa;
EngineMkI engineMkI;
EngineOpl engineOpl;

char clipboard[161];
signed char clipboardContent;


void resolvAppDir();

void unpackOpSwitch(char packOpValue);
Expand Down Expand Up @@ -204,7 +201,6 @@ public :
void sendCurrentSysexProgram();
void sendCurrentSysexCartridge();
void sendSysexCartridge(File cart);
bool hasClipboardContent();

//==============================================================================
AudioProcessorEditor* createEditor();
Expand Down

0 comments on commit bb5e23e

Please sign in to comment.