File tree Expand file tree Collapse file tree 4 files changed +41
-39
lines changed
examples-desktop/generator Expand file tree Collapse file tree 4 files changed +41
-39
lines changed Original file line number Diff line number Diff line change @@ -30,15 +30,15 @@ if(NOT arduino_audio_tools_POPULATED)
30
30
add_subdirectory (${arduino_audio_tools_SOURCE_DIR} )
31
31
endif ()
32
32
33
- # Hmm...This should not be needed!
34
- include_directories (
35
- "${arduino_emulator_SOURCE_DIR} /ArduinoCore-API/api"
36
- "${arduino_emulator_SOURCE_DIR} /MathFunctions/ArduinoCore-Linux/cores/arduino"
37
- "${arduino_audio_tools_SOURCE_DIR} /src"
38
- )
39
33
40
34
# build sketch to executable
41
35
add_executable (desktop generator.cpp )
42
36
37
+ # Hmm...This should not be needed!
38
+ target_include_directories (desktop PRIVATE
39
+ "${arduino_emulator_SOURCE_DIR} /ArduinoCore-API/api"
40
+ "${arduino_emulator_SOURCE_DIR} /ArduinoCore-Linux/cores/arduino"
41
+ "${arduino_audio_tools_SOURCE_DIR} /src"
42
+ )
43
43
# define dependencies
44
44
add_dependencies (desktop portaudio_static arduino_emulator arduino-audio-tools )
Original file line number Diff line number Diff line change
1
+ // Simple wrapper to make Arduino sketch compilable by cpp in cmake
1
2
#include " Arduino.h"
2
- #include " AudioTools.h"
3
-
4
- using namespace audio_tools ;
5
-
6
- uint16_t sample_rate=44100 ;
7
- uint8_t channels = 2 ; // The stream will have 2 channels
8
- SineWaveGenerator<int16_t > sineWave (32000 ); // subclass of SoundGenerator with max amplitude of 32000
9
- GeneratedSoundStream<int16_t > in (sineWave, channels); // Stream generated from sine wave
10
- DefaultStream out; // On desktop we use
11
- StreamCopy copier (out, in); // copy in to out
12
-
13
- // Arduino Setup
14
- void setup (void ) {
15
- Serial.begin (115200 );
16
-
17
- // open output
18
- auto config = out.defaultConfig ();
19
- config.sample_rate = sample_rate;
20
- config.channels = channels;
21
- config.bits_per_sample = sizeof (int16_t )*8 ;
22
- out.begin ();
23
-
24
- // Setup sine wave
25
- sineWave.begin (sample_rate, B4);
26
-
27
- }
28
-
29
- // Arduino loop
30
- void loop () {
31
- if (out)
32
- copier.copy ();
33
- }
3
+ #include " generator.ino"
Original file line number Diff line number Diff line change
1
+ #include " AudioTools.h"
2
+
3
+ using namespace audio_tools ;
4
+
5
+ uint16_t sample_rate=44100 ;
6
+ uint8_t channels = 2 ; // The stream will have 2 channels
7
+ SineWaveGenerator<int16_t > sineWave (32000 ); // subclass of SoundGenerator with max amplitude of 32000
8
+ GeneratedSoundStream<int16_t > in (sineWave, channels); // Stream generated from sine wave
9
+ DefaultStream out; // On desktop we use
10
+ StreamCopy copier (out, in); // copy in to out
11
+
12
+ // Arduino Setup
13
+ void setup (void ) {
14
+ Serial.begin (115200 );
15
+
16
+ // open output
17
+ auto config = out.defaultConfig ();
18
+ config.sample_rate = sample_rate;
19
+ config.channels = channels;
20
+ config.bits_per_sample = sizeof (int16_t )*8 ;
21
+ out.begin ();
22
+
23
+ // Setup sine wave
24
+ sineWave.begin (sample_rate, B4);
25
+
26
+ }
27
+
28
+ // Arduino loop
29
+ void loop () {
30
+ if (out)
31
+ copier.copy ();
32
+ }
Original file line number Diff line number Diff line change 5
5
*/
6
6
7
7
#if defined(__linux__) || defined(_WIN32) || defined(__APPLE__)
8
- #include " AudioTools/stream .h"
8
+ #include " AudioTools.h"
9
9
#include " portaudio.h"
10
10
11
11
/* *
You can’t perform that action at this time.
0 commit comments