28 using MenuItem::MenuItem;
31 audioOutputBeingEdited = (
AudioOutput*)getCurrentOutput();
32 numOutputs = currentSong->getNumOutputs();
35 outputIndex = getRecordableOutputIndex(selectedOutput);
36 if (outputIndex < 0) {
38 outputIndex = getNextRecordableOutputIndex(-1, 1);
39 selectedOutput = getOutputFromSelectedIndex();
40 audioOutputBeingEdited->setOutputRecordingFrom(selectedOutput);
43 if (outputIndex < 0) {
46 if (display->haveOLED()) {
55 int32_t newOutputIndex = getNextRecordableOutputIndex(outputIndex, offset);
56 if (newOutputIndex < 0) {
59 outputIndex = newOutputIndex;
60 auto newRecordingFrom = getOutputFromSelectedIndex();
61 audioOutputBeingEdited->setOutputRecordingFrom(newRecordingFrom);
62 if (display->haveOLED()) {
73 Output* output = getOutputFromSelectedIndex();
75 canvas.
drawStringCentred(
"No track", OLED_MAIN_TOPMOST_PIXEL + 21, kTextSpacingX, kTextSpacingY);
80 OutputType outputType = output->type;
84 if (outputType == OutputType::MIDI_OUT) {
89 char const* outputTypeText = getOutputTypeName(outputType, channel);
92 canvas.
drawStringCentred(outputTypeText, OLED_MAIN_TOPMOST_PIXEL + 14, kTextSpacingX, kTextSpacingY);
94 int32_t yPos = OLED_MAIN_TOPMOST_PIXEL + 28;
97 char const*
name = output->name.get();
101 if (stringLengthPixels <= OLED_MAIN_WIDTH_PIXELS) {
105 canvas.
drawString(
name, 0, yPos, kTextTitleSpacingX, kTextTitleSizeY);
106 deluge::hid::display::OLED::setupSideScroller(0,
name, 0, OLED_MAIN_WIDTH_PIXELS, yPos,
107 yPos + kTextTitleSizeY, kTextTitleSpacingX, kTextTitleSizeY,
113 Output* output = getOutputFromSelectedIndex();
114 char const* text = output ? output->name.get() :
"No track";
115 display->setScrollingText(text, 0);
119 audioOutputBeingEdited = (
AudioOutput*)getCurrentOutput();
120 return audioOutputBeingEdited->inputChannel == AudioInputChannel::SPECIFIC_OUTPUT;
127 int32_t outputIndex{0};
128 int32_t numOutputs{0};
131 bool canRecordFromOutput(
Output* output)
const {
return audioOutputBeingEdited->canRecordFrom(output); }
133 int32_t getRecordableOutputIndex(
Output* output)
const {
134 if (!canRecordFromOutput(output)) {
140 for (Output* candidate = currentSong->firstOutput; candidate; candidate = candidate->next) {
141 if (candidate == output) {
150 Output* getOutputFromSelectedIndex()
const {
151 Output* output = currentSong->getOutputFromIndex(outputIndex);
152 return canRecordFromOutput(output) ? output :
nullptr;
155 int32_t getNextRecordableOutputIndex(int32_t startIndex, int32_t offset)
const {
157 return getOutputFromSelectedIndex()
159 : getRecordableOutputIndex(audioOutputBeingEdited->getOutputRecordingFrom());
162 int32_t direction = offset > 0 ? 1 : -1;
163 int32_t steps = offset > 0 ? offset : -offset;
164 int32_t selectedIndex = startIndex;
166 for (int32_t step = 0; step < steps; step++) {
167 int32_t candidateIndex = selectedIndex;
170 candidateIndex += direction;
171 if (candidateIndex < 0 || candidateIndex >= numOutputs) {
172 return selectedIndex;
175 Output* candidate = currentSong->getOutputFromIndex(candidateIndex);
176 if (canRecordFromOutput(candidate)) {
177 selectedIndex = candidateIndex;
183 return selectedIndex;
void drawString(std::string_view str, int32_t pixelX, int32_t pixelY, int32_t textWidth, int32_t textHeight, int32_t scrollPos=0, int32_t endX=OLED_MAIN_WIDTH_PIXELS, bool useTextWidth=false)
Definition canvas.cpp:304
void drawStringCentred(char const *string, int32_t pixelY, int32_t textWidth, int32_t textHeight, int32_t centrePos=OLED_MAIN_WIDTH_PIXELS/2)
Definition canvas.cpp:383