rewrite noise
This commit is contained in:
parent
a945cabb4c
commit
5f6921bf5c
3 changed files with 56 additions and 41 deletions
|
@ -1,45 +1,62 @@
|
||||||
#define ID 0xEC57A71C
|
#include <string.h>
|
||||||
#define LABEL "crap_noise"
|
|
||||||
#define NAME "crap noise generator"
|
|
||||||
#define AUTHOR "Connor Olding"
|
|
||||||
#define COPYRIGHT "MIT"
|
|
||||||
#define PARAMETERS 0
|
|
||||||
|
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
#include "Param.hpp"
|
||||||
|
#include "Crap.hpp"
|
||||||
|
|
||||||
typedef struct {
|
struct Crap_noise
|
||||||
} personal;
|
:public AdjustAll<Crap> {
|
||||||
|
static constexpr ulong id = 0xEC57A71C;
|
||||||
|
static constexpr char label[] = "crap_noise";
|
||||||
|
static constexpr char name[] = "crap noise generator";
|
||||||
|
static constexpr char author[] = "Connor Olding";
|
||||||
|
static constexpr char copyright[] = "MIT";
|
||||||
|
static constexpr ulong parameters = 0;
|
||||||
|
|
||||||
template<typename T>
|
unsigned int mirand_L, mirand_R;
|
||||||
INNER void
|
|
||||||
process(personal *data,
|
inline
|
||||||
T *in_L, T *in_R,
|
Crap_noise()
|
||||||
T *out_L, T *out_R,
|
: mirand_L(123), mirand_R(456)
|
||||||
unsigned long count)
|
{}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
process(
|
||||||
|
double *in_L, double *in_R,
|
||||||
|
double *out_L, double *out_R,
|
||||||
|
ulong count)
|
||||||
{
|
{
|
||||||
// TODO: separate and preserve mirand for each channel
|
for (ulong i = 0; i < count; i++)
|
||||||
for (unsigned long pos = 0; pos < count; pos++)
|
out_L[i] = whitenoise(mirand_L);
|
||||||
out_L[pos] = whitenoise();
|
for (ulong i = 0; i < count; i++)
|
||||||
for (unsigned long pos = 0; pos < count; pos++)
|
out_R[i] = whitenoise(mirand_R);
|
||||||
out_R[pos] = whitenoise();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
INNER void
|
inline void
|
||||||
construct(personal *data)
|
process(
|
||||||
|
float *in_L, float *in_R,
|
||||||
|
float *out_L, float *out_R,
|
||||||
|
ulong count)
|
||||||
|
{
|
||||||
|
for (ulong i = 0; i < count; i++)
|
||||||
|
out_L[i] = whitenoise(mirand_L);
|
||||||
|
for (ulong i = 0; i < count; i++)
|
||||||
|
out_R[i] = whitenoise(mirand_R);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
construct_params(Param *params)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
INNER void
|
inline void
|
||||||
destruct(personal *data)
|
resume()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
INNER void
|
inline void
|
||||||
resume(personal *data)
|
pause()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
INNER void
|
inline void
|
||||||
pause(personal *data)
|
adjust_all(Param *params)
|
||||||
{}
|
|
||||||
|
|
||||||
INNER void
|
|
||||||
adjust(personal *data, unsigned long fs)
|
|
||||||
{}
|
{}
|
||||||
|
};
|
||||||
|
|
|
@ -37,10 +37,8 @@ disable_denormals()
|
||||||
#define ANGULAR_LIM(fc, fs) (2 * M_PI / (fs) * LIMIT((fc), 1, (fs)/2))
|
#define ANGULAR_LIM(fc, fs) (2 * M_PI / (fs) * LIMIT((fc), 1, (fs)/2))
|
||||||
|
|
||||||
/* via http://www.rgba.org/articles/sfrand/sfrand.htm */
|
/* via http://www.rgba.org/articles/sfrand/sfrand.htm */
|
||||||
static unsigned int mirand = 1;
|
|
||||||
|
|
||||||
INNER float
|
INNER float
|
||||||
whitenoise()
|
whitenoise(unsigned int &mirand)
|
||||||
{
|
{
|
||||||
union either {
|
union either {
|
||||||
float f;
|
float f;
|
||||||
|
|
|
@ -123,9 +123,9 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mirand = time(NULL);
|
unsigned int mirand = time(NULL);
|
||||||
for (int i = 0; i < audio_count*BLOCK_SIZE; i++)
|
for (int i = 0; i < audio_count*BLOCK_SIZE; i++)
|
||||||
audio_buffer[i] = whitenoise();
|
audio_buffer[i] = whitenoise(mirand);
|
||||||
|
|
||||||
if (d->activate) d->activate(h);
|
if (d->activate) d->activate(h);
|
||||||
for (int i = 0; i < 64*64*8; i++)
|
for (int i = 0; i < 64*64*8; i++)
|
||||||
|
|
Loading…
Add table
Reference in a new issue