Version 0 of Generating musical notes on windows

Updated 2012-01-02 10:34:47 by venks

2012-01-01 VI Minimalist Extension to generate musical notes on windows. I compiled this under mingw using:

  gcc -Id:/tools/tcl/8.6b2/include beep.c -shared -o beep.dll -Ld:/tools/tcl/8.6b2/lib/ -ltclstub86

Example Usage:

  load beep.dll
  beep 440.0 1000  ;# Generate the A4 (middle note) for 1 second

 /* beep.c
    Minimalist sound generation interface for windows.  Beep is *NOT* in the background.
    Author: Venkat Iyer <[email protected]>.   License: BSD 2-Clause.
 */


 #define USE_TCL_STUBS
 #include <windows.h>
 #include "tcl.h"

 static int 
 beepCmd (dummy, interp, objc, objv)
     ClientData dummy;
     Tcl_Interp *interp;
     int         objc;
     Tcl_Obj     *CONST objv[];
 {
   double freq;
   int duration;

   if (objc != 3) {
     Tcl_WrongNumArgs(interp, 1, objv, "freq duration");
     return TCL_ERROR;
   }
   if (Tcl_GetDoubleFromObj(interp, objv[1], &freq) != TCL_OK)
     return TCL_ERROR;

   if (Tcl_GetIntFromObj(interp, objv[2], &duration) != TCL_OK)
     return TCL_ERROR;

   Beep(freq,duration);
   return TCL_OK;
 }



 int Beep_Init (interp)
      Tcl_Interp *interp;
 {
   if (Tcl_InitStubs(interp, "8.4", 0) == NULL) {
     return TCL_ERROR;
   }
   if (Tcl_PkgRequire(interp, "Tcl", "8.4", 0) == NULL) {
     return TCL_ERROR;
   }
   if (Tcl_PkgProvide(interp, "beep", "0.7.5") == TCL_ERROR) {
     return TCL_ERROR;
   }
   Tcl_CreateObjCommand(interp, "beep", beepCmd, 
                        (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);

   return TCL_OK;
 }