Browse Source

Add Vec::flip()

pull/1639/head
Andrew Belt 7 years ago
parent
commit
b46241f886
3 changed files with 8 additions and 5 deletions
  1. +0
    -2
      include/dsp/frame.hpp
  2. +2
    -1
      include/engine.hpp
  3. +6
    -2
      include/util/math.hpp

+ 0
- 2
include/dsp/frame.hpp View File

@@ -9,8 +9,6 @@ namespace rack {
template <size_t CHANNELS> template <size_t CHANNELS>
struct Frame { struct Frame {
float samples[CHANNELS]; float samples[CHANNELS];

Frame() {}
}; };


} // namespace rack } // namespace rack

+ 2
- 1
include/engine.hpp View File

@@ -67,7 +67,8 @@ struct Module {
/** Advances the module by 1 audio frame with duration 1.0 / gSampleRate */ /** Advances the module by 1 audio frame with duration 1.0 / gSampleRate */
virtual void step() {} virtual void step() {}


/** Called when the engine sample rate is changed */
/** Called when the engine sample rate is changed
*/
virtual void onSampleRateChange() {} virtual void onSampleRateChange() {}
/** Called when module is created by the Add Module popup, cloning, or when loading a patch or autosave */ /** Called when module is created by the Add Module popup, cloning, or when loading a patch or autosave */
virtual void onCreate() {} virtual void onCreate() {}


+ 6
- 2
include/util/math.hpp View File

@@ -143,9 +143,10 @@ inline void cmult(float *cr, float *ci, float ar, float ai, float br, float bi)
struct Rect; struct Rect;


struct Vec { struct Vec {
float x, y;
float x = 0.f;
float y = 0.f;


Vec() : x(0.0f), y(0.0f) {}
Vec() {}
Vec(float x, float y) : x(x), y(y) {} Vec(float x, float y) : x(x), y(y) {}


Vec neg() { Vec neg() {
@@ -175,6 +176,9 @@ struct Vec {
float norm() { float norm() {
return hypotf(x, y); return hypotf(x, y);
} }
Vec flip() {
return Vec(y, x);
}
Vec min(Vec b) { Vec min(Vec b) {
return Vec(rack::min(x, b.x), rack::min(y, b.y)); return Vec(rack::min(x, b.x), rack::min(y, b.y));
} }


Loading…
Cancel
Save