WBL4014.hWBL4014.h
#include "WBLSlider.h"
#include "WBLLFO.h"
#include "WBL4014Formatting.h"
#include "KeyboardDiagram.h"
#include "MusicConstructionLibrary.h"
#if useWarholPrivates
#include "NoteAllocatorComponent.h"
#else
#include
#endif
#ifdef DoGlobals
StringPtr dCBNames[] =
{
"\pScramble 1",
"\pScramble 2",
"\pIgnore MIDI Keys",
"\pToggle Keys",
"\pExternal Sync",
"\pSync By Measure",
"\p."
};
#else
extern StringPtr dCBNames[];
#endif
enum
{
kCBFirstCheck = -1,
kCBScramble1, /* per grid */
kCBScramble2, /* per grid */
kCBIgnoreMIDIKeys, /* per grid */
kCBToggle, /* global */
kCBSlaveSync, /* global */
kCBSyncByMeasure, /* global */
kCBLastCheck
};
#define kCheckBoxCount kCBLastCheck
#define kFirstControllerMenuRef 10000
#define kCellsPerSecond 32 /* number of cells/second at rate 0x00010000 */
#define kCellsPerBeat 8
enum
{
mFirstDocOnly = 100,
mSaveDocument,
mLoadDocument,
mClose,
mFirstCheckBox,
mLastCheckBox = mFirstCheckBox + kCBLastCheck,
mPickInstrument,
mEditInstrument,
mEditPickInstrument,
mClearGrid,
mStdGrid,
mDoubleGrid,
mCopyGrid,
mFullScreen,
mRecordToMovie,
mLastDocOnly,
mOpen
};
/*
* One pattern within a single grid.
*/
typedef struct
{
unsigned char a[kMaxSequenceLength][kMaxSequenceKeys]; /* 1-128 = duration to play, 254 = filler mark, 255 = last beat */
long length;
unsigned char mKey[128]; /* array of 128 midi keys presently pressed */
unsigned long mKeySeed[128]; /* time-stamp for each key, so we know which is the earliest pressed */
long volume;
Boolean hasNotes;
} ArpPattern, *ArpPatternPtr;
#define kArpGridPatternCount 100
#define kWBLMovieTimeScale 600
typedef struct
{
long step; /* position in grid */
ArpPatternPtr ap[kArpGridPatternCount];
long playingGridNumber; /* which pattern number this grid is running */
long nextPlayingGridNumber; /* the one to switch to at next iteration... the last displayed one */
long markedPlayingGridNumber; /* last one to get a green mark in the pattern overview */
NoteChannel nc; /* note-channel for this grid only */
// NoteRequest nr; /* note it's assigned to */
AtomicInstrument iH; /* user-created instrument */
MusicComponent ncMC; /* to talk to the part on the synth directly */
long ncPart; /* part on music component */
Str31 synthName;
OSType synthType;
WBLLFO rfLFO[kMaxSequenceKeys]; /* velocity faders */
WBLKnobLFO knobLFO[kKnobLFOCount]; /* parameter LFO's */
OddMenu om; /* parameter menu for current synth */
short keyCount;
unsigned char pKey[kMaxSequenceKeys]; /* keys in arpeggiation order */
unsigned long pKeySeed[kMaxSequenceKeys]; /* time-stamp for each key, so we know which is the earliest pressed */
} ArpGrid;
typedef struct
{
long pitch;
NoteChannel nc;
short duration;
} CurrentNote;
typedef struct
{
/*
* document info that should be saved
*/
Boolean cb[kCheckBoxCount];
Fixed playRate; /* current rate of playing */
ArpGrid ag[kArpGridCount];
Boolean changed; /* must the user be prompted for change saving? */
/*
* run-state info
*/
WindowPtr w;
WBLSlider rateS;
WBLSlider volumeS; /* vertical slider for current pattern's volume */
Boolean fullScreen;
Rect windowRect; /* extents of window in screen space */
short originH,originV;
ControlHandle cbC[kCheckBoxCount];
ControlHandle instrumentC;
Rect rfR; /* level/rate (rowfade) sliders for pitch rows */
Rect gridLetterR;
Rect gridNumberR;
Rect gridEndR;
Rect gridR;
Rect timerR;
Rect bpmR;
Rect cbAreaR;
Rect statR;
Rect kdR;
Rect msR; /* Metasequence area */
long displayGridLetter;
long displayGridNumber;
ArpGrid *displayAg;
long drawnGridLetter; /* number of most recently draw grid, or -1 if its the same grid but should be updated */
long drawnDisplayGridNumber;
long drawnPlayingGridNumber;
KeyboardDiagram kd;
TimeBase tb;
QTCallBack qtcb;
long lfoTable[kLFOTableSize]; /* range 128 to -128 */
short displayedStep; /* [0,kMaxSequenceLength) */
short displayedKeyCount; /* last drawn keycount, so idle loop can track */
NoteAllocator na;
unsigned long keySeed;
Boolean drawnGridDirty;
ArpPattern drawnPattern;
short playingNoteCount;
CurrentNote playingNote[kArpGridCount * kMaxSequenceKeys];
Boolean using; /* true if we are USING the default MIDI input */
Boolean recording;
Boolean waitingToRecord;
long recordingT; /* timebase time updated each interrupt */
MusicConstructor mc;
long globalMagic;
long a5;
FSSpec docSpec;
} Globals;
#ifdef DoGlobals
Globals *g = nil;
#else
extern Globals *g;
#endif
#define kActiveNotesPatternRGB 0x008000
#define kActivePatternRGB 0x00FF00
#define kNotesPatternRGB 0x800080
#define kGridGrey1RGB 0x696969
#define kGridGrey2RGB 0x909090
#define kGlobalMagic 12345
/* ¥¥WBL4014.c */
MusicComponent GetNoteChannelMusicComponent(NoteChannel nc,long *part,OSType *synthType,StringPtr synthName);
OddMenu BuildKnobMenu(MusicComponent mc);
void BuildPKeys(Globals *g,ArpGrid *ag,ArpPattern *ap);
ArpPattern *NewAp(void);
void SendWBLVolume(Globals *g,ArpGrid *ag,ArpPattern *ap);
void PointToCell(Rect *gR,Point p,short *x,short *y);
void FCellToRect(Rect *gR,short x,short y,Rect *r,short cellW,short cellH);
void CellToRect(Rect *gR,short x,short y,Rect *r);
void FlashCheckBox(ControlHandle cH,Boolean *b);
void SetDisplayGrid(long nextGridLetter,long nextGridNumber);
void GetDisplayAgAp(Globals *g,ArpGrid **agOut,ArpPattern **apOut);
void CheckBoxChanged(short i);
void BlinkControl(ControlHandle cH);
void WBLPickInstrument(void);
void FillInGrid(void);
void KeyDownKey(Globals *g,ArpGrid *ag,short pitch,short vel,Boolean toggle);
pascal Boolean MyFilterProc(DialogPtr theDialog,
EventRecord *theEvent,short *itemHit);
void IdleDoc(short n, Boolean front);
void ClickDoc(short n,Point p,short mods);
void IdleDrawnGrid(void);
void RepairGrid(ArpGrid *ag,ArpPattern *ap,short y);
void FixUpMenus(Boolean front);
ComponentResult setAI(AtomicInstrument ai,ToneDescription *td);
ComponentResult WBLGetPartAtomicInstrument(MusicComponent nc,long partNumber,AtomicInstrument *aiOut,long flags);
/* ¥¥WBL4014Load.c WBL4014Save.c */
void SaveWBL4014Document(short n,short menu,short ref);
void LoadWBL4014Document(short n,short menu,short ref);
void LoadWBL4014FileSpec(FSSpec *spec);
void NewWBL4014Document(short n,short menu,short ref);
/* ¥¥WBL4014Sets.c */
ArpPattern *EnsureAgAp(long gridLetter,long gridNumber);
void ClearGrids(void);
void SetGridInstruments(long gridLetter);
void SetGridNotes(long gridLetter,long gridNumber);
void SetHasNotes(long gridLetter,long gridNumber);
void SetWBLVolume(long gridLetter,long gridNumber,Fixed volume);
void SetCheckBoxes(void);
void SetPlayRate(Fixed rate);
void SetEverything(void);
void CheckBoxesMenu(short n,short menu,short ref);
void RecordToMovie(short n,short menu,short ref);
void KeyDoc(short n,short key,short code,short mods);
void SetGridEnd(short newEnd);
void CopyPattern(long toGridLetter,long toGridNumber,
long fromGridLetter,long fromGridNumber);
/* ¥¥WBL4014 Drawing.c */
void DrawDoc(short n);
char GoGridColors(Boolean hGrey,Boolean vGrey,char cell);
void DrawInstrumentStat(void);
void DrawPatternOverview(short x,Boolean drawGrid,short cellNumber);
void DrawGridSelect(Boolean outside);
void DrawGridEnd(short old,short new);
void DrawGrid(short left,short right,Boolean hGrey,
short lowNote,short highNote,Boolean vGrey);
void DrawBPM(void);
void FPointToCell(Rect *gR,Point p,short *x,short *y,short cellW,short cellH);
void DrawCell(Rect *gR,short x,short y,unsigned char a);
void DrawGridNumber(Boolean outside);
void DrawTimer(short step);
void InitAllThemRects(void);
ToneDescription *FindAtomicTD(AtomicInstrument ai);
/* ¥¥WBL4014 Clicking.c */
void TrackKeyboardClick(KeyboardDiagram *kd,
NoteAllocator na,NoteChannel nc,Point p,short mods);
AM.4/17/96 - 6:59.PM