From e31dfc6f9838ef708880fb66e1f34684666d853e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 26 Aug 2019 04:37:22 -0400 Subject: [PATCH] Envelope: Make lookup table const This is only ever read from, so we can allow the compiler to toss it into the read-only segment. --- lib/Envelope.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/Envelope.cpp b/lib/Envelope.cpp index 455c71a..d5d27cc 100644 --- a/lib/Envelope.cpp +++ b/lib/Envelope.cpp @@ -1,20 +1,22 @@ #include "amuse/Envelope.hpp" +#include + #include "amuse/AudioGroupPool.hpp" #include "amuse/Voice.hpp" namespace amuse { -static int32_t MIDItoTIME[104] = {/* [0..103] -> milliseconds */ - 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, - 110, 120, 130, 140, 150, 160, 170, 190, 200, 220, 230, 250, - 270, 290, 310, 330, 350, 380, 410, 440, 470, 500, 540, 580, - 620, 660, 710, 760, 820, 880, 940, 1000, 1000, 1100, 1200, 1300, - 1400, 1500, 1600, 1700, 1800, 2000, 2100, 2300, 2400, 2600, 2800, 3000, - 3200, 3500, 3700, 4000, 4300, 4600, 4900, 5300, 5700, 6100, 6500, 7000, - 7500, 8100, 8600, 9300, 9900, 10000, 11000, 12000, 13000, 14000, 15000, 16000, - 17000, 18000, 19000, 21000, 22000, 24000, 26000, 28000, 30000, 32000, 34000, 37000, - 39000, 42000, 45000, 49000, 50000, 55000, 60000, 65000}; +// [0..103] -> milliseconds +constexpr std::array MIDItoTIME{ + 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 110, 120, 130, + 140, 150, 160, 170, 190, 200, 220, 230, 250, 270, 290, 310, 330, 350, 380, + 410, 440, 470, 500, 540, 580, 620, 660, 710, 760, 820, 880, 940, 1000, 1000, + 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 2000, 2100, 2300, 2400, 2600, 2800, 3000, + 3200, 3500, 3700, 4000, 4300, 4600, 4900, 5300, 5700, 6100, 6500, 7000, 7500, 8100, 8600, + 9300, 9900, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 21000, 22000, 24000, + 26000, 28000, 30000, 32000, 34000, 37000, 39000, 42000, 45000, 49000, 50000, 55000, 60000, 65000, +}; void Envelope::reset(const ADSR* adsr) { m_phase = State::Attack;