|
From: | Quentin Spencer |
Subject: | Re: Running C++ program from octave ?? |
Date: | Thu, 21 Jul 2005 09:08:11 -0500 |
User-agent: | Mozilla Thunderbird 1.0.6-1.1.fc4 (X11/20050720) |
Robert A. Macy wrote:
Is it possible to run a C++ program from octave? With it continually running while data keeps coming back? To clarify, the program is a real time audio interface called ASIO from Steinberg. Picture it's like the"recorded" sound.The program runs for some long time, continually creating rather large data sets as input buffers which are filled regularly [then hopefully picked up by octave. For example, 24 bits at 192Kb/s with 50 mS latency is like 9600of 4 bytes each, because the data is "long".Or, am I supposed to compile my octave program to run inC++?? Probably simple for all of you octave/C++ gurus.
How to do this depends on how you plan to communicate with the external program. I've done something like this where the data is tranferred via a file, but that is obviously slower than passing the data directly. I also killed the external process under certain conditions if necessary. Below is a bit of the code I used:
%% define variables 'command' and 'results_file' PID = system(mindist_cmd, 1, 'async'); while(waitpid(PID,1)~=PID) sleep(1); results = []; while(isempty(results)) F = fopen(results_file, 'rt');%% perform some operation that loads the file into the variable 'results'
fclose(F); if(isempty(results)) sleep(0.1); end end %% kill the external process if( <some condition is met> ) kill(PID,SIG.QUIT); waitpid(PID); break; end end Hope this helps. -Quentin ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------
[Prev in Thread] | Current Thread | [Next in Thread] |