InstrumentFile.h 12.2 KB
/*============================================================================
	InstrumentFile
	
	Copyright C 1992 Digidesign Inc.
	All rights reserved
	
	CONFIDENTIAL: This document contains confidential information. 
	Do not disclose any information contained in this documet to any
	third-party without the prior written consent of Digidesign Inc.
	
	Format and interface definition for SampleCell Instrument files.
	
	NOTE: Structures that start with 'SP' are old structures used
	for version 1.x of the SampleCell Editor. Structures that start
	with 'SCell' are for version 2.x of the SampleCell Editor.

============================================================================*/
#ifndef __InstrumentFile__
#define __InstrumentFile__

#include "type.h"
#include "SampleCellInterface.h"

const OSType kSCellInstrumentFileType = 'SCin';
const OSType kSCellStereoInstrumentFileType = 'SCsi';

const OSType kSCellSoundFileType = 'SCsd';
const OSType kSCellStereoSoundFileType = 'SCss';

const short kChannelDocumentRsrcID = 1000; // rsrc IDs for inst & sound files

// SampleCell instrument file chunk id's for the new file format
const OSType kSCellGeneralID = 'GenP';
const OSType kSCellEnvelopeID = 'EnvP';
const OSType kSCellLFOID = 'LFOP';
const OSType kSCellRampID = 'Ramp';
const OSType kSCellTrackerID = 'TrkP';
const OSType kSCellModulationPathID = 'ModP';

const OSType kSCellKeyGroupParametersID = 'KeyP';
const OSType kSCellKeyGroupSamplesID = 'KeyS';

const OSType kSCellNewInstrumentFileType = 'Monk';

// size of parameters written out with each sample
const long kSampleParametersSize = 64;

/*============================================================================
  Record definitions that match one to one with the Sample Players
  format.  This is so that we can load up and send a complete
  instrument/sound to the card as fast as possible. All parameters
  required by the program that are not used directly by the card are
  stored in other records defined below.
  ===========================================================================*/

typedef struct {

    //Actual Sample Player parameters: DO NOT CHANGE POSITION OR ORDER
    short InstrumentSoundFlag;  // 0-1:0=instrument,1=sound
    short MIDIChannel;          // 0-16:0=OMNI, 1-16=Channel
    short MIDILowNoteLimit;     // 0-127:low MIDI note that voice responds to
    short MIDIHiNoteLimit;      // 0-127:hi MIDI note that voice responds to

    short PitchOctave;          // -4-+3:unit=octave
    short PitchSemitone;        // -12-+12:unit=semitone

    short DetuneAmount;         // -99-+99:???
    short DetuneMode;           // 0-1:0=norm, 1=equal

    short KeyTrack;             // 0-1:0=OFF, 1=ON
    short KeyAssignMode;        // 0-1:0=norm, 1=mono

    short SoundPriorityLevel;   // 0-9:0=lowest, 9=highest

    short OverlapAmount;        // 0-99:0=none, 99=max overlap
    short CrossFade;            // 0-1:0=no xfade, 1=xfade

    short Send1BusSelect;       // 0-7:0=output 1,7=output8
    short Send1PrePostFader;    // 0-1:0=pre fader ie direct, 1=post fader
    short Send1Volume;          // 0-99:0=OFF, 99=full level ~.5dB per value
    short Send2BusSelect;       // 0-7:0=output 1,7=output8
    short Send2PrePostFader;    // 0-1:0=pre fader ie direct, 1=post fader
    short Send2Volume;          // 0-99:0=OFF, 99=full level ~.5dB per value
	
    short Panning;              // -99/+99: -99=left, +99=right, 0=center
    short LeftPanBusSelect;     // 0-7:0=output 1,7=output8
    short RightPanBusSelect;    // 0-7:0=output 1,7=output8
    short Mute;                 // 0-1:0=OFF,1=ON
    short Volume;               // 0-99:0=OFF, 99=full level ~.5dB per value
	
    short MIDIControllerANum;   // 0-121: MIDI controller assigned to cont A
    short MIDIControllerBNum;   // 0-121: MIDI controller assigned to cont B

    short PitchByPitchWheel;    // -12-+12: +12=+1 octave
    short VolumeByVelocity;     // -99-+99: ?????

    short DisableMIDIVolume;    // 0-1:0=Enabled/1=Disabled
    short UnUsed39;             // for future use
} SPGenParmsRec;

