Professional Web Applications Themes

Making OS X make music programatically? - Mac Programming

I've Googled and poked around Apple's developer site a bit but have not been able to figure this out: what's the easiest to develop a program that plays programatically generated music on OS X? More specifically, I'm interested in programatically playing specific notes in a specific rhythm. I'm not interested in synthesizing my own sounds though if I can play the notes I want with something that sounds like real intsruments without attaching any external synthesizers that's better. My prefered language would be Common Lisp followed by Objective C or Java. But really any language would be fine. (What I'm ...

  1. #1

    Default Making OS X make music programatically?

    I've Googled and poked around Apple's developer site a bit but have
    not been able to figure this out: what's the easiest to develop a
    program that plays programatically generated music on OS X?

    More specifically, I'm interested in programatically playing specific
    notes in a specific rhythm. I'm not interested in synthesizing my own
    sounds though if I can play the notes I want with something that
    sounds like real intsruments without attaching any external
    synthesizers that's better. My prefered language would be Common Lisp
    followed by Objective C or Java. But really any language would be
    fine.

    (What I'm really looking for is something like the old PLAY or
    PLAYNOTE or whatever it was that I had in BASIC on my original IBM PC
    except with the ability to play more than one note at a time and in
    something other than a sine wave.)

    Any suggestions?

    -Peter

    --
    Peter Seibel com

    Lisp is the red pill. -- John Fraser, comp.lang.lisp
    Peter Guest

  2. #2

    Default Re: Making OS X make music programatically?

    Peter Seibel <com> wrote:
     

    QuickTime comes on your computer and it's got lots of musical
    instruments. It is very easy to ask it to produce the sound of one of
    those instruments at a desired pitch and duration. In my REALbasic book
    I even provide code for an elementary MIDI-file-playing app. m.

    --
    matt neuburg, phd = com, http://www.tidbits.com/matt/
    AppleScript: The Definitive Guide
    http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
    Read TidBITS! It's free and smart. http://www.tidbits.com
    matt Guest

  3. #3

    Default Re: Making OS X make music programatically?

    com (matt neuburg) writes:
     
    >
    > QuickTime comes on your computer and it's got lots of musical
    > instruments. It is very easy to ask it to produce the sound of one of
    > those instruments at a desired pitch and duration. In my REALbasic book
    > I even provide code for an elementary MIDI-file-playing app. m.[/ref]

    So, sorry to be so ignorant about Mac programming, is the QuickTime
    API fundamentally an Objective C API? Or C? C++? Or something else?

    -Peter

    --
    Peter Seibel com

    Lisp is the red pill. -- John Fraser, comp.lang.lisp
    Peter Guest

  4. #4

    Default Re: Making OS X make music programatically?

    Peter Seibel <com> wrote:
     

    It is a C API, which can be accessed through Objective C, C and C++.

    I believe there is also QuickTime for Java too, but I haven't tried
    that.

    Here is Apple's table of contents page for their QuickTime docs:
    http://developer.apple.com/doentation/QuickTime/QuickTime.html

    --
    com http://www.mts.net/~gbeggs1/
    Gerry Guest

  5. #5

    Default Re: Making OS X make music programatically?

    Here, Peter Seibel <com> wrote: 

    I have a Python framework that does this. There's a native code module
    which interfaces with the sound system, but it builds on OSX (talking
    to CoreAudio).

    <http://www.eblong.com/zarf/boodler/>

    You don't need any special hardware; fundamentally the tool reads in
    sound files and plays them back at your chosen pitch and volume.
    (Sound files can be AIFF or WAV, although you're relying on Python's
    WAV-reading module, I don't know how good it is.) It can handle any
    number of sound files and simultaneous notes, at least until your RAM
    runs out or your CPU starts thrashing.

    You'd wind up writing little Python objects like this:

    class MusicClass(Agent):
    def run(self):
    self.sched_note('piano.aiff', pitch1, vol1, 0.0)
    self.sched_note('piano.aiff', pitch2, vol2, 0.25)
    self.sched_note('piano.aiff', pitch3, vol3, 0.5)

    This plays three notes, spaced a quarter-second apart (the last
    argument is the time parameter). But you can also write a loop and
    call sched_note algorithmically, of course. Say, read values from a
    file and schedule the lot of them.

    And agents can also reschedule themselves, or other agents. So you
    could have a bit of code which generates a bunch of notes, goes to
    sleep for an interval, and then wakes up and does it again.

    Yes, I *do* think I've created something unbearably clever. :) I
    haven't used it as much as it deserves. But one guy contributed a
    Python file which plays a thunderstorm, based on some rain and thunder
    samples. It s in, builds up, and fades out over the course of
    sixty minutes. Astonishing.

    --Z

    "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
    *
    * Make your vote count. Get your vote counted.
    Andrew Guest

  6. #6

    Default Re: Making OS X make music programatically?

    In article <com>,
    Peter Seibel <com> wrote:
     

    C. There are lots of docs on QT, but IMHO its a hard API set to learn
    because its so big and the docs are a bit, um, not-so-great.
    Sean Guest

  7. #7

    Default Re: Making OS X make music programatically?

    com (Gerry) writes:
     
    >
    > It is a C API, which can be accessed through Objective C, C and C++.[/ref]

    Ah I see. Thanks. I found some sample code on Apple's site but the C
    example wouldn't build under OS X--a bunch of warnings about header
    files that don't exist in OS X, etc. I didn't try to hard but it
    clearly wasn't packaged with OS X in mind. Anyone know where I can
    find some up to date examples of QTMA in C?
     

    Yup. It actually looks pretty good--I got an sample of this that
    opened up in Xcode and was able to hack on it a bit. Unfortunately I'd
    really rather find a C example because I want to wrap it in a foreign
    function interface from Common Lisp.

    -Peter

    --
    Peter Seibel com

    Lisp is the red pill. -- John Fraser, comp.lang.lisp
    Peter Guest

  8. #8

    Default Re: Making OS X make music programatically?

    Here, Peter Seibel <com> wrote: 

    Ah. Then the Python app I mentioned is less useful to you than I
    thought. :)

    I suppose you could take my C module, reshape the interface from
    foreign-file-in-Python into foreign-file-in-Lisp, and then rewrite the
    Python note-scheduling code in Lisp. Probably not the easy option.

    --Z

    "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
    *
    * Make your vote count. Get your vote counted.
    Andrew Guest

  9. #9

    Default Re: Making OS X make music programatically?

    Andrew Plotkin <com> writes:
     
    >
    > Ah. Then the Python app I mentioned is less useful to you than I
    > thought. :)[/ref]

    I took a quick look before. Your app seemed more focused on playing
    loops of sampled sounds (i.e. "soundscapes") than discrete notes. But
    I'll take a closer look. Is there overlap between CoreAudio and the
    QuickTime APIs?
     

    Hmmm. I'll take a look at that. It might not be so bad.

    -Peter

    --
    Peter Seibel com

    Lisp is the red pill. -- John Fraser, comp.lang.lisp
    Peter Guest

  10. #10

    Default Re: Making OS X make music programatically?

    Here, Peter Seibel <com> wrote: 
    > >
    > > Ah. Then the Python app I mentioned is less useful to you than I
    > > thought. :)[/ref]
    >
    > I took a quick look before. Your app seemed more focused on playing
    > loops of sampled sounds (i.e. "soundscapes") than discrete notes.[/ref]

    The sampled sound could be a single instrument note (piano, string,
    etc) as easily as a clap of thunder or a birdcall. I created the
    system more for environmental sounds, but really it just schedules and
    plays sounds -- the output could as well be music.

    (Although I don't really have support for attack/decay of notes. It
    can extend a sound by looping a segment of it, but that doesn't give
    you much for instruments like piano.)
     

    Not at all, I'm afraid.
     
    >
    > Hmmm. I'll take a look at that. It might not be so bad.[/ref]

    Let me know if it's helpful.

    --Z

    "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
    *
    * Make your vote count. Get your vote counted.
    Andrew Guest

Similar Threads

  1. help making an music download site
    By deadbeatbum in forum Coldfusion - Getting Started
    Replies: 4
    Last Post: November 29th, 10:39 AM
  2. How to make a music player in Flash?
    By Kev in forum Macromedia Flash
    Replies: 1
    Last Post: May 10th, 04:36 AM
  3. Making music videos
    By Jesper in forum Macromedia Flash
    Replies: 0
    Last Post: January 5th, 12:29 PM
  4. Making Music Videos...
    By Dancin Crab webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 1
    Last Post: July 29th, 01:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139