Convert the editor to use BitArray
This commit is contained in:
parent
e45dfbc50b
commit
9de0648075
2 changed files with 10 additions and 10 deletions
|
|
@ -69,7 +69,7 @@ else()
|
||||||
target_include_directories(sfizz_editor PRIVATE ${sfizz-gio_INCLUDE_DIRS})
|
target_include_directories(sfizz_editor PRIVATE ${sfizz-gio_INCLUDE_DIRS})
|
||||||
target_link_libraries(sfizz_editor PRIVATE ${sfizz-gio_LIBRARIES})
|
target_link_libraries(sfizz_editor PRIVATE ${sfizz-gio_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(sfizz_editor PRIVATE sfizz::filesystem)
|
target_link_libraries(sfizz_editor PRIVATE sfizz::bit_array sfizz::filesystem)
|
||||||
|
|
||||||
# layout tool
|
# layout tool
|
||||||
if(NOT CMAKE_CROSSCOMPILING)
|
if(NOT CMAKE_CROSSCOMPILING)
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "GUIComponents.h"
|
#include "GUIComponents.h"
|
||||||
#include "GUIPiano.h"
|
#include "GUIPiano.h"
|
||||||
#include "NativeHelpers.h"
|
#include "NativeHelpers.h"
|
||||||
|
#include "BitArray.h"
|
||||||
#include "plugin/MessageUtils.h"
|
#include "plugin/MessageUtils.h"
|
||||||
#include <absl/strings/string_view.h>
|
#include <absl/strings/string_view.h>
|
||||||
#include <absl/strings/match.h>
|
#include <absl/strings/match.h>
|
||||||
|
|
@ -396,11 +397,10 @@ void Editor::Impl::uiReceiveMessage(const char* path, const char* sig, const sfi
|
||||||
// TODO(jpc) key ranges
|
// TODO(jpc) key ranges
|
||||||
}
|
}
|
||||||
else if (Messages::matchOSC("/cc/slots", path, indices) && !strcmp(sig, "b")) {
|
else if (Messages::matchOSC("/cc/slots", path, indices) && !strcmp(sig, "b")) {
|
||||||
const uint8_t* bitChunks = args[0].b->data;
|
size_t numBits = 8 * args[0].b->size;
|
||||||
uint32_t byteSize = args[0].b->size;
|
ConstBitSpan bits { args[0].b->data, numBits };
|
||||||
|
for (unsigned cc = 0; cc < numBits; ++cc) {
|
||||||
for (unsigned cc = 0; cc < 8 * byteSize; ++cc) {
|
bool used = bits.test(cc);
|
||||||
bool used = bitChunks[cc / 8] & (1u << (cc % 8));
|
|
||||||
updateCCUsed(cc, used);
|
updateCCUsed(cc, used);
|
||||||
if (used) {
|
if (used) {
|
||||||
char pathBuf[256];
|
char pathBuf[256];
|
||||||
|
|
@ -414,10 +414,10 @@ void Editor::Impl::uiReceiveMessage(const char* path, const char* sig, const sfi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Messages::matchOSC("/cc/changed", path, indices) && !strcmp(sig, "b")) {
|
else if (Messages::matchOSC("/cc/changed", path, indices) && !strcmp(sig, "b")) {
|
||||||
const uint8_t* bitChunks = args[0].b->data;
|
size_t numBits = 8 * args[0].b->size;
|
||||||
uint32_t byteSize = args[0].b->size;
|
ConstBitSpan bits { args[0].b->data, numBits };
|
||||||
for (unsigned cc = 0; cc < 8 * byteSize; ++cc) {
|
for (unsigned cc = 0; cc < numBits; ++cc) {
|
||||||
bool changed = bitChunks[cc / 8] & (1u << (cc % 8));
|
bool changed = bits.test(cc);
|
||||||
if (changed) {
|
if (changed) {
|
||||||
char pathBuf[256];
|
char pathBuf[256];
|
||||||
sprintf(pathBuf, "/cc%u/value", cc);
|
sprintf(pathBuf, "/cc%u/value", cc);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue