/* sweep the tempo to a new value relative to the current value */
 public static void TempoControlSweepToAdjustedValue(
     TempoControlRec Tempo,
     LargeBCDType AdjustBPM,
     SmallExtBCDType NumBeatsToReach)
 {
     TempoControlSweepHelper(
         Tempo,
         Tempo.CurrentBeatsPerMinute + (double)AdjustBPM,
         NumBeatsToReach);
 }
 /* sweep the tempo to a new value */
 public static void TempoControlSweepToNewValue(
     TempoControlRec Tempo,
     LargeBCDType NewBPM,
     SmallExtBCDType NumBeatsToReach)
 {
     TempoControlSweepHelper(
         Tempo,
         (double)NewBPM,
         NumBeatsToReach);
 }
        /* helper for sweeping to new double-precision value */
        private static void TempoControlSweepHelper(
            TempoControlRec Tempo,
            double dNewBPM,
            SmallExtBCDType NumBeatsToReach)
        {
            if (dNewBPM < MINBPM)
            {
                dNewBPM = MINBPM;
            }
            double LocalNumBeatsToReach = (double)NumBeatsToReach;

            if (LocalNumBeatsToReach < 0)
            {
                LocalNumBeatsToReach = 0;
            }
            Tempo.BeatsPerMinuteChangeCountdown = (int)(LocalNumBeatsToReach * (DURATIONUPDATECLOCKRESOLUTION / 4));
            ResetLinearTransition(
                ref Tempo.BeatsPerMinuteChange,
                Tempo.CurrentBeatsPerMinute,
                dNewBPM,
                Tempo.BeatsPerMinuteChangeCountdown);
        }
Example #4
0
 public void ReadSXBCD(SmallExtBCDType sxbcd)
 {
     WriteInt32(sxbcd.rawInt32);
 }
