11#include "nlohmann/json.hpp"
12#include "xtl/xbase64.hpp"
24 size_t write(
const uint8_t *data,
size_t len)
override {
43 void setup(std::string fName,
int channelCount,
int channelNo) {
47 LOGE(
"Setting channels to 0");
67 is.open(
fname, is.binary);
69 std::list<int16_t> audioList;
71 size_t rec_size =
channels*
sizeof(T);
72 while(is.read((
char *)buffer, rec_size)){
75 string str_size =
"102400";
76 str <<
"<style>div.x-svg {width: "<< str_size <<
"px; }</style>";
77 str <<
"<div class='x-svg'><svg viewBox='0 0 "<< str_size <<
" 100'> <polyline fill='none' stroke='blue' stroke-width='1' points ='";
80 for(int16_t sample: audioList){
81 str << idx++ <<
"," << sample <<
" ";
83 str <<
"'/></svg></div>";
91 std::stringstream
str;
98 int result = x / 1000;
120 copier.resize(bufferSize);
135 const std::string &
name()
const {
140 const std::string
path()
const {
141 std::filesystem::path p =
fname;
142 std::string result = std::filesystem::absolute(p);
150 std::fstream fstream(
fname, fstream.binary | fstream.trunc | fstream.out);
160 }
catch(
const std::exception& ex){
161 std::cerr << ex.what();
166 ifstream f(
fname.c_str());
176 std::ifstream fin(
fname, std::ios::binary);
177 std::stringstream m_buffer;
178 m_buffer << fin.rdbuf();
179 return xtl::base64encode(m_buffer.str());
206 auto bundle = nl::json::object();
207 bundle[
"text/html"] = in.chartData();
213 auto bundle = nl::json::object();
215 bundle[
"text/html"] =
"<audio controls "
216 "src='data:audio/wav;base64," +
If you want to use the framework w/o Arduino you need to provide the implementation of a couple of cl...
#define LOGE(...)
Definition AudioLoggerIDF.h:30
nl::json mime_bundle_repr(Chart &in)
Disply Chart in Jupyterlab xeus.
Definition JupyterAudio.h:205
#define assert(T)
Definition avr.h:10