mirror of
https://github.com/erik-toth/audio-synth.git
synced 2025-12-06 12:00:02 +00:00
Software Update 4: Sequencer Block
Sequencer Klasse eingebaut Überprüfung noch ausständig
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#define MS_DEBOUNCE 20
|
||||
|
||||
#define N_MAX_DAC_CH 4
|
||||
#define N_MAX_SEQUENCE_STEPS 128
|
||||
|
||||
struct Key
|
||||
{
|
||||
@@ -25,6 +26,12 @@ struct Key
|
||||
int col;
|
||||
};
|
||||
|
||||
struct voltageDurationPair
|
||||
{
|
||||
uint16_t voltage;
|
||||
uint16_t duration;
|
||||
};
|
||||
|
||||
const Key NOT_A_KEY = {-1, -1};
|
||||
|
||||
bool isNotKey(Key k);
|
||||
@@ -83,4 +90,58 @@ class CV
|
||||
uint8_t _getKeyToVoltageIndex(Key k);
|
||||
};
|
||||
|
||||
class SequencerBlock
|
||||
{
|
||||
public:
|
||||
SequencerBlock(uint16_t maxDurationMS, uint16_t timeoutMS);
|
||||
|
||||
// Aufnahme-Funktionen
|
||||
void startRecord();
|
||||
void stopRecord();
|
||||
void addStep(uint16_t voltage);
|
||||
bool isRecording();
|
||||
|
||||
// Wiedergabe-Funktionen
|
||||
void startPlay();
|
||||
void stopPlay();
|
||||
void update(); // Muss regelmäßig aufgerufen werden
|
||||
bool isPlaying();
|
||||
|
||||
// Sequenz-Verwaltung
|
||||
void clear();
|
||||
void setLoop(bool loop);
|
||||
|
||||
// Status-Abfragen
|
||||
bool timeLimitReached();
|
||||
uint8_t getStepCount();
|
||||
uint16_t getCurrentVoltage();
|
||||
uint16_t getTotalDuration();
|
||||
|
||||
private:
|
||||
// Sequenz-Speicher
|
||||
voltageDurationPair _sequence[N_MAX_SEQUENCE_STEPS];
|
||||
uint8_t _stepCount;
|
||||
uint8_t _currentStep;
|
||||
|
||||
// Zeitverwaltung
|
||||
uint16_t _maxDurationMS;
|
||||
uint16_t _timeoutMS;
|
||||
unsigned long _recordStartTime;
|
||||
unsigned long _lastStepTime;
|
||||
unsigned long _playStartTime;
|
||||
unsigned long _stepStartTime;
|
||||
|
||||
// Status-Flags
|
||||
bool _isRecording;
|
||||
bool _isPlaying;
|
||||
bool _loop;
|
||||
|
||||
// Letzte aufgenommene Spannung
|
||||
uint16_t _lastVoltage;
|
||||
|
||||
// Hilfsfunktionen
|
||||
void _finishCurrentStep();
|
||||
bool _canAddStep();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user