Comments (10)
Hi, please open one discussion per issue.
The CCIncrementDecrementButtons
class is intended for use with relative controls. A value of 1
should be interpreted as +1
and a value of 127
as -1
. See relativeCCmode for details.
If you want the buttons to send absolute values, you'll need to keep track of the absolute value somehow. I'd recommend having a look at the Custom-MIDI-Output-Element.ino example. You can use the implementation of MIDIIncrementDecrementButtons as inspiration.
from control-surface.
Good afternoon! Thanks for the advice! I'll try to figure it out using other examples...
from control-surface.
Hello! Could you add an example sketch of how to use buttons to send absolute values, as is done in the example with an absolute encoder? I can't do anything with the implementation of MIDIIncrementDecrementButtons...
from control-surface.
При компиляции пишет ошибку exit status 1
invalid use of template-name 'CS::MIDIIncrementDecrementButtons' without an argument list
from control-surface.
Александр010360, у вас синтаксическая ошибка в коде - вызов сущности (метода?) без обязательных аргументов. КурИте документацию. Возможно, вы считаете, что ошибка не в Вашем коде, а в коде библиотеки?
from control-surface.
You could do something like this:
#include <Control_Surface.h>
BEGIN_CS_NAMESPACE
class CCAbsoluteIncrDecrButtons : public MIDIOutputElement {
public:
CCAbsoluteIncrDecrButtons(const AH::IncrementDecrementButtons &buttons,
MIDIAddress address, uint8_t initial_value = 0,
uint8_t multiplier = 1)
: buttons(buttons), address(address), initial_value(initial_value),
multiplier(multiplier) {}
public:
// Initialize: enable the pull-up resistors for the buttons
// This method is called once by `Control_Surface.begin()`.
void begin() final override { buttons.begin(); }
// Update: read the buttons and send MIDI messages when appropriate.
// This method is called continuously by `Control_Surface.loop()`.
void update() final override {
using IncrDecrButtons = AH::IncrementDecrementButtons;
switch (buttons.update()) {
case IncrDecrButtons::Nothing: break;
case IncrDecrButtons::IncrementShort: // fallthrough
case IncrDecrButtons::IncrementLong: // fallthrough
case IncrDecrButtons::IncrementHold:
if (value <= 0x7F - multiplier) {
value += multiplier;
Control_Surface.sendControlChange(address, value);
}
break;
case IncrDecrButtons::DecrementShort: // fallthrough
case IncrDecrButtons::DecrementLong: // fallthrough
case IncrDecrButtons::DecrementHold:
if (value >= multiplier) {
value -= multiplier;
Control_Surface.sendControlChange(address, value);
}
break;
case IncrDecrButtons::Reset:
if (value != initial_value) {
value = initial_value;
Control_Surface.sendControlChange(address, value);
}
break;
default: break;
}
}
private:
AH::IncrementDecrementButtons buttons;
const MIDIAddress address;
const uint8_t initial_value;
const uint8_t multiplier;
uint8_t value = initial_value;
};
END_CS_NAMESPACE
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //
// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;
// Instantiate a CCAbsoluteIncrDecrButtons object
CCAbsoluteIncrDecrButtons buttons {
{2, 3}, // Push buttons on pins 2 and 3
MIDI_CC::Channel_Volume, // Controller
0x40, // Initial value
};
void setup() {
Control_Surface.begin(); // Initialize Control Surface (calls buttons.begin())
}
void loop() {
Control_Surface.loop(); // Update the Control Surface (calls buttons.update())
}
from control-surface.
Александр010360, у вас синтаксическая ошибка в коде - вызов сущности (метода?) без дополнительных аргументов. КурИте документацию. Возможно, вы считаете, что ошибка не в вашем коде, а в кодовой библиотеке?
Нет я не считаю что ошибка в библиотеке! Для моего случая нет готового кода из коробки! Для отправки абсолютных значений нужно самому написать соответствующий код. Или создать свой класс. Есть примеры и инструкции как расширить библиотеку. В чём я сейчас и разбираюсь. Но у меня недостаточно опыта для этого. Нужно время чтобы разобраться. Поэтому и попросил помощи у автора библиотеки Петера П.
from control-surface.
Александр010360, у вас синтаксическая ошибка в коде - вызов сущности (метода?) без дополнительных аргументов. КурИте документацию. Возможно, вы считаете, что ошибка не в вашем коде, а в кодовой библиотеке?
Нет я не считаю что ошибка в библиотеке! Для моего случая нет готового кода из коробки! Для отправки абсолютных значений нужно самому написать соответствующий код. Или создать свой класс. Есть примеры и инструкции как расширить библиотеку. В чём я сейчас и разбираюсь. Но у меня недостаточно опыта для этого. Нужно время чтобы разобраться. Поэтому и попросил помощи у автора библиотеки Петера П.
Александр, Ваша позиция ясна.
Насколько я понимаю, библиотека это не Фреймворк. Т. е. Вы пишете свой проект и можете взять уже написанный код из библиотеки, чтобы не изобретать велосипед. С фреймворком иначе - Вы берете Фреймворк, а затем в его окружении пишете свой код.
Это я к чему?
Следует ли @tttapa (busy) расширять код библиотеки под Ваши задачи - большой философский вопрос. Больше кода => больше багов => сложнее поддержка.
Этот раздел (issues) - для того, чтобы @username сферический в вакууме мог сообщить о баге в коде.
Т.е. "issues" != "support".
Исходя из выше изложенного, настоятельно рекомендую самому разобраться в синтаксисе wiring/C, документации к библиотеке или найти профессионального разработчика, который решит задачу.
Следует также сказать спасибо(вы уже) @tttapa за то, что не нужно глубоко погружаться в спецификации MIDI и т.п.
С наилучшими пожеланиями творческих успехов!
from control-surface.
Peter P. Thank you very much! Everything worked out! You are a genius! I just had to tweak something in the code. For some reason, in the latest release of the library, it does not see the full name of sendControlChange. I had to change it to the abbreviated sendCC. And I also added an additional channel in my code. And I don't need a multiplier. This switching speed is also acceptable.`
#include <Control_Surface.h>
BEGIN_CS_NAMESPACE
class CCAbsoluteIncrDecrButtons : public MIDIOutputElement {
public:
CCAbsoluteIncrDecrButtons(const AH::IncrementDecrementButtons &buttons,
MIDIAddress address, uint8_t initial_value = 0,
uint8_t multiplier = 1)
: buttons(buttons), address(address), initial_value(initial_value),
multiplier(multiplier) {}
public:
// Initialize: enable the pull-up resistors for the buttons
// This method is called once by Control_Surface.begin()
.
void begin() final override { buttons.begin(); }
// Update: read the buttons and send MIDI messages when appropriate.
// This method is called continuously by Control_Surface.loop()
.
void update() final override {
using IncrDecrButtons = AH::IncrementDecrementButtons;
switch (buttons.update()) {
case IncrDecrButtons::Nothing: break;
case IncrDecrButtons::IncrementShort: // fallthrough
case IncrDecrButtons::IncrementLong: // fallthrough
case IncrDecrButtons::IncrementHold:
if (value <= 0x7F - multiplier) {
value += multiplier;
Control_Surface. sendCC(address, value);
}
break;
case IncrDecrButtons::DecrementShort: // fallthrough
case IncrDecrButtons::DecrementLong: // fallthrough
case IncrDecrButtons::DecrementHold:
if (value >= multiplier) {
value -= multiplier;
Control_Surface. sendCC(address, value);
}
break;
case IncrDecrButtons::Reset:
if (value != initial_value) {
value = initial_value;
Control_Surface. sendCC(address, value);
}
break;
default: break;
}
}
private:
AH::IncrementDecrementButtons buttons;
const MIDIAddress address;
const uint8_t initial_value;
const uint8_t multiplier;
uint8_t value = initial_value;
};
END_CS_NAMESPACE
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //
// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;
// Instantiate a CCAbsoluteIncrDecrButtons object
CCAbsoluteIncrDecrButtons buttons {
{2, 3}, // Push buttons on pins 2 and 3
{MIDI_CC::Channel_Volume, CHANNEL_3}, // Controller
// Initial value
};
void setup() {
Control_Surface.begin(); // Initialize Control Surface (calls buttons.begin())
Serial.begin(57600);
}
void loop() {
Control_Surface.loop(); // Update the Control Surface (calls buttons.update())
}
from control-surface.
Александр010360, у вас синтаксическая ошибка в коде - вызов сущности (метода?) без дополнительных аргументов. КурИте документацию. Возможно, вы считаете, что ошибка не в вашем коде, а в кодовой библиотеке?
Нет, я не считаю эту ошибку в библиотеке! В моем случае нет готового кода из коробки! Для вручения абсолютных оценок необходимо написать соответствующий код. Или создай свой класс. Существуют модели и разработки, связанные с развитием технологии. В чём я сейчас и разбираюсь. Но у меня недостаточно опыта для этого. Нужно время для выяснения. Поэтому и попросил помощи у автора библиотеки Петера П.
Александр, Ваша позиция ясна. Насколько я понимаю, библиотека это не Фреймворк. Т. е. Вы пишете свой проект и можете взять уже написанный код из библиотеки, чтобы не изобретать велосипед. С помощью Фреймворка иначе — вы берете Фреймворк, а затем в его рамках записываете свой код. Это я к чему?
ли@tttapa(занят) расширение кода библиотеки под Ваши задачи - большой философский вопрос. Больше кода => больше багов => сложнее поддержка.
Этот раздел (вопросы) - для того, чтобы @username сферический в вакууме мог сообщить о баге в коде. Т.е. "проблемы" != "поддержка".
Исходя из вышеизложенного, настоятельно рекомендуется разобраться в синтаксисе проводки/C, документации к библиотеке или найти профессионального разработчика, который решит задачу.
Также следует сказать спасибо(вы уже)@tttapaза то, что не нужно глубоко погружаться в особенности MIDI и т.п.
Сформулируйте пожелания творческих успехов!
Благодарю вас за пожелание и совет! Обязательно займусь углублённым изучением языка C++ Пока только учусь программировать в среде ардуино.
from control-surface.
Related Issues (20)
- Bankable::ManyAddresses::CCAbsoluteEncoder HOT 2
- Time Display does not work.
- Does it's support ESP32-S3/C3 via USB port? HOT 7
- How to use 1 shift button to change bank:
- The sketch compiles, but doesn't work HOT 3
- Error when compiling for ESP32 S3 HOT 3
- Metronome Led HOT 3
- Trying to setVelocity for all notebutton values in mux with piezo device HOT 1
- External app/webpage to change CC and Channel values HOT 1
- Hi, I would like to see the USBMIDI_Interface adapted so that you can specify the fixed cablenumber. This would it make possible to use pipes and filters connecting serial ports with virtual usb ports
- Support for MCP23S17 SPI
- error: 'SelectorPC' does not name a type HOT 2
- Switching presets Roland FP-30X HOT 2
- TYPO IN DOCUMENTATION HOT 1
- Error running on M1 Mac Sonoma with Teensy 4.0 HOT 4
- Arduino Nano 33 BLE Support? HOT 3
- Select bank HOT 2
- MIDI-монитор-OLED HOT 3
- Arduino Giga R1 Wifi support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from control-surface.