1
- /* Example of Ring Modulation synthesis,
1
+ /* Example of Self Modulation synthesis,
2
2
using Mozzi sonification library.
3
3
4
- Demonstrates the use of Oscil::phMod to modulate an Oscillator by itself: a ring modulator .
5
- Ring Modulation is a part of frequency modulation synthesis (FM).
4
+ Demonstrates the use of Oscil::phMod to modulate an Oscillator by itself.
5
+ Self Modulation is a part of frequency modulation synthesis (FM).
6
6
Compared to "standard" FM where one oscillator modulates another
7
- in Ring Modulation the output of one oscillator is used to modulate
7
+ in Self Modulation the output of one oscillator is used to modulate
8
8
itself, directly, of after further modulation, or to modulate one of its
9
9
modulator (looking at the DX7 diagram is probably clearer).
10
10
11
- Here we demonstrate the simple case of RM , one oscillator modulating himself.
11
+ Here we demonstrate the simple case of Self Modulation , one oscillator modulating himself.
12
12
The equivalent diagram is:
13
13
14
14
_____
33
33
Mozzi is licensed under the GNU Lesser General Public Licence (LGPL) Version 2.1 or later.
34
34
*/
35
35
36
- # define MOZZI_CONTROL_RATE 64 // Hz, powers of 2 are most reliable; 64 Hz is actually the default, but shown here, for clarity
36
+
37
37
#include < Mozzi.h>
38
38
#include < Oscil.h> // oscillator template
39
39
#include < tables/sin2048_int8.h> // sine table for oscillator
@@ -47,10 +47,10 @@ EventDelay kChangeNoteDelay; // to change the base note
47
47
Smooth<uint8_t > kSmoothModulation (0 .99f );
48
48
Oscil<SIN2048_NUM_CELLS, MOZZI_AUDIO_RATE> aSin (SIN2048_DATA);
49
49
50
- uint8_t ring_mod_amount, smoothed_ring_mod_amount ;
50
+ uint8_t self_mod_amount, smoothed_self_mod_amount ;
51
51
52
- UFix<8 , 0 > notes[4 ] = { 40 - 12 , 52 - 12 , 28 - 12 , 30 - 12 }; // note played. Because of the ringModulation the oscillator is called *two times*
53
- // hence produces a note which an octave to high, so we compensate for that here (12 midi notes makes an octave).
52
+ UFix<8 , 0 > notes[4 ] = { 40 - 12 , 52 - 12 , 28 - 12 , 30 - 12 }; // note played. Because of the Modulation the oscillator is called *two times*
53
+ // hence produces a note is which an octave to high, so we compensate for that here (12 midi notes makes an octave).
54
54
55
55
56
56
void setup () {
@@ -63,10 +63,10 @@ void setup() {
63
63
64
64
void updateControl () {
65
65
if (kModulationChangeDelay .ready ()) {
66
- ring_mod_amount = rand (255 ); // next target value of modulation
66
+ self_mod_amount = rand (255 ); // next target value of modulation
67
67
kModulationChangeDelay .start ();
68
68
}
69
- smoothed_ring_mod_amount = kSmoothModulation (ring_mod_amount ); // smoothing of the modulation
69
+ smoothed_self_mod_amount = kSmoothModulation (self_mod_amount ); // smoothing of the modulation
70
70
71
71
if (kChangeNoteDelay .ready ()) {
72
72
aSin.setFreq (mtof (notes[rand (4 )]));
@@ -76,7 +76,7 @@ void updateControl() {
76
76
77
77
78
78
AudioOutput updateAudio () {
79
- return MonoOutput::from8Bit (aSin.phMod ((int32_t (aSin.next ()) * smoothed_ring_mod_amount ) << 4 ));
79
+ return MonoOutput::from8Bit (aSin.phMod ((int32_t (aSin.next ()) * smoothed_self_mod_amount ) << 4 ));
80
80
}
81
81
82
82
0 commit comments