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
Code for limiting midi channels in chuck??
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [24 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
zeropoint



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Fri Mar 16, 2007 11:26 am    Post subject: Code for limiting midi channels in chuck?? Reply with quote  Mark this post and the followings unread

Hello everyone

I am trying to get a monome 40h to work in ableton live alongside two faderfox controllers. the 40h works fine on it's own using matthias ahlstrom's excellent monogrid code file. however, if I try to map the faderfoxes to the set it kills the shred with an arrayoutofbounds alert. the faderfoxes are inputting through my firewire 410 interface......

now i am not a coder.....it's a step off the end of the pier for me to get as far as i have in chuck....i.e. installing it and using the command line to initiate monogrid!.....so could anyone please either talk me through the code needed to limit the midi channels chuck is listening on or point me somewhere i can get the information i need to figure it out for myself....if indeed that is the right way round the problem. here's the monogrid code.

thanks

tim


MonoGrid.ck
 Description:

Download
 Filename:  MonoGrid.ck
 Filesize:  4.18 KB
 Downloaded:  171 Time(s)

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: Sat Mar 17, 2007 7:48 am    Post subject: Reply with quote  Mark this post and the followings unread

Welcome, Zero point!

This looks like good fun, the Mononome and ChucK sound like a very nice match, can I ask you where you got this code?

So, let's get this straight. The problem arises because the monome is broadcasting certain MIDI data on a known channel and the faderfoxes are on a different channel? Or perhaps the problem is caused by the foxes sending cc's that aren't in the monome's specs?

I'm realy bussy today so I won't be able to solve this for you right now. It might also be tricky to pinpoint the exact problem without having a monome at hand or knowing what your foxes are sending but it should be possible to build in extra checks that prevent arrays from getting the numbers that are sending them out of bound.

That's what's going on here; a array is a sort of look-up-table. It takes one number as a input and returns another number, being the one that's at the location indicated by the input. Now, if you get a input that's larger then the length of this table then ChucK doesn't know what to do anymore and gives up.

This should be fixable but it'd help if you could indicate with as much presision as possible what data causes this exactly; that would help a lot. We might have to go a few times back and forth because I don't have a Monome to test with (though I'd love to!). There might be more then one problem of this sort.

It's nice to see ChucK used this way too.

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



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Sat Mar 17, 2007 6:25 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hi Kassen

thanks for getting back to me so quickly. ok so i'll try and give you as much info as possible.....

i have created two virtual midi ports using the iac bus on my mac that address the monome. i also have a firewire 410 that my two faderfoxes are connected to. if i run chuck probe i can see this :

[chuck]: ------( chuck -- 4 MIDI inputs )------
[chuck]: [0] : "IAC Driver in"
[chuck]: [1] : "IAC Driver out"
[chuck]: [2] : "Network Tim to Les"
[chuck]: [3] : "FireWire 410"
[chuck]:
[chuck]: ------( chuck -- 4 MIDI outputs )-----
[chuck]: [0] : "IAC Driver in"
[chuck]: [1] : "IAC Driver out"
[chuck]: [2] : "Network Tim to Les"
[chuck]: [3] : "FireWire 410"

the shred dies if i boot live with a set that is already premapped to the faderfoxes even if the 410 is not enabled in the preferences. the monome is mapped on midi channels 1 thru 8. the faderfoxes are mapped on channels 15 and 16. this is why i thought that to telling chuck to ignore channels 9 thru 16 might solve the problem.

the monogrid chuck code came from the applications section of the monome website at www.monome.org

if you need any further info please let me know.

thanks man
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: Sun Mar 18, 2007 2:58 pm    Post subject: Reply with quote  Mark this post and the followings unread

yeah, I get it, and the "grid" uses a 2d array (like the monome's matirx so that makes sense) and going over 8 channels makes it go out of range. That means there is some aray in there with a dimension that's 8 in size and indexed by the MIDI channel. I think I can fix that.

Yesterday I had a (chuck) gig so I was prepering then. Today is reserved for post-gig chilling since it was a bit insane so tomorow I should be able to fix this.

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



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Sun Mar 18, 2007 3:26 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thanks man......that's very kind of you

I tried reading the chuck documentation naively imaging I might have a go myself. I did manage to get the monome to wait for a midi event before coming online but that was as far as I got. I tried to find some sort of array definition in the monogrid code but couldn't see anything that resembled the documentation....way beyond me dude. Just thankful that there's folk like you out there!

out of interest......and forgive me my ignorance...how exactly to you perform live with chuck when it takes three lines of code to play a middle c?

oh and I like your description of your interests as "complex systems and simple pleasures"......quite einsteinian....metaphysical even.
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: Mon Mar 19, 2007 4:20 am    Post subject: Reply with quote  Mark this post and the followings unread

Here I am again!
This might work. I found what I thought was the problem; there's a 8x8 array in there with the first dimention indexed by a MIDI channel but I can't see any checks that avoid it going out of bound (didn't go over all of it because I have no monome and am not that sure what data is coming in or where it's going). I added a check that will verify the midi channel is within the range; if it is we proceed as planned, if it isn't we do nothing. I hope this will make CHucK ignore the foxes in your setup.

Check to see wether it's good now. If it isn't I'll have another go and if it's fine you might want to send this to Ahlstrom so nobody else bumps into this.

So...yeah, performing with ChucK Smile
It's true; three lines to play a middle c... But then four lines gives you a long train of middle c's and six could give you a melody that loops forever so then it becomes a bit more economical. I didn't do that though, what I did is kinda similar to the sort of thing we have here. I wrote some code (a bit more then this file but not by *that* much) that takes data from some game controlers and uses it to controll sample playback in ChucK as well as send MIDI notes to my Nord Modular. It's basically a sort of very mutated x0x sequencer. The cool thing about ChucK is that you can develop such things very quickly and it's more about thinking about how you want it to work then about how hard the actual coding is.

It realy doesn't take that many lines to link a button to a kick-drum and you only have to write those lines once, if you want a snare and highhat as well you can re-use the ones you already wrote so then it gets even better and it realy is quite nice to be able to have it all just like you like it. Clearly you like the Monome better then a standard sequencer interface (and right you are!), I thought a arcade joystick would be cool Smile.


monogrid_139v2.ck
 Description:
hopefully fixed monogrid code, original file by Ahlstrom, see line 114 for the single check added. needs testing.

Download
 Filename:  monogrid_139v2.ck
 Filesize:  4.58 KB
 Downloaded:  163 Time(s)


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



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Mon Mar 19, 2007 5:24 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks for doing that so quickly.....it's still killing the shred however as soon as I boot a set that is premapped to the foxes.

[chuck](VM): ArrayOutofBounds in shred[id=1:monogrid_139v2.ck], PC=[494], index=[12]
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: Mon Mar 19, 2007 5:38 am    Post subject: Reply with quote  Mark this post and the followings unread

Oops! And there I was mailing with Ahlstrom like we had it....

Back to the drawing board then.
Thanks for the extra info, so the culprit is some array that has a size below 12, I'll hunt for it, might be the grid's second dimention.

_________________
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: Mon Mar 19, 2007 5:51 am    Post subject: Reply with quote  Mark this post and the followings unread

Ok, next try.

I added in some more checks. I overlooked two or three cases where "currentGrid" could be over 7. I also edited that line that sets "currentgrid" based on the incoming MIDI message so that's a bit overkill now but being defensive hewre can't hurt.

I think the array will now no longer go out of bound but it does mean that something is still being exected uppon receiving a MIDI mesage that's outside of the scope of the expected onmes which could lead to issues stiull (even if those issues aren't crashes).

Better would be checking that a incoming message is within the scope of the ones we expect to come from the monome and simply dropping everything else. That would be harder for me to write since I'm not sure what messages are being send or even exactly what this code is doing.

Please see how far we are now.


monogrid_139v3.ck
 Description:
v3....

Download
 Filename:  monogrid_139v3.ck
 Filesize:  4.57 KB
 Downloaded:  168 Time(s)


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



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Mon Mar 19, 2007 7:05 am    Post subject: Reply with quote  Mark this post and the followings unread

Great! We're getting somewhere now. The shred remains in place with no array out of bounds......but now there is some midi feedback getting through to the monome which is causing the leds to light in the same specific pattern on booting a set.

Monogrid splits up the 8 x 8 grid on the monome as follows:

first line of eight buttons is used to switch between 8 grids of 7 x 8 buttons.

with your code adjustment the grid select buttons on the first row- 1,3,4 and 7 are lit.
1 and 3 are lit on the second row
3 and 7 on the third
3 on the fourth
3 and 7 on the fifth
3 and 7 on the 6th
3 on the 7th
3 on the 8th.

however as soon as I start and stop a clip mapped to those buttons (all on channel 1) the leds go out. in some cases though another different one lights up. Grids 2 through 8 which are assigned midi channels 2 - 8 remain unaffected.

I guess this is where it might get tricky with you not having the 40h in front of you, but i think there might be a virtual version available on the website. I'll check it out. again if any more detail from my end will help let me know.
Back to top
View user's profile Send private message
zeropoint



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Mon Mar 19, 2007 7:12 am    Post subject: Reply with quote  Mark this post and the followings unread

ok...here's a link to the Max/Msp base patches which apparently include the virtual version of the 40h......

http://wiki.monome.org/view/AppMaxMspBasePatches
Back to top
View user's profile Send private message
zeropoint



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Mon Mar 19, 2007 7:47 am    Post subject: Reply with quote  Mark this post and the followings unread

actually i just checked the other grids.....and although they are intact at start up as soon as i map a grid 2 button to a clip slot the same pattern of lights appear......
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: Mon Mar 19, 2007 9:37 am    Post subject: Reply with quote  Mark this post and the followings unread

Hmmmm. If it's MIDI feedback that's involving the whole larger system of all of your ports and Live and whatever it is that's on the receiving end of the OSC stuff. Another matter is that I don't have MAX/MSP.

Realy the best thing would be to make ChucK ignore any MIDI message not aimed at it. Do you know what kind of message the monome is sending on those 8 channels? Is this just notes or also CC's? If it's just notes it would be possible to just filter anything that's not a note on those 8 channels out.

I'd also like to know what would happen if you'd try getting rid of your MIDI feedback loop.

_________________
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: Mon Mar 19, 2007 9:48 am    Post subject: Reply with quote  Mark this post and the followings unread

Wait!

I had another look, am I right in guessing that we can be sure the Monome is sending on channels 1 to 8? I thought for a while that it might be configured for other cahnnels and that this code would need to adapt. If we can be sure it's only channel 1 to 8 that would make it a bit more simple.

_________________
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: Mon Mar 19, 2007 9:57 am    Post subject: Reply with quote  Mark this post and the followings unread

Try me!

Next try, we should now be dropping all MIDI messages that aren't in the 8 channel range alltogether. I think this is basically the way it should function, not sure how feedback loops would affect this.


monogrid_139v4.ck
 Description:
fourth version

Download
 Filename:  monogrid_139v4.ck
 Filesize:  4.93 KB
 Downloaded:  165 Time(s)


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



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Mon Mar 19, 2007 10:00 am    Post subject: Reply with quote  Mark this post and the followings unread

ok so the note on note off are velocity triggers 127 for on and 0 for off.......
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: Mon Mar 19, 2007 10:07 am    Post subject: Reply with quote  Mark this post and the followings unread

zeropoint wrote:
ok so the note on note off are velocity triggers 127 for on and 0 for off.......


Yeah, that's normal, a "note on" message that has a velocity of zero counts as a "note off". That's according to the MIDI specs and basically what everybody does.

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



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Mon Mar 19, 2007 10:15 am    Post subject: Reply with quote  Mark this post and the followings unread

Kas you bloomin' genius! Yes!! That's done it.......everything working just fine now. I'll let Ahlstrom know what you've managed to do. If you are ever in London drop me a line and I'll buy you a beer or whatever floats your boat.

thank you so very much.

Tim
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: Mon Mar 19, 2007 10:20 am    Post subject: Reply with quote  Mark this post and the followings unread

I already notified Ahlstrom, he sounded quite happy that we were finding this little bug because it had eluded him so far, he should be aware of this topic.

I also left comments at my edit about what I'm doing and why so he should be able to clean things up and incorporate it all cleanly if he does a update.

So; cool! Thanks for your nice words and beers float my boat just fine, I'll be sure to drop you a line if I'm in London.

Cheers!

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



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Mon Mar 19, 2007 11:02 am    Post subject: Reply with quote  Mark this post and the followings unread

i have noticed another slight bug. If I map a row of eight buttons to a row of clips in Live everythign works fine until I map a second row....then when i trigger a clip in that row one of the leds in the previous row lights and stays on.......any ideas or should i take this up with ahlstrom now?
Back to top
View user's profile Send private message
zeropoint



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Mon Mar 19, 2007 11:05 am    Post subject: Reply with quote  Mark this post and the followings unread

you know....i don't wnat to hassle you unduly when you haven't got one of these babies of your own and are unable to enjoy the fruits of your own labours ...
Back to top
View user's profile Send private message
zeropoint



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Mon Mar 19, 2007 11:17 am    Post subject: Reply with quote  Mark this post and the followings unread

no....it seems that was a red herring....caused by having one of live's clips set to legato.....for some reason that must be kicking something out to the monome.
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: Mon Mar 19, 2007 11:27 am    Post subject: Reply with quote  Mark this post and the followings unread

Great! End good all good.

It was a fun puzzle for me so we both got something out of it. If you ever feel inclined to do some ChucKing of your own do check back in.

Maybe I'll want a monome in the future as well, they are still going to build that larger one, right? You could play games on that, I think. Smile

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



Joined: Mar 16, 2007
Posts: 19
Location: London, UK

PostPosted: Tue Mar 20, 2007 8:39 am    Post subject: Reply with quote  Mark this post and the followings unread

Yeah....the next one is the 100h which will be a 16 x 16 grid....about 10 inches square which will mean the buttons are a little smaller. It will market for about $1200 - $1400.....which is a litle bit pricey...if I want sixteen steps I just map two rows....I'm really starting to fly with the comb of the foxes and the 40h - you still need knobs and faders in your set up imo....although I'd be intrigued to see what you get up to with your joystick.....phnarr, phnarr....well you know what i mean. Take it easy man and I'll definitely swing by again from time to time.

peace
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 [24 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