mirror of
https://github.com/AxioDL/amuse.git
synced 2025-12-08 13:14:58 +00:00
Merge pull request #37 from lioncash/emitter
Emitter: Use std::array where applicable
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
@@ -39,7 +40,7 @@ public:
|
||||
void resetSampleRate(double sampleRate) override;
|
||||
|
||||
void resetChannelLevels() override;
|
||||
void setChannelLevels(IBackendSubmix* submix, const float coefs[8], bool slew) override;
|
||||
void setChannelLevels(IBackendSubmix* submix, const std::array<float, 8>& coefs, bool slew) override;
|
||||
void setPitchRatio(double ratio, bool slew) override;
|
||||
void start() override;
|
||||
void stop() override;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
|
||||
@@ -10,9 +11,9 @@
|
||||
namespace amuse {
|
||||
class Listener;
|
||||
|
||||
using Vector3f = float[3];
|
||||
using Vector3f = std::array<float, 3>;
|
||||
|
||||
inline float Dot(const Vector3f& a, const Vector3f& b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; }
|
||||
constexpr float Dot(const Vector3f& a, const Vector3f& b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; }
|
||||
|
||||
inline float Length(const Vector3f& a) {
|
||||
if (std::fabs(a[0]) <= FLT_EPSILON && std::fabs(a[1]) <= FLT_EPSILON && std::fabs(a[2]) <= FLT_EPSILON)
|
||||
@@ -20,14 +21,14 @@ inline float Length(const Vector3f& a) {
|
||||
return std::sqrt(Dot(a, a));
|
||||
}
|
||||
|
||||
inline float Normalize(Vector3f& out) {
|
||||
float dist = Length(out);
|
||||
if (dist == 0.f)
|
||||
return 0.f;
|
||||
out[0] /= dist;
|
||||
out[1] /= dist;
|
||||
out[2] /= dist;
|
||||
return dist;
|
||||
inline Vector3f Normalize(const Vector3f& in) {
|
||||
const float dist = Length(in);
|
||||
|
||||
if (dist == 0.f) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {in[0] / dist, in[1] / dist, in[2] / dist};
|
||||
}
|
||||
|
||||
/** Voice wrapper with positional-3D level control */
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace amuse {
|
||||
class IBackendSubmix;
|
||||
|
||||
@@ -34,7 +36,7 @@ public:
|
||||
virtual void resetChannelLevels() = 0;
|
||||
|
||||
/** Set channel-gains for audio source (AudioChannel enum for array index) */
|
||||
virtual void setChannelLevels(IBackendSubmix* submix, const float coefs[8], bool slew) = 0;
|
||||
virtual void setChannelLevels(IBackendSubmix* submix, const std::array<float, 8>& coefs, bool slew) = 0;
|
||||
|
||||
/** Called by client to dynamically adjust the pitch of voices with dynamic pitch enabled */
|
||||
virtual void setPitchRatio(double ratio, bool slew) = 0;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <list>
|
||||
@@ -146,7 +147,7 @@ class Voice : public Entity {
|
||||
float m_tremoloScale = 0.f; /**< minimum volume factor produced via LFO */
|
||||
float m_tremoloModScale = 0.f; /**< minimum volume factor produced via LFO, scaled via mod wheel */
|
||||
|
||||
float m_lfoPeriods[2] = {}; /**< time-periods for LFO1 and LFO2 */
|
||||
std::array<float, 2> m_lfoPeriods{}; /**< time-periods for LFO1 and LFO2 */
|
||||
std::unique_ptr<int8_t[]> m_ctrlValsSelf; /**< Self-owned MIDI Controller values */
|
||||
int8_t* m_extCtrlVals = nullptr; /**< MIDI Controller values (external storage) */
|
||||
|
||||
@@ -186,10 +187,10 @@ class Voice : public Entity {
|
||||
ObjToken<Voice> _startChildMacro(ObjectId macroId, int macroStep, double ticksPerSec, uint8_t midiKey,
|
||||
uint8_t midiVel, uint8_t midiMod, bool pushPc = false);
|
||||
|
||||
void _panLaw(float coefsOut[8], float frontPan, float backPan, float totalSpan) const;
|
||||
std::array<float, 8> _panLaw(float frontPan, float backPan, float totalSpan) const;
|
||||
void _setPan(float pan);
|
||||
void _setSurroundPan(float span);
|
||||
void _setChannelCoefs(const float coefs[8]);
|
||||
void _setChannelCoefs(const std::array<float, 8>& coefs);
|
||||
void _setPitchWheel(float pitchWheel);
|
||||
void _notifyCtrlChange(uint8_t ctrl, int8_t val);
|
||||
|
||||
@@ -261,7 +262,7 @@ public:
|
||||
void setSurroundPan(float span);
|
||||
|
||||
/** Set current voice channel coefficients immediately */
|
||||
void setChannelCoefs(const float coefs[8]);
|
||||
void setChannelCoefs(const std::array<float, 8>& coefs);
|
||||
|
||||
/** Start volume envelope to specified level */
|
||||
void startEnvelope(double dur, float vol, const Curve* envCurve);
|
||||
|
||||
Reference in New Issue
Block a user