<commit_before>#include <array>

#include <memory>

#include "view.h"
#include "frequencyprovider.h"

#include <emscripten.h>

#include <SDL/SDL.h>
#include <cstdio>

namespace {
    class ModifiableFrequencyProvider :
        public FMV::FrequencyProvider
    {
        public:
            static std::array<float, 255> frequencyData;

        public:
            void workWithCurrentFrequencies(Callback const &cb) override {
                cb(ModifiableFrequencyProvider::frequencyData.data());
            }
    };

    std::array<float, 255> ModifiableFrequencyProvider::frequencyData;
}

extern "C" {
    EMSCRIPTEN_KEEPALIVE
    int run_fmv_with_frequency_provider(int width, int height) {
        ModifiableFrequencyProvider::frequencyData.fill(0.0);
        ModifiableFrequencyProvider provider;
        return FMV::runViewLoop(0, nullptr, {width, height}, provider);
    }
    
    EMSCRIPTEN_KEEPALIVE
    void set_frequencies(float *frequencies, float minDB, float range) {
        for (size_t i = 0; i < ModifiableFrequencyProvider::frequencyData.size(); ++i) {
            ModifiableFrequencyProvider::frequencyData[i] = (frequencies[i] - minDB);
        }
    }
}

<commit_msg>Divide by range<commit_after>#include <array>

#include <memory>

#include "view.h"
#include "frequencyprovider.h"

#include <emscripten.h>

#include <SDL/SDL.h>
#include <cstdio>

namespace {
    class ModifiableFrequencyProvider :
        public FMV::FrequencyProvider
    {
        public:
            static std::array<float, 255> frequencyData;

        public:
            void workWithCurrentFrequencies(Callback const &cb) override {
                cb(ModifiableFrequencyProvider::frequencyData.data());
            }
    };

    std::array<float, 255> ModifiableFrequencyProvider::frequencyData;
}

extern "C" {
    EMSCRIPTEN_KEEPALIVE
    int run_fmv_with_frequency_provider(int width, int height) {
        ModifiableFrequencyProvider::frequencyData.fill(0.0);
        ModifiableFrequencyProvider provider;
        return FMV::runViewLoop(0, nullptr, {width, height}, provider);
    }
    
    EMSCRIPTEN_KEEPALIVE
    void set_frequencies(float *frequencies, float minDB, float range) {
        for (size_t i = 0; i < ModifiableFrequencyProvider::frequencyData.size(); ++i) {
            ModifiableFrequencyProvider::frequencyData[i] = (frequencies[i] - minDB) / range;
        }
    }
}


{'fraction_non_alphanumeric': 0.10642737896494157, 'fraction_numerical': 0.008347245409015025, 'mean_word_length': 3.234982332155477, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, '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': '2842791', 'n_tokens_mistral': 761, 'n_tokens_neox': 710, 'n_words': 141}