diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-08-27 13:19:21 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-08-27 13:19:21 +0100 |
| commit | c85e9dfbeeb447332545d40ac52c07630fbb9121 (patch) | |
| tree | 7afd810a3f151f8cc3b4224e4dcb3a52c899bba5 | |
| parent | 150c9823e71a161e97003849cf8b2f55b21520bd (diff) | |
audio thumbnail vector data
| -rwxr-xr-x | install_dependencies_linux.sh | 2 | ||||
| -rw-r--r-- | rotord/src/graph.cpp | 10 | ||||
| -rw-r--r-- | rotord/src/rendercontext.cpp | 9 | ||||
| -rwxr-xr-x | rotord/src/rotor.cpp | 12 | ||||
| -rwxr-xr-x | rotord/src/rotor.h | 4 |
5 files changed, 29 insertions, 8 deletions
diff --git a/install_dependencies_linux.sh b/install_dependencies_linux.sh index 57f09b9..3901fc9 100755 --- a/install_dependencies_linux.sh +++ b/install_dependencies_linux.sh @@ -35,7 +35,7 @@ sudo apt-get install libmp3lame-dev #svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg -cd ffmpeg +cd ffmpeg1 ./configure --prefix=/usr/local --enable-gpl --enable-nonfree --enable-shared --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-bzlib --enable-libfaac --enable-libmp3lame --enable-libschroedinger --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib #https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&ved=0CDYQFjAB&url=https%3A%2F%2Fgithub.com%2Fopenembedded%2Foe-core%2Fblob%2Fmaster%2Fmeta%2Frecipes-multimedia%2Fgstreamer%2Fgst-ffmpeg-0.10.13%2Fh264_qpel_mmx.patch&ei=IKPJUb5GzYuFB5fcgcAF&usg=AFQjCNFXPPb3HZRMdRCnOazSoteHQu6awA&sig2=Z2s4SUshqcOCoB5N_o1aVw&bvm=bv.48293060,d.ZG4 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 "<<settings["type"]<<" "<< nodeID << endl; } - // + //attributes + for (int m=0;m<jnodes[i]["attributes"].size();m++){ + string attribute=jnodes[i]["attributes"][m]["name"].asString(); + if (nodes[nodeID]->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 "<<settings["type"]<<" "<< nodeID << endl; + } } else cerr << "Rotor: duplicate node '"<<nodeID<<"' "<< endl; diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index 8c1e847..cbce728 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -56,7 +56,7 @@ void Render_context::add_queue(Session_task item) { } //const std::vector<std::string>& 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<Audio_processor*> 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;i<height;i++) { data[i*width+column]=abs(i-hh)<colheight?0xff:0x00; } + vectordata[column]=mean; column++; sample=0; samples=0; @@ -153,7 +154,14 @@ string Audio_thumbnailer::print(){ delete enc; return output.str(); } - +void Audio_thumbnailer::print_vector(xmlIO XML){ + string vdata; + for (int i=0;i<width;i++){ + if (i>0) 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<string,string> &_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; |
