summaryrefslogtreecommitdiff
path: root/rotord
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-08-27 13:19:21 +0100
committerTim Redfern <tim@eclectronics.org>2013-08-27 13:19:21 +0100
commitc85e9dfbeeb447332545d40ac52c07630fbb9121 (patch)
tree7afd810a3f151f8cc3b4224e4dcb3a52c899bba5 /rotord
parent150c9823e71a161e97003849cf8b2f55b21520bd (diff)
audio thumbnail vector data
Diffstat (limited to 'rotord')
-rw-r--r--rotord/src/graph.cpp10
-rw-r--r--rotord/src/rendercontext.cpp9
-rwxr-xr-xrotord/src/rotor.cpp12
-rwxr-xr-xrotord/src/rotor.h4
4 files changed, 28 insertions, 7 deletions
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;