instfile.h 3.04 KB
//====================================================================
// instfile.h
//
// Copyright 1993, Silicon Graphics, Inc.
// All Rights Reserved.
//
// This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
// the contents of this file may not be disclosed to third parties, copied or
// duplicated in any form, in whole or in part, without the prior written
// permission of Silicon Graphics, Inc.
//
// RESTRICTED RIGHTS LEGEND:
// Use, duplication or disclosure by the Government is subject to restrictions
// as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
// and Computer Software clause at DFARS 252.227-7013, and/or in similar or
// successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
// rights reserved under the Copyright Laws of the United States.
//====================================================================

#pragma once

#include <stdio.h>
#include "libbank.h"

typedef struct {
    long        ckID;
    long        ckSize;
} ChunkHeader;

typedef struct {
    long        ckId;
    long        ckSize;
    long        format;
} FileHeader;

typedef struct {
    char        volume[28];
    long        dirID;
    char        file[32];
    long        type;
} FILP;

#include "InstrumentFile.h"

class SCInstrumentFile
{
  protected:
    FILE                *file;
    char                *comment;       // annotation from this instrument
    char                *name;
    char                *dir;
    
    ICEnvelope          envelope;       // maps to SC envelope 3
    ICInst              instrument;
    
    int                 soundCount;     // number of sounds in the array
    ICSoundFile         **sounds;       // array of sound file pointers
    char                midiChannel;
    int                 scDebug;
    ICSymTab            *symtab;
    ICObjTab            *objtab;
    ICWavTab            *wavtab;
    
    void parseAnno(ChunkHeader *hdr);
    void parseKeyP(ChunkHeader *hdr);
    void parseKeyS(ChunkHeader *hdr);
    void parseFILP(ChunkHeader *hdr);
    
    void parseEnvP(ChunkHeader *hdr);
    void parseGenP(ChunkHeader *hdr);
    void parseLFOP(ChunkHeader *hdr);
    void parseRamp(ChunkHeader *hdr);
    void parseTrkP(ChunkHeader *hdr);
    void parseModP(ChunkHeader *hdr);

    ALMicroTime scTime2alTime(short scTime);
    short       scAmp2alVol(short scAmp);
    short       scTuning2Cents(short tuning);
    short       scVol2alVol(short scVol);
    ALPan       scPan2alPan(short scPan);

    void        makePath(char *out, char *dir, char *fName);
    void        unixName(char *str);
    
  public:
    SCInstrumentFile(char *name, char *mode);
    virtual ~SCInstrumentFile();
    
    void        Parse();
    
    char        GetMIDIChannel() { return midiChannel;}
    ICInst      *GetICInst() { return &instrument;}
    
    void        SetObjTab(ICObjTab *o) {objtab = o; }
    void        SetSymTab(ICSymTab *s) {symtab = s; }
    void        SetWavTab(ICWavTab *w) { wavtab = w; }
    void        SetDebug(int v) { scDebug = v; }
    
    void        ListFiles();
};