예제 #1
0
    public void ImportVGMFile(BinaryReader reader)
    {
        /*  TODO:
         *      Make sure that instrument editor is updated
         *      Make sure tracker controls are updated (specifically pattern length)
         */

        instruments.CreateInstrument();
        instruments.presets[0].volumeTable = new int[] { 0xF };
        instruments.presets[1].volumeTable = new int[] { 0xF };

        data.SetPatternLength(128);
        data.SetData(0, 0, 3, 0xf);
        data.SetData(0, 0, 4, 0x1);
        reader.BaseStream.Position = 0x40;
        data.currentPattern        = 0;
        m_LastVol = new int[4];

        bool eof = false;

        while (reader.BaseStream.Position < reader.BaseStream.Length && !eof)
        {
            byte cmd = reader.ReadByte();
            switch (cmd)
            {
            case 0x50:
                byte val = reader.ReadByte();
                ParsePSGData(val);
                break;

            case 0x61:
                int inc = Mathf.FloorToInt(reader.ReadUInt16() / 735.0f);
                m_CurrRow += inc;
                if (m_CurrRow >= data.patternLength)
                {
                    m_CurrRow -= data.patternLength;
                    data.AddPatternLine();
                }
                break;

            case 0x62:
            case 0x63:
                m_CurrRow++;
                if (m_CurrRow >= data.patternLength)
                {
                    m_CurrRow = 0;
                    data.AddPatternLine();
                }
                break;

            case 0x66:
                eof = true;
                break;
            }
        }

        matrix.UpdateMatrix();
        view.UpdatePatternData();
    }
예제 #2
0
 public void NewInstrument()
 {
     instruments.CreateInstrument( );
     UpdateEnvelopes();
     view.UpdatePatternData();
     UpdateInstruments();
     SetSelectedInstrument(instruments.presets.Length - 1);
 }
    private void IncInstrument(int dir)
    {
        keyboard.currentInstrument += dir;
        if (keyboard.currentInstrument < 0)
        {
            keyboard.currentInstrument = 0;
        }
        if (keyboard.currentInstrument >= instruments.presets.Length)
        {
            instruments.CreateInstrument( );
        }

        UpdateAttributes( );
    }