aboutsummaryrefslogtreecommitdiff
path: root/src/adlmidi_private.hpp
diff options
context:
space:
mode:
authorJP Cimalando <jpcima@users.noreply.github.com>2018-04-10 12:55:03 +0200
committerJP Cimalando <jpcima@users.noreply.github.com>2018-04-11 18:14:34 +0200
commit0bd662b2d7fc11c0b4c02372f97cf6062940c570 (patch)
tree378dd9714b6496f4f3a28424a468098c63cdf7d3 /src/adlmidi_private.hpp
parent47e2f73719ab55075d2d479daea3e9269370d421 (diff)
downloadlibADLMIDI-0bd662b2d7fc11c0b4c02372f97cf6062940c570.tar.gz
libADLMIDI-0bd662b2d7fc11c0b4c02372f97cf6062940c570.tar.bz2
libADLMIDI-0bd662b2d7fc11c0b4c02372f97cf6062940c570.zip
support for 32 bit mixing, and multiple sample formats
Diffstat (limited to 'src/adlmidi_private.hpp')
-rw-r--r--src/adlmidi_private.hpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp
index caaf4f9..63cadb3 100644
--- a/src/adlmidi_private.hpp
+++ b/src/adlmidi_private.hpp
@@ -132,6 +132,25 @@ typedef int32_t ssize_t;
extern std::string ADLMIDI_ErrorString;
/*
+ Sample conversions to various formats
+*/
+template <class Real>
+inline Real adl_cvtReal(int32_t x)
+{
+ return x * ((Real)1 / INT16_MAX);
+}
+inline int32_t adl_cvtS16(int32_t x)
+{
+ x = (x < INT16_MIN) ? INT16_MIN : x;
+ x = (x > INT16_MAX) ? INT16_MAX : x;
+ return x;
+}
+inline int32_t adl_cvtS8(int32_t x)
+{
+ return adl_cvtS16(x) / 256;
+}
+
+/*
Smart pointer for C heaps, created with malloc() call.
FAQ: Why not std::shared_ptr? Because of Android NDK now doesn't supports it
*/
@@ -909,7 +928,7 @@ public:
#endif
OPL3 opl;
- int16_t outBuf[1024];
+ int32_t outBuf[1024];
Setup m_setup;