electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
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 
go to the radio page Live at electro-music.com radio 1 Please visit the chat
poster
 Forum index » DIY Hardware and Software » ChucK programming language
New to Chuck...
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
Verbal



Joined: Apr 12, 2007
Posts: 6
Location: Detroit

PostPosted: Thu Apr 12, 2007 5:12 am    Post subject: New to Chuck... Reply with quote  Mark this post and the followings unread

Anyone know where I could find a quick tutorial to help me get the basics of Chuck? And/or the midi basics of Chuck?

I have some code that I'm using with the Monome 40h and I'd like to modify it so different midi parts play on different midi channels.

Thanks!
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 Apr 12, 2007 6:09 am    Post subject: Reply with quote  Mark this post and the followings unread

Welcome!

There's some guidance in the online docs and I thgink the manual has a introductory section that covers the basics.

No real "teach yourself ChucK in two weeks" ready-made classes yet but the example files are good and we have a comunity so we all help eachother.

I'd say start with the manual, examples and online docs, then shout as soon as you get stuck, there are plenty of people here and on the list that actually like sorting out interesting problems.

Happy ChucKing!

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



Joined: Apr 12, 2007
Posts: 6
Location: Detroit

PostPosted: Thu Apr 12, 2007 10:26 am    Post subject: Reply with quote  Mark this post and the followings unread

I've been looking at these two pieces of code for a few hours now and I'm going nuts. I've figured a few things out but I have things that are driving me crazy.

I think you know already but the 40h is an 8x8 grid of 64 buttons. The ChucK code I'm looking at maps first column (far left side going up and down) of buttons to toggle as grid selectors.

Kassen, I know you worked on the monogrid code (I extend my thanks to you for working out the channel issue! Smile). If you remember, that code maps the bottom row of buttons to act as grid selectors.

The other code so the grid selectors are at the bottom instead of the left column. I've been comparing the code for the past three hours but I can't seem to figure out what defines the grid. I think I have it understood, but I think they're defined in two different ways in each code.

I was looking in the monogrid and the code I want to edit but I can't figure out what sets where the grid selectors are located. Can anyone please give me and idea of what to look for?
Back to top
View user's profile Send private message
dp



Joined: Apr 12, 2007
Posts: 2
Location: san francisco

PostPosted: Thu Apr 12, 2007 11:22 am    Post subject: wazup verbal Reply with quote  Mark this post and the followings unread

i'm in the same boat, monome owner, clueless when it comes to programming, but eager to learn and play.

in the monome forums, i happened on this detail in the thread on the ruby/reactor life patch. gotacsii ported the whole thing to chuck and dropped these tips, but this was for the version with a single instance:

Quote:
Also on line176 "144 => msg.data1;" you
can change the midi channel. 144 is channel 1, 145 channel 2 etc.

* The clock is generated inside of chuck. I'm not sure if this is the
best way. Maybe someday I'll make it synced to a host master clock.
Regardless, you set the number of steps and the speed in ms near the
bottom of the file:
clk.set_num_steps(16);
clk.set_speed(150);

The app generates midi notes in the range c2-c3 (c2, d2, e2, f2, g2, a2,
b2, c3) so anything that can be triggered by midi notes will work. You
could change that scale by editing this line:

[48, 50, 52, 53, 55, 57, 59, 60] @=> int notes[];

in the Midifier class.



this might be the blind leading the blind, but maybe it will help.
best
dp
Back to top
View user's profile Send private message
Verbal



Joined: Apr 12, 2007
Posts: 6
Location: Detroit

PostPosted: Thu Apr 12, 2007 11:28 am    Post subject: Reply with quote  Mark this post and the followings unread

Heh, I've seen you one the forums. Good job on the custom Monome BTW.

The bit that you pasted here is for which notes are played and the channels. Which I'm also working on.

In the updated one where you can choose grids to edit (the other thread on the Monome forums), you can select 8 grids using the buttons in the far left column. I don't really like them there and want to move them to the bottom like in the monogrid chuck program.

I'm currently at work but I've been staring at the code almost all day and comparing it to the monogrid code but I can't figure out how the hell to move the grid select buttons to the bottom. It's driving me crazy and it doesn't help that I don't have a programming mindset. Sad

Once those buttons are moved to the bottom, we'll be one step closer to an all in one monogrid and monolife ChucK program. Smile :crossesfingers:
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 Apr 12, 2007 11:36 am    Post subject: Reply with quote  Mark this post and the followings unread

@Verbal;

Well, "work on" is realy a big word. There was one quite speciffic issue that was also fairly easy to pinpoint.. But yes, I did.

I could look for this too (but not at this very moment Smile ), There are two little problems (for me); first of all; that code is quite structured but not structured by me so for me it's still a bit of a maze. Second; I don't have a Monome so I'm basically flying blind. For the midi-channel fix we had to go back&forth a few times...

As I remember the grid itself (very sensibly) is a 8x8 array of ints and it's simply called "grid". It should be defined in a line that goes something like this;

int grid[8][8];

Aside from defining the grid the code deals with MIDI in, out and I think some OSC, everything else is just operations on the grid based on input and sending output; that's all there is to it but that can still get quite complicated.

As I remember the "grid selectors" are just numbers used to index the array.

_________________
Kassen

Last edited by Kassen on Thu Apr 12, 2007 11:52 am; edited 1 time in total
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: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Apr 12, 2007 11:39 am    Post subject: Reply with quote  Mark this post and the followings unread

