Skip to content

Commit 6f9bdc4

Browse files
committed
Desktop support
1 parent da17b01 commit 6f9bdc4

File tree

7 files changed

+288
-52
lines changed

7 files changed

+288
-52
lines changed

.gitignore

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
#################
2+
## Eclipse
3+
#################
4+
5+
*.pydevproject
6+
.project
7+
.metadata
8+
bin/
9+
tmp/
10+
*.tmp
11+
*.bak
12+
*.swp
13+
*~.nib
14+
local.properties
15+
.classpath
16+
.settings/
17+
.loadpath
18+
19+
# External tool builders
20+
.externalToolBuilders/
21+
22+
# Locally stored "Eclipse launch configurations"
23+
*.launch
24+
25+
# CDT-specific
26+
.cproject
27+
28+
# PDT-specific
29+
.buildpath
30+
31+
32+
#################
33+
## Visual Studio
34+
#################
35+
36+
## Ignore Visual Studio temporary files, build results, and
37+
## files generated by popular Visual Studio add-ons.
38+
39+
# User-specific files
40+
*.suo
41+
*.user
42+
*.sln.docstates
43+
44+
# Build results
45+
46+
[Dd]ebug/
47+
[Rr]elease/
48+
x64/
49+
build/
50+
[Bb]in/
51+
[Oo]bj/
52+
53+
# MSTest test Results
54+
[Tt]est[Rr]esult*/
55+
[Bb]uild[Ll]og.*
56+
57+
*_i.c
58+
*_p.c
59+
*.ilk
60+
*.meta
61+
*.obj
62+
*.pch
63+
*.pdb
64+
*.pgc
65+
*.pgd
66+
*.rsp
67+
*.sbr
68+
*.tlb
69+
*.tli
70+
*.tlh
71+
*.tmp
72+
*.tmp_proj
73+
*.log
74+
*.vspscc
75+
*.vssscc
76+
.builds
77+
*.pidb
78+
*.log
79+
*.scc
80+
81+
# Visual C++ cache files
82+
ipch/
83+
*.aps
84+
*.ncb
85+
*.opensdf
86+
*.sdf
87+
*.cachefile
88+
89+
# Visual Studio profiler
90+
*.psess
91+
*.vsp
92+
*.vspx
93+
94+
# Guidance Automation Toolkit
95+
*.gpState
96+
97+
# ReSharper is a .NET coding add-in
98+
_ReSharper*/
99+
*.[Rr]e[Ss]harper
100+
101+
# TeamCity is a build add-in
102+
_TeamCity*
103+
104+
# DotCover is a Code Coverage Tool
105+
*.dotCover
106+
107+
# NCrunch
108+
*.ncrunch*
109+
.*crunch*.local.xml
110+
111+
# Installshield output folder
112+
[Ee]xpress/
113+
114+
# DocProject is a documentation generator add-in
115+
DocProject/buildhelp/
116+
DocProject/Help/*.HxT
117+
DocProject/Help/*.HxC
118+
DocProject/Help/*.hhc
119+
DocProject/Help/*.hhk
120+
DocProject/Help/*.hhp
121+
DocProject/Help/Html2
122+
DocProject/Help/html
123+
124+
# Click-Once directory
125+
publish/
126+
127+
# Publish Web Output
128+
*.Publish.xml
129+
*.pubxml
130+
131+
# NuGet Packages Directory
132+
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
133+
#packages/
134+
135+
# Windows Azure Build Output
136+
csx
137+
*.build.csdef
138+
139+
# Windows Store app package directory
140+
AppPackages/
141+
142+
# Others
143+
sql/
144+
*.Cache
145+
ClientBin/
146+
[Ss]tyle[Cc]op.*
147+
~$*
148+
*~
149+
*.dbmdl
150+
*.[Pp]ublish.xml
151+
*.pfx
152+
*.publishsettings
153+
154+
# RIA/Silverlight projects
155+
Generated_Code/
156+
157+
# Backup & report files from converting an old project file to a newer
158+
# Visual Studio version. Backup files are not needed, because we have git ;-)
159+
_UpgradeReport_Files/
160+
Backup*/
161+
UpgradeLog*.XML
162+
UpgradeLog*.htm
163+
164+
# SQL Server files
165+
App_Data/*.mdf
166+
App_Data/*.ldf
167+
168+
#############
169+
## Windows detritus
170+
#############
171+
172+
# Windows image file caches
173+
Thumbs.db
174+
ehthumbs.db
175+
176+
# Folder config file
177+
Desktop.ini
178+
179+
# Recycle Bin used on file shares
180+
$RECYCLE.BIN/
181+
182+
# Mac crap
183+
.DS_Store
184+
185+
186+
#############
187+
## Python
188+
#############
189+
190+
*.py[co]
191+
192+
# Packages
193+
*.egg
194+
*.egg-info
195+
dist/
196+
build/
197+
eggs/
198+
parts/
199+
var/
200+
sdist/
201+
develop-eggs/
202+
.installed.cfg
203+
204+
# Installer logs
205+
pip-log.txt
206+
207+
# Unit test / coverage reports
208+
.coverage
209+
.tox
210+
211+
#Translations
212+
*.mo
213+
214+
#Mr Developer
215+
.mr.developer.cfg
Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
cmake_minimum_required(VERSION 3.0)
1+
cmake_minimum_required(VERSION 3.20)
22

33
# set the project name
44
project(desktop)
5+
set (CMAKE_CXX_STANDARD 11)
6+
include(FetchContent)
7+
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
58

6-
# Build with arduino-audio-tools
7-
FetchContent_Declare(arduino_audio_tools GIT_REPOSITORY "https://github.com/pschatzmann/arduino-audio-tools.git" GIT_TAG main )
8-
FetchContent_GetProperties(arduino_audio_tools)
9-
if(NOT arduino_audio_tools_POPULATED)
10-
FetchContent_Populate(arduino_audio_tools)
11-
add_subdirectory(${arduino_audio_tools_SOURCE_DIR})
9+
# Build with Portaudio
10+
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG master )
11+
FetchContent_GetProperties(portaudio)
12+
if(NOT portaudio_POPULATED)
13+
FetchContent_Populate(portaudio)
14+
add_subdirectory(${portaudio_SOURCE_DIR})
1215
endif()
1316

1417
# Build with Linux Arduino Emulator
@@ -19,15 +22,23 @@ if(NOT arduino_emulator_POPULATED)
1922
add_subdirectory(${arduino_emulator_SOURCE_DIR})
2023
endif()
2124

22-
# Build with Portaudio
23-
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/pschatzmann/Arduino-Emulator.git" GIT_TAG main )
24-
FetchContent_GetProperties(portaudio)
25-
if(NOT portaudio_POPULATED)
26-
FetchContent_Populate(portaudio)
27-
add_subdirectory(${portaudio_SOURCE_DIR})
25+
# Build with arduino-audio-tools
26+
FetchContent_Declare(arduino_audio_tools GIT_REPOSITORY "https://github.com/pschatzmann/arduino-audio-tools.git" GIT_TAG main )
27+
FetchContent_GetProperties(arduino_audio_tools)
28+
if(NOT arduino_audio_tools_POPULATED)
29+
FetchContent_Populate(arduino_audio_tools)
30+
add_subdirectory(${arduino_audio_tools_SOURCE_DIR})
2831
endif()
2932

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+
)
3039

3140
# build sketch to executable
32-
add_executable (desktop desktop_example.cpp)
41+
add_executable (desktop generator.cpp)
3342

43+
# define dependencies
44+
add_dependencies(desktop portaudio_static arduino_emulator arduino-audio-tools )

examples-desktop/generator/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Desktop Implementation
2+
3+
We provide some generic output which will also work on Linux, Windows and OS/X
4+
The provided cmake is downloading all dependencies and builds an executable from the sketch
5+
6+
To build the example execute
7+
8+
```
9+
mkdir build
10+
cd build
11+
cmake ..
12+
make
13+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#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+
}

examples/desktop/README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/desktop/desktop_example.cpp

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/AudioConfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
*
109109
*/
110110
#if defined(__linux__) || defined(_WIN32) || defined(__APPLE__)
111-
typedef PortAudioStream DefaultStream
111+
typedef PortAudioStream DefaultStream;
112112
#elif defined(ESP32) || defined(ESP8266) || defined(__SAMD21G18A__)
113-
typedef A2DPStream DefaultStream
113+
typedef A2DPStream DefaultStream;
114114
#endif

0 commit comments

Comments
 (0)