Deluge Firmware 1.3.0
Build date: 2026.07.15
Loading...
Searching...
No Matches
stem_export.h
1/*
2 * Copyright (c) 2024 Sean Ditny
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include "gui/l10n/strings.h"
22#include "processing/sound/sound_drum.h"
23#include "util/d_string.h"
24#include <cstdint>
25
26class Output;
27class Clip;
28class SoundDrum;
29
30class StemExport {
31public:
32 StemExport();
33
34 // start & stop process
35 void startStemExportProcess(StemExportType stemExportType);
37 void abortStemExportProcess(deluge::l10n::String reason);
39 void stopPlayback();
41 bool checkForLoopEnd();
42 bool checkForSilence();
43 bool processStarted;
44 bool stopRecording;
45 StemExportType currentStemExportType;
46 uint32_t timePlaybackStopped;
47 uint32_t timeThereWasLastSomeActivity;
48
49 // export config variables
50 bool allowNormalization;
51 bool allowNormalizationForDrums;
52 bool exportToSilence;
53 bool includeSongFX;
54 bool includeKitFX;
55 bool renderOffline;
56 bool exportMixdown;
57
58 // export instruments
59 int32_t disarmAllInstrumentsForStemExport(StemExportType stemExportType);
60 int32_t exportInstrumentStems(StemExportType stemExportType);
61 int32_t exportMixdownStem(StemExportType stemExportType);
62 void restoreAllInstrumentMutes(int32_t totalNumOutputs);
63
64 // export clips
66 int32_t exportClipStems(StemExportType stemExportType);
67 void restoreAllClipMutes(int32_t totalNumClips);
69 void getLoopEndPointInSamplesForAudioFile(int32_t loopLength);
70 bool writeLoopEndPos();
71 int32_t loopLengthToStopStemExport;
72 int32_t loopEndPointInSamplesForAudioFile;
73
74 // export drums
76 int32_t exportDrumStems(StemExportType stemExportType);
77 void restoreAllDrumMutes(int32_t totalNumNoteRows);
78
79 // start exporting
80 bool startCurrentStemExport(StemExportType stemExportType, Output* output, bool& muteState, int32_t fileNumber,
81 bool exportStem, SoundDrum* drum = nullptr);
82
83 // finish exporting
84 void finishCurrentStemExport(StemExportType stemExportType, bool& muteState);
85 void finishStemExportProcess(StemExportType stemExportType, int32_t elementsProcessed);
86 void updateScrollPosition(StemExportType stemExportType, int32_t indexNumber);
87
88 // export status
89 void displayStemExportProgress(StemExportType stemExportType);
90 void displayStemExportProgressOLED(StemExportType stemExportType);
91 void displayStemExportProgress7SEG();
92 int32_t numStemsExported;
93 int32_t totalNumStemsToExport;
94
95 // audio file management
96 Error getUnusedStemRecordingFilePath(String* filePath, AudioRecordingFolder folder);
97 Error getUnusedStemRecordingFolderPath(String* filePath, AudioRecordingFolder folder);
98 int32_t highestUsedStemFolderNumber;
99 String lastFolderNameForStemExport;
102 [[nodiscard]] bool setWavFileNameForStemExport(StemExportType type, Output* output, int32_t fileNumber,
103 SoundDrum* drum = nullptr);
104 String wavFileNameForStemExport;
105 bool wavFileNameForStemExportSet;
106
107 // check if we're in context menu
108 bool inContextMenu();
109 bool renderingOffline() { return processStarted && renderOffline; }
110};
111
112extern StemExport stemExport;
Definition clip.h:46
Definition output.h:81
Definition sound_drum.h:28
Definition stem_export.h:30
int32_t exportClipStems(StemExportType stemExportType)
Definition stem_export.cpp:519
bool checkForLoopEnd()
Definition stem_export.cpp:219
bool setWavFileNameForStemExport(StemExportType type, Output *output, int32_t fileNumber, SoundDrum *drum=nullptr)
Definition stem_export.cpp:1091
void restoreAllInstrumentMutes(int32_t totalNumOutputs)
set instrument mutes back to their previous state (before exporting stems)
Definition stem_export.cpp:327
void getLoopEndPointInSamplesForAudioFile(int32_t loopLength)
converts clip / drum loop length into samples so that clip / drum end position can be written to clip...
Definition stem_export.cpp:502
Error getUnusedStemRecordingFolderPath(String *filePath, AudioRecordingFolder folder)
Definition stem_export.cpp:904
void stopPlayback()
simulate pressing play
Definition stem_export.cpp:194
int32_t exportMixdownStem(StemExportType stemExportType)
Definition stem_export.cpp:393
bool inContextMenu()
Definition stem_export.cpp:1189
void finishCurrentStemExport(StemExportType stemExportType, bool &muteState)
Definition stem_export.cpp:735
void stopOutputRecording()
simulate pressing record
Definition stem_export.cpp:201
bool writeLoopEndPos()
Definition stem_export.cpp:508
int32_t exportInstrumentStems(StemExportType stemExportType)
Definition stem_export.cpp:342
void updateScrollPosition(StemExportType stemExportType, int32_t indexNumber)
Definition stem_export.cpp:783
void startStemExportProcess(StemExportType stemExportType)
Definition stem_export.cpp:85
int32_t disarmAllDrumsForStemExport()
disarms and prepares all the drums so that they can be exported
Definition stem_export.cpp:572
void displayStemExportProgress(StemExportType stemExportType)
display how many stems we've exported so far
Definition stem_export.cpp:804
void stopStemExportProcess()
Stop stem export process.
Definition stem_export.cpp:152
int32_t disarmAllClipsForStemExport()
disarms and prepares all the clips so that they can be exported
Definition stem_export.cpp:429
void abortStemExportProcess(deluge::l10n::String reason)
Stop stem export process, telling the user why it couldn't continue.
Definition stem_export.cpp:157
void getLoopLengthOfLongestNotEmptyNoteRow(Clip *clip)
Definition stem_export.cpp:482
void restoreAllClipMutes(int32_t totalNumClips)
set clip mutes back to their previous state (before exporting stems)
Definition stem_export.cpp:468
void restoreAllDrumMutes(int32_t totalNumNoteRows)
set drum mutes back to their previous state (before exporting stems)
Definition stem_export.cpp:614
int32_t exportDrumStems(StemExportType stemExportType)
Definition stem_export.cpp:628
bool checkForSilence()
Definition stem_export.cpp:246
void startOutputRecordingUntilLoopEndAndSilence()
Simulate pressing record and play in order to trigger resampling of out output that ends when loop en...
Definition stem_export.cpp:166
int32_t disarmAllInstrumentsForStemExport(StemExportType stemExportType)
disarms and prepares all the instruments so that they can be exported
Definition stem_export.cpp:276
Definition d_string.h:41