Thread: C programming with MAX MSP

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    3

    C programming with MAX MSP

    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

    Arnie

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    278
    Let's see the "array".

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by astroboom View Post
    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.
    This is very ambiguous IMO.

    If all you have is the array with the selection of note numbers -- about 3 lines of code -- then you do not have an "all" to fit together. You just have an array. In that case, you need to think about how "a random number is selected from an array" and what "outputs the note number and plays back".

    But I'm guessing you have more than just a few lines defining an array. In that case, post some code and ask a more specific question.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    278
    Sheesh, "some code" starts with a something that's compilable. PLEASE!

  5. #5
    Registered User
    Join Date
    May 2011
    Posts
    3
    I dont really know what that means, sorry buddy! You want libraries?

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Or links to where we can find out more information.

    Like for example, what a "Max MSP" is?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Mar 2011
    Posts
    278
    Quote Originally Posted by astroboom View Post
    I dont really know what that means, sorry buddy! You want libraries?
    Code:
     void i ntCallback(t_ipamax *x, int inletnumber)
    While I can believe you have a function ntCallback, I don't know what type an 'i' is!

    It is far better (for you and for us as helpers) if you can isolate the the MaxMSP-isms from the pure c (e.g., from the code you've posted, we cannot tell if t_ipamax is a MaxMSP creature, or one of yours). Then you can cut-and-paste and show us something that we can understand and compile.

    In your original post it seemed that you were having trouble understanding a basic 'c' issue: the use of arrays. Certainly learning about arrays can be handled using ANSI-C and not some hardware-specific version of it.

  8. #8
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by astroboom View Post
    This is what i have so far, i've been trying really hard to create it. Im doing it for a music assignment, and it needs to be almost organized randomness, much like Mozart's dice music, or the 12 note row by Schoenberg or whatever.

    Thanks,
    Arnie
    You are still not asking any specific questions.

    Max MSP looks like interesting software with a probably complex API. What have you done with it so far?

    You seem to be concerned with the "general concept" of what you are doing. Unfortunately, you probably need someone familiar with the Max MSP API to help with that (there could be cboard regulars who are, but you'll have to wait for them to cruise by); anyone else is just going to throw darts.

    On the other hand, if you can describe your problem in terms that are not specific to the API, or at least describing the relevant aspects of it, you might get some help. That might mean you have to put together a few descriptive paragraphs going into detail and referring to your code.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  9. #9
    Registered User
    Join Date
    May 2011
    Posts
    3
    Would it be easier for me to name the idea behind what i need? for example i need to have a section of code in C which would perform the same operation as a tempo controller ? and that also code that would operate as a Makenote/Noteout object in Max/MSP.

  10. #10
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Ok... so what you're trying to do is feed midi events to play back in a random fashion through the Max MSP interfaces...

    You aren't going to get very good answers here, and *especially* not without showing us your C source code. Midi events are not simple numbers, each event contains a note number, keyboard velocity (loudness) and duration (length) that has to be fed into one of the MIDI inputs on the Max software. As I understand it they have a set of COM objects you can use for the purpose, but COM is not simple programming...

    The best I can offer you is their tutorials repository ... MSP Tutorials: Table of Contents

    More information about MIDI protocal and MIDI programming is here... http://home.roadrunner.com/~jgglatt/

  11. #11
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by astroboom View Post
    Would it be easier for me to name the idea behind what i need? for example i need to have a section of code in C which would perform the same operation as a tempo controller ?
    Altho it's not in the standard, most C libraries have a nanosleep() function you could use to create rhythms. But I would bet your high-level API (Max MSP) already has something.

    CommonTater pointed to some tutorials. Have you looked at those?

    Basically, when you are approaching a new API (Application Programming Interface), you are going to have to do some preliminary experimentation with it -- writing simple programs that use the API to do one, simple thing -- before you try and use it for a serious project. This may sound like it takes more time, but in the end you will probably save yourself some, because you will know what you are doing when you finally tackle the project. Also, it can make the difference between something that works, and something that is a hopeless mess, meaning most of the time spent doing it was wasted. Of course, sometimes you do have to learn the wrong way by doing it, but it is always preferable and much more efficient to just learn the right way

    "Normal" API documentation, in the form of function references and class hierarchies, can be very frustrating and confusing to new programmers, certainly it was to me. Eventually, it starts to make sense why they are the way they are. Tutorials, if available, are usually the best starting point.
    Last edited by MK27; 05-13-2011 at 09:21 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by MK27 View Post
    Altho it's not in the standard, most C libraries have a nanosleep() function you could use to create rhythms. But I would bet your high-level API (Max MSP) already has something.

    CommonTater pointed to some tutorials. Have you looked at those?
    MIDI programming is an interresting challenge... MIDI music is not a waveform, it's an abstraction of the old "roll player" piano... It's driven by "Events" (Command packets sent to a controller) you give it a note number, a loudnes and a duration, it then adds this "event" to it's queue and plays the notes in the order received. In a MIDI (*.mid) file all you have is a series of MIDI events( control signals) and a time index... at the right time hand the packet to the MIDI device. Multiply this by 16 asynchronous channels, each capable of 16 simultaneous notes, and you can do some pretty interesting stuff. There's literally nothing there that even vaguely resembles a waveform until the MIDI device interprets the packet and plays the sound.

    But MIDI can do a lot more than play music. It can control events such as lighting, pyrotechnics, mixing boards, even robotics... All done through the same basic Event structure. You know that video "Wizards of Winter" with the guy's front lawn going nuts to the music? Yep, that's MIDI stuff.

    Jeff Glatt pretty much wrote the book on this at his brainwashing center... and it's a fascinating read.
    Last edited by CommonTater; 05-13-2011 at 09:33 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. About Device Driver Programming And Socket Programming
    By pritesh in forum Linux Programming
    Replies: 6
    Last Post: 01-23-2010, 03:46 AM
  2. Replies: 1
    Last Post: 08-19-2007, 03:55 AM
  3. small programming job VCPP / Object Oriented Programming
    By calgonite in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 01-04-2006, 11:48 PM
  4. Total newb to programming here... Question about the many programming languages. Ty!
    By tsubotakid1 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-05-2003, 10:32 AM

Tags for this Thread