chenlh
2026-03-26 36e42207da4c088b5bfd96f2cfc8944f890440d7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
#include <climits>
#include "RandomBuffer.h"
#include "LcgRandom.h"
 
namespace ReverbHallRoom
{
    std::vector<float> RandomBuffer::Generate(uint64_t seed, int count)
    {
        LcgRandom rand(seed);
        std::vector<float> output;
 
        for (int i = 0; i < count; i++)
        {
            unsigned int val = rand.NextUInt();
            float fVal = val / (float)UINT_MAX;
            output.push_back(fVal);
        }
 
        return output;
    }
 
    std::vector<float> RandomBuffer::Generate(uint64_t seed, int count, float crossSeed)
    {
        auto seedA = seed;
        auto seedB = ~seed;
        auto seriesA = Generate(seedA, count);
        auto seriesB = Generate(seedB, count);
 
        std::vector<float> output;
        for (int i = 0; i < count; i++)
            output.push_back(seriesA[i] * (1 - crossSeed) + seriesB[i] * crossSeed);
 
        return output;
    }
}