<commit_before>//------------------------------------------------------------------------------
//  SoundTest.cc
//------------------------------------------------------------------------------
#include "Pre.h"
#include "Core/App.h"
#include "Gfx/Gfx.h"
#include "Input/Input.h"
#include "Sound/Sound.h"
#include "IMUI/IMUI.h"
#include "Assets/Sound/SoundGen.h"
#include "glm/trigonometric.hpp"

using namespace Oryol;

class SoundTestApp : public App {
public:
    AppState::Code OnInit();
    AppState::Code OnRunning();
    AppState::Code OnCleanup();

    struct Effect {
        Id id;
        float* samples = nullptr;   // duplicate for visualization via imgui!
        int numSamples = 0;
        int uiOffset = 0;
        int uiNum = 0;

        ~Effect() {
            if (this->samples) {
                Memory::Free(this->samples);
                this->samples = nullptr;
            }
        };
        float* Alloc(int numSamples_) {
            o_assert(nullptr == this->samples);
            o_assert(numSamples_ > 0);
            this->uiOffset = 0;
            this->uiNum = numSamples_;
            this->numSamples = numSamples_;
            this->samples = (float*) Memory::Alloc(this->numSamples * sizeof(float));
            return this->samples;
        };
    };

    enum EffectId {
        Waka = 0,
        Song1,
        Power1,
        EatGhost,

        NumEffects
    };

    Effect effects[NumEffects];
    int uiCurEffect = Song1;
    const char* uiEffectNames[NumEffects] = {
        "Waka",
        "Song1",
        "Power1",
        "EatGhost"
    };
};
OryolMain(SoundTestApp);

//------------------------------------------------------------------------------
AppState::Code
SoundTestApp::OnInit() {
    Gfx::Setup(GfxSetup::Window(1024, 480, "Sound Test"));
    Input::Setup();
    Sound::Setup(SoundSetup());
    IMUI::Setup();

    this->effects[Waka].id = Sound::CreateResource(SoundEffectSetup::FromSampleFunc(1, 0.25f, 44100, [this](float dt, int16* samples, int numSamples) {

        using namespace SoundGen;
        float* floatSamples = this->effects[Waka].Alloc(numSamples);

        const float32 maxFreq = 500.0f;
        const float32 minFreq = 50.0f;
        NamcoVoice voice(dt, NamcoVoice::Pacman2);
        float32 t = 0.0f;
        Range range;
        for (int i = 0; i < numSamples; i++, t += dt) {
            if (range.In(t, 0.0f, 0.1f)) {
                voice.Frequency = Mod::Lerp(t, range.Begin, range.End, maxFreq, minFreq);
            }<commit_msg>Fixed minor VS2013 compile problem (initializer list)<commit_after>//------------------------------------------------------------------------------
//  SoundTest.cc
//------------------------------------------------------------------------------
#include "Pre.h"
#include "Core/App.h"
#include "Gfx/Gfx.h"
#include "Input/Input.h"
#include "Sound/Sound.h"
#include "IMUI/IMUI.h"
#include "Assets/Sound/SoundGen.h"
#include "glm/trigonometric.hpp"

using namespace Oryol;

class SoundTestApp : public App {
public:
    AppState::Code OnInit();
    AppState::Code OnRunning();
    AppState::Code OnCleanup();

    struct Effect {
        Id id;
        float* samples = nullptr;   // duplicate for visualization via imgui!
        int numSamples = 0;
        int uiOffset = 0;
        int uiNum = 0;

        ~Effect() {
            if (this->samples) {
                Memory::Free(this->samples);
                this->samples = nullptr;
            }
        };
        float* Alloc(int numSamples_) {
            o_assert(nullptr == this->samples);
            o_assert(numSamples_ > 0);
            this->uiOffset = 0;
            this->uiNum = numSamples_;
            this->numSamples = numSamples_;
            this->samples = (float*) Memory::Alloc(this->numSamples * sizeof(float));
            return this->samples;
        };
    };

    enum EffectId {
        Waka = 0,
        Song1,
        Power1,
        EatGhost,

        NumEffects
    };

    Effect effects[NumEffects];
    int uiCurEffect = Song1;
    static const char* uiEffectNames[NumEffects];
};
OryolMain(SoundTestApp);

const char* SoundTestApp::uiEffectNames[SoundTestApp::NumEffects] = {
    "Waka",
    "Song1",
    "Power1",
    "EatGhost"
};

//------------------------------------------------------------------------------
AppState::Code
SoundTestApp::OnInit() {
    Gfx::Setup(GfxSetup::Window(1024, 480, "Sound Test"));
    Input::Setup();
    Sound::Setup(SoundSetup());
    IMUI::Setup();

    this->effects[Waka].id = Sound::CreateResource(SoundEffectSetup::FromSampleFunc(1, 0.25f, 44100, [this](float dt, int16* samples, int numSamples) {

        using namespace SoundGen;
        float* floatSamples = this->effects[Waka].Alloc(numSamples);

        const float32 maxFreq = 500.0f;
        const float32 minFreq = 50.0f;
        NamcoVoice voice(dt, NamcoVoice::Pacman2);
        float32 t = 0.0f;
        Range range;
        for (int i = 0; i < numSamples; i++, t += dt) {
            if (range.In(t, 0.0f, 0.1f)) {
                voice.Frequency = Mod::Lerp(t, range.Begin, range.End, maxFreq, minFreq);
            }
{'fraction_non_alphanumeric': 0.21694255111976632, 'fraction_numerical': 0.020253164556962026, 'mean_word_length': 1.6946484784889821, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4022533', 'n_tokens_mistral': 1623, 'n_tokens_neox': 1492, 'n_words': 328}