Creating a max MSP object in C
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
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".
Ok, thank you very much! I will probably post a bit more information about this project soon enough, when i know more myself.
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…
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.
Forums > Dev