I've started working (hacking) on a program but realized i have no idea how to do the next part, so i figured i ought to "seek wisdom" at perlmonks.

So here's the deal:

The program is a curses based drum machine, written in, of course, perl. I'm using the excellent CDK (Curses-DevKit) and have hacked up a pretty slick little matrix interface. The program will pipe it's output to CSound, which will handle the audio part.

Now what happens is you create patterns in a matrix and the program *should* step through it at whatever tempo we are going at, see if a note is going to be played, and if so send a little line to the csound program like:

i 1 0 2 3 4
or whatever.

Now this all happens in real time, so i need to have some kind of timer loop that polls the matrix at a regular interval, but doesn't steal all the cycles from the interface.

seems that this is your classic case for a fork with a sleeping child, but my concerns are: will the timing be accurate enough for an audio app ( <3ms or so), and how painful is IPC in perl. i haven't done any IPC programming for quite a while, and would rather avoid it if possible.

is there a magic module that i'm looking for? i looked at Time::HiRes but it didn't seem quite right. (maybe i'm just dumb;-)


In reply to using timers in a music app by dockthepod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.