ofxPDSP
GrainCloud.h
1 
2 // GrainCloud.h
3 // ofxPDSP
4 // Nicola Pisanti, MIT License, 2016
5 
6 #ifndef PDSP_MODULE_GRAINCLOUD_H_INCLUDED
7 #define PDSP_MODULE_GRAINCLOUD_H_INCLUDED
8 
9 #include "../../DSP/pdspCore.h"
10 #include "../../DSP/utility/OneMinusInput.h"
11 #include <string>
12 #include "TriggeredGrain.h"
13 
14 namespace pdsp{
15 
22 class GrainCloud : public Patchable {
23 
24 
25  class MultiGrainTrigger : public Unit {
26  public:
27 
28  MultiGrainTrigger(int outputs);
29 
30  std::vector<OutputNode> outs;
31 
32  private:
33  void prepareUnit( int expectedBufferSize, double sampleRate ) override;
34  void releaseResources () override {};
35  void process (int bufferSize) noexcept override;
36 
37  InputNode in_distance_ms;
38  InputNode in_jitter_ms;
39 
40  int counter;
41  float sampleRateMult;
42  int currentOut;
43  int outputs;
44  };
45 
46 
47 public:
48 
49  GrainCloud(int voices);
50  GrainCloud();
51  GrainCloud(const GrainCloud &other);
52  GrainCloud& operator=(const GrainCloud &other);
53 
57  float meter_env(int voice) const;
58 
62  float meter_position(int voice) const;
63 
67  float meter_jitter(int voice) const;
68 
73 
78 
83 
87  Patchable& in_select();
88 
93 
98 
103 
108 
113 
118  Patchable& ch( size_t index );
119 
123  int getVoicesNum() const;
124 
129  void addSample(SampleBuffer* newSample);
130 
136  void setSample(SampleBuffer* samplePointer, int index=0);
137 
143  void setWindowType(Window_t type, int window_length=1024 );
144 
148  [[deprecated("out_L() deprecated for this module, use the ch( 0 ) method instead")]]
149  Patchable& out_L();
150 
151  [[deprecated("out_R() deprecated for this module, use the ch( 1 ) method instead")]]
152  Patchable& out_R();
157 private:
158 
159  void patch();
160 
161  PatchNode ctrl_start;
162  PatchNode ctrl_grain_length;
163  PatchNode ctrl_pitch;
164  PatchNode ctrl_select;
165  PatchNode ctrl_direction;
166 
167  PatchNode ctrl_pitch_jit;
168  PatchNode ctrl_pos_jit_scale;
169  PatchNode ctrl_pos_jit;
170 
171  OneMinusInput ctrl_density;
172 
173  MultiGrainTrigger triggers;
174 
175  std::vector<TriggeredGrain> streams;
176 
177  Amp density_amp;
178 
179  Amp outL;
180  Amp outR;
181 
182  int voices;
183 
184 };
185 
186 } //END NAMESPACE
187 
188 
189 
190 
191 #endif // PDSP_MODULE_GRAINCLOUD_H_INCLUDED
Patchable & in_length()
Sets "length" as selected input and returns this module ready to be patched. Controls the grain lengt...
Definition: GrainCloud.cpp:154
Patchable & in_density()
Sets "density" as selected input and returns this module ready to be patched. Controls the density of...
Definition: GrainCloud.cpp:166
Patchable & in_pitch()
Sets "pitch" as selected input and returns this module ready to be patched. Controls the grain pitch ...
Definition: GrainCloud.cpp:158
float meter_env(int voice) const
returns the last processed envelope amplitude value of the selected grain. This method is thread-safe...
Definition: GrainCloud.cpp:138
void setSample(SampleBuffer *samplePointer, int index=0)
Sets the SampleBuffer pointer at the given index to a new pointer.
Definition: GrainCloud.cpp:197
Patchable & in_position()
Sets "position" as selected input and returns this module ready to be patched. This is the default in...
Definition: GrainCloud.cpp:150
Abstract class for implementing Units.
Definition: BasicNodes.h:223
float meter_position(int voice) const
returns a value from 0.0f to 1.0f that broadly rapresent the "playhead" of the selected grain...
Definition: GrainCloud.cpp:142
float meter_jitter(int voice) const
returns a value from -1.0f to 1.0f that rapresent the jitter of the selected grain. This method is thread-safe.
Definition: GrainCloud.cpp:146
output is 1.0f - input
Definition: OneMinusInput.h:18
Abstract class for implementing Units and Modules.
Definition: BasicNodes.h:82
Multiply in("signal") for in("mod").
Definition: Amp.h:23
Contains the data loaded from an audio file.
Definition: SampleBuffer.h:28
Input of a Unit, process all the connected Outputs and sum them. Has an internal variable state...
Definition: BasicNodes.h:536
void addSample(SampleBuffer *newSample)
adds a pointer to a SampleBuffer to an internal array of SampleBuffer pointers
Definition: GrainCloud.cpp:203
int getVoicesNum() const
returns the number of voices used for the graincloud.
Definition: GrainCloud.cpp:215
Patchable & ch(size_t index)
Uses the selected channel as output for the patching operation. 0 is for the left channel (default ou...
Definition: GrainCloud.cpp:186
Thread-safe value control with smoothing.
Definition: SequencerBridge.h:11
Patchable & in_direction()
Sets "direction" as selected input and returns this module ready to be patched. A positive value make...
Definition: GrainCloud.cpp:182
Patchable & in_distance_jitter()
Sets "distance_jitter" as selected input and returns this module ready to be patched. Controls a random value in millisecond that is added to the time between grain retriggerings.
Definition: GrainCloud.cpp:170
A Unit with no dsp inside, it just pass it&#39;s input to the output. Patching float to this Unit is thre...
Definition: PatchNode.h:41
void setWindowType(Window_t type, int window_length=1024)
sets the envelope window shape, optionally the resolution of the table.
Definition: GrainCloud.cpp:209
Patchable & in_select()
Sets "select" as selected input and returns this module ready to be patched. Select the sample to str...
Definition: GrainCloud.cpp:162
Stereo "cloud" of really short sampled segments.
Definition: GrainCloud.h:22
Patchable & in_pitch_jitter()
Sets "pitch_jitter" as selected input and returns this module ready to be patched. Grain pitch jitter in semitones.
Definition: GrainCloud.cpp:178
Patchable & in_position_jitter()
Sets "position_jitter" as selected input and returns this module ready to be patched. Grain position jitter control relative to the sample length. 0.0f = no jitter, 1.0f = position jitter as long as the entire sample lenght.
Definition: GrainCloud.cpp:174