Example #5
0
 public SmallExtBCDType ReadSXBCD()
 {
     return(SmallExtBCDType.FromRawInt32(ReadInt32()));
 }
        /* process commands in the queue that occur now.  this should be called after */
        /* queueing commands, but before incrementing the execution index, and before */
        /* processing the data, so that commands are handled at the beginning of a */
        /* transition. */
        public static void TrackEffectProcessQueuedCommands(
            TrackEffectGenRec Generator,
            SynthParamRec SynthParams)
        {
            if (Generator.List != null)
            {
                while ((Generator.ScanningGapListHead != null) &&
                       (Generator.ScanningGapListHead.StartTime <= Generator.ExecutionIndex))
                {
                    CommandConsCell Cell;

                    /* since the start time of commands can't be adjusted, there should */
                    /* never be a command that is strictly less than. */
#if DEBUG
                    if (Generator.ScanningGapListHead.StartTime < Generator.ExecutionIndex)
                    {
                        // early command
                        Debug.Assert(false);
                        throw new InvalidOperationException();
                    }
#endif
                    /* unlink the cons cell */
                    Cell = Generator.ScanningGapListHead;
                    Generator.ScanningGapListHead = Generator.ScanningGapListHead.Next;
                    if (Generator.ScanningGapListHead == null)
                    {
                        Generator.ScanningGapListTail = null;
                    }
                    /* see what we're supposed to do with the command */
                    switch ((NoteCommands)(Cell.Command.Flags & ~NoteFlags.eCommandFlag))
                    {
                    default:
                        Debug.Assert(false);
                        throw new ArgumentException();

                    case NoteCommands.eCmdSetEffectParam1:     /* specify the new default effect parameter in <1l> */
                    case NoteCommands.eCmdSetScoreEffectParam1:
                    case NoteCommands.eCmdSetSectionEffectParam1:
                        Generator.Accents0.Current
                            = (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents0.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdIncEffectParam1:     /* add <1l> to the default effect parameter */
                    case NoteCommands.eCmdIncScoreEffectParam1:
                    case NoteCommands.eCmdIncSectionEffectParam1:
                        Generator.Accents0.Current
                            += (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents0.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdSweepEffectParamAbs1:     /* <1l> = new effect parameter, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamAbs1:
                    case NoteCommands.eCmdSweepSectionEffectParamAbs1:
                        SweepToNewValue(
                            ref Generator.Accents0,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSweepEffectParamRel1:     /* <1l> = effect parameter adjust, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamRel1:
                    case NoteCommands.eCmdSweepSectionEffectParamRel1:
                        SweepToAdjustedValue(
                            ref Generator.Accents0,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSetEffectParam2:     /* specify the new default effect parameter in <1l> */
                    case NoteCommands.eCmdSetScoreEffectParam2:
                    case NoteCommands.eCmdSetSectionEffectParam2:
                        Generator.Accents1.Current
                            = (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents1.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdIncEffectParam2:     /* add <1l> to the default effect parameter */
                    case NoteCommands.eCmdIncScoreEffectParam2:
                    case NoteCommands.eCmdIncSectionEffectParam2:
                        Generator.Accents1.Current
                            += (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents1.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdSweepEffectParamAbs2:     /* <1l> = new effect parameter, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamAbs2:
                    case NoteCommands.eCmdSweepSectionEffectParamAbs2:
                        SweepToNewValue(
                            ref Generator.Accents1,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSweepEffectParamRel2:     /* <1l> = effect parameter adjust, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamRel2:
                    case NoteCommands.eCmdSweepSectionEffectParamRel2:
                        SweepToAdjustedValue(
                            ref Generator.Accents1,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSetEffectParam3:     /* specify the new default effect parameter in <1l> */
                    case NoteCommands.eCmdSetScoreEffectParam3:
                    case NoteCommands.eCmdSetSectionEffectParam3:
                        Generator.Accents2.Current
                            = (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents2.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdIncEffectParam3:     /* add <1l> to the default effect parameter */
                    case NoteCommands.eCmdIncScoreEffectParam3:
                    case NoteCommands.eCmdIncSectionEffectParam3:
                        Generator.Accents2.Current
                            += (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents2.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdSweepEffectParamAbs3:     /* <1l> = new effect parameter, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamAbs3:
                    case NoteCommands.eCmdSweepSectionEffectParamAbs3:
                        SweepToNewValue(
                            ref Generator.Accents2,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSweepEffectParamRel3:     /* <1l> = effect parameter adjust, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamRel3:
                    case NoteCommands.eCmdSweepSectionEffectParamRel3:
                        SweepToAdjustedValue(
                            ref Generator.Accents2,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSetEffectParam4:     /* specify the new default effect parameter in <1l> */
                    case NoteCommands.eCmdSetScoreEffectParam4:
                    case NoteCommands.eCmdSetSectionEffectParam4:
                        Generator.Accents3.Current
                            = (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents3.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdIncEffectParam4:     /* add <1l> to the default effect parameter */
                    case NoteCommands.eCmdIncScoreEffectParam4:
                    case NoteCommands.eCmdIncSectionEffectParam4:
                        Generator.Accents3.Current
                            += (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents3.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdSweepEffectParamAbs4:     /* <1l> = new effect parameter, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamAbs4:
                    case NoteCommands.eCmdSweepSectionEffectParamAbs4:
                        SweepToNewValue(
                            ref Generator.Accents3,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSweepEffectParamRel4:     /* <1l> = effect parameter adjust, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamRel4:
                    case NoteCommands.eCmdSweepSectionEffectParamRel4:
                        SweepToAdjustedValue(
                            ref Generator.Accents3,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSetEffectParam5:     /* specify the new default effect parameter in <1l> */
                    case NoteCommands.eCmdSetScoreEffectParam5:
                    case NoteCommands.eCmdSetSectionEffectParam5:
                        Generator.Accents4.Current
                            = (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents4.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdIncEffectParam5:     /* add <1l> to the default effect parameter */
                    case NoteCommands.eCmdIncScoreEffectParam5:
                    case NoteCommands.eCmdIncSectionEffectParam5:
                        Generator.Accents4.Current
                            += (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents4.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdSweepEffectParamAbs5:     /* <1l> = new effect parameter, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamAbs5:
                    case NoteCommands.eCmdSweepSectionEffectParamAbs5:
                        SweepToNewValue(
                            ref Generator.Accents4,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSweepEffectParamRel5:     /* <1l> = effect parameter adjust, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamRel5:
                    case NoteCommands.eCmdSweepSectionEffectParamRel5:
                        SweepToAdjustedValue(
                            ref Generator.Accents4,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSetEffectParam6:     /* specify the new default effect parameter in <1l> */
                    case NoteCommands.eCmdSetScoreEffectParam6:
                    case NoteCommands.eCmdSetSectionEffectParam6:
                        Generator.Accents5.Current
                            = (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents5.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdIncEffectParam6:     /* add <1l> to the default effect parameter */
                    case NoteCommands.eCmdIncScoreEffectParam6:
                    case NoteCommands.eCmdIncSectionEffectParam6:
                        Generator.Accents5.Current
                            += (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents5.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdSweepEffectParamAbs6:     /* <1l> = new effect parameter, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamAbs6:
                    case NoteCommands.eCmdSweepSectionEffectParamAbs6:
                        SweepToNewValue(
                            ref Generator.Accents5,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSweepEffectParamRel6:     /* <1l> = effect parameter adjust, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamRel6:
                    case NoteCommands.eCmdSweepSectionEffectParamRel6:
                        SweepToAdjustedValue(
                            ref Generator.Accents5,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSetEffectParam7:     /* specify the new default effect parameter in <1l> */
                    case NoteCommands.eCmdSetScoreEffectParam7:
                    case NoteCommands.eCmdSetSectionEffectParam7:
                        Generator.Accents6.Current
                            = (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents6.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdIncEffectParam7:     /* add <1l> to the default effect parameter */
                    case NoteCommands.eCmdIncScoreEffectParam7:
                    case NoteCommands.eCmdIncSectionEffectParam7:
                        Generator.Accents6.Current
                            += (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents6.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdSweepEffectParamAbs7:     /* <1l> = new effect parameter, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamAbs7:
                    case NoteCommands.eCmdSweepSectionEffectParamAbs7:
                        SweepToNewValue(
                            ref Generator.Accents6,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSweepEffectParamRel7:     /* <1l> = effect parameter adjust, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamRel7:
                    case NoteCommands.eCmdSweepSectionEffectParamRel7:
                        SweepToAdjustedValue(
                            ref Generator.Accents6,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSetEffectParam8:     /* specify the new default effect parameter in <1l> */
                    case NoteCommands.eCmdSetScoreEffectParam8:
                    case NoteCommands.eCmdSetSectionEffectParam8:
                        Generator.Accents7.Current
                            = (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents7.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdIncEffectParam8:     /* add <1l> to the default effect parameter */
                    case NoteCommands.eCmdIncScoreEffectParam8:
                    case NoteCommands.eCmdIncSectionEffectParam8:
                        Generator.Accents7.Current
                            += (double)LargeBCDType.FromRawInt32(Cell.Command._Argument1);
                        Generator.Accents7.ChangeCountdown = 0;
                        break;

                    case NoteCommands.eCmdSweepEffectParamAbs8:     /* <1l> = new effect parameter, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamAbs8:
                    case NoteCommands.eCmdSweepSectionEffectParamAbs8:
                        SweepToNewValue(
                            ref Generator.Accents7,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdSweepEffectParamRel8:     /* <1l> = effect parameter adjust, <2xs> = # of beats to get there */
                    case NoteCommands.eCmdSweepScoreEffectParamRel8:
                    case NoteCommands.eCmdSweepSectionEffectParamRel8:
                        SweepToAdjustedValue(
                            ref Generator.Accents7,
                            LargeBCDType.FromRawInt32(Cell.Command._Argument1),
                            SmallExtBCDType.FromRawInt32(Cell.Command._Argument2));
                        break;

                    case NoteCommands.eCmdTrackEffectEnable:
                    case NoteCommands.eCmdScoreEffectEnable:
                    case NoteCommands.eCmdSectionEffectEnable:
                        if (!Generator.AutoQuiescence)
                        {
                            /* if autoquiescence is enabled, ignore the commands */
                            Generator.Enable = (Cell.Command._Argument1 < 0);
                        }
                        break;
                    }
                }

                /* increment our scanning gap back edge clock, after scheduling commands */
                /* (this way, commands are scheduled on the beginning of the clock they */
                /* should occur on). */
                Generator.ExecutionIndex += 1;
                /* since this routine is only called when samples are being generated, */
                /* we don't have to worry about when to increment this counter */
            }
        }