Forums > Dev

Creating a max MSP object in C

May 13 2011 | 1:24 pm

Hi there!

Im trying to Create a Object in Max MSP using C that Randomly generates a Melody, similar to Mozart’s "dice music". For example, when a random number is selected from an array, it corresponds to a note number for example 61. This then outputs the note number and plays back. This should happen 16 times, in order to create a random melody every time its activated.

I’ve created an array which contains a selection of note numbers, but i’ m very stuck on how to make it all fit together.

Any help would be very welcomed, and I hope this makes sense! Reply if your willing to help! Thank you very much


May 13 2011 | 2:30 pm

To start with, since there is no built in C random number generator, or random selector at all, you will have write such a beast, or find an available C library to give you that. After that, the coding is , well, "cookie-cutter" , with little to do but clearly define the actions you want to respond to, and coding in c those. The examples in the MAX/MSP SystemDevKit will go far in teaching this: you’ll not only need to download that, you should study the given examples!

the hardest part will be the random selection: there are libs to help here, and lotsa examples of c random functions out there on the web: do take a look. Also recent "AudioProgramming book" edited by R Boulanger and V. Lazzarini has lovely C examples that can be "ported" to a msp object. Earlier but also cool, and also C based is F.R. Moore’s "Elements of Computer Music".


May 13 2011 | 2:46 pm

Ok, thank you very much! I will probably post a bit more information about this project soon enough, when i know more myself.


May 13 2011 | 4:54 pm

actually, C has one random number generator, rand() (prototype in stdlib.h). It might not produce highest-quality random series, but for most uses it works just fine…


Aug 13 2011 | 3:32 pm

Take care if you use rand() function: if you do not initialize the seed, you always get the same result when rand() returns.
Do not forget to call srand() at the beginning of your code. An easy way is to call srand(time(NULL)), so each time you start your external, you are sure to get a different random serie.


Viewing 5 posts - 1 through 5 (of 5 total)

Forums > Dev