ofxPDSP
MidiKeys.h
1 
2 // ofxPDSPMidiKeys.h
3 // ofxPDSP
4 // Nicola Pisanti, MIT License, 2016
5 
6 #ifndef OFXPDSPMIDI_PDSPMIDIKEYS_H_INCLUDED
7 #define OFXPDSPMIDI_PDSPMIDIKEYS_H_INCLUDED
8 
9 #ifndef __ANDROID__
10 
11 #include "ofxMidi.h"
12 #include "../DSP/pdspCore.h"
13 #include "../DSP/control/SequencerGateOutput.h"
14 #include "../DSP/control/SequencerValueOutput.h"
15 #include "helper/PositionedMidiMessage.h"
16 #include "helper/MidiKeysBuffers.h"
17 #include "helper/Controller.h"
18 #include "MidiIn.h"
19 
24 namespace pdsp { namespace midi {
25 
26 class Keys : public pdsp::Controller {
27 
28 public:
29  Keys();
30 
38  void setPolyMode(int maxNotes, int unisonVoices = 1);
39 
46  void setMonoMode(int unisonVoices, bool legato, MonoPriority priority = Last);
47 
53  void setPitchBend( float down, float up);
54 
62  void setPortamento(PortamentoMode portamentoMode, float timeMs, pdsp::SlewMode_t slewMode = pdsp::Time, float scaling=12.0f);
63 
69  void setNoteRange(int lowNote, int highNote);
70 
75  void setUnisonDetune(float pitchDetune);
76 
81  void setSlew(float slewTimeMs);
82 
87  void setMidiChannel( int channel );
88 
92  int getVoicesNumber() const;
93 
99  void setTuning( int i, float value );
100 
106  void setTuningByPitch( int i, float value );
107 
112  float getTuning( int i ) const;
113 
114 
119  pdsp::PatchNode & out_trig( int voice );
120 
125  pdsp::PatchNode & out_pitch( int voice );
126 
131 
136 
141 
142 
149  std::vector<pdsp::PatchNode> outs_trig;
150 
154  std::vector<pdsp::PatchNode> outs_pitch;
155 
159  pdsp::SequencerGateOutput out_singletrigger;
160 
164  pdsp::SequencerValueOutput out_pitchbend;
165 
169  pdsp::SequencerValueOutput out_pressure;
170 
171  void processMidi(const pdsp::midi::Input &midiInProcessor, const int &bufferSize ) noexcept override;
176 private:
177 
178  pdsp::ValueNode unisonDetuneAmt;
179 
180  int maxNotes;
181  int maxVoices;
182 
183  PortamentoMode portamentoMode;
184  float portamentoTime;
185  pdsp::SlewMode_t slewMode;
186  float slewTime;
187 
188  helper::MidiKeysBuffers midiConverter;
189 
190  std::vector<pdsp::SequencerGateOutput> gates;
191  std::vector<pdsp::SequencerValueOutput> values;
192  std::vector<pdsp::Amp> unisonPitchDetune;
193  std::vector<pdsp::ValueNode> voiceUnisonMod;
194 
195 
196 };
197 
198 }} // end namespaces
199 
200 #endif
201 
202 #endif //OFXPDSPMIDI_PDSPMIDIKEYS_H_INCLUDED
Definition: MidiIn.h:22
Definition: MidiKeys.h:26
void setMonoMode(int unisonVoices, bool legato, MonoPriority priority=Last)
set the mode to Mono, with the given unison voices value and priority
Definition: MidiKeys.cpp:152
pdsp::PatchNode & out_trig(int voice)
returns the trigger output of the given voice
Definition: MidiKeys.cpp:238
int getVoicesNumber() const
returns the actual voice number
Definition: MidiKeys.cpp:67
void setUnisonDetune(float pitchDetune)
sets the detune amout for the unison
Definition: MidiKeys.cpp:37
void setSlew(float slewTimeMs)
sets the slew time of the value outputs
Definition: MidiKeys.cpp:46
void setPitchBend(float down, float up)
sets the pitch bend amount for up and down bending
Definition: MidiKeys.cpp:57
float getTuning(int i) const
gets the tuning in hertz for the given note
Definition: MidiKeys.cpp:275
Takes messages from a MessageBuffer and convert them in an optionally smoothed value output...
Definition: SequencerValueOutput.h:23
pdsp::PatchNode & out_pitch(int voice)
returns the pitch output of the given voice
Definition: MidiKeys.cpp:242
Takes messages from a MessageBuffer and convert them in a trigger output.
Definition: SequencerGateOutput.h:20
Definition: MidiKeysBuffers.h:40
void setPolyMode(int maxNotes, int unisonVoices=1)
set the mode to Poly, with the given max notes and the given unison voices
Definition: MidiKeys.cpp:76
void setTuningByPitch(int i, float value)
sets the tuning in semitones for the given note
Definition: MidiKeys.cpp:266
Definition: Controller.h:11
pdsp::SequencerGateOutput & out_single_trigger()
single trigger output for the Poly mode
Definition: MidiKeys.cpp:246
Thread-safe value control with smoothing.
Definition: SequencerBridge.h:11
void setPortamento(PortamentoMode portamentoMode, float timeMs, pdsp::SlewMode_t slewMode=pdsp::Time, float scaling=12.0f)
sets the portamento parameters
Definition: MidiKeys.cpp:226
void setTuning(int i, float value)
sets the tuning in hertz for the given note
Definition: MidiKeys.cpp:258
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
pdsp::SequencerValueOutput & out_aftertouch()
channel pressure output
Definition: MidiKeys.cpp:254
void setNoteRange(int lowNote, int highNote)
set the note rang for the message parsing, messages out of this range will be ignored ...
Definition: MidiKeys.cpp:71
void setMidiChannel(int channel)
sets the midi channel, default is 0 = all channels
Definition: MidiKeys.cpp:33
pdsp::SequencerValueOutput & out_pitch_bend()
pitchbend output. The pitchbend is also summed to the pitch outputs, so this is just for modulations ...
Definition: MidiKeys.cpp:250
An OutputNode that is always set at control rate with a set value. Setting or patching float to this ...
Definition: BasicNodes.h:490