You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am providing a simple integration for [Mozzi](https://sensorium.github.io/Mozzi/). Unfortunatly I needed to make some small changes to make things work together. Those can be found in my [fork](https://github.com/pschatzmann/Mozzi).
4
+
5
+
A standard Sketch will need to combine the Audio-Tools with the Mozzi Logic:
6
+
7
+
```
8
+
#include "AudioTools.h"
9
+
#include "AudioA2DP.h"
10
+
#include "AudioMozzi.h"
11
+
// Mozzi includes
12
+
// ....
13
+
14
+
15
+
using namespace audio_tools;
16
+
17
+
// Audio Tools
18
+
MozziGenerator mozzi(CONTROL_RATE); // subclass of SoundGenerator
19
+
GeneratedSoundStream<int16_t> in(mozzi, 2); // Stream with 2 channels generated with mozzi
20
+
A2DPStream out = A2DPStream::instance() ; // A2DP input - A2DPStream is a singleton!
21
+
StreamCopy copier(out, in); // copy in to out
22
+
23
+
```
24
+
25
+
As you can see above you can add the __MozziGenerator__ like any other Generator to the __GeneratedSoundStream__ class.
26
+
In the setup you need to combine the Audio-Tools setup and then call the Mozzi specific setup functions. Replace the __startMozzi()__ with our __GeneratedSoundStream.begin()__:
27
+
28
+
```
29
+
void setup(){
30
+
Serial.begin(115200);
31
+
32
+
if (mozzi.config().sample_rate!=44100){
33
+
Serial.println("Please set the AUDIO_RATE in the mozzi_config.h to 44100");
34
+
stop();
35
+
}
36
+
37
+
// We send the generated sound via A2DP - so we conect to the MyMusic Bluetooth Speaker
38
+
out.begin(TX_MODE, "MyMusic");
39
+
Serial.println("A2DP is connected now...");
40
+
41
+
// Add your Mozzi setup here
42
+
// ...
43
+
in.begin();
44
+
}
45
+
```
46
+
47
+
Like in any other Mozzi Sketch you need to define the __updateControl()__
48
+
49
+
```
50
+
// Mozzi updateControl
51
+
void updateControl(){
52
+
}
53
+
```
54
+
55
+
And like in any other Mozzi Sketch you need to define the __updateAudio()__
56
+
57
+
```
58
+
// Mozzi updateAudio
59
+
AudioOutput_t updateAudio(){
60
+
}
61
+
```
62
+
63
+
In the loop you need to replace the __audioHook()__ with your copy logic:
64
+
65
+
```
66
+
// Arduino loop
67
+
void loop() {
68
+
if (out)
69
+
copier.copy();
70
+
}
71
+
```
72
+
73
+
That's all to output the generated sound to a Bluetooth Speaker...
0 commit comments