Music, Sound Design, and Software Programming

There are quite a few ways to convert from decimal to binary or, as I should say, from base ten to base two and the reverse when using Max/MSP. I’ve written abstractions using native objects that provide this function and I’ve also written a javascript that does both conversions (and bases up to 36) in one line of code. It is fairly trivial in javascript using the parseInt() and toString() methods. Continue reading…

I’ve recently been piecing together a performance patch and using the [bpatcher] object to hold multiple instances of the same subpatch. As I think of new things to add into the subpatch I find it a bit annoying having to shuffle the [bpatcher] view around so the new user interface objects fit in. Presentation mode helps but to make things really simple I wrote this javascript which I can drop into the subpatch to do all the hard work for me. It automatically resizes and repositions the [bpatcher] view when everything loads. This way I don’t have to make any changes by hand, it saves me some time and lets me concentrate on the project work. If you’re using presentation mode you should give it a positive number argument so it knows to look out for only the objects you need, otherwise it uses every object on the canvas to calculate the dimensions. Continue reading…

Sometimes when writing javascript for use with Max/MSP I find I need to reuse bits of code that I’ve already created for a different project. Most of the time a simple search, copy and paste suffices but in some situations it would be better to have the ability to import other javascript files to get access to all of the functions they contain. This would also be useful when trying to organise where you files are stored. I don’t always want my javascripts in the Max search path (too many files here will cause the program to take ages to load), and I don’t always want them in the same directory as my main patch (which is the default place Max will look for a javascript/abstraction/image). The following code will import a specified javascript file into the current one. Continue reading…

Here’s a tutorial patch explaining how to use regular expressions with the [regexp] object in Max to parse text. It shows a few different techniques and includes examples of each. The code is below in JSON format so Max4 users can convert it and take a look too. Copy it into a new window, switch out of edit mode and click the titles to view them one by one. There are quite a few more complicated things you can ask regular expressions to do and if I ever find repeated uses for them I will try to add these topics to the file as well. Continue reading…

I’ve just updated the collection of abstractions and javascripts I use on one of my project pages. One of my favourite things about Max MSP is the ability to extend and re-use pieces of code. There’s a list of all the included files with a short description included in the zipped archive. As stated it is a work in progress so if you notice that something is missing then let me know and I’ll look into it. I hope someone out there finds it helpful.

When using javascript in MaxMSP you can query most of the attributes of the available objects. Things like the screen co-ordinates, the scripting name and whether the object is included in presentation mode. There are a few things that it cannot tell you with one example being the number of inlets or outlets an object has. One way to do this is to parse the file in the uncompressed text format. MaxMSP files are stored as JSON so reading them inside javascript isn’t too difficult. We can then query any of the values that you can see if you open a file as text. I’ve written a script to load in the parent patch and report object attributes in a few different ways. Continue reading…

Here is the updated version which allows you to set the order with any number including negatives and decimals, which should be useful for collecting groups of events together. If you instantiate the object with any other arguments these will be sent on load instead of the usual “bang” so the object functions as a [loadmess] replacement too. Continue reading…