Exemple #1
0
 void pingManagers()
 {
     GameManager.ping();
     BeatManager.ping();
     GraphicsManager.ping();
     StageManager.ping();
     GDMethods.init();
 }
Exemple #2
0
 public static Note getCurrentNote(GD type)
 {
     for (int i = 0; i < maxSearch; i++)
     {
         Note note = NotesToPlay[notePosition + i];
         if (GDMethods.getBeatType(note.instrumentName) == type)
         {
             return(note);
         }
     }
     return(null);
 }
    private string ToMBT(long eventTime, int ticksPerQuarterNote, NAudio.Midi.TimeSignatureEvent timeSignature)
    {
        int   beatsPerBar  = timeSignature == null ? 4 : timeSignature.Numerator;
        int   ticksPerBar  = timeSignature == null ? ticksPerQuarterNote * 4 : (timeSignature.Numerator * ticksPerQuarterNote * 4) / (1 << timeSignature.Denominator);
        int   ticksPerBeat = ticksPerBar / beatsPerBar;
        long  bar          = (eventTime / ticksPerBar);
        long  beat         = ((eventTime % ticksPerBar) / ticksPerBeat);
        long  tick         = eventTime % ticksPerBeat;
        float milsPerTick  = milliSecondsPerQuartNote / ticksPerBeat;

        String initialMidiString = currentMidiEvent.ToString();

        int currentChannel = getChannelNumber(initialMidiString);
        int noteLength     = getMidiNoteLength(initialMidiString);

        if (noteLength != 0 && currentChannel > -1)
        {
            //START TIME AND DURATION TIME ARE CALCULATED HERE!!!!
            Note newNote = new Note();
            //Double theStartTime = (bar * milliSecondsPerQuartNote * 4) + (milliSecondsPerQuartNote * (beat));
            Double theStartTime = eventTime * milsPerTick;
            newNote.startTime = theStartTime;             //Start time Measured in milliseconds
            String midiInfo   = currentMidiEvent.ToString();
            String typeOfNote = getTypeOfNote(midiInfo, currentChannel);
            newNote.notePitch       = typeOfNote;
            newNote.noteVelocity    = getVelocity(midiInfo);
            newNote.notePitchNumber = GDMethods.getPitchNumber(newNote.notePitch);
            //Debug.Log("Converted " + typeOfNote + " to -> " + newNote.notePitchNumber);
            Double timeOfNote = noteLength;
            //newNote.durationTime = ((((double)(timeOfNote))/(double)ticksPerBeat)* milliSecondsPerQuartNote);//Duration slso meseaured in milliseconds
            //TODO - check this
            newNote.durationTime = noteLength * milsPerTick;
            Channels[currentChannel].Notes.Add(newNote);

            if (!Channels[currentChannel].TypesOfNotes.Contains(typeOfNote))
            {
                Channels[currentChannel].TypesOfNotes.Add(typeOfNote);
            }
        }


        string finalReturn = String.Format("{0}:{1}:{2}", bar + 1, beat + 1, tick);

        Console.WriteLine(finalReturn);
        return(finalReturn);
        //Print out this string to see full output
    }
Exemple #4
0
    public static void checkBeats(float time)
    {
        if (NotesToPlay != null)
        {
            while (notePosition < NotesToPlay.Count && NotesToPlay[notePosition].startTime <= time)
            {
                Note note     = NotesToPlay[notePosition];
                GD   noteType = GDMethods.getBeatType(note.instrumentName);

                float interp = (float)(time - note.startTime) / 1000;

                if (note.durationTime >= GameManager.durationForHold)
                {
                    callBeat(noteType, interp, (float)note.durationTime);
                }
                else
                {
                    callBeat(noteType, interp);
                }
                notePosition++;
            }

            while (noteBarPosition < NotesToPlay.Count && NotesToPlay[noteBarPosition].startTime <= (time + 4500f))
            {
                //Debug.Log ("" + noteBarPosition + ":" + NotesToPlay[noteBarPosition].startTime);
                Note note     = NotesToPlay[noteBarPosition];
                GD   noteType = GDMethods.getBeatType(note.instrumentName);

                float interp = (float)(time + 4500f - note.startTime) / 1000;
                callNoteBarBeat(noteType, interp);
                noteBarPosition++;
            }
        }

        if (notePosition >= NotesToPlay.Count)
        {
            delayToScores -= Time.deltaTime;

            if (delayToScores <= 0)
            {
                GameManager.endLevel();
            }
        }
    }