-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGranularLine.h
52 lines (45 loc) · 1.12 KB
/
GranularLine.h
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// GranularLine.h
// DSPLibrary
//
// Created by Mayank on 9/11/12.
// Copyright (c) 2012 Mayank Sanganeria. All rights reserved.
//
#ifndef __DSPLibrary__GranularLine__
#define __DSPLibrary__GranularLine__
#include <iostream>
#include <math.h>
struct Grain
{
int grainLength;
int elapsed;
int readHead;
bool isActive;
float currentNumGrainsAmplitude;
};
class GranularLine
{
private:
int length; // size of the buffer in samples
int writeHead, rate;
int maxNumGrains = 50;
int numGrains = maxNumGrains;
Grain *grains;
float *circularBuffer;
float *cosValues;
float avgDelay = 0.5; // in seconds
float spread = 0.5; // in percentage of buffer length
const float maxSpread = 0.5; // tweak this later
int srate;
public:
void resetGrain(int i);
void setLength(const float withLength, float withFs);
void clearBuffer();
void advanceWriteHead();
void write(float withSample);
float readGrain(int i);
float getWindow(float x);
void populateWindow();
void setRate(float withRate);
};
#endif /* defined(__DSPLibrary__GranularLine__) */