Skip to content

Commit

Permalink
Merge branch 'master' of github.com:marcel303/framework
Browse files Browse the repository at this point in the history
  • Loading branch information
marcel303 committed Jun 13, 2022
2 parents 3be2bb7 + 5d71787 commit 134036c
Show file tree
Hide file tree
Showing 51 changed files with 5,614 additions and 5,472 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
| Platform | Build status
|:--|:--|
| macOS | [![Build status](https://ci.appveyor.com/api/projects/status/kqradcg3ruto0uhy?svg=true)](https://ci.appveyor.com/project/MarcelSmit/framework-macos) |
| Ubuntu linux | [![Build status](https://ci.appveyor.com/api/projects/status/1spm8vp61ax61yox?svg=true)](https://ci.appveyor.com/project/MarcelSmit/framework-ubuntu) |
| Windows | [![Build status](https://ci.appveyor.com/api/projects/status/c82webixs5kbw6xt?svg=true)](https://ci.appveyor.com/project/MarcelSmit/framework) |
| macOS | [![Build status](https://ci.appveyor.com/api/projects/status/kqradcg3ruto0uhy?svg=true)](https://ci.appveyor.com/project/MarcelSmit/framework-macos) |
| Ubuntu linux | [![Build status](https://ci.appveyor.com/api/projects/status/1spm8vp61ax61yox?svg=true)](https://ci.appveyor.com/project/MarcelSmit/framework-ubuntu) |
| Windows - VS 2019 | [![Build status](https://ci.appveyor.com/api/projects/status/c82webixs5kbw6xt?svg=true)](https://ci.appveyor.com/project/MarcelSmit/framework) |
| Windows - VS 2022 | [![Build status](https://ci.appveyor.com/api/projects/status/qsm90rcfvid4qoaf?svg=true)](https://ci.appveyor.com/project/MarcelSmit/framework-windows-vs2022) |

# README #

Expand Down
73 changes: 73 additions & 0 deletions audioGraph/audioGraphCore/audioTypes-compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "audioTypes.h"

#if AUDIO_USE_SSE && defined(WIN32)

// Clang and GCC support this nice syntax where vector types support the same basic operations as floats or integers. on Windows we need to re-implement a subset here to make the code compile

inline __m128 operator+(__m128 a, __m128 b)
{
return _mm_add_ps(a, b);
}

inline __m128 operator-(__m128 a, __m128 b)
{
return _mm_sub_ps(a, b);
}

inline __m128 operator*(__m128 a, __m128 b)
{
return _mm_mul_ps(a, b);
}

inline __m128d operator+(__m128d a, __m128d b)
{
return _mm_add_pd(a, b);
}

inline __m128d operator-(__m128d a, __m128d b)
{
return _mm_sub_pd(a, b);
}

inline __m128d operator*(__m128d a, __m128d b)
{
return _mm_mul_pd(a, b);
}

#if __AVX__

#include <immintrin.h>

inline __m256 operator+(__m256 a, __m256 b)
{
return _mm256_add_ps(a, b);
}

inline __m256 operator-(__m256 a, __m256 b)
{
return _mm256_sub_ps(a, b);
}

inline __m256 operator*(__m256 a, __m256 b)
{
return _mm256_mul_ps(a, b);
}

inline __m256d operator+(__m256d a, __m256d b)
{
return _mm256_add_pd(a, b);
}

inline __m256d operator-(__m256d a, __m256d b)
{
return _mm256_sub_pd(a, b);
}

inline __m256d operator*(__m256d a, __m256d b)
{
return _mm256_mul_pd(a, b);
}

#endif

#endif
73 changes: 0 additions & 73 deletions audioGraph/audioGraphCore/audioTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,78 +144,6 @@
#define SCOPED_FLUSH_DENORMALS do { } while (false)
#endif

#if AUDIO_USE_SSE && defined(WIN32)

// Clang and GCC support this nice syntax where vector types support the same basic operations as floats or integers. on Windows we need to re-implement a subset here to make the code compile

inline __m128 operator+(__m128 a, __m128 b)
{
return _mm_add_ps(a, b);
}

inline __m128 operator-(__m128 a, __m128 b)
{
return _mm_sub_ps(a, b);
}

inline __m128 operator*(__m128 a, __m128 b)
{
return _mm_mul_ps(a, b);
}

inline __m128d operator+(__m128d a, __m128d b)
{
return _mm_add_pd(a, b);
}

inline __m128d operator-(__m128d a, __m128d b)
{
return _mm_sub_pd(a, b);
}

inline __m128d operator*(__m128d a, __m128d b)
{
return _mm_mul_pd(a, b);
}

#if __AVX__

#include <immintrin.h>

inline __m256 operator+(__m256 a, __m256 b)
{
return _mm256_add_ps(a, b);
}

inline __m256 operator-(__m256 a, __m256 b)
{
return _mm256_sub_ps(a, b);
}

inline __m256 operator*(__m256 a, __m256 b)
{
return _mm256_mul_ps(a, b);
}

inline __m256d operator+(__m256d a, __m256d b)
{
return _mm256_add_pd(a, b);
}

inline __m256d operator-(__m256d a, __m256d b)
{
return _mm256_sub_pd(a, b);
}

inline __m256d operator*(__m256d a, __m256d b)
{
return _mm256_mul_pd(a, b);
}

#endif

#endif

struct AudioControlValue
{
enum Type
Expand Down Expand Up @@ -280,4 +208,3 @@ struct AudioRNG
#else
#define ALIGNED_AUDIO_NEW_AND_DELETE()
#endif

1 change: 1 addition & 0 deletions audioGraph/audioGraphCore/soundmix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
OTHER DEALINGS IN THE SOFTWARE.
*/

#include "audioTypes-compat.h"
#include "soundfile/SoundIO.h"
#include "soundmix.h"

Expand Down
1 change: 1 addition & 0 deletions audioGraph/objects/wavefield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
OTHER DEALINGS IN THE SOFTWARE.
*/

#include "audioTypes-compat.h"
#include "Noise.h"
#include "wavefield.h"
#include <algorithm>
Expand Down
1 change: 1 addition & 0 deletions framework/framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2159,6 +2159,7 @@ void Framework::present()
{
if (window->getWindowData()->needsPresent)
{
SDL_GL_MakeCurrent(window->getWindow(), globals.glContext);
SDL_GL_SwapWindow(window->getWindow());
window->getWindowData()->needsPresent = false;
}
Expand Down
19 changes: 19 additions & 0 deletions users/marcel/flacdecode1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,41 @@

#include <stdio.h>

#ifdef _MSC_VER
#include <intrin.h>
#endif

struct Integer
{
static int numberOfLeadingZeros(const uint32_t value)
{
return
value == 0
? 32
#ifdef _MSC_VER
: __lzcnt(value);
#else
: __builtin_clz(value);
#endif
}

static int numberOfLeadingZeros64(const uint64_t value)
{
#ifdef _MSC_VER
if (value == 0)
return 64;

const int n = numberOfLeadingZeros(uint32_t(value >> 32));
if (n != 0)
return n;

return 32 + numberOfLeadingZeros(uint32_t(value));
#else
return
value == 0
? 64
: __builtin_clzll(value);
#endif
}
};

Expand Down
Binary file added users/marcel/ovr-cubes/data/mod/Chrysilis.s3m
Binary file not shown.
Binary file added users/marcel/ovr-cubes/data/veemsounds.ogg
Binary file not shown.
63 changes: 32 additions & 31 deletions users/marcel/ovr-cubes/main6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ struct CelestialSphereObject

for (int i = 0; i < numStars; ++i)
{
const float a1 = random<float>(-M_PI, +M_PI);
const float a2 = random<float>(-M_PI, +M_PI);
const float a1 = random<float>(-float(M_PI), +float(M_PI));
const float a2 = random<float>(-float(M_PI), +float(M_PI));

const Mat4x4 rotation = Mat4x4(true).RotateX(a1).RotateY(a2);
const Vec4 position = rotation * Vec4(0, 0, 1, 1);
Expand Down Expand Up @@ -1191,7 +1191,8 @@ void Scene::create()
//jgplayer.init("K_vision.s3m");
//jgplayer.init("25 - Surfacing.s3m");
//jgplayer.init("05 - Shared Dig.s3m");
jgplayer.init("UNATCO.it");
//jgplayer.init("UNATCO.it");
jgplayer.init("mod/Chrysilis.s3m");

parameterMgr.addChild(&jgplayer.parameterMgr, ++jgplayerIdx);
}
Expand Down Expand Up @@ -1799,9 +1800,6 @@ struct SpatialAudioSystemAudioStream : AudioStream

virtual int Provide(int numSamples, AudioSample * __restrict samples) override final
{
ALIGN16 float outputSamplesL[numSamples];
ALIGN16 float outputSamplesR[numSamples];

// note : we update the audio in steps of 32 samples, to improve the timing for notes when the sample size is
// large. hopefully this fixes strange timing issues during Oculus Vr movie recordings. also this will
// reduce (the maximum) binauralization latency by a little and make it more stable/less jittery
Expand All @@ -1814,37 +1812,40 @@ struct SpatialAudioSystemAudioStream : AudioStream
? numSamplesRemaining
: kUpdateSize;

ALIGN16 float outputSamplesL[kUpdateSize];
ALIGN16 float outputSamplesR[kUpdateSize];

spatialAudioSystem->generateLR(
outputSamplesL + i,
outputSamplesR + i,
outputSamplesL,
outputSamplesR,
numSamplesThisUpdate);

i += numSamplesThisUpdate;
}

#if AUDIO_BUFFER_VALIDATION
for (int i = 0; i < numSamples; ++i)
Assert(isfinite(outputSamplesL[i]) && isfinite(outputSamplesR[i]));
#endif
#if AUDIO_BUFFER_VALIDATION
for (int j = 0; j < numSamplesThisUpdate; ++j)
Assert(isfinite(outputSamplesL[j]) && isfinite(outputSamplesR[j]));
#endif

limiter.chunk_analyze(outputSamplesL, numSamples, 16);
limiter.chunk_analyze(outputSamplesR, numSamples, 16);
limiter.chunk_applyInPlace(outputSamplesL, numSamples, 16, 1.f);
limiter.chunk_applyInPlace(outputSamplesR, numSamples, 16, 1.f);
limiter.chunk_end(powf(.995f, numSamples/256.f));
limiter.chunk_analyze(outputSamplesL, numSamplesThisUpdate, 16);
limiter.chunk_analyze(outputSamplesR, numSamplesThisUpdate, 16);
limiter.chunk_applyInPlace(outputSamplesL, numSamplesThisUpdate, 16, 1.f);
limiter.chunk_applyInPlace(outputSamplesR, numSamplesThisUpdate, 16, 1.f);
limiter.chunk_end(powf(.995f, numSamplesThisUpdate/256.f));

const float scale_s16 = (1 << 15) - 1;
const float scale_s16 = (1 << 15) - 1;

for (int i = 0; i < numSamples; ++i)
{
const int32_t valueL = int32_t(outputSamplesL[i] * scale_s16);
const int32_t valueR = int32_t(outputSamplesR[i] * scale_s16);

Assert(valueL >= -((1 << 15) - 1) && valueL <= +((1 << 15) - 1));
Assert(valueR >= -((1 << 15) - 1) && valueR <= +((1 << 15) - 1));

samples[i].channel[0] = valueL;
samples[i].channel[1] = valueR;
for (int j = 0; j < numSamplesThisUpdate; ++j)
{
const int32_t valueL = int32_t(outputSamplesL[j] * scale_s16);
const int32_t valueR = int32_t(outputSamplesR[j] * scale_s16);

Assert(valueL >= -((1 << 15) - 1) && valueL <= +((1 << 15) - 1));
Assert(valueR >= -((1 << 15) - 1) && valueR <= +((1 << 15) - 1));

samples[i + j].channel[0] = valueL;
samples[i + j].channel[1] = valueR;
}

i += numSamplesThisUpdate;
}

return numSamples;
Expand Down
11 changes: 9 additions & 2 deletions users/marcel/pitchshift1/pshifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "fourier.h"

#include "Debugging.h"
#include "Log.h"

#ifdef HAVE_SSE_INTRINSICS
Expand Down Expand Up @@ -95,8 +96,12 @@ static int double2int(double value)

template <typename T> static void complex_fft(T & buffer, double direction)
{
ALIGN16 double real[buffer.size()];
ALIGN16 double imag[buffer.size()];
const int kMaxBufferSize = 4096;

Assert(buffer.size() <= kMaxBufferSize);

ALIGN16 double real[kMaxBufferSize];
ALIGN16 double imag[kMaxBufferSize];

const int numBits = Fourier::integerLog2(buffer.size());

Expand Down Expand Up @@ -394,6 +399,8 @@ int main(int argc, char * argv[])
provideInfo.outputSamples[c][i] = dst.values[i];
}
}

return provideInfo.numOutputChannels;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,18 @@ void SpatialAudioSystem_Binaural::updatePanning()

void SpatialAudioSystem_Binaural::generateLR(float * __restrict outputSamplesL, float * __restrict outputSamplesR, const int numSamples)
{
const int kMaxSamples = binaural::Binauralizer::SampleBuffer::kBufferSize;

Assert(numSamples <= kMaxSamples);

memset(outputSamplesL, 0, numSamples * sizeof(float));
memset(outputSamplesR, 0, numSamples * sizeof(float));

sources_mutex.lock();
{
for (Source * source = sources; source != nullptr; source = source->next)
{
ALIGN16 float inputSamples[numSamples];
ALIGN16 float inputSamples[kMaxSamples];

// generate source audio
source->audioSource->generate(inputSamples, numSamples);
Expand All @@ -200,8 +204,8 @@ void SpatialAudioSystem_Binaural::generateLR(float * __restrict outputSamplesL,
source->elevation.load(),
source->azimuth.load());

ALIGN16 float samplesL[numSamples];
ALIGN16 float samplesR[numSamples];
ALIGN16 float samplesL[kMaxSamples];
ALIGN16 float samplesR[kMaxSamples];
source->binauralizer.generateLR(
samplesL,
samplesR,
Expand Down
Loading

0 comments on commit 134036c

Please sign in to comment.