File AUDIO\CSPSET~2.C:
 * cspsetchlvol.c^J *^J * Copyright 1995, Silicon Graphics, Inc.^J * All Rights Reserved.^J *^J * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,^J * Inc.; the contents of this file may not be disclosed to third^J * parties, copied or duplicated in any form, in whole or in part,^J * without the prior written permission of Silicon Graphics, Inc.^J *^J * RESTRICTED RIGHTS LEGEND:^J * Use, duplication or disclosure by the Government is subject to^J * restrictions as set forth in subdivision (c)(1)(ii) of the Rights^J * in Technical Data and Computer Software clause at DFARS^J * 252.227-7013, and/or in similar or successor clauses in the FAR,^J * DOD or NASA FAR Supplement. Unpublished - rights reserved under the^J * Copyright Laws of the United States.^J *====================================================================*/^J^J#include <libaudio.h>^J^Jvoid alCSPSetChlVol(ALCSPlayer *seqp, u8 chan, u8 vol)^J{^J    ALEvent       evt;^J^J    evt.type            = AL_SEQP_MIDI_EVT;^J    evt.msg.midi.ticks  = 0;^J    evt.msg.midi.status = AL_MIDI_ControlChange | chan;^J    evt.msg.midi.byte1  = AL_MIDI_VOLUME_CTRL;^J    evt.msg.midi.byte2  = vol;^J                    ^J    alEvtqPostEvent(&seqp->evtq, &evt, 0);^J}^J
