electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 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
Work (very much) in progress: UnitGens and Instruments
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [15 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Thu Feb 21, 2008 9:29 am    Post subject: Work (very much) in progress: UnitGens and Instruments
Subject description: my laptop is taking a maintenance break
Reply with quote  Mark this post and the followings unread

I was hoping that I would get these things a bit more ready before releasing any versions...
My laptop's fan is slowly starting to get musical on it's own... In fact it's starting to sound like a gabber song driven through a lawnmover. I have to get it repaired so I won't be able to work with ChucK for a while.

The attached piece of code is something I've been working on and I'll propably redo it a couple of times to get what I want. No useful comments or code examples on how to use these things (it's basically a back up from how I left it) but if(you're feeling adventurous){ dig_in(); }


template.ck
 Description:
more or less a random collection of random classes that do whatever

Download
 Filename:  template.ck
 Filesize:  97.83 KB
 Downloaded:  214 Time(s)


_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Thu Feb 21, 2008 11:53 am    Post subject: Reply with quote  Mark this post and the followings unread

Wow, a real treasure-trove!

Thanks for sharing this.

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



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Thu Feb 21, 2008 10:59 pm    Post subject: Reply with quote  Mark this post and the followings unread

arg!! this is a huge compilation of many useful tools.

Hmm I still haven't checked out all the codes
But I stopped and look at the Clipper that use a GEN as a transfer-function..
I've got another candidate I haven't done before but simple enough.

The Idea is that, I'd try to limit a signal in the range [-1, 1] by using HalfRect, by this method:

take the input, add with 1, HalfRect, multiply with -1, add with 2, HalfRect, multiply with -1, add with 1: done

If we imagine a linear input, it'd clip the signal definitely..

input => Gain AddOne => HalfRect rect1 => Gain AddTwo => HalfRect rect2 => output;
// and set gain to do the multiplication
-1.0 => rect1.gain => rect2.gain;

// add to AddOne and AddTwo
Step One => AddOne;
One => output;
Step Two => AddTwo;
1.0 => One.next;
2.0 => Two.next;

I still haven't tried in code, but I think it'd work well, because it looks simple and straightforward to me heheh ^_^"
- - -

(edited: last time, i forgot to add 1 to the result thus making the result 1.0 too low all the time)

Last edited by kijjaz on Fri Feb 22, 2008 4:23 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Fri Feb 22, 2008 3:11 am    Post subject: Reply with quote  Mark this post and the followings unread

Well that was a short maintenance break. I just walked in to the place and they luckily had a spare fan around. Five minutes later I got lappy back well and healthy. Razz

EDIT: Oh you're right Kijjaz! I had the same idea but didn't write it down. It had already escaped me when I wrote the Clipper. Thanks for the heads up! Smile

I'll start putting these classes in to their own files and then make a mother file to machine.add("them all"). It was easier to work with a single file in miniAudicle but now it has grown too big.

_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Mon Mar 03, 2008 12:46 pm    Post subject: Reply with quote  Mark this post and the followings unread

Now it has been broken in to pieces!
There are still lots of bugs around and features that do not work as supposed. Also the naming standard of the varibles may not be consistient and the names not always informative.
No documentation yet as this is work in progress. Ask if you do not understand something.


frostburn_snapshot03032008.zip
 Description:
UnitGens and Instruments snapshot 03032008.

Download
 Filename:  frostburn_snapshot03032008.zip
 Filesize:  54.89 KB
 Downloaded:  117 Time(s)


_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Thu Mar 13, 2008 10:08 am    Post subject: Reply with quote  Mark this post and the followings unread

Sigh... I just realized that my approach to the Instruments is running face first to the lack of ChucKian garbage collection... I'm happily sporking shreds with loads of stuff and just letting the shred exit after a note off.
Converting everything to a recycling format will be a hassle as most of the filters I'm using are IIR and clearing delay buffers by sucking out all the samples isn't too fun...
Maybe I'll just keep things the way they are, hope for the glorious garbage collection to arrive one bright day and render my songs in pieces in the meanwhile.

_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Thu Mar 13, 2008 3:21 pm    Post subject: Reply with quote  Mark this post and the followings unread

Well, Frostburn, you seem to have a high level of quality and perhaps a hint of perfectionism in your code, so I'm not surprised you're pushing ChucK's limits. I have done the same thing by writing bloatware! Guitar Lab uses up most of my CPU even at idle, and when recording a four-instrument song ChucK gives periodic warnings about CPU limits. But the recordings turn out just fine due to that ChucKian "strongly timed" feature I guess.
Back to top
View user's profile Send private message Send e-mail
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Sat Mar 15, 2008 8:12 am    Post subject: Reply with quote  Mark this post and the followings unread

Beta release.
Try running "demo.ck" for three short demonstrations and take a look at the examples.
Inventor, if you wish to re-use anything take a look at noteplay.ck under "/frostburn/examples/" on how to play individual notes.
See "/frostburn/library.ck" for the list of available Instruments.


frostburn_beta00.zip
 Description:
UnitGens and Instruments version 0.0 beta

Download
 Filename:  frostburn_beta00.zip
 Filesize:  787.39 KB
 Downloaded:  121 Time(s)


_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sat Mar 15, 2008 7:18 pm    Post subject: Reply with quote  Mark this post and the followings unread

Nice Frostburn, that seems to be a very structured and organized library, and quite extensive as well. Bummer though when I tried the example files they wouldn't run. I got the following error:

[melody.ck]:line(37): undefined type 'FastAdditive'...
[melody.ck]:line(37): ... in declaration ...

I tried going up to the folder level and running mother.ck frostburn / examples / melody.ck but it did not work. How do I source your libraries and then run your examples?
Back to top
View user's profile Send private message Send e-mail
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Sun Mar 16, 2008 12:49 am    Post subject: Reply with quote  Mark this post and the followings unread

Inventor wrote:
Nice Frostburn, that seems to be a very structured and organized library, and quite extensive as well. Bummer though when I tried the example files they wouldn't run. I got the following error:

[melody.ck]:line(37): undefined type 'FastAdditive'...
[melody.ck]:line(37): ... in declaration ...

I tried going up to the folder level and running mother.ck frostburn / examples / melody.ck but it did not work. How do I source your libraries and then run your examples?


You need to somehow run the "frostburn/library.ck" before you can run anything else. It does a machine.add for every file in the "frostburn" folder.
The files "demo.ck" and "mother.ck" do this by machine.adding the library, yielding and then adding the "melody.ck" or any other file depending on the public classes:
Code:
"frostburn/library.ck" => Machine.add;
me.yield();
"frostburn/examples/melody.ck" => Machine.add;

There are two ways this can still go wrong:
-You nee be on the folder where the "frostburn" folder is, not in the "frostburn" folder.
-Your system needs to use the slash "/" instead of the backslash "\" to determine the folder structure.

I don't know how mac handles these things but you can try modifying the "mother.ck" and "library.ck" to point to the right folders.
Modify the line:
Code:
"frostburn/" => string path;

in "library.ck".

Let me know how it goes so I can write a readme.txt for the next release.

_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sun Mar 16, 2008 1:56 am    Post subject: Reply with quote  Mark this post and the followings unread

I don't know what it is, i tried both in the frostburn folder and standing on top of it, same error message. Mac uses a forward slash. I issue the comand:

chuck frostburn/library.ck frostburn/examples/melody.ck

and get the same error. Maybe the library needs to be loaded prior to the melody.ck file somehow?
Back to top
View user's profile Send private message Send e-mail
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Sun Mar 16, 2008 3:26 am    Post subject: Reply with quote  Mark this post and the followings unread

Inventor wrote:
chuck frostburn/library.ck frostburn/examples/melody.ck

That won't work.
You need to call me.yield() after adding "library.ck" and chuck doesn't do that automatically.

The best way is to work with "mother" files that do the yielding.

You can also try the following:
chuck --loop &
chuck + frostburn/library.ck
chuck + frostburn/examples/melody.ck
chuck --kill

That way library.ck gets added and chuck yields because it advances time in the loop.

Did you try "chuck demo.ck" ?
What does that output?

_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sun Mar 16, 2008 5:55 am    Post subject: Reply with quote  Mark this post and the followings unread

OK, I got it to work by editing the mother.ck file. One thing confuses me. Normally to use a library you have some snippet of code at the beginning of your source code that reads in that libray, such as:

#include library.ck

But here we are using this "mother.ck" file which seems to be a more complicated solution. I have to edit that file every time I want to run an example.

Is it possible to put the statement that calls the library in the example ChucK file? That would be more conventional, if I understand it correctly.

Thanks, this is cool, I didn't know we could have library files in ChucK.
Back to top
View user's profile Send private message Send e-mail
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Sun Mar 16, 2008 6:31 am    Post subject: Reply with quote  Mark this post and the followings unread

I banged my head on this one. The mother-file solution was the only one I could get to work.

Code:
chuck library.ck myfile.ck

Doesn't work because ChucK checks the syntax of both files before loading anything.
Code:
Machine.add("public.ck");
me.yield();
PublicClass pc;

Doesn't work for the same reason. Syntax is checked before "public.ck" gets added.

So either you're using "chuck --loop" or mother files.

I wish chuck could have include files... Things would be so much easier.

_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
Sweet Pablo



Joined: Nov 15, 2007
Posts: 3
Location: Illinois, US

PostPosted: Sun Mar 16, 2008 9:57 pm    Post subject: Include Files Reply with quote  Mark this post and the followings unread

Quote:
I wish chuck could have include files... Things would be so much easier.

Forgive me if this is off-topic, but it is possible to include files with #include rather than Machine.add by taking advantage of the C preprocessor (cpp) and using a shell script. The following bash script works for me.
Code:

for f in $@; do
    files="$files /tmp/chuck.$f.$$"
    cpp -P $f > /tmp/chuck.$f.$$
done
chuck $files
rm -f $files

I suppose the disadvantage is that it will make your chuck files harder to share.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [15 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
e-m mkii

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 through 2009 by electro-music.com - Conditions Of Use