Пример #1
0
        private void SaveButtonListener()
        {
            var ccDef = new CcDef(int.Parse(View.CcInput.text));

            ccDef.SetLabel(View.NameInput.text);
            ccDef.SetStartValue(int.Parse(View.StartInput.text));
            ccDef.SetMinValue(int.Parse(View.MinInput.text));
            ccDef.SetMaxValue(int.Parse(View.MaxInput.text));

            AddCcDefSignal.Dispatch(ccDef);
            ResetValues();
        }
Пример #2
0
        public InstrumentDef ParseInstrument(string name, JSONNode json)
        {
            var instrumentDef = new InstrumentDef();

            var defaultPatternString = json[JsonKeys.DEFAULT_PATT];

            Enum.TryParse(defaultPatternString, true, out PatternType defaultPattern);

            // GLOBAL
            instrumentDef.Name        = name;
            instrumentDef.MidiPort    = json[JsonKeys.MIDI_PORT];
            instrumentDef.MidiChannel = json[JsonKeys.MIDI_CHAN];

            if (json[JsonKeys.DEFAULT_NOTE] != "off")
            {
                instrumentDef.DefaultNote = new Note((string)json[JsonKeys.DEFAULT_NOTE]);
            }

            instrumentDef.DefaultPattern = defaultPattern;
            instrumentDef.Multi          = json[JsonKeys.MULTI];
            instrumentDef.PolySpread     = json[JsonKeys.POLY_SPREAD];
            instrumentDef.NoFts          = json[JsonKeys.NO_FTS];
            instrumentDef.NoXpose        = json[JsonKeys.NO_XPOSE];

            Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() : =================={name}==================</color>");
            Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() GLOBAL - MidiPort:{instrumentDef.MidiPort}</color>");
            Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() GLOBAL - MidiChannel:{instrumentDef.MidiChannel}</color>");
            Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() GLOBAL - DefaultNote:{instrumentDef.DefaultNote}</color>");
            Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() GLOBAL - DefaultPattern:{instrumentDef.DefaultPattern}</color>");
            Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() GLOBAL - Multi:{instrumentDef.Multi}</color>");
            Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() GLOBAL - PolySpread:{instrumentDef.PolySpread}</color>");
            Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() GLOBAL - NoFts:{instrumentDef.NoFts}</color>");
            Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() GLOBAL - NoXpose:{instrumentDef.NoXpose}</color>");

            //TRACK VALUES
            var trackValuesJson = json[JsonKeys.TRACK_VALUES];

            foreach (string trackValueKey in trackValuesJson.Keys)
            {
                var slotIndex     = int.Parse(trackValueKey.Substring(TRACK_VALUE_INT_POS));
                var trackValueDef = ParseTrackValueDef(slotIndex, trackValuesJson[trackValueKey]);
                if (trackValueDef != null)
                {
                    instrumentDef.TrackValues[trackValueDef.SlotIndex] = trackValueDef;

                    if (trackValueDef.Type == TrackValueType.MidiCC)
                    {
                        Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() TRACK VALUE - Label: {trackValueDef.Label}, CC: {trackValueDef.MidiCC}</color>");
                    }
                    else if (trackValueDef.Type == TrackValueType.TrackControl)
                    {
                        Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() TRACK VALUE - TrackControl: {trackValueDef.TrackControl}</color>");
                    }
                }
            }

            //CC DEFS
            var ccDefsJson = json[JsonKeys.CC_DEFS];

            foreach (string ccDefKey in ccDefsJson.Keys)
            {
                var ccNum     = int.Parse(ccDefKey.Substring(CC_DEF_INT_POS));
                var ccDefJson = ccDefsJson[ccDefKey];
                var ccDef     = new CcDef(ccNum);

                ccDef.SetLabel(ccDefJson[JsonKeys.LABEL]);
                ccDef.SetMinValue(ccDefJson[JsonKeys.MIN_VAL]);

                if (ccDefJson[JsonKeys.MAX_VAL] != null)
                {
                    ccDef.SetMaxValue(ccDefJson[JsonKeys.MAX_VAL]);
                }

                ccDef.SetStartValue(ccDefJson[JsonKeys.START_VAL]);

                instrumentDef.CcDefs[ccNum] = ccDef;

                Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() CC DEF - Label: {ccDef.Label}, ccNum: {ccDef.CcNum}</color>");
            }

            //NOTE ROWS
            var noteRowsJson = json[JsonKeys.ROW_DEFS];

            foreach (string noteDefKey in noteRowsJson.Keys)
            {
                var noteRowJson = noteRowsJson[noteDefKey];
                var noteRow     = new NoteRowDef();
                noteRow.SetNote(new Note(noteDefKey));
                noteRow.SetLabel(noteRowJson[JsonKeys.LABEL]);
                noteRow.SetAlwaysShow(noteRowJson[JsonKeys.ALWAYS_SHOW]);

                instrumentDef.NoteRowDefs[noteRow.Note.Id] = noteRow;

                Debug.LogWarning($"<color=\"aqua\">InitAppCommand.ParseInstrument() {instrumentDef.Name} - NOTE ROW DEF - Note: {noteRow.Note.Name}, Label: {noteRow.Label}, AlwaysShow: {noteRow.AlwaysShow}, </color>");
            }

            return(instrumentDef);
        }