ofxPDSP
SequencerProcessor.h
1 
2 // SequencerProcessor.h
3 // ofxPDSP
4 // Nicola Pisanti, MIT License, 2016 - 2018
5 
6 #ifndef PDSP_SCORE_H_INCLUDED
7 #define PDSP_SCORE_H_INCLUDED
8 
9 #include "../messages/header.h"
10 #include "../DSP/pdspCore.h"
11 #include "SequencerSection.h"
12 #include "Function.h"
13 #include <vector>
14 
15 
16 namespace pdsp{
23 public:
25 
30  void setTempo( double tempo );
31 
35  double getTempo() const;
36 
45  void process(int const &bufferSize) noexcept;
54  void pause();
55 
59  void stop();
60 
64  void play();
65 
69  bool isPlaying();
70 
76  void setMaxBars(double maxBars);
77  //void synchronizeInterface(bool active);
78 
79 
84  double getMaxBars() const;
85 
90  void setDefaultSteplen( double steplen );
91 
95  float meter_playhead();
96 
100  [[deprecated("this method is deprecated, directly use sections.resize(int size) instead ")]]
101  void setSections(int sectionsNumber);
102 
103  // DEPRECATE ALL THIS STUFF
104  std::vector<SequencerSection> sections;
105 
106  void init ( int sections, int sequences, float tempo );
107 
108  void launchMultipleCells(int index, bool quantizeLaunch=false, double quantizeGrid=1.0);
113 private:
114  void prepareToPlay( int expectedBufferSize, double sampleRate ) override;
115  void releaseResources() override ;
116 
121  void setPlayHead(float newPlayHead);
122 
123  double playHead;
124  double playHeadEnd;
125  std::atomic<float> newPlayHead;
126 
127  double tempo;
128  double barsPerSample;
129  double sampleRate;
130 
131  double maxBars;
132 
133  std::atomic<bool> playing;
134  //bool synchronizeClockable;
135 
136  std::mutex playheadMutex;
137 
138  std::atomic<float> playhead_meter;
139  int clearToken;
140 
141  std::atomic<double> tempoControl;
142 
143 };
144 
145 
146 
147 
148 
149 }
150 
151 
152 #endif //PDSP_SCORE_H_INCLUDED
void pause()
pause the playhead and stop emitting messages and updating the playhead. Thread-safe.
Definition: SequencerProcessor.cpp:113
bool isPlaying()
returns true if the SequencerProcessor is playing. Thread-safe.
Definition: SequencerProcessor.cpp:151
void stop()
reset the playhead to 0.0f and stop emitting messages and updating the playhead. Thread-safe.
Definition: SequencerProcessor.cpp:120
void setDefaultSteplen(double steplen)
sets the default step lenght for initializing sequences #param[in] steplen default step lenght ...
Definition: SequencerProcessor.cpp:174
Contains all the needed framework for generating and sequencing messages for the DSPs.
Definition: SequencerProcessor.h:22
void setMaxBars(double maxBars)
sets the maximum value the global playhead can take, in bars, after it wraps back ...
Definition: SequencerProcessor.cpp:32
void play()
starts emitting message and updating the playhead again. Thread-safe.
Definition: SequencerProcessor.cpp:138
void setTempo(double tempo)
sets the global tempo
Definition: SequencerProcessor.cpp:102
double getTempo() const
returns the global tempo
Definition: SequencerProcessor.cpp:178
Thread-safe value control with smoothing.
Definition: SequencerBridge.h:11
float meter_playhead()
returns the playhead position in bars. Thread-safe.
Definition: SequencerProcessor.cpp:143
double getMaxBars() const
gets the maximum value the global playhead can take, in bars, after it wraps back ...
Definition: SequencerProcessor.cpp:147
Definition: Preparable.h:36