Re: Event sensing
[email protected] (Roger Crew) 21 Dec 2001 01:52:58 -0800
| Newsgroups | perl.midi |
|---|---|
| Message-ID | <[email protected]> |
> Is it possible yet in perl [to do real-time event monitoring]? Note that since the granularity of MIDI isn't much smaller than half a millisecond, and even the low-end machines these days go through LOTS of cycles in that time, you don't truly need real-time response (or at least, "real-time" in MIDI terms isn't as stringent a requirement as it used to be) If your midi device driver is such that you get a filehandle you can call select() on, then you're in business. In this case, writing Perl code to deal with midi events coming in is essentially no different from, say, writing a mail server in Perl, which has already been done a few thousand times. If select() *doesn't* work on your midi device, then you're either polling (i.e., watch everything else on your machine slow to a crawl...) or you're off in Multithreaded Programming Hell, e.g., having a separate midi reader thread that stays blocked waiting for events, while your other thread(s) manage your sequencing and whatever else you're doing... which is perhaps not as horrible as I'm making it out to be --- some would argue that it's actually EASIER to have different tasks off in different threads and not having to write one big select() loop with EVERYTHING funneling through it. However, since Perl's multithread support is still slightly wonky (or so I infer from the EXPERIMENTAL warnings I saw in the docs last I looked, and the fact that the ActivePerl binary distribution still leaves it all turned off...), this may mean (*) having to do n-1 of your threads off to the side in C code, and thus (*) having to learn how to write a C extension,... which then probably doesn't qualify as "in Perl". Mailing-List: contact [email protected]; run by ezmlm From: "Scott Webster Wood" <[email protected]> Date: Wed, 19 Dec 2001 17:01:31 -0500 Organization: Webster Internet Services X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 I played a few months back with some of the perl midi tools but wasn't highly impressed with the real-time event monitoring on receive. I have an AX-1 and MOTU that I use to connect to my laptop. I will likely also get the expansion base so there is less of a fuss trying to find linux drivers for the MOTU and/or my sound canvas pc-midi interface. Anyway - I have wanted for some time to be able to monitor a midi channel for key strokes to trigger 'sounds' on my PC. I will have no problem programming the sound library or the playback, but I am wondering if anyone has opinions on real-time event monitoring. Is it possible yet in perl for an application like this? (i.e. - hit a particular key, and play back a particular audio sample - these are sound effect mind you, like south park quotes, monty python, etc) Scott _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com