1 /* stk path initialization */ 2 3 #include "stdlib.h" 4 #include "string.h" 5 // #include "instr.h" 6 #include "Stk.h" 7 #include "stkinit.h" 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 #include "xlisp.h" 14 15 #ifdef __cplusplus 16 } 17 #endif 18 19 using namespace Nyq; 20 21 const char *rawwave_path = NULL; 22 stk_init()23extern "C" void stk_init() 24 { 25 /* wherever the sinewave.raw file is, that will become 26 * the rawwave_path for STK 27 */ 28 char filename[32]; 29 strcpy(filename, "rawwaves"); 30 filename[8] = os_pathchar; 31 filename[9] = '\0'; 32 strcat(filename, "sinewave.raw"); 33 /* find_in_xlisp_path returns const char *, but we're going to 34 * alter it to get just the path, so we have to coerce out the 35 * const attribute 36 */ 37 char *path = (char *) find_in_xlisp_path(filename); 38 if (!path) { 39 errputstr("\nERROR: Could not find sinewave.raw in rawwaves. Something is wrong with the installation or configuration.\n\n"); 40 rawwave_path = ""; 41 return; 42 } 43 /* remove sinewave.raw to get just the path */ 44 path[strlen(path) - 12] = '\0'; 45 rawwave_path = strcpy((char *) malloc(strlen(path) + 1), path); /* keep a copy */ 46 /* note: rawwave_path is allocated but never freed */ 47 Stk::setRawwavePath(path); // PJM 48 } 49 50 51