Skip to content

Commit aa723ab

Browse files
committed
Portaudio support
1 parent 6f9bdc4 commit aa723ab

File tree

4 files changed

+41
-39
lines changed

4 files changed

+41
-39
lines changed

examples-desktop/generator/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ if(NOT arduino_audio_tools_POPULATED)
3030
add_subdirectory(${arduino_audio_tools_SOURCE_DIR})
3131
endif()
3232

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-
)
3933

4034
# build sketch to executable
4135
add_executable (desktop generator.cpp)
4236

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+
)
4343
# define dependencies
4444
add_dependencies(desktop portaudio_static arduino_emulator arduino-audio-tools )
Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1+
// Simple wrapper to make Arduino sketch compilable by cpp in cmake
12
#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"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

src/AudioTools/PortAudioStream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
#if defined(__linux__) || defined(_WIN32) || defined(__APPLE__)
8-
#include "AudioTools/stream.h"
8+
#include "AudioTools.h"
99
#include "portaudio.h"
1010

1111
/**

0 commit comments

Comments
 (0)