From fba0ecb5dcfd7bf1fb7f68bdb832f25b50182b7e Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 8 Jun 2018 14:38:43 +0200 Subject: [PATCH] Testing summing up tone generation as integer instead of float. --- .fm_op_kernel.cpp.swp | Bin 20480 -> 0 bytes config.h | 5 +++-- dexed.cpp | 28 ++++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) delete mode 100644 .fm_op_kernel.cpp.swp diff --git a/.fm_op_kernel.cpp.swp b/.fm_op_kernel.cpp.swp deleted file mode 100644 index e9aa84b24c1071c592ce8ed6d64a1619aa2900c1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20480 zcmeI3dyHIF9mg*ZsYNLjj7AdV*R9ss?d-gEXLmchU0rs!?Sy^Q-EJGGWOC=uotOh(G~Gx}YKm!$smp39Szag@wZakA)YWQ2snyn(6{UzY z5NY5HG|;fh-2)d%J(;vH_3a(o=+aB(&OktvG}1t%fk*?91|kha8i+IyX&}--q=C1( z2CUk7(x=dfbDf4<@BE$<`aR#dmz`hE!y>`1d=}cJK%AD{v<`0j>etz-I8mCP{i0{1rS6{tW&Ez6ADxt>DxJ zcn*FIz6Xwj!{7kOgB*A-c=a8U^gD1nxEWMI2^<1xa2a?38!-2Rli&uh3{0SdDmVf@ z4hBIEJdX{T?*JY2fe(W7!L#V+-+-TiZ-CE%Ij|S-7!c#Y8HZ$FE3}(tH9eQB8pe@E zEmo_@b(MBfU6HG5sZcI<4oXhS6q2sEcbabXWD1s_4liRXDdb$~q~T$Tm5YUXMJro) zlJ;cG%bHF*cTVBCF}YN7Zk%$t-YBBj zC?8H=%aYs*p$^`gRMQ)~X}d}Mrh<7ywRRK#q=U~zHMwE@CPUqJ3bZJO8geVsouaW5 zdka&XZ}rQqU6)_< z#zL)Ospv)4ut?fvG%P&x^V-_*@5`ooU0jm3m(;SRtF$k_cVA&-baZZJWb|t9scwu- z&s{k&?!S?aOGJ$Oum4N7#<|~FxUVR?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z=ilYhT>s?y%wE?+zO=XyFFC!~n1(Xv+v_8h}n14u7-_7Vvfs z#A1W4DH`WQc%|M1rT`)oQ)XADO@u{&7MXp+bi=u(V|x-i^+&~at|Kp<$Yx!E*@2L} z&S1FrqkT_*3j2S~%plu4ka8-d@Ij5&74!Y*))e9w-S6oVj|;xSGXjh_FEBb2f?nTG z1}6m0nqa+2e7is$4w53Uh-h0?!U$IjGFFcq;n>jR8G@DbeT*ZMg&|vN=lkd(-^>0e_Ysaz5GqM6YA={n_j;KOGyCJ<}5M;*{yn zCNgf)bf2HnT{i?A$u57{kj|!ey&*@!R%Q9N-)b$Mqfjt@y_=@#biHLCz%>)A$@rQw zDQvAsCr$x1ZCJF5+Zd0ewDm~dirQK9ht}`)cA4C{I-ACZdazEMfkG&{t|6QF;7ZDh zQnmd~YrkxS7Yl2I=k)IUKeXAJ3PwFOnTUf`^1)eZp)q% xgbsxUJ+^n&m=AIKQ?XT#fl6#^L~W0JA_l#QPBb^2WIIiL@Uc-h-kz>P{s$!HqD=q* diff --git a/config.h b/config.h index 12ae091..c5853bf 100644 --- a/config.h +++ b/config.h @@ -22,18 +22,18 @@ */ -//#define TEST_MIDI 1 +#define TEST_MIDI 1 #define TEST_NOTE 40 #define TEST_VEL_MIN 60 #define TEST_VEL_MAX 110 +#define SHOW_DEXED_TIMING 1 #define DEBUG 1 #define SERIAL_SPEED 38400 #define VOLUME 0.1 #define SAMPLE_RATE 44100 //#define DEXED_ENGINE DEXED_ENGINE_MODERN #define USE_ONBOARD_USB_HOST 1 -//#define SHOW_DEXED_TIMING 1 #define SHOW_MIDI_EVENT 1 #define SHOW_XRUN 1 #define SHOW_CPU_LOAD_MSEC 5000 @@ -48,6 +48,7 @@ #define MASTER_BANK_SELECT 83 // B5 #define USE_TEENSY_DSP 1 +//#define SUM_UP_AS_INT 1 // Use these with the Teensy Audio Shield #define SDCARD_CS_PIN 10 diff --git a/dexed.cpp b/dexed.cpp index 51dec11..6b5f188 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -127,11 +127,15 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer) for (i = 0; i < n_samples; i += _N_) { AlignedBuf audiobuf; +#ifndef SUM_UP_AS_INT float sumbuf[_N_]; +#endif for (uint8_t j = 0; j < _N_; ++j) { audiobuf.get()[j] = 0; +#ifndef SUM_UP_AS_INT sumbuf[j] = 0.0; +#endif } int32_t lfovalue = lfo.getsample(); @@ -144,22 +148,38 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer) int32_t val = audiobuf.get()[j]; val = val >> 4; #ifdef USE_TEENSY_DSP - int32_t clip_val=signed_saturate_rshift(val,24,9); + int32_t clip_val = signed_saturate_rshift(val, 24, 9); #else int32_t clip_val = val < -(1 << 24) ? 0x8000 : val >= (1 << 24) ? 0x7fff : val >> 9; #endif - float f = static_cast(clip_val >> 1) / 0x8000; +#ifdef SUM_UP_AS_INT + int32_t tmp = buffer[i + j] + clip_val; + if (buffer[i + j] > 0 && clip_val > 0) + { + if ((tmp < buffer[i + j]) && (tmp < clip_val)) + tmp = 0x8000; + } + else if (buffer[i + j] < 0 && clip_val < 0) + { + if ((tmp > buffer[i + j]) && (tmp > clip_val)) + tmp = 0x7FFF; + } + buffer[i + j] = tmp; +#else + float f = static_cast(clip_val) / 0x8000; if (f > 1) f = 1; if (f < -1) f = -1; sumbuf[j] += f; audiobuf.get()[j] = 0; +#endif } } } - +#ifndef SUM_UP_AS_INT for (uint8_t j = 0; j < _N_; ++j) { buffer[i + j] = static_cast(sumbuf[j] * 0x8000); } +#endif } } @@ -194,7 +214,7 @@ bool Dexed::processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2) controllers.refresh(); break; case 32: // BankSelect LSB - bank=data2; + bank = data2; break; case 64: sustain = value > 63;