home *** CD-ROM | disk | FTP | other *** search
/ Sound Sensations! / sound_sensations.iso / miscprog / ad-prog / insbank.h < prev    next >
C/C++ Source or Header  |  1989-02-07  |  3KB  |  120 lines

  1. /*
  2. Definition and type file to be used with the new instrument bank file.
  3. Function prototypes are at the end of this file.
  4. BANK_WRITE_ACCESS must be defined if you wish to update a bank.
  5.  
  6. Dec-88, DJG, MSA
  7. */
  8.  
  9. #define BANK_FILLER_SIZE    8
  10.  
  11. #define BANK_SIG            "ADLIB-"
  12. #define BANK_SIG_LEN        6
  13.  
  14. #define BANK_OK             0
  15. #define BANK_NOT_FOUND      -1
  16. #define BAD_BANK_FILE       -2
  17. #define NOT_DEFINED         -3
  18. #define CREATE_ERROR        -4
  19. #define READ_WRITE_ERR      -5
  20.  
  21. #pragma pack(1)
  22.  
  23. /* Instrument bank file header */
  24. typedef struct {
  25.    char      majorVersion;
  26.    char      minorVersion;
  27.     char      sig[ BANK_SIG_LEN];    /* signature: "ADLIB-" */
  28.    unsigned  nrDefined;        /* number of list entries used */
  29.    unsigned  nrEntry;          /* number of total entries in list */
  30.    long      offsetIndex;      /* offset in file of start of list of names */
  31.    long      offsetTimbre;     /* offset in file of start of data */
  32.    char      filler[ BANK_FILLER_SIZE];      /* must be zero */
  33. } BankHeader;
  34.  
  35.  
  36. /* Bank descriptor: */
  37. typedef
  38.     struct {
  39.         int        bank_id;
  40.         BankHeader head;
  41.     } BankRec, * BankPtr;
  42.  
  43.  
  44.  
  45. /* Name of instrument with a pointer to its position in the file */
  46. typedef struct {
  47.    unsigned nrReference;
  48.    char  usedFlag;             /* 0 if not used */
  49.    char  TimbreName [9];       /* max 8 char's + NULL */
  50. } BankEntry;
  51.  
  52.  
  53. /* Operator structure */
  54. typedef struct {
  55.    int  ksl;
  56.    int  freqMult;
  57.    int  feedBack;              /* used by operator 0 only */
  58.    int  attack;
  59.    int  sustLevel;
  60.    int  sustain;
  61.    int  decay;
  62.    int  release;
  63.    int  output;
  64.    int  am;
  65.    int  vib;
  66.    int  ksr;
  67.    int  fm;                    /* used by operator 0 only */
  68. } Operator;
  69.  
  70.  
  71. /* Timbre structure (old .INS file structure) */
  72. typedef struct {
  73.    char      mode;             /* 0=melodic, 1=percussive */
  74.    char      percVoice;        /* if mode=1, voice number to be used */
  75.    Operator  op0;
  76.    Operator  op1;
  77.    int       wave0;            /* waveform for operator 0 */
  78.    int       wave1;            /* waveform for operator 1 */
  79. } Timbre;
  80.  
  81. typedef struct {
  82.     char    mode;
  83.     char    percVoice;
  84.     char    param[ 13 * 2];
  85.     char    wave0;
  86.     char    wave1;
  87.     } PackedTimbre;
  88.  
  89. #pragma pack()
  90.  
  91. #define  DEFAULT_BANK    "standard"
  92. #define  BANK_EXTENSION  "bnk"
  93.  
  94.  
  95. #define MAJ_VERSION    1
  96. #define MIN_VERSION    0
  97.  
  98.  
  99. /***************************************************************************
  100.                  FUNCTION PROTOTYPES FOR PUBLIC ROUTINES
  101. ****************************************************************************/
  102.  
  103. /*
  104. Routines for read only access to bank
  105. */
  106. int Open_Bank (char *fname, int writeFlag, BankPtr bkp);
  107. int Close_Bank (BankPtr bkp);
  108. int Read_Timbre_def (char *ins_name, Timbre *timbre, BankPtr bkp);
  109. int Seek_Nth_Timbre (unsigned n, BankPtr bkp);
  110.  
  111. /*
  112. Routines for read/write access to bank
  113. BANK_WRITE_ACCESS must be defined in order to user these routines.
  114. */
  115. int Open_New_Bank (char *name, BankPtr bkp);
  116. int Write_Timbre (char *ins_name, Timbre *timbre, BankPtr bkp);
  117. int Delete_Timbre (char *ins_name, BankPtr bkp);
  118. int Read_timbre_name (unsigned n, char *name, BankPtr bkp);
  119.  
  120.