Beispiel #1
0
        public static Increments FromJSON(JSONObject j)
        {
            var o = Increments.Prototype();

            try
            {
                j.Assign("hz", ref o.hz);
                j.Assign("base_hz", ref o.base_hz);
                j.Assign("tuned_hz", ref o.tuned_hz);
                j.Assign("fixedFreq", ref o.fixedFreq);

                j.Assign("mult", ref o.mult);
                j.Assign("coarse", ref o.coarse);
                j.Assign("fine", ref o.fine);

                o.Detune = j.GetItem("detune", o.Detune); //Set up real detune values using the setter
                j.Assign("detune_randomness", ref o.detune_randomness);
                j.Assign("increment_offset", ref o.increment_offset);

                o.Recalc();
            } catch (Exception e) {
                System.Diagnostics.Debug.Assert(false, "PG Copy failed:  " + e.Message);
            }

            return(o);
        }
Beispiel #2
0
        public bool FromJSON(JSONObject j)
        {
            try
            {
                if (j.HasItem("intent")) //Probably clipboard data or data from UI.  Check for matching intent.  If not the same, fail operation.
                {
                    var expectedIntent = (RTableIntent)j.GetItem("intent", -1);
                    if (intent != expectedIntent)
                    {
                        throw new Exception("Intent does not match!");
                    }
                }

                j.Assign("floor", ref floor);
                j.Assign("ceiling", ref ceiling);

                if (j.HasItem("tbl"))
                {
                    try
                    {                       //Call the appropriate override for ValuesFromBase64() for the given intent.
                        values = ValuesFromBase64(j.GetItem("tbl", ""));
                    } catch (Exception e) { //Catch any exceptions that ValuesFromBase64() might've thrown trying to parse the table.
                        #if DEBUG
                        System.Diagnostics.Debug.Fail(String.Format("{1}: Value table copy failed: {0}", e.Message, GetType().Name));
                        System.Diagnostics.Debugger.Break();
                        throw e;
                        #endif
                        //FIXME:  Consider printing some shit to output in release mode, otherwise this func will just return false.
                    }
                }
            } catch (Exception e) {
                System.Diagnostics.Debug.Fail(String.Format("{1} copy failed: {0}", e.Message, GetType().Name)); //DEBUG, REMOVE ME?

                return(false);
            }

            return(true);
        }