File AUDIO\CSPSET~3.C:
void alCSPSetChlFXMix(ALCSPlayer *seqp, u8 chan, u8 fxmix)^J{^J    ALEvent       evt;^J^J    evt.type            = AL_SEQP_MIDI_EVT;^J    evt.msg.midi.ticks  = 0;^J    evt.msg.midi.status = AL_MIDI_ControlChange | chan;^J    evt.msg.midi.byte1  = AL_MIDI_FX1_CTRL;^J    evt.msg.midi.byte2  = fxmix;^J                    ^J    alEvtqPostEvent(&seqp->evtq, &evt, 0);^J}^J
File AUDIO\CSPSET~4.C:
void alCSPSetChlPan(ALCSPlayer *seqp, u8 chan, ALPan pan)^J{^J    ALEvent       evt;^J^J    evt.type            = AL_SEQP_MIDI_EVT;^J    evt.msg.midi.ticks  = 0;^J    evt.msg.midi.status = AL_MIDI_ControlChange | chan;^J    evt.msg.midi.byte1  = AL_MIDI_PAN_CTRL;^J    evt.msg.midi.byte2  = pan;^J                    ^J    alEvtqPostEvent(&seqp->evtq, &evt, 0);^J}^J
File AUDIO\CSPSET~5.C:
void alCSPSetChlPriority(ALCSPlayer *seqp, u8 chan, u8 priority)^J{^J    ALEvent evt;^J^J    evt.type = AL_SEQP_PRIORITY_EVT;^J    evt.msg.sppriority.chan = chan;^J    evt.msg.sppriority.priority = priority;^J^J    alEvtqPostEvent(&seqp->evtq, &evt, 0);^J}
File AUDIO\CSPSET~6.C:
void alCSPSetChlProgram(ALCSPlayer *seqp, u8 chan, u8 prog)^J{^J    ALEvent       evt;^J^J    evt.type            = AL_SEQP_MIDI_EVT;^J    evt.msg.midi.ticks  = 0;^J    evt.msg.midi.status = AL_MIDI_ProgramChange | chan;^J    evt.msg.midi.byte1  = prog;^J    evt.msg.midi.byte2  = 0;^J                    ^J    alEvtqPostEvent(&seqp->evtq, &evt, 0);^J}^J
File AUDIO\SEQPLA~1.C:
s32     seqpSetChannelMask(SEQP *seqp, u16 bitmask);^J^J#endif^J^Jvoid __seqpReleaseVoice(ALSeqPlayer *seqp, ALVoice *voice,^J                        ALMicroTime deltaTime)^J{^J    ALEvent             evt;^J    ALVoiceState *vs = (ALVoiceState *)voice->clientPrivate;^J^J    /*^J     * if in attack phase, remove all pending volume^J     * events for this voice from the queue^J     */^J^J    if (vs->envPhase == AL_PHASE_ATTACK) {^J       ALLink              *thisNode;^J        ALLink              *nextNode;^J        ALEventListItem     *thisItem, *nextItem;^J^J   thisNode = seqp->evtq.allocList.next;^J while( thisNode != 0 ) {^J          nextNode = thisNode->next;^J            thisItem = (ALEventListItem *)thisNode;^J       nextItem = (ALEventListItem *)nextNode;^J       if (thisItem->evt.type == AL_SEQP_ENV_EVT) {^J              if(thisItem->evt.msg.vol.voice == voice) {^J                if( nextItem )^J                    nextItem->delta += thisItem->delta;^J               alUnlink(thisNode);^J                   alLink(thisNode, &seqp->evtq.freeList);^J           }^J         }^J     thisNode = nextNode;^J      }^J    }^J    ^J    vs->velocity = 0;^J    vs->envPhase = AL_PHASE_RELEASE;^J    vs->envGain  = 0;^J    vs->envEndTime = seqp->curTime + deltaTime;^J^J    alSynSetPriority(seqp->drvr, voice, 0); /* make candidate for stealing */^J    alSynSetVol(seqp->drvr, voice, 0, deltaTime);^J    evt.type  = AL_NOTE_END_EVT;^J    evt.msg.note.voice = voice;^J    ^J    alEvtqPostEvent(&seqp->evtq, &evt, deltaTime);^J}^J^J^J^J/*^J  This special purpose routine is called only when processing^J  a stopping event in order to properly kill all active voices.^J  ^J  The routine searches through the seqp's event queue for an^J  AL_NOTE_END_EVT for the given voice.  If the event's execution^J  time is greater than kill time, it removes the event from the^J  event queue and returns true that it needs to kill the voice.^J  Otherwise, if the event's time is less than the kill time, it^J  returns false that the voice needs to be killed.^J^J  sct 1/3/96^J*/^J^J#define VOICENEEDSNOTEKILL_DEBUG    _DEBUG_INTERNAL&&0      /* For debugging voiceNeedsNoteKill routine. */^J^Jchar __voiceNeedsNoteKill (ALSeqPlayer *seqp, ALVoice *voice, ALMicroTime killTime)^J{^J    ALLink              *thisNode;^J    ALLink              *nextNode;^J    ALEventListItem     *thisItem;^J    ALMicroTime          itemTime = 0;^J    char         needsNoteKill = TRUE;^J^J#if VOICENEEDSNOTEKILL_DEBUG^J    alEvtqPrintAllocEvts (&seqp->evtq);^J#endif^J^J    thisNode = seqp->evtq.allocList.next;^J    while (thisNode != 0)^J    {^J nextNode = thisNode->next;^J    thisItem = (ALEventListItem *)thisNode;^J       itemTime += thisItem->delta;^J^J        if (thisItem->evt.type == AL_NOTE_END_EVT)^J    {^J         if (thisItem->evt.msg.note.voice == voice)^J            {^J         if (itemTime > killTime)^J              {^J                 if ((ALEventListItem *)nextNode)^J                  ((ALEventListItem *)nextNode)->delta += thisItem->delta;^J                  alUnlink(thisNode);^J                   alLink(thisNode, &seqp->evtq.freeList);^J           }^J             else^J              needsNoteKill = FALSE;^J            break;^J            }^J }^J     thisNode = nextNode;^J    }^J^J#if VOICENEEDSNOTEKILL_DEBUG ^J    if (thisNode)^J       osSyncPrintf("vox 0x%0x: end time %d  kill time %d\n\n", voice, itemTime, killTime);^J    else^J        osSyncPrintf("vox 0x%0x: not found\n\n", voice);^J^J    alEvtqPrintAllocEvts (&seqp->evtq);^J#endif^J^J   return needsNoteKill;^J}^J^J^J^J    ^Jvoid __initFromBank(ALSeqPlayer *seqp, ALBank *b)^J{^J    /*^J     * init the chanState with the default instrument^J     */^J    s32 i;    ^J    ALInstrument *inst = 0;^J    ^J    /* set to the first available instrument. */^J    for(i = 0; !inst ; i++)^J      inst = b->instArray[i];^J    ^J    /* sct 11/6/95 - Setup the channel state for the given instrument. */^J    /* There is some wasted effort here since both calls the same state vars */^J    /* but it's safer. */^J    for (i = 0; i < seqp->maxChannels; i++) {^J      __resetPerfChanState(seqp, i);^J      __setInstChanState(seqp, inst, i);^J    }^J^J    if (b->percussion) {^J      __resetPerfChanState(seqp, i);^J      __setInstChanState(seqp, b->percussion, 9);^J    }^J}^J^J^J/*^J  sct 11/6/95 - Call this whenever a new instrument gets assigned to a channel^J  such as when changing banks or in response to a MIDI program change event.^J  Currently also gets called when changing sequences.^J*/^Jvoid __setInstChanState(ALSeqPlayer *seqp, ALInstrument *inst, s32 chan)^J{^J    seqp->chanState[chan].instrument = inst;^J    seqp->chanState[chan].pan = inst->pan;^J    seqp->chanState[chan].vol = inst->volume;^J    seqp->chanState[chan].priority = inst->priority;^J    seqp->chanState[chan].bendRange = inst->bendRange;^J}^J^J^J/*^J  sct 11/6/95 -- Call this whenever a new sequence is to be played or when^J  initializing a sequence player.^J*/^Jvoid __resetPerfChanState(ALSeqPlayer *seqp, s32 chan) ^J{^J  seqp->chanState[chan].fxId = AL_FX_NONE;^J  seqp->chanState[chan].fxmix = AL_DEFAULT_FXMIX;^J  seqp->chanState[chan].pan = AL_PAN_CENTER;^J  seqp->chanState[chan].vol = AL_VOL_FULL;^J  seqp->chanState[chan].priority = AL_DEFAULT_PRIORITY;^J  seqp->chanState[chan].sustain = 0;^J  seqp->chanState[chan].bendRange = 200;^J  seqp->chanState[chan].pitchBend = 1.0f;^J}^J^J^J/*^J  sct 11/6/95 - Called only when creating a new sequence player.^J*/^Jvoid __initChanState(ALSeqPlayer *seqp) ^J{^J    int i;^J    ^J    for (i = 0; i < seqp->maxChannels; i++)^J    {^J        seqp->chanState[i].instrument = 0;^J   __resetPerfChanState (seqp, i);^J    }^J}^J^J^Jvoid __seqpStopOsc(ALSeqPlayer *seqp, ALVoiceState *vs)^J{^J    ALEventListItem  *thisNode,*nextNode;^J    s16              evtType;^J    ^J    thisNode = (ALEventListItem*)seqp->evtq.allocList.next;^J    while(thisNode)^J    {^J        nextNode = (ALEventListItem*)thisNode->node.next;^J        evtType = thisNode->evt.type;^J        if(evtType == AL_TREM_OSC_EVT || evtType == AL_VIB_OSC_EVT)^J        {^J            if(thisNode->evt.msg.osc.vs == vs)^J            {^J                (*seqp->stopOsc)(thisNode->evt.msg.osc.oscState);^J                alUnlink((ALLink*)thisNode);^J                if(nextNode)^J                    nextNode->delta += thisNode->delta;^J                alLink((ALLink*)thisNode, &seqp->evtq.freeList);^J                if(evtType == AL_TREM_OSC_EVT)^J                    vs->flags = vs->flags & 0xFE;^J                else /* must be a AL_VIB_OSC_EVT */^J                    vs->flags = vs->flags & 0xFD;^J                if(!vs->flags)^J                    return;  /* there should be no more events */^J            }^J        }^J        ^J        thisNode = nextNode;^J    }^J}^J^J^J^J/*^J  This routine safely calculates the sequence player's^J  uspt value based on the given tempo.  It does this safely^J  by making sure that the player has a target sequence and^J  therefore a qnpt value which is needed for the calculation.^J*/^Jstatic void __setUsptFromTempo (ALSeqPlayer *seqp, f32 tempo)^J{^J    if (seqp->target)^J        seqp->uspt = (s32)((f32)tempo * seqp->target->qnpt);^J    else^J        seqp->uspt = 488;               /* This is the initial value set by alSeqpNew. */^J}
File AUDIO\SEQPSE~3.C:
 * seqpsetchlvol.c^J *^J * Copyright 1995, Silicon Graphics, Inc.^J * All Rights Reserved.^J *^J * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,^J * Inc.; the contents of this file may not be disclosed to third^J * parties, copied or duplicated in any form, in whole or in part,^J * without the prior written permission of Silicon Graphics, Inc.^J *^J * RESTRICTED RIGHTS LEGEND:^J * Use, duplication or disclosure by the Government is subject to^J * restrictions as set forth in subdivision (c)(1)(ii) of the Rights^J * in Technical Data and Computer Software clause at DFARS^J * 252.227-7013, and/or in similar or successor clauses in the FAR,^J * DOD or NASA FAR Supplement. Unpublished - rights reserved under the^J * Copyright Laws of the United States.^J *====================================================================*/^J^J#include <libaudio.h>^J^Jvoid alSeqpSetChlVol(ALSeqPlayer *seqp, u8 chan, u8 vol)^J{^J    ALEvent       evt;^J^J    evt.type            = AL_SEQP_MIDI_EVT;^J    evt.msg.midi.ticks  = 0;^J    evt.msg.midi.status = AL_MIDI_ControlChange | chan;^J    evt.msg.midi.byte1  = AL_MIDI_VOLUME_CTRL;^J    evt.msg.midi.byte2  = vol;^J                    ^J    alEvtqPostEvent(&seqp->evtq, &evt, 0);^J}^J
