From c85e9dfbeeb447332545d40ac52c07630fbb9121 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 27 Aug 2013 13:19:21 +0100 Subject: audio thumbnail vector data --- rotord/src/graph.cpp | 10 +++++++++- rotord/src/rendercontext.cpp | 9 +++++---- rotord/src/rotor.cpp | 12 ++++++++++-- rotord/src/rotor.h | 4 ++++ 4 files changed, 28 insertions(+), 7 deletions(-) (limited to 'rotord/src') diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 5871b7b..162232f 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -187,7 +187,15 @@ bool Graph::parseJson(string &data,string &media_path){ else cerr << "Rotor: cannot find parameter '" << parameter << "' of "<attributes.find(attribute)!=nodes[nodeID]->attributes.end()) { + string val=jnodes[i]["attributes"][m]["value"].asString(); + nodes[nodeID]->attributes.find(attribute)->second->value=val; + } + else cerr << "Rotor: cannot find attribute '" << attribute << "' of "<& command void Render_context::session_command(const Session_command& command,xmlIO& XML,HTTPResponse::HTTPStatus& status){ - + string s; for (auto c:command.commands){ s+=c; @@ -132,7 +132,8 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H //for now status=HTTPResponse::HTTP_OK; XML.addValue("status","Audio ready"); - XML.addValue("audio",audio_thumb->print()); + audio_thumb->print_vector(XML); + //XML.addValue("audio",audio_thumb->print()); } else { logger.error("ERROR: audio thumbnail requested but no audio loaded"); @@ -236,7 +237,7 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H if (false) { //graph.signal_render(signal_xml,framerate)){ status=HTTPResponse::HTTP_OK; logger.information("rendering signal to xml"); - XML.addValue("signal",signal_xml); //this doesn't work >> pseudo xml + XML.addValue("signal",signal_xml); //this doesn't work >> pseudo xml } else { status=HTTPResponse::HTTP_INTERNAL_SERVER_ERROR; @@ -352,7 +353,7 @@ bool Render_context::load_audio(const string &filename,vector int rate = loader.codecContext->sample_rate; int samples = ((loader.formatContext->duration + 5000)*rate)/AV_TIME_BASE; //why 5000 more? int channels= loader.codecContext->channels; - int bits = loader.codecContext->bits_per_raw_sample; + int bits = 16; //??? loader.codecContext->bits_per_raw_sample; for (auto p: processors) { if(!p->init(channels,bits,samples,rate) ){ diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp index bbae972..9cd1d7c 100755 --- a/rotord/src/rotor.cpp +++ b/rotord/src/rotor.cpp @@ -82,7 +82,7 @@ bool Audio_thumbnailer::init(int _channels,int _bits,int _samples,int _rate) { column=0; //point thumbnail bitmap out_sample=0; //sample in whole track offset=0x1<<(bits-1); //signed audio - scale=1.0/offset; + scale=1.0f/offset; sample=0; samples=0; accum=0.0; @@ -125,6 +125,7 @@ int Audio_thumbnailer::process_frame(uint8_t *_data,int samples_in_frame){ for (int i=0;i0) vdata+=","; + vdata+=ofToString(vectordata[i]); + } + XML.addValue("data",vdata); +} bool Audio_analysis::init(int _channels,int _bits,int _samples, int _rate) { //need these to make sense of data channels=_channels; diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index da1ac8a..b47dcc0 100755 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -1229,16 +1229,20 @@ namespace Rotor { width=512; //fit data=new uint8_t[height*width]; memset(data,0,height*width); + vectordata =new float[width]; }; ~Audio_thumbnailer(){ delete[] data; + delete[] vectordata; }; Audio_thumbnailer* clone(map &_settings) { return new Audio_thumbnailer();}; bool init(int _channels,int _bits,int _samples,int _rate); void cleanup(){}; int process_frame(uint8_t *data,int samples_in_frame); string print(); + void print_vector(xmlIO XML); uint8_t *data; + float *vectordata; int height,width,samples_per_column; int column,out_sample,sample,samples; int offset; -- cgit v1.2.3