Skip to content

Commit

Permalink
Embryo for master page
Browse files Browse the repository at this point in the history
  • Loading branch information
zorzella committed Nov 29, 2019
1 parent c6d009f commit 60b1be0
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 23 deletions.
18 changes: 0 additions & 18 deletions src/ZrFuncTypeDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,6 @@ class ZrFuncTypeDescription {
}
}

static const ZrFuncType typeForPosition(int h, int v) {
if (h >= 0 && h <= 17) {
switch (v) {
case 0:
return GAIN;
case 1:
return EQ;
case 2:
return FADER;
}
}
return TYPE_UNKNOWN;
}

static const ZrFuncTypeDescription posToFuncTypeDescription(int h, int v) {
return fromType(typeForPosition(h, v));
}

private:
ZrFuncType m_type;
std::string m_humanName;
Expand Down
2 changes: 1 addition & 1 deletion src/ZrFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class ZrFunction {
void triggerCacheUpdateIfNeeded();

private:
friend class ZrNavigation;
friend class ZrChannelsPagePopulator;
friend class ZrMasterPagePopulator;

int m_hPos;
int m_vPos;
Expand Down
8 changes: 6 additions & 2 deletions src/ZrNavigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
#include "ZrNavigation.h"
#include "ZrPage.h"
#include "page/ZrChannelsPagePopulator.h"
#include "page/ZrMasterPagePopulator.h"

static const int PAGE_COUNT = 2;

ZrPage m_currentPage{ZrChannelsPagePopulator::V_COUNT,
ZrChannelsPagePopulator::H_COUNT};

ZrPage m_masterPage{ZrMasterPagePopulator::V_COUNT,
ZrMasterPagePopulator::H_COUNT};

// TODO: capacity!
std::map<std::string, ZrFunction*> m_oscAddrToFunctionMap;

Expand Down Expand Up @@ -46,8 +50,8 @@ void ZrNavigation::buildFunctions() {

for (int i = 0; i < m_currentPage.indexCount(); i++) {
ZrFunction& toPopulate = m_currentPage.m_functions[i];
if (toPopulate.m_oscAddr != UNKNOWN_OSC_ADDR) {
m_oscAddrToFunctionMap.insert({toPopulate.m_oscAddr, &toPopulate});
if (toPopulate.oscAddr() != UNKNOWN_OSC_ADDR) {
m_oscAddrToFunctionMap.insert({toPopulate.oscAddr(), &toPopulate});
}
}
}
Expand Down
24 changes: 22 additions & 2 deletions src/page/ZrChannelsPagePopulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ZrChannelsPagePopulator {
sprintf(temp, "CH%02d", channelNumber);
toPopulate.m_humanChannelName = temp;
toPopulate.m_typeDesc =
ZrFuncTypeDescription::posToFuncTypeDescription(h, v);
posToFuncTypeDescription(h, v);
switch (toPopulate.m_typeDesc.type()) {
case GAIN:
sprintf(temp, "/headamp/%02d/gain", channelNumber);
Expand All @@ -44,5 +44,25 @@ class ZrChannelsPagePopulator {
}

private:
static const int index(ZrPage& currentPage, int h, int v) { return h + v * currentPage.m_hCount; }
static const int index(ZrPage& currentPage, int h, int v) {
return h + v * currentPage.m_hCount;
}

static const ZrFuncType typeForPosition(int h, int v) {
if (h >= 0 && h <= 17) {
switch (v) {
case 0:
return GAIN;
case 1:
return EQ;
case 2:
return FADER;
}
}
return TYPE_UNKNOWN;
}

static const ZrFuncTypeDescription posToFuncTypeDescription(int h, int v) {
return ZrFuncTypeDescription::fromType(typeForPosition(h, v));
}
};
59 changes: 59 additions & 0 deletions src/page/ZrMasterPagePopulator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#pragma once

#include "ZrPage.h"

class ZrMasterPagePopulator {
public:
static const int H_COUNT = 1;
static const int V_COUNT = 2;

static void populate(ZrPage& currentPage) {
char temp[50];

for (int h = 0; h < currentPage.m_hCount; h++) {
for (int v = 0; v < currentPage.m_vCount; v++) {
int channelNumber = h + 1;
int ind = index(currentPage, h, v);
ZrFunction& toPopulate = currentPage.m_functions[ind];
toPopulate.m_hPos = h;
toPopulate.m_vPos = v;
sprintf(temp, "CH%02d", channelNumber);
toPopulate.m_humanChannelName = temp;
toPopulate.m_typeDesc = posToFuncTypeDescription(h, v);
switch (toPopulate.m_typeDesc.type()) {
case EQ:
sprintf(temp, "/ch/%02d/eq/on", channelNumber);
toPopulate.m_oscAddr = temp;
break;
case FADER:
sprintf(temp, "/ch/%02d/mix/fader", channelNumber);
toPopulate.m_oscAddr = temp;
break;
default:
break;
}
}
}
}

private:
static const int index(ZrPage& currentPage, int h, int v) {
return h + v * currentPage.m_hCount;
}

static const ZrFuncType typeForPosition(int h, int v) {
if (h >= 0 && h <= 17) {
switch (v) {
case 0:
return EQ;
case 1:
return FADER;
}
}
return TYPE_UNKNOWN;
}

static const ZrFuncTypeDescription posToFuncTypeDescription(int h, int v) {
return ZrFuncTypeDescription::fromType(typeForPosition(h, v));
}
};

0 comments on commit 60b1be0

Please sign in to comment.