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 auto* output = getCurrentOutput();
120 return output and output->type == OutputType::AUDIO
121 and ((
AudioOutput*)output)->inputChannel == AudioInputChannel::SPECIFIC_OUTPUT;
128 int32_t outputIndex{0};
129 int32_t numOutputs{0};
132 bool canRecordFromOutput(
Output* output)
const {
return audioOutputBeingEdited->canRecordFrom(output); }
134 int32_t getRecordableOutputIndex(
Output* output)
const {
135 if (!canRecordFromOutput(output)) {
141 for (Output* candidate = currentSong->firstOutput; candidate; candidate = candidate->next) {
142 if (candidate == output) {
151 Output* getOutputFromSelectedIndex()
const {
152 Output* output = currentSong->getOutputFromIndex(outputIndex);
153 return canRecordFromOutput(output) ? output :
nullptr;
156 int32_t getNextRecordableOutputIndex(int32_t startIndex, int32_t offset)
const {
158 return getOutputFromSelectedIndex()
160 : getRecordableOutputIndex(audioOutputBeingEdited->getOutputRecordingFrom());
163 int32_t direction = offset > 0 ? 1 : -1;
164 int32_t steps = offset > 0 ? offset : -offset;
165 int32_t selectedIndex = startIndex;
167 for (int32_t step = 0; step < steps; step++) {
168 int32_t candidateIndex = selectedIndex;
171 candidateIndex += direction;
172 if (candidateIndex < 0 || candidateIndex >= numOutputs) {
173 return selectedIndex;
176 Output* candidate = currentSong->getOutputFromIndex(candidateIndex);
177 if (canRecordFromOutput(candidate)) {
178 selectedIndex = candidateIndex;
184 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:307
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:404