typedef struct
{
    //Actual Sample Player parameters: DO NOT CHANGE POSITION OR ORDER
    // (I) indicates a SCell I only param, (II) an SCell II only param
    short InstrumentSoundFlag;	// 0-1:0=instrument,1=sound

    short MIDIChannel;		// 0-16:0=OMNI, 1-16= MIDI channel
    short MIDILowNoteLimit;     // 0-127:low MIDI note that voice responds to
    short MIDIHiNoteLimit;      // 0-127:hi MIDI note that voice responds to

    short PitchOctave;		// -4-+3:unit=octave
    short PitchSemitone;        // -12-+12:unit=semitone

    short DetuneAmount;		// -99-+99:???
    short DetuneMode;		// 0-1:0=norm, 1=equal

    short KeyTrack;             // 0-1:0=OFF, 1=ON
    short KeyAssignMode;        // 0-1:0=norm, 1=mono

    short SoundPriorityLevel;	// 0-9:0=lowest, 9=highest

    short OverlapAmount;        // 0-99:0=none, 99=max overlap
    short CrossFade;		// 0-1:0=no xfade, 1=xfade

    short Send1BusSelect;       // (I) 0-7:0=output 1,7=output8 
    short Send1PrePostFader;	// (I) 0-1:0=pre fader ie direct, 1=post fader
    short Send1Volume;		// (I) 0-99:0=OFF, 99=full level ~.5dB per value
    short Send2BusSelect;       // (I) 0-7:0=output 1,7=output8
    short Send2PrePostFader;	// (I) 0-1:0=pre fader ie direct, 1=post fader
    short Send2Volume;		// (I) 0-99:0=OFF, 99=full level ~.5dB per value
	
    short Panning;              // -99/+99: -99=left, +99=right, 0=center
    short LeftPanBusSelect;     // (I) 0-7:0=output 1,7=output8
                                // Also - PanBusSelect (II) 0-3:0 = output
                                // 1&2...3 = output 7&8

    short RightPanBusSelect;	// (I) 0-7:0=output 1,7=output8
	
    short Mute;			// 0-1:0=OFF,1=ON
    short Volume;               // 0-99:0=OFF, 99=full level ~.5dB per value
	
    short MIDIControllerANum;	// 0-121: MIDI controller assigned to cont A
    short MIDIControllerBNum;	// 0-121: MIDI controller assigned to cont B

    short PitchByPitchWheel;	// -12-+12: +12=+1 octave
    short VolumeByVelocity;     // -99-+99: ?????

    short DisableMIDIVolume;	// 0-1:0=Enabled/1=Disabled
    short InitialFilterFreq;    // (II) 0-240: initial low pass filter freq
} SCellGeneralParametersRec;

//=============================================================================
typedef struct
{
    short SampVolume;		// 0-99:0=-50dB,99=0dB
    short SampNumber;		// 0-1000: which DRAM sample to use:
                                // 0=no samp, 1=sine

    short SampDirection;        // 0-1: 0=fowards,1=backwards
    short SampStart;		// 0-127: 0=no offset
    short SampBaseNote;		// 0-127: MIDI note where sample plays
                                // at orig pitch
} SPVelocityZoneRec;

typedef struct
{
    //Actual Sample Player parameters: DO NOT CHANGE POSITION OR ORDER
    short HighNoteLimit;        // 0-128: 128=key group not used
	
    // 0-15:mod level where med/loug sample starts
    short Thresholds[kSCellINumVelocityZones - 1];

    SPVelocityZoneRec VelocityZones[kSCellINumVelocityZones];
	
    short Panning;              // -99-+99: -99=left, +99=right, 0=center
} SPKeyGroupRec;

//=============================================================================
typedef struct
{
    short Threshold;		// 0-15:mod level where med/loug sample starts
    short SampVolume;		// 0-99:0=-50dB,99=0dB
    short SampDirection;        // 0-1: 0=fowards,1=backwards
    short SampStart;		// 0-127: 0=no offset
    short SampBaseNote;		// 0-127: MIDI note where sample plays at orig pitch
} SCellVelocityZoneRec;

typedef struct
{
    short HighNoteLimit;        // 0-128: 128=key group not used
    short Panning;              // -99-+99: -99=left, +99=right, 0=center

    SCellVelocityZoneRec VelocityZones[kSCellIINumVelocityZones];
} SCellKeyGroupRec;

