I'm trying to write a program that plays tones through the PC Speaker on OSX and Linux but I can't find any way to either directly access the PC speaker port or an API to go through.

I know on Windows there is a function in windows.h, Beep(frequency, duration) which works well, how can I find something like that for Unix based platforms?