Skip to content

Commit 2ca4bdf

Browse files
Added some new effects
1 parent 830dbf4 commit 2ca4bdf

File tree

11 files changed

+1194
-1
lines changed

11 files changed

+1194
-1
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ML SynthTools
2-
version=1.0.1
2+
version=1.1.0
33
author=Marcel Licence <marcel.licence.o@gmail.com>
44
maintainer=Marcel Licence <marcel.licence.o@gmail.com>
55
sentence=Synthesizer Tools

src/ml_lfo.cpp

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright (c) 2023 Marcel Licence
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* Dieses Programm ist Freie Software: Sie können es unter den Bedingungen
18+
* der GNU General Public License, wie von der Free Software Foundation,
19+
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder neueren
20+
* veröffentlichten Version, weiter verteilen und/oder modifizieren.
21+
*
22+
* Dieses Programm wird in der Hoffnung bereitgestellt, dass es nützlich sein wird, jedoch
23+
* OHNE JEDE GEWÄHR,; sogar ohne die implizite
24+
* Gewähr der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
25+
* Siehe die GNU General Public License für weitere Einzelheiten.
26+
*
27+
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
28+
* Programm erhalten haben. Wenn nicht, siehe <https://www.gnu.org/licenses/>.
29+
*/
30+
31+
/**
32+
* @file ml_lfo.cpp
33+
* @author Marcel Licence
34+
* @date 01.09.2023
35+
*
36+
* @brief LFO implementation
37+
*
38+
* @see little demo: https://youtu.be/hqK_U22Jha8 (more details coming soon)
39+
*/
40+
41+
42+
#ifdef __CDT_PARSER__
43+
#include <cdt.h>
44+
#endif
45+
46+
47+
#include <ml_lfo.h>
48+
#include <math.h>
49+
#include <string.h>
50+
51+
52+
ML_LFO::ML_LFO(float sample_rate, float *buffer, uint32_t sample_count)
53+
{
54+
this->sample_rate = sample_rate;
55+
frequency = 1.0f;
56+
phase = 0.0f;
57+
this->buffer = buffer;
58+
bufferSize = sample_count;
59+
memset(buffer, 0, sizeof(float) * sample_count);
60+
}
61+
62+
void ML_LFO::Process(const float *frequency_in, float *buffer, uint32_t len)
63+
{
64+
for (uint32_t n = 0; n < len; n++)
65+
{
66+
const float omega = frequency_in[n] * 2.0f * M_PI / (sample_rate);
67+
68+
phase += omega;
69+
if (phase >= 2.0f * M_PI)
70+
{
71+
phase -= 2.0f * M_PI;
72+
}
73+
buffer[n] = sinf(phase);
74+
}
75+
}
76+
77+
void ML_LFO::Process(const float *frequency_in, uint32_t len)
78+
{
79+
for (uint32_t n = 0; n < len; n++)
80+
{
81+
const float omega = frequency_in[n] * 2.0f * M_PI / (sample_rate);
82+
83+
phase += omega;
84+
if (phase >= 2.0f * M_PI)
85+
{
86+
phase -= 2.0f * M_PI;
87+
}
88+
buffer[n] = sinf(phase);
89+
}
90+
}
91+
92+
void ML_LFO::Process(uint32_t len)
93+
{
94+
const float omega = frequency * 2.0f * M_PI / (sample_rate);
95+
96+
for (uint32_t n = 0; n < len; n++)
97+
{
98+
phase += omega;
99+
if (phase >= 2.0f * M_PI)
100+
{
101+
phase -= 2.0f * M_PI;
102+
}
103+
buffer[n] = sinf(phase);
104+
}
105+
}
106+
107+
void ML_LFO::setFrequency(float frequency)
108+
{
109+
this->frequency = frequency;
110+
}
111+
112+
void ML_LFO::setPhase(float phase)
113+
{
114+
this->phase = phase;
115+
}
116+

src/ml_lfo.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2023 Marcel Licence
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* Dieses Programm ist Freie Software: Sie können es unter den Bedingungen
18+
* der GNU General Public License, wie von der Free Software Foundation,
19+
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder neueren
20+
* veröffentlichten Version, weiter verteilen und/oder modifizieren.
21+
*
22+
* Dieses Programm wird in der Hoffnung bereitgestellt, dass es nützlich sein wird, jedoch
23+
* OHNE JEDE GEWÄHR,; sogar ohne die implizite
24+
* Gewähr der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
25+
* Siehe die GNU General Public License für weitere Einzelheiten.
26+
*
27+
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
28+
* Programm erhalten haben. Wenn nicht, siehe <https://www.gnu.org/licenses/>.
29+
*/
30+
31+
/**
32+
* @file ml_lfo.h
33+
* @author Marcel Licence
34+
* @date 01.09.2023
35+
*
36+
* @brief LFO declarations
37+
*
38+
* @see little demo: https://youtu.be/hqK_U22Jha8 (more details coming soon)
39+
*/
40+
41+
42+
#ifndef SRC_ML_LFO_H_
43+
#define SRC_ML_LFO_H_
44+
45+
46+
#include <inttypes.h>
47+
48+
49+
class ML_LFO
50+
{
51+
public:
52+
ML_LFO(float sample_rate, float *buffer, uint32_t sample_count);
53+
~ML_LFO() {};
54+
void Process(const float *frequency_in, float *buffer, uint32_t len);
55+
void Process(const float *frequency_in, uint32_t len);
56+
void Process(uint32_t len);
57+
void setFrequency(float speed);
58+
void setPhase(float phase);
59+
60+
private:
61+
float sample_rate;
62+
float frequency;
63+
float phase;
64+
float *buffer;
65+
float bufferSize;
66+
};
67+
68+
69+
#endif /* SRC_ML_LFO_H_ */
70+

0 commit comments

Comments
 (0)