MusicKit  0.0.0
errors.h
00001 /*
00002   $Id$
00003   Defined In: The MusicKit
00004 
00005   Description:
00006     This file has trace codes as well as error codes used by the MusicKit.
00007 
00008   Original Author: David Jaffe
00009 
00010   Copyright (c) 1988-1992, NeXT Computer, Inc.
00011   Portions Copyright (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT
00012   Portions Copyright (c) 1994 Stanford University
00013   Portions Copyright (c) 1999-2005 The MusicKit Project.
00014 */
00015 #ifndef __MK_errors_H___
00016 #define __MK_errors_H___
00017 
00018 #import <Foundation/Foundation.h>
00019 
00042 #define MK_TRACEORCHALLOC 1
00043 
00044 #define MK_TRACEPARS 2
00045 
00046 #define MK_TRACEDSP 4
00047 
00048 #define MK_TRACEMIDI 8
00049 
00050 #define MK_TRACEPREEMPT 16
00051 
00052 #define MK_TRACESYNTHINS  32
00053 
00054 #define MK_TRACESYNTHPATCH 64
00055 
00056 #define MK_TRACEUNITGENERATOR 128
00057 
00058 #define MK_TRACECONDUCTOR 256
00059 
00060 #define MK_TRACEDSPARRAYS 512
00061 
00403 extern unsigned MKSetTrace(int traceCode);
00404 
00424 extern unsigned MKClearTrace(int traceCode);
00425 
00445 extern BOOL MKIsTraced(int traceCode);
00446 
00466 extern void MKSetScorefileParseErrorAbort(int threshholdCount);
00467 
00505 extern void MKSetErrorProc(void (*errProc)(NSString *msg));
00506 
00532 extern void MKError(NSString *msg);
00533 
00563 extern void MKSetErrorStream(NSMutableData *aStream);
00564 
00571 extern NSMutableData *MKErrorStream(void);
00572 
00573 /* Errors generated by the MusicKit. You don't normally generate these 
00574  * yourself. */
00575 
00576 #define MK_ERRORBASE 4000    /* 1000 error codes for us start here */
00577 
00586 typedef enum _MKErrno {
00587     // <b>GENERAL ERRORS</b>
00589     MK_musicKitErr = MK_ERRORBASE,
00592     MK_machErr,
00593 
00594     // <b>REPRESENTATION ERRORS</b>General purpose errors dealing with music representation.    
00596     MK_cantOpenFileErr,
00598     MK_cantCloseFileErr,
00600     MK_outOfOrderErr,           /* Scorefile parsing/writing error */
00603     MK_samplesNoResampleErr,
00605     MK_noMoreTagsErr,
00608     MK_notScorefileObjectTypeErr,
00609     
00610     /* Synthesis errors */    
00612     MK_orchBadFreeErr,
00614     MK_synthDataCantClearErr,   /* MKSynthData errors */ 
00616     MK_synthDataLoadErr,
00618     MK_synthDataReadonlyErr,
00620     MK_synthInsOmitNoteErr,     /* MKSynthInstrument errors */
00622     MK_synthInsNoClass,
00624     MK_ugLoadErr,               /* MKUnitGenerator errors. */
00626     MK_ugBadArgErr,
00628     MK_ugBadAddrPokeErr,
00630     MK_ugBadDatumPokeErr,
00632     MK_ugOrchMismatchErr,
00634     MK_ugArgSpaceMismatchErr,
00637     MK_ugNonAddrErr,
00640     MK_ugNonDatumErr,
00641 
00642     /* Scorefile Language Errors. */
00644     MK_sfBadExprErr,     /* Illegal constructs */
00646     MK_sfBadDefineErr,
00648     MK_sfBadParValErr,
00650     MK_sfNoNestDefineErr,
00651 
00653     MK_sfBadDeclErr,     /* Missing constructs */
00655     MK_sfMissingStringErr,
00657     MK_sfBadNoteTypeErr,
00659     MK_sfBadNoteTagErr,
00661     MK_sfMissingBackslashErr,
00663     MK_sfMissingSemicolonErr,
00665     MK_sfUndeclaredErr,
00667     MK_sfBadAssignErr,
00669     MK_sfBadIncludeErr,
00671     MK_sfBadParamErr,
00673     MK_sfNumberErr,
00675     MK_sfStringErr,
00677     MK_sfGlobalErr,
00679     MK_sfCantFindGlobalErr,
00680     
00682     MK_sfMulDefErr, /* Duplicate constructs */
00684     MK_sfDuplicateDeclErr,
00685 
00687     MK_sfNotHereErr,
00689     MK_sfWrongTypeDeclErr,
00691     MK_sfBadHeaderStmtErr,
00693     MK_sfBadStmtErr,
00694 
00696     MK_sfBadInitErr,
00698     MK_sfNoTuneErr,
00700     MK_sfNoIncludeErr,
00702     MK_sfCantFindFileErr,
00704     MK_sfCantWriteErr,
00706     MK_sfOutOfOrderErr,
00708     MK_sfUnmatchedCommentErr,
00710     MK_sfInactiveNoteTagErr,
00712     MK_sfCantFindClass,
00714     MK_sfBoundsErr, 
00716     MK_sfTypeConversionErr,
00718     MK_sfReadOnlyErr,
00720     MK_sfArithErr,
00722     MK_sfNonScorefileErr,
00724     MK_sfTooManyErrorsErr,
00725     
00726     /* Unit generator library errors. */
00728     MK_ugsNotSetRunErr,
00730     MK_ugsPowerOf2Err,
00732     MK_ugsNotSetGetErr,
00733 
00734     /* Synth patch library errors. */
00736     MK_spsCantGetMemoryErr,
00739     MK_spsSineROMSubstitutionErr,
00741     MK_spsInvalidPartialsDatabaseKeywordErr, 
00743     MK_spsOutOfRangeErr,
00747     MK_spsCantGetUGErr,
00748 
00749     /* Errors added in Release 3.0 */
00751     MK_synthDataCantReadDSPErr,
00753     MK_dspMonitorVersionError,
00754     /* End marker */
00755     MK_highestErr,
00756     /* Reserved from here until MK_maxErr */
00757     MK_maxErr = (MK_ERRORBASE + 1000)
00758 } MKErrno;
00759 
00760 #define MK_sfNonAsciiErr MK_sfNonScorefileErr /* For backwards compatibility */
00761 
00762 
00763 /* The remaining functions are the MusicKit's own internal error handling
00764  * functions. Normally, you don't call these functions.  However, if you 
00765  * need to raise an error with a MusicKit error code, you call MKErrorCode().  
00766  */
00767 
00768 extern void MKErrorCode(int errorCode, ...); 
00769 /* Calling sequence like printf, but first arg is musickit error code instead
00770  * of formating info, the second arg is a formating NSString derived from the string in
00771  * /Local/Library/MusicKit/Languages/<language>.lproj/Localized.strings. 
00772  *
00773  * It's the caller's responsibility that the expansion of the arguments 
00774  * using sprintf doesn't exceed the size of the error buffer (_MK_ERRLEN). 
00775  * Fashions the error message and sends it to MKError(). 
00776  */
00777 
00778 #define _MK_ERRLEN 2048
00779 
00780 /* 
00781  * These functions are for accessing MusicKit's localized strings. 
00782  */ 
00783 extern NSBundle *_MKErrorBundle(void); 
00784 /* 
00785  * MusicKit bundle for selected language in 
00786  * /usr/local/lib/MusicKit/Languages, if found.  
00787  */
00788 extern NSString *_MKErrorStringFile(void); 
00789 /* Returns "Localized" if _MKErrorBundle() returns non-null */
00790 
00791 #endif