Example #1
0
    public string GetSentence()
    {
        string cond1String    = ConditionString(cond1Ind, true);
        string cond2String    = ConditionString(cond2Ind, false);
        string boolCondString = greater ? ">" : "<";
        string actionString   = ActionString(action);

        return(string.Format("If {0} {1} {2}, {3} for {4} note", cond1String, boolCondString, cond2String, actionString, note.ToString()));
    }
Example #2
0
    void Play(List <PlayInstructs> instructs, ConstFile.Notes note)
    {
        DebugPanel.Log(note.ToString(), "W/E", instructs.Count);
        IGATProcessedSample sample;

        string[] noteArr;
        while (GATManager.DefaultPlayer.NbOfTracks < 20)
        {
            GATManager.DefaultPlayer.AddTrack <GATTrack>();

            /*
             * noteArr = chords[chordIndex];
             *
             * sample = sampleBank.GetProcessedSample(string.Format(noteArr[0], 3), wholeEnv);
             * sample.Play(0);
             * sample = sampleBank.GetProcessedSample(string.Format(noteArr[1], 3), wholeEnv);
             * sample.Play(0);
             * sample = sampleBank.GetProcessedSample(string.Format(noteArr[2], 3), wholeEnv);
             * sample.Play(0);
             */
        }
        noteArr = chords[chordIndex];
        GATData mySampleData;

        switch (note)
        {
        case ConstFile.Notes.WHOLE:
            chordIndex++;
            chordIndex = chordIndex % chords.Count;
            wholeCnt++;
            halfCnt      = -1;
            quarterCnt   = -1;
            eigthCnt     = -1;
            sixteenthCnt = -1;
            sampleBank.FlushCacheForEnvelope(wholeEnv);
            sampleBank.FlushCacheForEnvelope(halfEnv);
            sampleBank.FlushCacheForEnvelope(quarterEnv);
            sampleBank.FlushCacheForEnvelope(eigthEnv);
            sampleBank.FlushCacheForEnvelope(sixteenthEnv);
            break;

        case ConstFile.Notes.HALF:
            halfCnt++;
            break;

        case ConstFile.Notes.QUARTER:
            quarterCnt++;
            if (quarterCnt % 4 == 1 || quarterCnt % 4 == 3)
            {
                mySampleData = sampleBank.GetAudioData("clap-808");
                GATManager.DefaultPlayer.PlayData(mySampleData, 1, 1);
            }
            break;

        case ConstFile.Notes.EIGHTH:
            eigthCnt++;
            if (eigthCnt % 8 == 0 || eigthCnt % 8 == 1 || eigthCnt % 8 == 5)
            {
                mySampleData = sampleBank.GetAudioData("kick-gritty");
                GATManager.DefaultPlayer.PlayData(mySampleData, 1, 1);
            }
            mySampleData = sampleBank.GetAudioData(string.Format(noteArr[0], 2));
            GATManager.DefaultPlayer.PlayData(mySampleData, 3, .2f);
            break;

        case ConstFile.Notes.SIXTEENTH:
            sixteenthCnt++;
            if ((sixteenthCnt % 16 == 14 || sixteenthCnt % 16 == 15) && wholeCnt % 2 == 0)
            {
                mySampleData = sampleBank.GetAudioData("hihat-808");
                GATManager.DefaultPlayer.PlayData(mySampleData, 2, 1);
            }
            break;
        }

        if (instructs.Count == 0)
        {
            return;
        }
        GATEnvelope env;

        switch (instructs[0].note)
        {
        case ConstFile.Notes.WHOLE:
            env = wholeEnv;
            break;

        case ConstFile.Notes.HALF:
            env = halfEnv;
            break;

        case ConstFile.Notes.QUARTER:
            env = quarterEnv;
            break;

        case ConstFile.Notes.EIGHTH:
            env = eigthEnv;
            break;

        case ConstFile.Notes.SIXTEENTH:
            env = sixteenthEnv;
            break;

        default:
            throw new System.Exception(string.Format("Invalid note: {0}", instructs[0].note));
        }


        for (int i = 0; i < instructs.Count; i++)
        {
            if (instructs[i].Alive())
            {
                instructs[i].MakeMove();
                if (instructs[i].action != ConstFile.Actions.REST || instructs[i].puppetType() == ConstFile.PuppetType.TOWER)
                {
                    // Attempt to double size of note area for more variance.
                    int noteInd = ArenaGrid.FindSubsection(noteArr.Length * 2, instructs[i].y);
                    int octave  = instructs[i].puppetType() == PuppetType.BASS ? 2 : 4;
                    if (noteInd > noteArr.Length)
                    {
                        octave++;
                    }
                    noteInd = noteInd % noteArr.Length;
                    sample  = sampleBank.GetProcessedSample(string.Format(noteArr[noteInd], octave), env);
                    sample.Play(0);
                    //Debug.Log("Played " + instructs[i].note);
                }
            }
        }
    }