download errors.h
Language: C
Copyright: (c) 1988-1992, NeXT Computer, Inc. (c) 1999-2005 The MusicKit Project. (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT (c) 1994 Stanford University
LOC: 103
Project Info
The MusicKit(musickit)
Server: SourceForge
Type: cvs
...sicKit\Frameworks\MusicKit\
   _ArielQP.h
   _DSPMK.h
   _error.h
   _midi.h
   _MKAppProxy.h
   _MKAppProxy.m
   _MKNameTable.h
   _MKNameTable.m
   _MKParameter.h
   _MTCHelper.h
   _MTCHelper.m
   _musickit.h
   _noteRecorder.h
   _OrchloopbeginUG.h
   _OrchloopbeginUG.m
   _ParName.h
   _ParName.m
   _scorefile.h
   _ScorefileVar.h
   _ScorefileVar.m
   _SharedSynthInfo.h
   _SharedSynthInfo.m
   _synthElementMethods.m
   _time.h
   ArielQP.h
   ArielQP.m
   classFuncs.h
   ConductorPrivate.h
   dsp_types.h
   DSPSerialPortDevice.h
   dspwrap.h
   EnvelopePrivate.h
   equalTempered.m
   errors.h
   fastFFT.c
   fastFFT.h
   GNUmakefile.postamble
   GNUmakefile.preamble.in
   InstrumentPrivate.h
   keynums.h
   libMusicKit.def
   Localized.strings
   make.sh
   Makefile.postamble
   Makefile.preamble
   midi_spec.h
   midifile.h
   midifile.m
   MidiPrivate.h
   midiTranslation.h
   MKConductor.h
   MKConductor.m
   MKConductorDelegate.h
   MKDeviceStatus.h
   MKEnvelope.h
   MKEnvelope.m
   MKFilePerformer.h
   MKFilePerformer.m
   MKFileWriter.h
   MKFileWriter.m
   MKInstrument.h
   MKInstrument.m
   MKMidi.h
   MKMidi.m
   MKMixerInstrument.h
   MKMixerInstrument.m
   MKMTCPerformer.h
   MKMTCPerformer.m
   MKNote.h
   MKNoteFilter.h
   MKNoteFilter.m
   MKNoteReceiver.h
   MKNoteReceiver.m
   MKNoteSender.h
   MKNoteSender.m
   MKOrchestra.h
   MKPart.m
   MKPartials.h
   MKPartials.m
   ...tialsWaveshapingTable.m
   MKPartPerformer.h
   MKPartPerformer.m
   MKPartRecorder.h
   MKPartRecorder.m
   MKPatch.h
   MKPatch.m
   MKPatchConnection.h
   MKPatchConnection.m
   MKPatchEntry.h
   MKPatchEntry.m
   MKPatchTemplate.h
   MKPatchTemplate.m
   MKPerformer.h
   MKPerformer.m
   MKPerformerDelegate.h
   MKPlugin.h
   MKSamplerInstrument.h
   MKSamplerInstrument.m
   MKSamples.h
   MKScore.h
   MKScore.m
   MKScorefileObject.h
   MKScorefilePerformer.h
   MKScorefilePerformer.m
   MKScorefileWriter.m
   MKScorePerformer.h
   MKScorePerformer.m
   MKScoreRecorder.h
   MKScoreRecorder.m
   MKSynthData.h
   MKSynthData.m
   MKSynthInstrument.h
   MKSynthPatch.h
   MKTimbre.h
   MKTimbre.m
   MKTuningSystem.h
   MKTuningSystem.m
   MKUnitGenerator.h
   MKUnitGenerator.m
   MKWaveTable.h
   MKWaveTable.m
   mtcMidi.m
   mtcMidiPrivate.m
   MusicKit-Info.plist
   MusicKit.h
   MusicKitConfig.h.in
   names.h
   noDVal.h
   noteDispatcherMethods.m
   NotePrivate.h
   noteRecorderCFuncs.m
   noteRecorderMethods.m
   orch.h
   OrchestraPrivate.h
   OrchloopbeginUG.h
   OrchloopbeginUG.m
   orchloopbeginUGInclude.m
   params.h
   parNames.m
   partialsDBInclude.m
   PartialsPrivate.h
   PartPerformerPrivate.h
   PartPrivate.h
   PartRecorderPrivate.h
   PatchTemplatePrivate.h
   PB.project
   PerformerPrivate.h
   pitches.h
   platform.make
   ...efilePerformerPrivate.h
   ScorePerformerPrivate.h
   ScorePrivate.h
   ScoreRecorderPrivate.h
   SynthDataPrivate.h
   synthElementCFuncs.m
   synthElementMethods.m
   SynthInstrumentPrivate.h
   SynthPatchList.h
   SynthPatchList.m
   SynthPatchPrivate.h
   timetagInclude.m
   timeunits.h
   tokenNames.m
   tokens.h
   trigonometry.c
   trigonometry.h
   TuningSystemPrivate.h
   UnitGeneratorPrivate.h
   win32-def.top
   writeBinary.m
   writeMidi.m
   writeScore.m

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
/*
  $Id: errors.h,v 1.14 2005/05/30 03:28:19 leighsmith Exp $
  Defined In: The MusicKit

  Description:
    This file has trace codes as well as error codes used by the MusicKit.

  Original Author: David Jaffe

  Copyright (c) 1988-1992, NeXT Computer, Inc.
  Portions Copyright (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT
  Portions Copyright (c) 1994 Stanford University
  Portions Copyright (c) 1999-2005 The MusicKit Project.
*/
#ifndef __MK_errors_H___
#define __MK_errors_H___

#import <Foundation/Foundation.h>

/*!
  @file errors.h
 */

/*!
  @defgroup Tracing Trouble-shoot the MusicKit.
  */
/*!
  @brief Trace Constants
 
  To enable a set of messages, you pass a trace code to the
  <b>MKSetTrace()</b> function.  You can enable more than one set with a
  single function call by bitwise-or'ing the codes.   Clearing a trace is
  done similarly, by passing codes to <b>MKClearTrace()</b>.  The
  <b>MKIsTraced()</b> function returns YES or NO as the argument code is
  or isn't currently traced.  These functions should only be used while
  you're debugging and fine-tuning your application.  
 
  For more information on the constants and their meaning, see
  the trace function documentation.
 */
/*! DSP (MKOrchestra) resource allocation */
#define MK_TRACEORCHALLOC 1
/*! Application-defined parameters, when first encountered. */
#define MK_TRACEPARS 2
/*! DSP manipulation */
#define MK_TRACEDSP 4
/*! MIDI in/out/time warnings */
#define MK_TRACEMIDI 8
/*! MKSynthPatch preemption */
#define MK_TRACEPREEMPT 16
/*! MKSynthInstrument mechanations */
#define MK_TRACESYNTHINS  32
/*! MKSynthPatch library messages */
#define MK_TRACESYNTHPATCH 64
/*! MKUnitGenerator library messages */
#define MK_TRACEUNITGENERATOR 128
/*! MKConductor time setting messages */
#define MK_TRACECONDUCTOR 256
/*! DSP array-setting messages */
#define MK_TRACEDSPARRAYS 512

/*!
  @brief Turns on specified trace bit.

  To aid in debugging, the MusicKit is peppered with activity-tracing
  messages that print to <b>stderr</b> if but asked.The trace messages are
  divided into eight categories, represented by the following codes:
     
   <b>	Code	Value	Meaning</b>
   	MK_TRACEORCHALLOC	1	DSP resource allocation
   	MK_TRACEPARS	2	Application-defined parameters
   	MK_TRACEDSP	4	DSP manipulation
   	MK_TRACEMIDI	8	MIDI manipulation
   	MK_TRACEPREEMPT	16	MKSynthPatch preemption
   	MK_TRACESYNTHINS	32	MKSynthInstrument mechanations
     	MK_TRACESYNTHPATCH	64	MKSynthPatch library messages
     	MK_TRACEUNITGENERATOR	128	MKUnitGenerator library messages
     	MK_TRACECONDUCTOR	256	Conductor time setting messages
     	MK_TRACEDSPARRAYS	512	DSP array-setting messages
     
   To enable a set of messages, you pass a trace code to the
  <b>MKSetTrace()</b> function.  You can enable more than one set with a
  single function call by bitwise-or'ing the codes.   Clearing a trace is
  done similarly, by passing codes to <b>MKClearTrace()</b>.  The
  <b>MKIsTraced()</b> function returns YES or NO as the argument code is
  or isn't currently traced.  These functions should only be used while
  you're debugging and fine-tuning your application.  
     
   You should note that the codes given above are <b>#define</b>'d as
  their corresponding values and so can be used only when you call one of
  these functions within an application - they can't be used in a symbolic
  debugger such as <b>gdb</b>.  For this reason, the integer values
  themselves are also given; you must use the integer values to enable and
  disable a set of trace messages from within a debugger.  
     
   The debug flags are listed below with some of the possible messages
  you may see when using them.   MKNote that not all possible messages are
  included.
   
   <b>MK_TRACEORCHALLOC</b>
   The Orchestra allocation messages inform you of DSP resource
  allocation.  The most important of these have to do with MKSynthPatch,
  MKUnitGenerator, and Synth Data allocation.  When a MKSynthPatch is
  allocated, one of the following messages is printed:
     
  <tt>"allocSynthPatch returns <i>MKSynthPatchClass_SynthPatchId</i></tt>"
  <tt>"allocSynthPatch building <i>MKSynthPatchClass_SynthPatchId</i>..."</tt>
  <tt>"allocSynthPatch can't allocate <i>MKSynthPatchClass</i>"</tt>
     
   The first of these signifies that an appropriate MKSynthPatch object
  was found.  The second means that a new object was created.  The third
  denotes an inability to construct the requested object because of
  insufficient DSP resources.  As a MKSynthPatch's MKUnitGenerators are
  connected, the following message is printed:
   
   	<tt>"allocSynthPatch connectsContents of <i>MKSynthPatchClass_SynthPatchId</i></tt>"
   
   When a MKSynthPatch is deallocated and when it's freed, respectively,
  the following are printed:
   
   	<tt>"Returning <i>MKSynthPatchClass_SynthPatchId</i> to avail
  pool."</tt>
   <tt>	"Freeing <i>MKSynthPatchClass_SynthPatchId</i>"</tt>
     
   A MKUnitGenerator can be allocated without reference to other
  MKUnitGenerators, or it can be positioned before, after, or between
  other objects.  Examples:
   
   <tt>"allocUnitGenerator looking for a <i>UGClass</i>."</tt>
   <tt>"allocUnitGenerator looking for a <i>UGClass</i> before <i>UGClass_UGid</i>"</tt>
   <tt>"allocUnitGenerator looking for a <i>UGClass</i> after <i>UGClass_UGid</i>"</tt>
   <tt>"allocUnitGenerator looking for a <i>UGClass</i> after <i>UGClass_UGid</i> and before <i>UGClass_UGid</i>"</tt>
   
   If a new MKUnitGenerator is built, the addresses (relocation or
  &ldquo;Reloc&rdquo;) and sizes (resources or &ldquo;Reso&rdquo;) of the
  allocated DSP resources are given:
   
  <tt>"Reloc: pLoop <i>address</i>, xArg <i>address</i>, yArg <i>address</i>, lArg <i>address</i>,</tt>
   <tt>		xData <i>address</i>, yData <i>address</i>, pSubr <i>address</i>"</tt>
   <tt>	"Reso: pLoop <i>size</i>, xArg <i>size</i>, yArg <i>size</i>, lArg <i>size</i>, xData <i>size</i>,</tt>
   <tt>		yData <i>size</i>, pSubr <i>size</i>, time <i>orchestraLoopDuration</i>"</tt>
   
   As the MKUnitGenerator search (or allocation) succeeds or fails, one
  of the following is printed:
   
   <tt>"allocUnitGenerator returns</tt> <tt><i>UGClass_UGid</i>"</tt>
   <tt>"Allocation failure: Can't allocate before specified ug."</tt>
   <tt>"Allocation failure. DSP error."</tt>
   <tt>"Allocation failure. Not enough computeTime."</tt>
   <tt>"Allocation failure. Not enough <i>memorySegment</i> memory."</tt>
   
   Allocating a MKSynthData generates the first and then either the second
  or third of these messages:
   
  <tt>"allocSynthData: looking in segment <i>memorySegment</i> for size <i>size</i>."</tt>
  <tt>"allocSynthData returns <i>memorySegment</i> address of length <i>size</i>."</tt>
  <tt>"Allocation failure: No more offchip data memory."</tt>
     
   When you install shared data, the following is printed: 
     
   <tt>"Installing shared data <i>keyObjectName</i> in segment <i>memorySegment</i>."</tt>
   
  During allocation of MKUnitGenerators and MKSynthDatas, existing
  resources might be compacted.  Compaction can cause free
  MKUnitGenerators and unreferenced shared data to be garbage collected,
  and active MKUnitGenerators to be relocated:
   
   <tt>"Compacting stack."</tt>
   <tt>"Copying arguments."</tt>
   <tt>"Copying p memory."</tt>
   <tt>"Garbage collecting freed unit generator UGClass_UGid"</tt>
   <tt>"Moving <i>UGClass_UGid</i>."</tt>
   <tt>"NewReloc: pLoop <i>address</i>, xArg <i>address</i>, yArg <i>address</i>, lArg <i>address</i>."</tt>
   <tt>"Garbage collecting unreferenced shared data."</tt>
   <tt>"No unreferenced shared data found."</tt>
   
   <b>MK_TRACEDSP</b>
   The DSP-trace messages give you details of how the DSP is being used.
   For example, when a MKUnitGenerator is allocated, the following message
  is printed among the search-build-return messages given above:
     
   <tt>"Loading <i>UGClass_UGid</i> as UG <i>ugNum</i>."</tt>
     
   Unit Generators are given integer numbers for debugging purposes. 
  These numbers simply count up.  Numbers are not recycled.   Thus, an
  example of an actual "Loading..." message would be:
   
   <tt>"Loading Out1aUGx_0x43100 as UG3."</tt>
   
   The most important of the DSP-trace messages reflect the setting of a
  MKUnitGenerator's memory arguments.  A memory argument takes either an
  address value or a data value.  When you set an address-valued argument,
  the following is printed:
   
   <tt>"Setting <i>argName</i> of <i>UGugNum_Class</i> to <i>memSegment memNum</i> (0x<i>address</i>)."</tt>
   
   <i>argName</i> is the argument name in the source DSP (.asm) file.  
     
  A data-valued arguments is either a 24-bit or 48-bit word; separate
  functions (and cover methods) are defined for setting the two sizes of
  arguments.  The following messages are printed as the
  &ldquo;correct&rdquo; function is used to set an argument's value:
     
   <tt>	"Setting <i>argName</i> of <i>UGugNum_Class</i> to datum <i>value</i>."</tt>
   <tt>	"Setting <i>argName</i> of <i>UGugNum_Class</i> to long: <i>hi wd value</i> and <i>low wd value</i>."</tt>
   
   A 24-bit argument that's set with the long-setting function and vice
  versa produce these messages, respectively:
   
   <tt>	"Setting (L-just, 0-filled) <i>argName</i> of <i>UGugNum_Class</i> to datum <i>value</i>."</tt>
   <tt>	"Setting <i>argName</i> of <i>UGugNum_Class</i> to: <i>value</i>"</tt>
   
   If an argument is declared as optimizable, the following is printed
  when the optimization obtains:
   
   "<tt>Optimizing away poke of <i>argName</i> of <i>UGugNum_Class</i>."</tt>
   
   MKSynthData allocation doesn't actually involve the DSP; the address of
  the memory that will be allocated on the DSP is computed, but the state
  of the DSP itself doesn't change until data is loaded into the
  MKSynthData:
   
  <tt>"Loading array into <i>memorySegment</i> <i>memNum</i> [<i>lowAddr-highAddr</i>]."</tt>
  <tt>"Loading constant value into <i>memorySegement</i> <i>memNum</i> [<i>lowAddr-highAddr</i>]."</tt>
   
   Here <i>memNum</i> is an integer assigned for debugging purposes. 
  <i>memorySegment</i> if one of xData, yData, xPatch or yPatch.  When an
  array is loaded, the loaded values are printed if <b>MK_DSPTRACEARRAYS</b> has been enabled.  Example:
   
   <tt>"Loading array into <i>xPatch</i> <i>4</i> [<i>0x412-0x418</i>]."</tt>
   
   Clearing a SynthData's memory produces the following:
     
   <tt>	"Clearing <i>memorySegment</i> <i>memNum</i> [<i>lowAddr-highAddr</i>]."</tt>
   
   DSP manipulations that are performed as an atomic unit are bracketed
  by the messages:
   
   <tt>"&lt;&lt;&lt; Begin orchestra atomic unit "</tt>
   <tt>"end orchestra atomic unit.&gt;&gt;&gt; "</tt>
   
   <b>MK_TRACESYNTHINS</b>
   The MKSynthInstrument messages are printed when a MKSynthInstrument
  object receives MKNotes, and as it finds or creates MKSynthPatches to
  realize these MKNotes.  
   
   If a received MKNote's note tag is active or inactive, or if its note
  type is mute, the following are printed, respectively:
     
   <tt>"MKSynthInstrument receives note for active notetag stream <i>noteTag</i> at time <i>time</i>."</tt>
   <tt>"MKSynthInstrument receives note for new notetag stream <i>noteTag</i> at time <i>time</i>."</tt>
   <tt>"MKSynthInstrument receives mute MKNote at time <i>time</i>."</tt>
     
   MKSynthPatch allocation is noted <i>only</i> if the MKSynthInstrument
  is in auto-allocation mode:
   
   <tt>"MKSynthInstrument creates patch <i>synthPatchId</i> at time <i>time</i> for tag <i>noteTag</i>."</tt>
   
   However, MKSynthPatch reuse and preemption produce the following
  messages, respectively, regardless of the MKSynthInstrument's allocation
  mode:
   
   <tt>"MKSynthInstrument uses patch <i>synthPatchId</i> at time <i>time</i> for tag <i>noteTag</i>."</tt>
   <tt>"MKSynthInstrument preempts patch <i>synthPatchId</i> at time <i>time</i> for tag <i>noteTag</i>."</tt>
   
   If a MKSynthPatch of the correct MKPatchTemplate isn't found and can't
  be allocated, an alternative is used; barring that, the MKSynthInstrument
  omits the MKNote:
   
   <tt>	"No patch of requested template was available. Using alternative template."</tt>
   <tt>	"MKSynthInstrument omits note at time <i>time</i> for tag <i>noteTag</i>."</tt>
   
   <b>MK_TRACEPREEMPT</b>
   These are a subset of the MKSynthInstrument messages that deal with
   MKSynthPatch preemption and MKNote omission:
   
   <tt>	"MKSynthInstrument preempts patch <i>synthPatchId</i> at time <i>time</i> for tag noteTag."</tt>
   <tt>	"MKSynthInstrument omits note at time <i>time</i> for tag <i>noteTag</i>.</tt>
   
   <b>MK_TRACEMIDI</b>
   The following are printed as ill-formed MKNote objects are converted
  to MIDI messages: 
   
   <tt>"MKNoteOn missing a noteTag at time <i>time</i>"</tt>
   <tt>"MKNoteOff missing a note tag at time <i>time</i>"</tt>
   <tt>"MKNoteOff for noteTag which is already off at time <i>time</i>"</tt>
   <tt>"PolyKeyPressure with invalid noteTag or missing keyNum: time <i>time</i>;"</tt>
   
   <b>MK_TRACESYNTHPATCH</b>
   This referes to MKSynthPatch Library messages.  When debugging
  MKSynthPatches, you may also want to turn on TRACEUNITGENERATOR.
     
   <b>MK_TRACEUNITGENERATOR</b>
   This refers to MKUnitGenerator library messages.  f the sine ROM,
  which resides in Y memory, is requested by a MKUnitGenerator's X-space
  memory argument, the following appears:
   
   <tt>"X-space oscgaf cannot use sine ROM at time <i>time</i>."</tt> 
   
   If insufficient DSP memory is available to load a WaveTable of the
  requested length, the following is printed:
   
  <tt>"Insufficient wavetable memory at time <i>time</i>. Using smaller table length <i>newLength</i>."</tt>
     
   <b>MK_TRACEPARS</b>
   By tracing MK_TRACEPARS, you're informed when an application-defined
  parameter is created:
   
   <tt>"Adding new parameter <i>parameterName</i>"</tt>
     
   <b>MK_TRACECONDUCTOR</b>
   By tracing MK_TRACECONDUCTOR, a message giving the time in seconds is
  printed whenever time advances:
   
   <tt>"t 4.1"</tt>
  @param  traceCode is an int.
  @return Return the value of the new (cumulative) trace code.
  @ingroup Tracing
*/
extern unsigned MKSetTrace(int traceCode);

/*!
  @brief Turns off specified trace bit.

  To aid in debugging, the MusicKit is peppered with activity-tracing
  messages that print to <b>stderr</b> if but asked.The trace messages are
  divided into eight categories, represented by the following codes:
     
   <b>	Code	Value	Meaning</b>
   	MK_TRACEORCHALLOC	1	DSP resource allocation
   	MK_TRACEPARS	2	Application-defined parameters
   	MK_TRACEDSP	4	DSP manipulation
   	MK_TRACEMIDI	8	MIDI manipulation
   	MK_TRACEPREEMPT	16	MKSynthPatch preemption
   	MK_TRACESYNTHINS	32	MKSynthInstrument mechanations
     	MK_TRACESYNTHPATCH	64	MKSynthPatch library messages
     	MK_TRACEUNITGENERATOR	128	MKUnitGenerator library messages
     	MK_TRACECONDUCTOR	256	Conductor time setting messages
     	MK_TRACEDSPARRAYS	512	DSP array-setting messages
     
   To enable a set of messages, you pass a trace code to the
  <b>MKSetTrace()</b> function.  You can enable more than one set with a
  single function call by bitwise-or'ing the codes.   Clearing a trace is
  done similarly, by passing codes to <b>MKClearTrace()</b>.  The
  <b>MKIsTraced()</b> function returns YES or NO as the argument code is
  or isn't currently traced.  These functions should only be used while
  you're debugging and fine-tuning your application.  
     
  @param  traceCode is an int.
  @return Return the value of the new (cumulative) trace code. 
  @see MKSetTrace().
  @ingroup Tracing
*/
extern unsigned MKClearTrace(int traceCode);

/*!
  @brief Returns whether specified trace bit is on.

  To aid in debugging, the MusicKit is peppered with activity-tracing
  messages that print to <b>stderr</b> if but asked.The trace messages are
  divided into eight categories, represented by the following codes:
     
   <b>	Code	Value	Meaning</b>
   	MK_TRACEORCHALLOC	1	DSP resource allocation
   	MK_TRACEPARS	2	Application-defined parameters
   	MK_TRACEDSP	4	DSP manipulation
   	MK_TRACEMIDI	8	MIDI manipulation
   	MK_TRACEPREEMPT	16	MKSynthPatch preemption
   	MK_TRACESYNTHINS	32	MKSynthInstrument mechanations
     	MK_TRACESYNTHPATCH	64	MKSynthPatch library messages
     	MK_TRACEUNITGENERATOR	128	MKUnitGenerator library messages
     	MK_TRACECONDUCTOR	256	Conductor time setting messages
     	MK_TRACEDSPARRAYS	512	DSP array-setting messages
     
   To enable a set of messages, you pass a trace code to the
  <b>MKSetTrace()</b> function.  You can enable more than one set with a
  single function call by bitwise-or'ing the codes.   Clearing a trace is
  done similarly, by passing codes to <b>MKClearTrace()</b>.  The
  <b>MKIsTraced()</b> function returns YES or NO as the argument code is
  or isn't currently traced.  These functions should only be used while
  you're debugging and fine-tuning your application.  

  @param  traceCode is an int.
  @return Returns a BOOL.
  @see MKSetTrace().
  @ingroup Tracing
*/
extern BOOL MKIsTraced(int traceCode);

/*!
  @defgroup ErrorFns Handle MusicKit errors.
 */

/*!
  @brief Set the scorefile error threshhold, the number of parser errors to abort on.

  As a scorefile is read into an application, errors sometimes occur: 
  Time tags may be out of order; undeclared or mistyped names may pop up
  in the middle of the file.  The MusicKit keeps a count of these errors
  for each file it reads.  If the error count for a particular file
  exceeds the threshhold set as the <i>threshholdCount</i> argument to
  this function, the scorefile parsing is aborted and the file is closed
  (if the MusicKit opened it itself).  The default limit is ten
  errors.
  @param  threshholdCount is an int. To abort on the first error, 
  pass 1 as the argument. To never abort, pass MAXINT as the argument.
  @ingroup ErrorFns
*/
extern void MKSetScorefileParseErrorAbort(int threshholdCount);

/*!
  @brief Sets function to be used when MKError() and MKErrorCode() are called.

  These functions define the MusicKit's error handling mechanism. 
  <b>MKError()</b> is used to signal an error.  It calls the current Music
  Kit error function, set through <b>MKSetErrorProc()</b>, to which it
  passes the single argument <i>msg</i>.  If the user hasn't declared an
  error function, then <i>msg</i> is written to the MusicKit error
  stream, as set through <b>MKSetErrorStream()</b>.  The default error
  stream is open to <b>stderr</b>. <b>MKErrorStream()</b> returns a
  pointer to the current MusicKit error stream.  Note that you
  <i>shouldn't</i> use <b>stderr</b> as the error stream if you're running
  a separate-threaded performance.
   
   A number of error codes represented by integer constants are provided
  by the MusicKit and listed in <b>&lt;MusicKit/errors.h&gt;</b>.  If the
  MusicKit itself generates an error, the global system variable
  <b>errno</b> is set to one of these error codes.  If you call
  <b>MKError()</b> from your application, <b>errno</b> isn't set. 
  
  @param errProc is a pointer to a function taking an NSString instance.
  @ingroup ErrorFns
*/
 /* Due to the requirements of real-time The MusicKit uses a different 
    mechanism from that of the Application Kit to do error handling. The 
    following functions implement that mechanism. 

    Note that it is not guaranteed to be safe to NS_RAISE an error in any 
    performance-oriented class. 
   */
extern void MKSetErrorProc(void (*errProc)(NSString *msg));
    /*  
       If errProc is NULL, uses the default error proc, which writes to the 
       MusicKit error NSMutableData (see MKSetErrorStream()). 
       errProc takes one string argument. 
       When the *errProc is called in response to a MusicKit error, errno is 
       set to the MKErrno corresponding to the error. If *errProc is invoked in
       response to an application-defined error (see MKError), errno is not
       set; it's up to the application to set it, if desired. 
       */


/*!
  @brief Calls the user's error procedure (aka function, set with MKSetErrorProc), if any, with 
         one argument, the message. Otherwise, writes the message on the MusicKit error stream.

  These functions define the MusicKit's error handling mechanism. 
  <b>MKError()</b> is used to signal an error.  It calls the current Music
  Kit error function, set through <b>MKSetErrorProc()</b>, to which it
  passes the single argument <i>msg</i>.  If the user hasn't declared an
  error function, then <i>msg</i> is written to the MusicKit error
  stream, as set through <b>MKSetErrorStream()</b>.  The default error
  stream is open to<b> stderr</b>.<b>  MKErrorStream()</b> returns a
  pointer to the current MusicKit error stream.  MKNote that you
  <i>shouldn't</i> use <b>stderr</b> as the error stream if you're running
  a separate-threaded performance.
   
   A number of error codes represented by integer constants are provided
  by the MusicKit and listed in <b>&lt;MusicKit/errors.h&gt;</b>.  If the
  MusicKit itself generates an error, the global system variable
  <b>errno</b> is set to one of these error codes.  If you call
  <b>MKError()</b> from your application, <b>errno</b> isn't set. 
  
  @param  msg is an NSString instance.
  @see MKSetErrorStream.
  @ingroup ErrorFns
 */
extern void MKError(NSString *msg);

/*!
  @brief Sets the MusicKit error stream.

  These functions define the MusicKit's error handling mechanism. 
  <b>MKError()</b> is used to signal an error.  It calls the current Music
  Kit error function, set through <b>MKSetErrorProc()</b>, to which it
  passes the single argument <i>msg</i>.  If the user hasn't declared an
  error function, then <i>msg</i> is written to the MusicKit error
  stream, as set through <b>MKSetErrorStream()</b>.  The default error
  stream is open to<b> stderr</b>.<b>  MKErrorStream()</b> returns a
  pointer to the current MusicKit error stream.  MKNote that you
  <i>shouldn't</i> use <b>stderr</b> as the error stream if you're running
  a separate-threaded performance.
   
   A number of error codes represented by integer constants are provided
  by the MusicKit and listed in <b>&lt;MusicKit/errors.h&gt;</b>.  If the
  MusicKit itself generates an error, the global system variable
  <b>errno</b> is set to one of these error codes.  If you call
  <b>MKError()</b> from your application, <b>errno</b> isn't set. 

  The MusicKit initialization sets the error stream to stderr. 
  Note that during a multi-threaded MusicKit 
  performance, errors invoked from the MusicKit thread are not sent
  to the error stream. Use MKSetErrorProc to see them.
 
  @param  aStream is a NSMutableData instance. nil means stderr.
  @ingroup ErrorFns
*/
extern void MKSetErrorStream(NSMutableData *aStream);

/*!
  @brief Returns the MusicKit error stream. This is, by default, stderr.
  @return Returns an NSMutableData instance.
  @ingroup ErrorFns
*/
extern NSMutableData *MKErrorStream(void);

/* Errors generated by the MusicKit. You don't normally generate these 
 * yourself. */

#define MK_ERRORBASE 4000    /* 1000 error codes for us start here */

/*!
  @brief This enumeration defines the exceptions that the MusicKit can generate
  via the <b>MKErrorCode</b>() mechanism.
 
  The errors are in six categories: general errors, representation errors, synthesis errors,
  scorefile errors, MKUnitGenerator library errors and MKSynthPatch
  library errors.
 */
typedef enum _MKErrno {
    // <b>GENERAL ERRORS</b>
    /*!	Used as a way of specifying MusicKit errors not otherwise defined. */	
    MK_musicKitErr = MK_ERRORBASE,
    /*! Used for errors from the operating system. For example, the MIDI object 
        uses this error to report problems gaining access to the MIDI device. */
    MK_machErr,

    // <b>REPRESENTATION ERRORS</b>General purpose errors dealing with music representation.	
    /*! Warns that a file can't be opened.  */
    MK_cantOpenFileErr,
    /*! Warns that a file can't be closed. */
    MK_cantCloseFileErr,
    /*! Warns that notes were found in a scorefile with times out of order. */
    MK_outOfOrderErr,           /* Scorefile parsing/writing error */
    /*! Samples class: Warns that the MKSamples object cannot change the sampling 
	rate of a waveform by anything but a negative power of 2. */
    MK_samplesNoResampleErr,
    /*!	Warns that the MusicKit has run out of <i>noteTags</i>. */
    MK_noMoreTagsErr,
    /*!	Warns that a class is specified in a scorefile as a <i>scorefile object type</i>; 
        but that class does not implement the appropriate protocol to be used in that way. */
    MK_notScorefileObjectTypeErr,
    
    /* Synthesis errors */    
    /*!	MKOrchestra class: Attempt to free a MKUnitGenerator that's in use. */
    MK_orchBadFreeErr,
    /*! MKSynthData class: A DSP error occurred when trying to clear a MKSynthData. */
    MK_synthDataCantClearErr,   /* MKSynthData errors */ 
    /*!	MKSynthData class: A DSP error occurred when trying to load a MKSynthData. */
    MK_synthDataLoadErr,
    /*!	MKSynthData class: An attempt was made to set the value of a read-only MKSynthData. */
    MK_synthDataReadonlyErr,
    /*! MKSynthInstrument class: A MKNote had to be omitted. */
    MK_synthInsOmitNoteErr,     /* MKSynthInstrument errors */
    /*!	MKSynthInstrument class: No MKSynthPatch class was set. */
    MK_synthInsNoClass,
    /*! MKUnitGenerator class: A DSP error occurred when loading a unit generator. */
    MK_ugLoadErr,               /* MKUnitGenerator errors. */
    /*!	MKUnitGenerator class: A bad argument was specified.  Probably a bug in a subclass. */
    MK_ugBadArgErr,
    /*!	MKUnitGenerator class: A DSP error occurred when trying to put an address in an argument. */
    MK_ugBadAddrPokeErr,
    /*!	MKUnitGenerator class: A DSP error occurred when trying to put a datum in an argument. */
    MK_ugBadDatumPokeErr,
    /*!	MKUnitGenerator class: An attempt was made to set an argument to a MKSynthData from a different MKOrchestra. */
    MK_ugOrchMismatchErr,
    /*!	MKUnitGenerator class: The memory space of an address-valued argument does not match the MKSynthData it was given. */
    MK_ugArgSpaceMismatchErr,
    /*!	MKUnitGenerator class: An attempt was made to set a DSP unit generator argument to a datum value when that
        unit generator argument accepts only an address. */
    MK_ugNonAddrErr,
    /*!	MKUnitGenerator class: An attempt was made to set a DSP unit generator argument to an address value when
        that unit generator argument accepts only a datum. */
    MK_ugNonDatumErr,

    /* Scorefile Language Errors. */
    /*!	Illegal expression. */
    MK_sfBadExprErr,     /* Illegal constructs */
    /*! Illegal definition. */
    MK_sfBadDefineErr,
    /*! Illegal parameter value. */
    MK_sfBadParValErr,
    /*! Illegal nesting of definitions. */
    MK_sfNoNestDefineErr,

    /*! Illegal declaration. */
    MK_sfBadDeclErr,     /* Missing constructs */
    /*! Missing string where a string is required. */
    MK_sfMissingStringErr,
    /*! Illegal note type. */
    MK_sfBadNoteTypeErr,
    /*! Illegal (non-integer) note tag. */
    MK_sfBadNoteTagErr,
    MK_sfMissingBackslashErr,
    /*! Missing semicolon. */
    MK_sfMissingSemicolonErr,
    /*! Undeclared symbol. */
    MK_sfUndeclaredErr,
    /*! Illegal assignment. */
    MK_sfBadAssignErr,
    /*! Illegal include. */
    MK_sfBadIncludeErr,
    /*! Illegal parameter. */
    MK_sfBadParamErr,
    /*! Illegal number. */
    MK_sfNumberErr,
    /*! Illegal string. */
    MK_sfStringErr,
    /*! Illegal global symbol. */
    MK_sfGlobalErr,
    /*! Undefined global symbol. */
    MK_sfCantFindGlobalErr,
    
    /*! Multiple definitions. */
    MK_sfMulDefErr, /* Duplicate constructs */
    /*! Duplicate declarations. */
    MK_sfDuplicateDeclErr,

    /*! Something may not appear where it does appear. */
    MK_sfNotHereErr,
    /*! Something is declared where it should not be   declared.. */
    MK_sfWrongTypeDeclErr,
    /*! Illegal header statement. */
    MK_sfBadHeaderStmtErr,
    /*! Illegal body statement. */
    MK_sfBadStmtErr,

    /*! Illegal initialization. */
    MK_sfBadInitErr,
    /*! Illegal argument follows the <b>tune</b> construct. */
    MK_sfNoTuneErr,
    /*! Unused. */
    MK_sfNoIncludeErr,
    /*! Can't find a file. */
    MK_sfCantFindFileErr,
    /*! Can't write a file. */
    MK_sfCantWriteErr,
    /*! Times appear out of order in a file. */
    MK_sfOutOfOrderErr,
    /*! <b>comment</b> without a matching  <b>endComment</b>. */
    MK_sfUnmatchedCommentErr,
    /*! A noteOff or noteUpdate appears for an inactive noteTag. */
    MK_sfInactiveNoteTagErr,
    /*! An Objective-C class is specified which can not be found. */
    MK_sfCantFindClass,
    /*! Lookup value is out of bounds. */
    MK_sfBoundsErr, 
    /*! Illegal type conversion. */
    MK_sfTypeConversionErr,
    /*! An attempt to set a read-only variable. */
    MK_sfReadOnlyErr,
    /*! An arithmetic error, such as divide by zero. */
    MK_sfArithErr,
    /*! An attempt to read a text file that is not a ScoreFile. */
    MK_sfNonScorefileErr,
    /*! Too many errors have occurred -- aborting. */
    MK_sfTooManyErrorsErr,
    
    /* Unit generator library errors. */
    /*! MK_ugsNotSetRunErr Indicates a memory argument that needs to be set before <b>run</b> is sent. */
    MK_ugsNotSetRunErr,
    /*!	Indicates that a MKUnitGenerator that accepts only power-of-2 length MKSynthData was passed a MKSynthData of some other length. */
    MK_ugsPowerOf2Err,
    /*! Indicates that a value was queried before a dependent value was set. */
    MK_ugsNotSetGetErr,

    /* Synth patch library errors. */
    /*! Indicates a MKSynthPatch cannot get enough DSP  memory for some purpose. */
    MK_spsCantGetMemoryErr,
    /*! Indicates a MKSynthPatch is substituting the sine ROM for the requested wavetable,
	due to a lack of DSP memory. */
    MK_spsSineROMSubstitutionErr,
    /*! Indicates an invalid keyword was passed to the MKTimbre data base. */
    MK_spsInvalidPartialsDatabaseKeywordErr, 
    /*! Indicates that a parameter is out of range. */
    MK_spsOutOfRangeErr,
    /*!	Indicates that a MKSynthPatch can't allocate an MKUnitGenerator it needs.
        This can arise, for example, if a MKSynthPatch allocates MKUnitGenerators
	outside of its basic definition (i.e. outside of the <b>patchTemplateFor:</b> method.) */
    MK_spsCantGetUGErr,

    /* Errors added in Release 3.0 */
    /*!	MKSynthData class: Problem reading MKSynthData from DSP.  */
    MK_synthDataCantReadDSPErr,
    /*!	MKOrchestra class: Mismatch between DSP monitor version and MKOrchestra version. */
    MK_dspMonitorVersionError,
    /* End marker */
    MK_highestErr,
    /* Reserved from here until MK_maxErr */
    MK_maxErr = (MK_ERRORBASE + 1000)
} MKErrno;

#define MK_sfNonAsciiErr MK_sfNonScorefileErr /* For backwards compatibility */


/* The remaining functions are the MusicKit's own internal error handling
 * functions. Normally, you don't call these functions.  However, if you 
 * need to raise an error with a MusicKit error code, you call MKErrorCode().  
 */

extern void MKErrorCode(int errorCode, ...); 
/* Calling sequence like printf, but first arg is musickit error code instead
 * of formating info, the second arg is a formating NSString derived from the string in
 * /Local/Library/MusicKit/Languages/<language>.lproj/Localized.strings. 
 *
 * It's the caller's responsibility that the expansion of the arguments 
 * using sprintf doesn't exceed the size of the error buffer (_MK_ERRLEN). 
 * Fashions the error message and sends it to MKError(). 
 */

#define _MK_ERRLEN 2048

/* 
 * These functions are for accessing MusicKit's localized strings. 
 */ 
extern NSBundle *_MKErrorBundle(void); 
/* 
 * MusicKit bundle for selected language in 
 * /usr/local/lib/MusicKit/Languages, if found.  
 */
extern NSString *_MKErrorStringFile(void); 
/* Returns "Localized" if _MKErrorBundle() returns non-null */

#endif

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us