Exemplo n.º 1
0
 protected override void Load(int table)
 {
     SetOffset(table);
     for (int i = 0; i < Length; i++)
     {
         int off = table + (i * 0xC);
         if (!ROM.IsValidRomOffset(off))
         {
             break;
         }
         var voice = ROM.Instance.Reader.ReadObject <M4AVoiceEntry>(off);
         voice.SetOffset(off);
         if (voice.Type == (int)M4AVoiceFlags.KeySplit)
         {
             voices[i] = new M4AWrappedKeySplit(voice);
         }
         else if (voice.Type == (int)M4AVoiceFlags.Drum)
         {
             voices[i] = new M4AWrappedDrum(voice);
         }
         else if ((voice.Type & 0x7) == (int)M4AVoiceType.Direct)
         {
             voices[i] = new M4AWrappedDirect(voice);
         }
         else
         {
             voices[i] = new WrappedVoice(voice);
         }
     }
 }
Exemplo n.º 2
0
        public override WrappedVoice GetVoiceFromNote(byte voice, sbyte note, out bool fromDrum)
        {
            fromDrum = false;

            WrappedVoice sv = voices[voice];

Read:
            M4AVoiceEntry v = (M4AVoiceEntry)sv.Voice;

            switch (v.Type)
            {
            case (int)M4AVoiceFlags.KeySplit:
                fromDrum = false;     // In case there is a multi within a drum
                var  keySplit = (M4AWrappedKeySplit)sv;
                byte inst     = ROM.Instance.Reader.ReadByte(v.Keys - ROM.Pak + note);
                sv = keySplit.Table[inst];
                goto Read;

            case (int)M4AVoiceFlags.Drum:
                fromDrum = true;
                var drum = (M4AWrappedDrum)sv;
                sv = drum.Table[note];
                goto Read;

            default:
                return(sv);
            }
        }
Exemplo n.º 3
0
        // Places voice info into the panel
        void SetVoice(int mainIndex, int subIndex)
        {
            subVoicesListView.SelectedIndexChanged -= SubIndexChanged;
            addressValue.ValueChanged  -= ArgumentChanged;
            voiceAValue.ValueChanged   -= ArgumentChanged; voiceDValue.ValueChanged -= ArgumentChanged; voiceSValue.ValueChanged -= ArgumentChanged; voiceRValue.ValueChanged -= ArgumentChanged;
            addressValue.Visible        = addressLabel.Visible =
                voiceAValue.Visible     = voiceDValue.Visible = voiceSValue.Visible = voiceRValue.Visible =
                    voiceALabel.Visible = voiceDLabel.Visible = voiceSLabel.Visible = voiceRLabel.Visible = false;

            WrappedVoice voice = table[mainIndex];
            var          subs  = voice.GetSubVoices().ToArray();

            if (voice.Voice is M4AVoiceEntry m4aEntry)
            {
                if (subIndex != -1)
                {
                    m4aEntry = (M4AVoiceEntry)((WrappedVoice)subs[subIndex]).Voice;
                }
                entry = m4aEntry;
                var flags = (M4AVoiceFlags)m4aEntry.Type;
                var type  = (M4AVoiceType)(m4aEntry.Type & 0x7);

                #region Addresses (Direct, Key Split, Drum, Wave)

                if (type == M4AVoiceType.Direct || type == M4AVoiceType.Wave || flags == M4AVoiceFlags.KeySplit || flags == M4AVoiceFlags.Drum)
                {
                    addressValue.Hexadecimal = true;
                    addressValue.Maximum     = ROM.Capacity - 1;
                    addressValue.Visible     = addressLabel.Visible = true;
                    addressValue.Value       = m4aEntry.Address - ROM.Pak;
                }

                #endregion

                #region ADSR (everything except Key Split, Drum and invalids)

                if (flags != M4AVoiceFlags.KeySplit && flags != M4AVoiceFlags.Drum && !m4aEntry.IsInvalid())
                {
                    bool bDirect = !m4aEntry.IsGBInstrument();
                    voiceAValue.Hexadecimal = voiceDValue.Hexadecimal = voiceSValue.Hexadecimal = voiceRValue.Hexadecimal = false;
                    voiceAValue.Maximum     = voiceDValue.Maximum = voiceRValue.Maximum = bDirect ? byte.MaxValue : 0x7;
                    voiceSValue.Maximum     = bDirect ? byte.MaxValue : 0xF;
                    voiceAValue.Minimum     = voiceDValue.Minimum = voiceSValue.Minimum = voiceRValue.Minimum = byte.MinValue;
                    voiceAValue.Visible     = voiceDValue.Visible = voiceSValue.Visible = voiceRValue.Visible =
                        voiceALabel.Visible = voiceDLabel.Visible = voiceSLabel.Visible = voiceRLabel.Visible = true;
                    voiceAValue.Value       = m4aEntry.ADSR.A;
                    voiceDValue.Value       = m4aEntry.ADSR.D;
                    voiceSValue.Value       = m4aEntry.ADSR.S;
                    voiceRValue.Value       = m4aEntry.ADSR.R;
                }

                #endregion
            }
            else if (voice.Voice is MLSSVoice mlss)
            {
                if (mlss.Entries.Length > 0)
                {
                    if (subIndex == -1)
                    {
                        subIndex = 0;
                    }
                    var mlssEntry = mlss.Entries[subIndex];
                    entry = mlssEntry;

                    #region Last 4 values are probably ADSR

                    voiceAValue.Hexadecimal = voiceDValue.Hexadecimal = voiceSValue.Hexadecimal = voiceRValue.Hexadecimal = true;
                    voiceAValue.Maximum     = voiceDValue.Maximum = voiceSValue.Maximum = voiceRValue.Maximum = byte.MaxValue;
                    voiceAValue.Minimum     = voiceDValue.Minimum = voiceSValue.Minimum = voiceRValue.Minimum = byte.MinValue;
                    voiceAValue.Visible     = voiceDValue.Visible = voiceSValue.Visible = voiceRValue.Visible =
                        voiceALabel.Visible = voiceDLabel.Visible = voiceSLabel.Visible = voiceRLabel.Visible = true;

                    voiceAValue.Value = mlssEntry.Unknown1;
                    voiceDValue.Value = mlssEntry.Unknown2;
                    voiceSValue.Value = mlssEntry.Unknown3;
                    voiceRValue.Value = mlssEntry.Unknown4;

                    #endregion
                }
            }

            subVoicesListView.SelectedIndex         = subIndex;
            subVoicesListView.SelectedIndexChanged += SubIndexChanged;
            addressValue.ValueChanged += ArgumentChanged;
            voiceAValue.ValueChanged  += ArgumentChanged; voiceDValue.ValueChanged += ArgumentChanged; voiceSValue.ValueChanged += ArgumentChanged; voiceRValue.ValueChanged += ArgumentChanged;
        }