Re: Beep ( duration, frequency )
Re: Beep ( duration, frequency )
- Subject: Re: Beep ( duration, frequency )
- From: Jens Alfke <email@hidden>
- Date: Wed, 23 Sep 2015 17:40:49 -0700
> On Sep 23, 2015, at 4:41 PM, Raglan T. Tiger <email@hidden> wrote:
>
> I want code that is this simple on Windows:
>
> DWORD freq = 587;
> if(!something) freq = 659;
> if(another) freq = 523;
> Beep(freq, 150);
No, there’s no simple API for this. This API in Windows is a relic of the early PC days when getting any kind of audio out was amazing, even if it was crap square-waves. I remember demos on the Apple II that would use APIs like this to play “Happy Birthday” or something.
(It’s kind of like you’re asking “where’s the Cocoa API to fill the whole screen with red”.)
Nowadays, if you want to write code to create audio, people’s expectations are a bit higher :) and the APIs are correspondingly more complex. OS X is the premier pro audio platform so it’s been designed to do serious audio really well. But the APIs aren’t easy to learn.
If you want to fool around and write a bit of code to play a tune for fun, I think CoreMIDI might not be too hard. The good thing is there’s a full set of General MIDI instruments built into the OS, so you can play the tune on a decent sounding piano or organ or whatever.
There are also 3rd party cross-platform APIs for “trackers” that do really high level stuff where you just create a file describing a few notes and they take care of the rest. I’m not familiar with the details, though.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden