-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchorusFD.h
118 lines (93 loc) · 3.8 KB
/
chorusFD.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
******************************************************************************
* File Name : chorusFD.h
* Author : Xavier Halgand (thanks to Gabriel Rivas)
* Date :
* Description :
******************************************************************************
*/
/************************************************************************************************************
* chorus/flanger diagram (one channel) :
*
* ---------[mix >----------------------------
* | |
* | |
* |x1 v
* xin ------>[+]----->[z^-M]--[interp.]----[fw >--------->[+]-----> yout
* ^ delay line |
* | |
* --< fb]<-------------------
*
************************************************************************************************************/
#ifndef __CHORUSFD_H__
#define __CHORUSFD_H__
/*--------------------------------------------------------------------------------------*/
#include "constants.h"
#include "sinetable.h"
#include <stdint.h>
#include <math.h>
#include <stdint.h>
/*--------------------------------------------------------------------------------------*/
#define DEPTH 1400 // Size of delay buffer, in samples : 29.17 ms
#define LEFT_DELAY 240 /* initial left delay */
#define RIGHT_DELAY 240 /* initial right delay */
#define LEFT_SWEEP 50
#define RIGHT_SWEEP 50
#define MAX_RATE 7.f // in Hz
#define MIN_RATE 0.02f // in Hz
#define LEFT_RATE 0.11f // in Hz
#define RIGHT_RATE 0.12f // in Hz
#define FEEDBACK -0.2f // look at the diagram
#define FORWARD 0.5f
#define MIX 0.5f
/*---------------------------------------------------------------------------------------*/
typedef struct
{
float amp;
float freq;
float phase;
float out;
} Lfo_t;
/*---------------------------------------------------------------------------------------*/
typedef struct
{
float mix; /* delay blend parameter */
float fb; /* feedback volume */
float fw; /* delay tap mix volume */
int32_t in_idx; /* delay write index */
float dline[DEPTH] ; /* delay buffer */
float baseDelay; /* tap position */
int8_t mode; /* constant or variable delayed feedback ? */
} monochorus_t ;
/*---------------------------------------------------------------------------------------------*/
void Chorus_reset(uint8_t val);
void Chorus_init(void);
void ChorusDelay_init(monochorus_t *del, float delay_samples,float dfb,float dfw, float dmix);
void stereoChorus_compute (float * left_out, float * right_out, float in);
void inc_chorusFeedback(void);
void dec_chorusFeedback(void);
void ChorusFeedback_set(uint8_t val);
void inc_chorusRate(void);
void dec_chorusRate(void);
void ChorusRate_set(uint8_t val);
void ChorusSecondRate_set(uint8_t val);
void inc_chorusDelay(void);
void dec_chorusDelay(void);
void ChorusDelay_set(uint8_t val);
void inc_chorusSweep(void);
void dec_chorusSweep(void);
void ChorusSweep_set(uint8_t val);
void ChorusMode_toggle(void);
void ChorusMode_switch(uint8_t val);
void ChorusFDBsign_change(void);
void ChorusFDBsign_switch(uint8_t val);
void Delay_set_fb(monochorus_t *del, float val);
void Delay_set_fw(monochorus_t *del, float val);
void Delay_set_mix(monochorus_t *del, float val);
void Delay_set_delay(monochorus_t *del, float n_delay);
float Delay_get_fb(monochorus_t *del);
float Delay_get_fw(monochorus_t *del);
float Delay_get_mix(monochorus_t *del);
float mono_chorus_compute(monochorus_t *del, Lfo_t *lfo, float xin);
/*****************************************************************************************************/
#endif