snapshot
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(min-generator)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Deactivate Emulator and Portaudio
|
||||
set(ADD_ARDUINO_EMULATOR OFF CACHE BOOL "Add Arduino Emulator Library")
|
||||
set(ADD_PORTAUDIO OFF CACHE BOOL "Add Portaudio Library")
|
||||
|
||||
# Build with arduino-audio-tools
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../.. ${CMAKE_CURRENT_BINARY_DIR}/arduino-audio-tools )
|
||||
endif()
|
||||
|
||||
# build sketch as executable
|
||||
set_source_files_properties(min-generator.ino PROPERTIES LANGUAGE CXX)
|
||||
add_executable (min-generator min-generator.ino)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(min-generator PUBLIC -DIS_MIN_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(min-generator arduino-audio-tools)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# Minimum Desktop Runtime
|
||||
|
||||
We provide some generic output which will also work on Linux, Windows and OS/X
|
||||
The cmake is downloading all dependencies and builds an executable from the sketch.
|
||||
|
||||
This example is not using the Arduino-Emulator!
|
||||
|
||||
You just need to provide an Arduino Sketch as cpp file. In our example we use an example setup that can be compiled both in Arduin and with cmake:
|
||||
|
||||
- the sketch is provided as ino file
|
||||
- you must not include Arduino.h since this is not available
|
||||
|
||||
To build the example execute
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "AudioTools.h"
|
||||
|
||||
AudioInfo info(44100, 1, 16);
|
||||
SineWaveGenerator<int16_t> sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000
|
||||
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave
|
||||
CsvOutput<int16_t> out; // Or use StdOuput
|
||||
StreamCopy copier(out, in); // copy in to out
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
// open output
|
||||
auto config = out.defaultConfig();
|
||||
config.copyFrom(info);
|
||||
out.begin(config);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
}
|
||||
|
||||
// Arduino loop
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
Reference in New Issue
Block a user