From a29217ecc368cdeee7e908fc7db3c717cc51fd70 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 10 Apr 2013 16:31:40 +0100 Subject: signal and audio stuff working --- rotord/rotor.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'rotord/rotor.cpp') 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"+ofToString(u)+"\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& 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="Starting audio analysis: "+command[3]+"\n"; @@ -133,10 +134,10 @@ Command_response Render_context::session_command(const std::vector& response.description="Rotor: graph not loaded\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& 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,vectorduration + 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 "<sample_fmt<< " (aka "<< av_get_sample_fmt_name(codecContext->sample_fmt) << ") "<cleanup(); } + av_free(frame); avcodec_close(codecContext); av_close_input_file(formatContext); -- cgit v1.2.3