Author |
Message |
Mr Theremin
Joined: Mar 22, 2008 Posts: 22 Location: Ohio
|
Posted: Wed Mar 26, 2008 12:43 pm Post subject:
Newbe Question on Wavefile Cleanup Subject description: Cleanup wave file buffer |
|
|
I’m trying to code up a sampler in chuck in WinXP. This project may be too challenging for a beginner but I want to discover ChucK’s qualities and problems quickly so I jumped in with both feet.
What I am trying to understand is how to clean up after SndBuf.
I have been watching the Task Manager and it seems that memory and CPU are never released. I have tried several different methods of starting and sporking. The wave files here are any large sample (so that you can see memory usage meter move). Every instance of this code will grab more memory and not release until the main task is killed. Does any one know why this would leak the memory?
Is there a simple way to unload the file "FileName.wav" =< buf.read; ?
Code: |
// spork the test function, store the shred reference
spork ~ Play() @=> Shred @ s;
3::second => now;
// remove by id
Machine.remove( s.id() );
3::second => now;
// test function
fun void Play()
{
SndBuf buf1;
"Large.wav" => buf1.read;
buf1 => dac;
SndBuf buf2;
"Large.wav" => buf2.read;
buf2 => dac;
SndBuf buf3;
"Large.wav" => buf3.read;
buf3 => dac;
3::second => now;
} | [/code] |
|
Back to top
|
|
|
Frostburn
Joined: Dec 12, 2007 Posts: 255 Location: Finland
Audio files: 9
|
Posted: Wed Mar 26, 2008 1:21 pm Post subject:
|
|
|
Garbage collection is one of the lacking features in ChucK at the moment.
If memory taken it is usually not released.
I ran a quick test and it seems that you can manually release the memory SndBuf uses by loading up an empty sound file to it. (Hopefully it also work in Windows. Linux here.)
EDIT: Oh and welcome to the board!
Theremins rock. _________________ To boldly go where no man has bothered to go before. |
|
Back to top
|
|
|
Mr Theremin
Joined: Mar 22, 2008 Posts: 22 Location: Ohio
|
Posted: Wed Mar 26, 2008 1:39 pm Post subject:
|
|
|
Wow Frostburn, thanks for a speedy reply... with an experiment included no less. You guys rock. Your idea will make a fine workaround until something gets revised.
Now if I could only figure out how to display this cool avatar image I found of Léon Theremin playing his early instrument. I uploaded it to the profile page but I don’t see it on my message. |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Wed Mar 26, 2008 2:45 pm Post subject:
|
|
|
Mr Theremin wrote: | I uploaded it to the profile page but I don’t see it on my message. |
Maybe it's too large? _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
Mr Theremin
Joined: Mar 22, 2008 Posts: 22 Location: Ohio
|
Posted: Wed Mar 26, 2008 3:25 pm Post subject:
|
|
|
Well, my image is only 6K. I'm testing one more time with a different image. If this doesn't work it must be me and I'll stop cluttering this wonderful forum with my void messages. |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Wed Mar 26, 2008 3:53 pm Post subject:
|
|
|
Post with reckless abandon! You should see some of the thinking out loud nonsense I post sometimes, I bet folks get a good laugh from time to time. _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Wed Mar 26, 2008 4:16 pm Post subject:
|
|
|
Mr Theremin wrote: | Well, my image is only 6K. |
Ok, so it's probably smaller than 100x100 pixels as well ... weird ... I checked your profile, nothing indeed ... maybe try to upload the image here or PM it to me so I can try to get it into your profile. _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Wed Mar 26, 2008 6:07 pm Post subject:
|
|
|
Inventor wrote: | Post with reckless abandon! You should see some of the thinking out loud nonsense I post sometimes, I bet folks get a good laugh from time to time. |
Yeah, just start typing and see where you end up, that's the ChucKian way! _________________ Kassen |
|
Back to top
|
|
|
|