Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Dump to file
            MidiFile.UserMods mods = new MidiFile.UserMods();

            mods.difficulty = new float[4];
            for (int i = 0; i < 4; i++)
            {
                mods.difficulty[i] = difficulties[i];
            }

            mods.GuitarTracks = GuitarTracks;
            mods.RhythmTracks = RhythmTracks;
            mods.DrumTracks   = DrumTracks;
            mods.VocalTracks  = VocalTracks;

            mods.changedNotes = changes;

            // Copy .mid to .fff
            System.IO.File.Copy(filename, filename.Substring(0, filename.Length - 4) + ".fff", true);

            // Dump mods to a .ffm file
            mods.filename = filename.Substring(0, filename.Length - 4) + ".ffm";
            mods.DumpToFile();
        }
Ejemplo n.º 2
0
        public MidiManager(Game game, Player player, int instrument, float difficulty, String filename)
            : base(game)
        {
            this.player = player;
            MidiFile.UserMods mods   = new MidiFile.UserMods(filename);
            List <int>        tracks = instrument == Player.GUITAR ? mods.GuitarTracks : instrument == Player.RHYTHM ? mods.RhythmTracks : instrument == Player.DRUMS ? mods.DrumTracks : mods.VocalTracks;

            curMusicFile = new MidiFile();

            if (!curMusicFile.GenerateNotesFromFile(filename, tracks, difficulty))
            {
                throw new System.NotSupportedException();
            }

            // Apply user defined individual note changes
            List <int[]> changes = difficulty >= 0.95 ? null : mods.GetChangedNotes(instrument, difficulty < 0.25 ? 0 : difficulty < 0.5 ? 1 : difficulty < 0.75 ? 2 : 3);

            if (changes != null)
            {
                foreach (int[] i_a in changes)
                {
                    curMusicFile.AllNotes[i_a[0]].type = (ulong)i_a[1];
                }
            }

            // Set HOPO/tappable notes
            if (curMusicFile.AllNotes.Count > 1)
            {
                NoteX last = curMusicFile.AllNotes[0];
                for (int i = 1; i < curMusicFile.AllNotes.Count; i++)
                {
                    NoteX curr = curMusicFile.AllNotes[i];
                    if (curr.type != last.type && curr.time != last.time)
                    {
                        // Make sure next note isn't at the same time slot
                        if (i == curMusicFile.AllNotes.Count - 1 || curr.time != curMusicFile.AllNotes[i + 1].time)
                        {
                            if (curr.time - last.time < HOPO_Threshold)
                            {
                                curMusicFile.AllNotes[i].type |= (1 << 5);
                            }
                        }
                    }
                    last = curr;
                }
            }

            /*
             * // Add quarter-note ticks (may change by a factor of 2 for fast and slow songs)
             * int msToNextQuarterNote = 0;
             * curMusicFile.ticksPerBeat;
             * curMusicFile.ticksPerFrame;
             * curMusicFile.timeCode;
             *
             * int[] indexs = new int[curMusicFile.totalTracks];
             * for(int ii=0; ii<curMusicFile.totalTracks; ii++)
             *  indexs[ii] = 0;
             *
             * bool loop;
             * do
             * {
             *  loop = false;
             *  for (int ii = 0; ii < curMusicFile.totalTracks; ii++)
             *  {
             *      if(curMusicFile.allTracks[ii].allEvents[indexs[ii]].eventType == 0x51
             *  }
             *
             * } while (loop);
             *
             */
            allBeats = curMusicFile.markers;
            _noteSet = curMusicFile.AllNotes.ToArray();
            NoteX.InitializeSet(NoteSet, player);

            // Build in Unsigned format
            _songData      = new SongData();
            _songData.info = new SongData.FullBandChunk();
            SongData.Barline[] myBarlines = new SongData.Barline[curMusicFile.markers.Count];
            for (int i = 0; i < curMusicFile.markers.Count; i++)
            {
                myBarlines[i] = new SongData.Barline((uint)curMusicFile.markers[i], 1);
            }
            _songData.info.barlines = myBarlines;
        }