File AUDIO\SEQPSE~4.C:
void alSeqpSetChlFXMix(ALSeqPlayer *seqp, u8 chan, u8 fxmix)^J{^J    ALEvent       evt;^J^J    evt.type            = AL_SEQP_MIDI_EVT;^J    evt.msg.midi.ticks  = 0;^J    evt.msg.midi.status = AL_MIDI_ControlChange | chan;^J    evt.msg.midi.byte1  = AL_MIDI_FX1_CTRL;^J    evt.msg.midi.byte2  = fxmix;^J                    ^J    alEvtqPostEvent(&seqp->evtq, &evt, 0);^J}^J
File AUDIO\SEQPSE~5.C:
void alSeqpSetChlPan(ALSeqPlayer *seqp, u8 chan, ALPan pan)^J{^J    ALEvent       evt;^J^J    evt.type            = AL_SEQP_MIDI_EVT;^J    evt.msg.midi.ticks  = 0;^J    evt.msg.midi.status = AL_MIDI_ControlChange | chan;^J    evt.msg.midi.byte1  = AL_MIDI_PAN_CTRL;^J    evt.msg.midi.byte2  = pan;^J                    ^J    alEvtqPostEvent(&seqp->evtq, &evt, 0);^J}^J
File AUDIO\SEQPSE~6.C:
void alSeqpSetChlPriority(ALSeqPlayer *seqp, u8 chan, u8 priority)^J{^J    ALEvent evt;^J^J    evt.type = AL_SEQP_PRIORITY_EVT;^J    evt.msg.sppriority.chan = chan;^J    evt.msg.sppriority.priority = priority;^J^J    alEvtqPostEvent(&seqp->evtq, &evt, 0);^J}
File AUDIO\SEQPSE~7.C:
void alSeqpSetChlProgram(ALSeqPlayer *seqp, u8 chan, u8 prog)^J^J{^J    ALEvent       evt;^J^J    evt.type            = AL_SEQP_MIDI_EVT;^J    evt.msg.midi.ticks  = 0;^J    evt.msg.midi.status = AL_MIDI_ProgramChange | chan;^J    evt.msg.midi.byte1  = prog;^J    evt.msg.midi.byte2  = 0;^J                    ^J    alEvtqPostEvent(&seqp->evtq, &evt, 0);^J}^J
File IO\CONTSE~1.C:
osContSetCh(u8 ch)^J{^J s32     ret = 0;^J^J    /* Block to get resource token */^J     __osSiGetAccess();^J^J  if (ch > MAXCONTROLLERS)^J              __osMaxControllers = MAXCONTROLLERS;^J  else^J          __osMaxControllers = ch;^J              ^J      __osContLastCmd = (u8)CONT_SETCH;^J     /* Return resource token */^J   __osSiRelAccess();^J    return(ret);^J}^J#endif 
