diff options
| author | Tim Redfern <tim@herge.(none)> | 2013-04-10 16:31:40 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@herge.(none)> | 2013-04-10 16:31:40 +0100 |
| commit | a29217ecc368cdeee7e908fc7db3c717cc51fd70 (patch) | |
| tree | 1f6447cfecc19c90a98ff86cb575ad7109371267 /rotord/rotor.cpp | |
| parent | 6275e8f15b63f85c2206f0acb64023610c711f24 (diff) | |
signal and audio stuff working
Diffstat (limited to 'rotord/rotor.cpp')
| -rw-r--r-- | rotord/rotor.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index af0bd7e..360b75e 100644 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -54,11 +54,12 @@ bool Signal_input::connect(Signal_node* source) { }; bool Signal_output::render(const float duration, const float framerate,string &xml_out){ + //testing signal routes cerr << "Rotor: Signal_output rendering " << duration << " seconds at " << framerate << " frames per second" << endl; float step=1.0f/framerate; float v=0.0f; for (float f=0.0f;f<duration;f+=step) { - float u=get_output(f); + float u=get_output(Time_spec(f,framerate)); if (!fequal(u,v)) { xml_out+=("<signal time='"+ofToString(f)+"'>"+ofToString(u)+"</signal>\n"); v=u; @@ -68,18 +69,18 @@ bool Signal_output::render(const float duration, const float framerate,string &x } Command_response Render_context::session_command(const std::vector<std::string>& command){ - //method,id,command1,{command2,}{body} - //here we allow the controlling server to communicate with running tasks + //method,id,command1,{command2,}{body} + //here we allow the controlling server to communicate with running tasks Command_response response; response.status=HTTPResponse::HTTP_BAD_REQUEST; if (command[2]=="audio") { - if (command[0]=="PUT") { //get audio file location and initiate analysis + if (command[0]=="PUT") { //get audio file location and initiate analysis if (command.size()>2) { if (state==IDLE) { - //check file exists + //check file exists Poco::File f=Poco::File(command[3]); if (f.exists()) { - //pass to worker thread ??if engine is ready?? ??what if engine has finished but results aren't read?? + //pass to worker thread ??if engine is ready?? ??what if engine has finished but results aren't read?? audio_filename=command[3]; //for now, store session variables in memory add_queue(ANALYSE_AUDIO); response.description="<status context='"+command[1]+"'>Starting audio analysis: "+command[3]+"</status>\n"; @@ -133,10 +134,10 @@ Command_response Render_context::session_command(const std::vector<std::string>& response.description="<status>Rotor: graph not loaded</status>\n"; } } - if (command[0]=="PUT") { //get new graph from file + if (command[0]=="PUT") { //get new graph from file if (command.size()>2) { - //should interrupt whatever is happening? - //before begining to load from xml + //should interrupt whatever is happening? + //before begining to load from xml if (state==IDLE) { //eventually not like this Poco::File f=Poco::File(command[3]); if (f.exists()) { @@ -173,7 +174,7 @@ Command_response Render_context::session_command(const std::vector<std::string>& if (command[0]=="GET") { //generate xml from 1st signal output if (state==IDLE) { //direct call for testing - float framerate=0.0f; + float framerate=25.0f; if (command.size()>2) { framerate=ofToFloat(command[3]); } @@ -324,6 +325,7 @@ bool Render_context::load_audio(const string &filename,vector<Base_audio_process av_dump_format(formatContext, 0, 0, false); //avformat.h line 1256 int samples = ((formatContext->duration + 5000)*codecContext->sample_rate)/AV_TIME_BASE; + graph.duration=((float)formatContext->duration)/AV_TIME_BASE; std::cout << "This stream has " << codecContext->channels << " channels, a sample rate of " << codecContext->sample_rate << "Hz and "<<samples <<" samples" << std::endl; std::cout << "The data is in format " <<codecContext->sample_fmt<< " (aka "<< av_get_sample_fmt_name(codecContext->sample_fmt) << ") "<<std::endl; @@ -407,6 +409,7 @@ bool Render_context::load_audio(const string &filename,vector<Base_audio_process p->cleanup(); } + av_free(frame); avcodec_close(codecContext); av_close_input_file(formatContext); |
