electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks GalleryGallery 
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
An Audio CPU Usage Meter
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [9 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Inventor



Joined: Oct 13, 2007
Posts: 1700
Location: Florida, USA
Audio files: 67

PostPosted: Thu Jan 17, 2008 3:09 am    Post subject: An Audio CPU Usage Meter
Subject description: That needs some TLC to make it rock!
Reply with quote  Mark this post and the followings unread

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?


rev_engine.ck
 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
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6716
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Jan 17, 2008 3:25 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Inventor



Joined: Oct 13, 2007
Posts: 1700
Location: Florida, USA
Audio files: 67

PostPosted: Thu Jan 17, 2008 9:23 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Inventor



Joined: Oct 13, 2007
Posts: 1700
Location: Florida, USA
Audio files: 67

PostPosted: Thu Jan 17, 2008 1:03 pm    Post subject: Reply with quote  Mark this post and the followings unread

Well, I toyed around a bit more and got the sound to be a lot more like a real car. I turned the frequency way down on the square waves so that actual edge transitions occurred at 1000 rpm speeds or so, then put a bandpass filter at 100 Hz to model the muffler system. Then I added averaging so that the sample - to - sample variations are smoothed, and finally it works great but it still skips on my system. Not sure why, oh well. it's a pretty cool application.


rev_engine2.ck
 Description:
Sounds much more like a musclecar, but still skips on my machine.

Download
 Filename:  rev_engine2.ck
 Filesize:  530 Bytes
 Downloaded:  24 Time(s)

Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6716
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Jan 17, 2008 1:48 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Inventor



Joined: Oct 13, 2007
Posts: 1700
Location: Florida, USA
Audio files: 67

PostPosted: Thu Jan 17, 2008 4:44 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6716
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Jan 17, 2008 8:38 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
spencer



Joined: Aug 16, 2006
Posts: 52
Location: northern california

PostPosted: Mon Jan 21, 2008 7:29 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
Code:
=> now;
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
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 1700
Location: Florida, USA
Audio files: 67

PostPosted: Mon Jan 21, 2008 8:39 pm    Post subject: Reply with quote  Mark this post and the followings unread

Dude, you are amazing on may levels to discover both obscure unix knowledge and display ChucK wizardry as well. Attached is the "fixed up" program that, despite clicks and pops, is way better than the first one. Kudos to spencer.

Rev your engine CPU Monitor, Vroom Vroom:


rev_engine2.ck
 Description:
Fixed up with advice from an expert!

Download
 Filename:  rev_engine2.ck
 Filesize:  484 Bytes
 Downloaded:  25 Time(s)

Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [9 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Music123.com - Customer Appreciation Sale Extended! - Save Up To $80 Off Your Order - Sale Ends Soon!

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003, 2004, 2005, 2006 and 2007 by electro-music.com