how to pipe -L events in linux/unix
Date | 1998-06-15 18:43 |
From | Paul Winkler |
Subject | how to pipe -L events in linux/unix |
I'm new to C programming. I'm trying to make a test program write a series of csound score events to somewhere csound can read them in realtime (by using the -L flag). So far the only thing that works is to do "foobar | csound -L etc..." which is not what I want, because eventually I want foobar to accept some user commands before starting csound itself via system(). I tried doing that and having my app just printf() the score events to standard output. Doesn't work: csound does in fact start, but it seems to ignore the score events even though I see them on stdout. Of course then I realized why -- the pipe's missing! I know there's a way to do this, and I think it has to do with mkfifo or popen or something, but my limited C/unix knowledge is hampering me and I can't seem to figure it out from my big fat C book ("A Book on C" by Kelley & Pohl). Can anyone sketch out a basic method to use for this? What device to I want to use with the -L flag, and how do I get my code to write to it? Point me to some tutorials, man pages, or anything else useful... or just send me a few lines of code and I'll figure it out from there... thanks, PW ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com |
Date | 1998-06-16 07:49 |
From | Jens Kilian |
Subject | Re: how to pipe -L events in linux/unix |
> I know there's a way to do this, and I think it has to do with mkfifo or > popen or something, but my limited C/unix knowledge is hampering me and > I can't seem to figure it out from my big fat C book ("A Book on C" by > Kelley & Pohl). popen() is what you want. popen() combines system() with fopen(): FILE *fp = popen("csound -L ...", "w"); fprintf(fp, "score event", ...); pclose(fp); HTH, Jens. -- mailto:jjk@acm.org phone:+49-7031-14-7698 (HP TELNET 778-7698) http://www.bawue.de/~jjk/ fax:+49-7031-14-7351 PGP: 06 04 1C 35 7B DC 1F 26 As the air to a bird, or the sea to a fish, 0x555DA8B5 BB A2 F0 66 77 75 E1 08 so is contempt to the contemptible. [Blake] |
Date | 1998-06-16 07:58 |
From | Nicola Bernardini |
Subject | Re: how to pipe -L events in linux/unix |
On Tue, 16 Jun 1998, Jens Kilian wrote: > > I know there's a way to do this, and I think it has to do with mkfifo or > > popen or something, but my limited C/unix knowledge is hampering me and > > I can't seem to figure it out from my big fat C book ("A Book on C" by > > Kelley & Pohl). > > popen() is what you want. > > popen() combines system() with fopen(): > > FILE *fp = popen("csound -L ...", "w"); ^^^ ^^^ precisely, what name would you put there for a device? I tried making a fifo queue with mkfifo, then piping data into it, then opening csound -L fifo etc. etc. but it does'nt work. It says: Csound Version 3.482 (Jun 5 1998) orchname: osc.orc realtime performance using dummy numeric scorefile orch compiler: 13 lines read instr 1 MIT Csound: 3.482 (Jun 5 1998) orch now loaded displays suppressed stdmode = 00000000 Linefd = 3 audio buffered in 1024 sample-frame blocks WARNING: Sample rate set to 44194 (instead of 44100) hardware buffers set to 2048 bytes writing 2048-byte blks of shorts to devaudio (IRCAM) cannot reopen (null) stdmode = 00000000 Linefd = 3 and quits. Of course if we were to use real unix facilities, we should be doing something like this: echo "i1, f1, etc. blah blah" | csound -do devaudio -L - orc.orc where the '-' after the -L, as in all unix utilities would be intended to be 'stdin' because there is no name for stdin since it can be the tty you're working on *OR* a redirected file *OR* a pipe etc. (everything is automatically handled by your shell so there's no single stdin device). Not yet implemented perhaps? > > fprintf(fp, "score event", ...); > > pclose(fp); Yes and there would be no need for C programming at all, BTW. Nicola ------------------------------------------------------------------------ Nicola Bernardini E-mail: nicb@axnet.it Re graphics: A picture is worth 10K words -- but only those to describe the picture. Hardly any sets of 10K words can be adequately described with pictures. |
Date | 1998-06-16 09:36 |
From | Jens Kilian |
Subject | Re: how to pipe -L events in linux/unix |
> > FILE *fp = popen("csound -L ...", "w"); > ^^^ > ^^^ > precisely, what name would you put there for a device? I tried making a > fifo queue with mkfifo, then piping data into it, then opening > csound -L fifo etc. etc. but it does'nt work. It should be whatever causes Csound to read from stdin. I don't recall offhand if that's even possible. Perhaps "stdin" or "console"? (It *should* be "-", of course.) > where the '-' after the -L, as in all unix utilities would be intended > to be 'stdin' because there is no name for stdin since it can be the > tty you're working on *OR* a redirected file *OR* a pipe etc. (everything > is automatically handled by your shell so there's no single stdin > device). Not yet implemented perhaps? I think that at least some Csound versions can read from stdin, but don't call it "-". Bye, Jens. -- mailto:jjk@acm.org phone:+49-7031-14-7698 (HP TELNET 778-7698) http://www.bawue.de/~jjk/ fax:+49-7031-14-7351 PGP: 06 04 1C 35 7B DC 1F 26 As the air to a bird, or the sea to a fish, 0x555DA8B5 BB A2 F0 66 77 75 E1 08 so is contempt to the contemptible. [Blake] |