BTW; Can somebody get me the latest official version of the monogrid? Ahlstrom was going to do a update that would have my fix in it so if that's already out it would be better to refer to that instead of the v4 of my edit.

Let's confirm we're on the same page before we start refering to line numbers and think eachother crazy Smile

_________________
Kassen

Last edited by Kassen on Thu Apr 12, 2007 11:54 am; edited 1 time in total
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: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Apr 12, 2007 11:46 am    Post subject: Reply with quote  Mark this post and the followings unread

I think I got it anyway;

In line 57 (of my v4 file) a while(true) loop starts that will define a variable called "active grid" if something on the right most column is pressed, but only if "state is 1".

That's it, I think.

_________________
Kassen
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: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Apr 12, 2007 11:51 am    Post subject: Re: wazup verbal Reply with quote  Mark this post and the followings unread

gotacsii wrote:

* The clock is generated inside of chuck. I'm not sure if this is the
best way. Maybe someday I'll make it synced to a host master clock.


Yeah, that's likely the best way right now beacase at the moment ChucK doesn't allow for parsing of MIDI clock messages. Right now ChucK normally only likes messaages that are three bytes long, though it can be coaxed into sending two-byte ones like program changes and bank select ones.

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



Joined: Apr 12, 2007
Posts: 6
Location: Detroit

PostPosted: Thu Apr 12, 2007 12:03 pm    Post subject: Reply with quote  Mark this post and the followings unread

http://forum.monome.org/attachment/51/Monolife.tar.gz

There's the link to what I'm trying to edit. Currently the left row it set to toggle grid editing. Hold one button down, edit, and let go and the Life chuck program does it's thing.

I'm trying to move the grid edit buttons to the bottom row like they are in the mongrid chuck file. Just move them to a different row, no change to how they act.
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 Apr 12, 2007 12:41 pm    Post subject: Reply with quote  Mark this post and the followings unread

Ok, this is a gamble;

In Life.ck, line 142, change "(x == 0)" to "(y ==7)", then re-run.

I think that has a good chance of fixing it but I have no idea what else it might break. That's some pritty dense stuff.

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



Joined: Apr 12, 2007
Posts: 6
Location: Detroit

PostPosted: Thu Apr 12, 2007 5:21 pm    Post subject: Reply with quote  Mark this post and the followings unread

I will try that tonight. Thanks!

Any other possibilities? I'll be playing with it late tonight.
Back to top
View user's profile Send private message
Verbal



Joined: Apr 12, 2007
Posts: 6
Location: Detroit

PostPosted: Thu Apr 12, 2007 10:10 pm    Post subject: Reply with quote  Mark this post and the followings unread

Kassen wrote:
Ok, this is a gamble;

In Life.ck, line 142, change "(x == 0)" to "(y ==7)", then re-run.

I think that has a good chance of fixing it but I have no idea what else it might break. That's some pritty dense stuff.

Well, that changes the row that makes the grid editable, but the Life.ck doesn't run like it's supposed to.

I guess I should just leave this to the programmers that have a monome. I don't have the time to spend attempting to learn Chuck. Sad

Thanks a lot for your help Kassen.
Back to top
View user's profile Send private message
gotascii



Joined: Mar 08, 2007
Posts: 4
Location: usa

PostPosted: Sun Jul 29, 2007 2:10 pm    Post subject: hey yall, i wrote that Reply with quote  Mark this post and the followings unread

hey nice to see people digging into this app. it is dense, ive actually been wracking my brain trying to develop a really clean user friendly interface to this app. I had a really nice one in ruby but it was just too slow and a lot more musically inclined programmers know chuck as opoosed to ruby. i dont have my monome with me (I live in new orleans currently in wash, dc for business) but I am pretty sure you can move the indexing to the buttons on the bottom by modifying the button_scanner method in Life.ck. You were on the right track:

fun static void button_scanner()
{
int x, y, state;
while(true)
{
while (oe.nextMsg() != 0)
{
oe.getInt() => x;
oe.getInt() => y;
oe.getInt() => state;

if (y == 0)
{
if (state == 1)
{
lifes[x] @=> cur_life;
cur_life.set_edit(1);
Life.led_set(x, y, 1, cur_life);
}
else
{
cur_life.set_edit(0);
}
}
else if (state == 1)
{
cur_life.toggle(x, y);
}
}
0.005::second => now;
}
}

The thing you missed was assinging cur_life the Life instance thats at the x index as opposed to the y index. I am something like 75% sure this will work heh. Ill test when I get home. Fwiw I am also putting together a screencast with audio instructions about how to manipulate the clocks, midi notes, note length, channel and all that good stuff in real time. I would love to simplify the interface with some help from chuck programmers. If anyone is interested let me know.
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: Tue Jul 31, 2007 3:33 am    Post subject: Reply with quote  Mark this post and the followings unread

I'd still be happy to help if anyone gets stuck.

One possibly usefull optimalisation about the above;

Is there a reason not to chuck the OSC event to now? Right now you are running that loop every 5 ms, regardless of wether any OSC messages are there. You could also chuck the event to now, like in the example, and have it run every time a message arrives. That way it will run only when usefull and as many times as usefull which should save cpu.

Oh, and in Clock.ck, line 16 it says "Shred @ cur_cycle;". I don't get that one at all, what's going on there? I can't find "Shred" anywhere else. In fact I understand very little of what's going on in Clock.ck, it looks to me like there is a lot going on there with sporking shreds and killing them off again in clever ways? I'd love some explanation on that but I also have a suspicion that one could be simplified too.

_________________
Kassen
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 [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


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use