//=============================================================================
typedef struct
{
    //Actual Sample Player parameters: DO NOT CHANGE POSITION OR ORDER
    short Attack;               // 0/99: 0=fastest, 99=slowest
    short Decay;                // 0/99: 0=fastest, 99=slowest
    short SustainLevel;		// 0/99: 0=lowest, 99=highest
    short SustainDecay;		// 0/99: 0=fastest, 99=slowest
    short Release;              // 0/99: 0=fastest, 99=slowest
    short GateTime;             // 0/99: 0=fastest, 99=slowest
    short TimeTrack;		// 0/1: 0=OFF, 99=ON
    short Amplitude;		// 0/99: 0=lowest, 99=highest
} SPEnvelopeRec;

typedef SPEnvelopeRec SCellEnvelopeRec;

//=============================================================================
typedef struct
{
    // Actual Sample Player parameters: DO NOT CHANGE POSITION OR ORDER
    short Speed;                // 0/99: 0=slowest, 99=fastest
    short Amplitude;		// 0/99: 0=lowest, 99=highest
    short Trigger;              // 0/3: 0=off,1=sync,2=trig,3=both
    short WaveShape;		// 0/6:0=sine,tri,usw,dsw,sq,rnd,noise=6
} SPLFORec;

typedef SPLFORec SCellLFORec;

//=============================================================================
typedef struct
{
    // Actual Sample Player parameters: DO NOT CHANGE POSITION OR ORDER
    short RampTime;             // 0/99: 0=fastest
} SPRampGeneratorRec;

typedef SPRampGeneratorRec SCellRampGeneratorRec;

//=============================================================================
typedef struct
{
    // Actual Sample Player parameters: DO NOT CHANGE POSITION OR ORDER
    short Input;    // 0/16: the mod source input to track generator

    short TrackPoints[kSCellINumTrackPoints]; // 0/99
	
}
SPTrackGeneratorRec;

typedef struct
{
    // Actual Sample Player parameters: DO NOT CHANGE POSITION OR ORDER
    short Input;  // 0/16: the mod source input to track generator

    short TrackPoints[kSCellIINumTrackPoints]; // 0/99
} SCellTrackGeneratorRec;

//=============================================================================
typedef struct
{
    // Actual Sample Player parameters: DO NOT CHANGE POSITION OR ORDER
    short Gate;			// 0/1: 0=OFF,1=ON
    short Source;               // 0/16
    short Destination;		// 0/25
    short Amplitude;		// -99/+99
}
SPModPathRec;

typedef SPModPathRec SCellModPathRec;

//=============================================================================
// Record definitions for information that the application requires but that is
// not directly used by the Sample Player.

// digi's internal way of doing FSSpec stuff before FSSpec existed
typedef struct
{
    Str31 FileName;
    Str27 VolumeName;
    short VolRefNum;
    long DirID;
    OSType FileType;
} FindFileRec;

typedef struct
{
    FindFileRec	FindFileInfo;	// file pointer to the SampleFile

    short Channel;			// which channel from the file should we load
    long SampleStart;		// sample number to start loading from in file

    short SampleFineTune;		// 0/126: 63=0 fine tune sample rate for this sample
    short Loop1Enable;		// 0/1: 0=disable loop, 1=enable
    short Loop1FineTune;		// 0/126: 63=0 fine tune for loop1 speed
    short Loop2Enable;		// 0/1: 0=disable loop, 1=enable
    short Loop2FineTune;		// 0/126: 63=0 fine tune for loop1 speed
}
SPVelocityZoneFileRec;

/*	RECORD of an ARRAY as opposed to a two dimensional array as an object
	field is so the structure mirrors the SPKeyGroupRec structure and in
	addition it allows key groups to be moved using block move. */

typedef struct
{
    SPVelocityZoneFileRec VelocityZoneFiles[kSCellINumVelocityZones];
}
SPKeyGroupFileRec;

//==============================================================================
typedef struct
{
    short NumKeyGroups;		// 1/20
    long TotalSampleBytes;		// 0..?
}
ChannelInfoRec;	

typedef struct 
{
    long        fileIndex;      // 0 based index into files dictionary (ie FILP or FILA)
    long        regionID;	// id from SDII file if this came from one, otherwise -1
    short       audioChannel;   // channel this region refers to ie 1 = left, 2 = right??
    long	startFrame;     // first sample frame in the region
    long	stopFrame;      // frame after the last frame in the region

    Str31 	sampleName;     // name of the region/sample
	
    long	sampleStart;    // where to start playback relative to start of region
    short	sampleFineTune; // sample fine tune

    short	loop1Enabled;   // 1 = enabled, 0 = not enabled
    short	loop1FineTune;  // loop fine tune
	
    short	loop2Enabled;	// 1 = enabled, 0 = not enabled
    short	loop2FineTune;	// loop fine tune
} SCellSampleRec;

#endif