snapshot
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(container-binary)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
include(FetchContent)
|
||||
|
||||
# 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
|
||||
add_executable (container-binary container-binary.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(container-binary PUBLIC -DIS_MIN_DESKTOP)
|
||||
|
||||
# OS/X might need this setting for core audio
|
||||
#target_compile_definitions(portaudio PUBLIC -DPA_USE_COREAUDIO=1)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(container-binary arduino-audio-tools)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @file communication-container-binary.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/ContainerBinary.h"
|
||||
|
||||
AudioInfo info(8000,1,16);
|
||||
SineWaveGenerator<int16_t> sineWave( 32000); // subclass of SoundGenerator with max amplitude of 32000
|
||||
GeneratedSoundStream<int16_t> sound( sineWave); // Stream generated from sine wave
|
||||
CsvOutput<int16_t> out(Serial);
|
||||
EncodedAudioStream decoder(&out,new BinaryContainerDecoder()); // encode and write
|
||||
EncodedAudioStream encoder(&out,new BinaryContainerEncoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start
|
||||
Serial.println("starting...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
Reference in New Issue
Block a user