| Author |
Message |
Inventor

Joined: Oct 13, 2007 Posts: 1700 Location: Florida, USA
Audio files: 67
|
Posted: Thu Jan 17, 2008 3:09 am Post subject:
An Audio CPU Usage Meter Subject description: That needs some TLC to make it rock! |
 |
|
Here is a nifty little piece of ChucK code that monitors your CPU usage and generates square wave tones that vary in frequency and amplitude as a function of the CPU usage. I originally envisioned it as an automobile engine sound, hence the filename, but got mired down in details. One such detail is that ChucK stops outputting sound while it does the system call to find the cpu usage, not good. This leads me to some questions. 1. is there some way to estimate CPU usage from within ChucK? 2. Does anyone know of a way to make ChucK sound like the throaty rumble of a muscle-car V8 engine? Perhaps we could use the waveguides to model the flowmaster mufflers (joke - remember I'm only half serious and you never know which half). 3. Can you think of some other pleasing sound that you wouldn't mind listening to for hours while your system performance is expressed musically? 4. If I make Chuck monitor its own CPU usage, does that make ChucK schizophrenic, narcissistic, or paranoid? Just a little project to entertain myself this evening. Suggestions, thoughts, anyone? kijjaz, my man, you got a 57 Chevy engine sound up your sleeve or care to take a shot at one?
| Description: |
| Changes sound as a function of your CPU usage. Needs some work to make it worth listening to, but off to a good start. |
|
 Download |
| Filename: |
rev_engine.ck |
| Filesize: |
510 Bytes |
| Downloaded: |
36 Time(s) |
|
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 6716 Location: The Hague, NL
G2 patch files: 3
|
Posted: Thu Jan 17, 2008 3:25 am Post subject:
|
 |
|
A engine could likely be moddeled as a low resonator (the car) fed with a train of muffled pulses (the pistons).
Let's first fix your issue where it stops while it waits for the return of the call. I wonder if that will still stop the sound if this is made in a seperate shred? I don't understand how this stops the sounds, it's not like the oscilator depends on the value for it's existance. _________________ Modern technology offers an endless field day to any deviant strains in our personalities. --J.G.Ballard |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1700 Location: Florida, USA
Audio files: 67
|
Posted: Thu Jan 17, 2008 9:23 am Post subject:
|
 |
|
| Kassen wrote: | | A engine could likely be moddeled as a low resonator (the car) fed with a train of muffled pulses (the pistons). |
Very interesting concept, I think it would work well. I don't know what the delay between beeps is all about, but I just turned it on and noticed that the sound was different. It's higher pitched which means faster, and the duration between beeps is longer. I notice now that firefox is hogging the cpu at 65%, so that is why. So you see, it detected a problem in my system already. Now I gotta restart firefox!
I remember hearing from some sage source that those system calls are slow as molasses, wouldn't be surprised if that's the problem.
Inventor
Finding the weirdest uses for ChucK... VroomVroom |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1700 Location: Florida, USA
Audio files: 67
|
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 6716 Location: The Hague, NL
G2 patch files: 3
|
Posted: Thu Jan 17, 2008 1:48 pm Post subject:
|
 |
|
I get a error.
Debian, Studio64 32bit repository, probably "testing".
It's only right as I don't have a driver's licence :¬)
| Code: | ERROR: User name does not exist.
********* simple selection ********* ********* selection by list *********
-A all processes -C by command name
-N negate selection -G by real group ID (supports names)
-a all w/ tty except session leaders -U by real user ID (supports names)
-d all except session leaders -g by session OR by effective group name
-e all processes -p by process ID
T all processes on this terminal -s processes in the sessions given
a all w/ tty, including other users -t by tty
g OBSOLETE -- DO NOT USE -u by effective user ID (supports names)
r only running processes U processes for specified users
x processes w/o controlling ttys t by tty
*********** output format ********** *********** long options ***********
-o,o user-defined -f full --Group --User --pid --cols --ppid
-j,j job control s signal --group --user --sid --rows --info
-O,O preloaded -o v virtual memory --cumulative --format --deselect
-l,l long u user-oriented --sort --tty --forest --version
-F extra full X registers --heading --no-heading --context
********* misc options *********
-V,V show version L list format codes f ASCII art forest
-m,m,-L,-T,H threads S children in sum -y change -l format
-M,Z security data c true command name -c scheduling class
-w,w wide output n numeric WCHAN,UID -H process hierarchy |
To fix, note that "Shakers" has a wrench preset, that should be good to fix a engine? _________________ Modern technology offers an endless field day to any deviant strains in our personalities. --J.G.Ballard |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1700 Location: Florida, USA
Audio files: 67
|
Posted: Thu Jan 17, 2008 4:44 pm Post subject:
|
 |
|
| hmmm, i can guess at this error. since it says user name does not exist, the ps command is running and it thinks the syntax that follows is a username that you are running ps on. It thinks this because you are not running bash, the same shell as me. you are probably running csh. bash i believe is the default shell for the mac, which i'm on, so those unix calls, especially the quotes and such escape character dealies are handled differently. try bash, then chuck rev_engine2.ck, then after its done exit or quit or something to get back out of b |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 6716 Location: The Hague, NL
G2 patch files: 3
|
Posted: Thu Jan 17, 2008 8:38 pm Post subject:
|
 |
|
Weird.
I think BASH is the default on Debian and what I use for a shell but I not sure the Mini (which I ran this is) agrees with that. That would be a fairly odd issue. I'ĺl investigate tomorrow. _________________ Modern technology offers an endless field day to any deviant strains in our personalities. --J.G.Ballard |
|
|
Back to top
|
|
 |
spencer

Joined: Aug 16, 2006 Posts: 52 Location: northern california
|
Posted: Mon Jan 21, 2008 7:29 pm Post subject:
|
 |
|
Try editing this line: | Code: | | Std.system("ps -uCax | awk \'BEGIN{cpu=0}{cpu+=$3}END{exit(int(cpu))}\'") /256 +=> pcpu; |
to this:
| Code: | | Std.system("ps uCax | awk \'BEGIN{cpu=0}{cpu+=$3}END{exit(int(cpu))}\'") /256 +=> pcpu; |
(no dash before command line arguments)
ps has 2 or 3 different compatibility modes, and the meaning of command line arguments can change depending on what mode is used. Taking out the dash changes the compatibility mode to what seems to be desired for this command. See the ps man page for the rather gory details... maybe this originally worked on OS X because it fudged the compatibility mode thing. Though, FWIW on OS X 10.5 I get the same error as Kassen. Taking out the dash fixed it.
Also, the audio will skip because Std.system just calls libc system(), which blocks/hangs until the calling program exits. ChucK code execution and audio synthesis occur in the same thread, so ChucK code that blocks will block audio synthesis. Ultimately, if any ChucK code takes longer than bufsize / sample rate before hitting a you will hear skipping.
I can think of a few nifty ideas to get around this limitation, I might try to whip that up if I can find some time...
spencer |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1700 Location: Florida, USA
Audio files: 67
|
|
|
Back to top
|
|
 |
|