MCPcopy Create free account
hub / github.com/VCVRack/Rack / process

Method process

src/core/MIDICC_CV.cpp:73–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71 }
72
73 void process(const ProcessArgs& args) override {
74 midi::Message msg;
75 while (midiInput.tryPop(&msg, args.frame)) {
76 processMessage(msg);
77 }
78
79 int channels = mpeMode ? 16 : 1;
80
81 for (int id = 0; id < 16; id++) {
82 if (!outputs[CC_OUTPUT + id].isConnected())
83 continue;
84 outputs[CC_OUTPUT + id].setChannels(channels);
85
86 int8_t cc = learnedCcs[id];
87 if (cc < 0) {
88 outputs[CC_OUTPUT + id].clearVoltages();
89 continue;
90 }
91
92 for (int c = 0; c < channels; c++) {
93 int16_t cellValue = int16_t(ccValues[cc][c]) * 128;
94 if (lsbMode && cc < 32)
95 cellValue += ccValues[cc + 32][c];
96 // Maximum value for 14-bit CC should be MSB=127 LSB=0, not MSB=127 LSB=127, because this is the maximum value that 7-bit controllers can send.
97 float value = float(cellValue) / (128 * 127);
98 // Support negative values because the gamepad MIDI driver generates nonstandard 8-bit CC values.
99 value = clamp(value, -1.f, 1.f);
100
101 // Detect behavior from MIDI buttons.
102 if (smooth && std::fabs(valueFilters[id][c].out - value) < 1.f) {
103 // Smooth value with filter
104 valueFilters[id][c].process(args.sampleTime, value);
105 }
106 else {
107 // Jump value
108 valueFilters[id][c].out = value;
109 }
110 outputs[CC_OUTPUT + id].setVoltage(valueFilters[id][c].out * 10.f, c);
111 }
112 }
113 }
114
115 void processMessage(const midi::Message& msg) {
116 switch (msg.getStatus()) {

Callers

nothing calls this directly

Calls 7

fabsFunction · 0.85
tryPopMethod · 0.80
isConnectedMethod · 0.80
clearVoltagesMethod · 0.80
setVoltageMethod · 0.80
clampFunction · 0.50
setChannelsMethod · 0.45

Tested by

no test coverage detected