void Awake() { syntheStation = GameObject.FindObjectOfType <MySyntheStation>(); sampleTools = GameObject.FindObjectOfType <SampleTools>(); mmlBox = sampleTools.GetComponent <MyMMLBox>(); { Button extend = transform.FindChild("Panel/Extend").GetComponent <Button>(); extend.onClick.AddListener(() => { param.Extended = !param.Extended; updateParam(); loadTone(param); }); } { inputField = transform.FindChild("Panel/InputField").GetComponent <InputField>(); inputField.onEndEdit.AddListener((v) => { if ((v != null) && (v.Length != 0)) { loadTone(new ToneParam(v)); } else { loadTone(new ToneParam(defaultTone)); } }); PresetButton [] presets = GetComponentsInChildren <PresetButton>(); foreach (PresetButton pb in presets) { Button btn = pb.GetComponent <Button>(); ToneParam tp = new ToneParam(pb.ToneData); btn.onClick.AddListener(() => { loadTone(tp); }); } } { GameObject obj = transform.FindChild("Panel/LFO").gameObject; setupSlider(obj, "WaveForm", "lw:", (val) => { param.Lfo.WS = (Byte)val; updateParam(); }); setupSlider(obj, "Frequency", "lf:", (val) => { param.Lfo.LF = (Byte)val; updateParam(); }); setupSlider(obj, "PMPower", "lp:", (val) => { param.Lfo.LP = (Byte)val; updateParam(); }); setupSlider(obj, "AMPower", "la:", (val) => { param.Lfo.LA = (Byte)val; updateParam(); }); setupSlider(obj, "AttackRate", "ar:", (val) => { param.Lfo.Env.AR = (Byte)val; updateParam(); }); setupSlider(obj, "DecayRate", "dr:", (val) => { param.Lfo.Env.DR = (Byte)val; updateParam(); }); setupSlider(obj, "SustainLevel", "sl:", (val) => { param.Lfo.Env.SL = (Byte)val; updateParam(); }); setupSlider(obj, "SustainRate", "sr:", (val) => { param.Lfo.Env.SR = (Byte)val; updateParam(); }); setupSlider(obj, "ReleaseRate", "rr:", (val) => { param.Lfo.Env.RR = (Byte)val; updateParam(); }); } { GameObject obj = transform.FindChild("Panel/ENV").gameObject; setupSlider(obj, "WaveStyle", "ws:", (val) => { param.WS = (Byte)val; updateParam(); }); setupSlider(obj, "KeyScale", "ks:", (val) => { param.Env.KS = (Byte)val; updateParam(); }); setupSlider(obj, "VelocitySense", "vs:", (val) => { param.Env.VS = (Byte)val; updateParam(); }); setupSlider(obj, "TotalLevel", "tl:", (val) => { param.Env.TL = (Byte)val; updateParam(); }); setupSlider(obj, "AttackRate", "ar:", (val) => { param.Env.AR = (Byte)val; updateParam(); }); setupSlider(obj, "DecayRate", "dr:", (val) => { param.Env.DR = (Byte)val; updateParam(); }); setupSlider(obj, "SustainLevel", "sl:", (val) => { param.Env.SL = (Byte)val; updateParam(); }); setupSlider(obj, "SustainRate", "sr:", (val) => { param.Env.SR = (Byte)val; updateParam(); }); setupSlider(obj, "ReleaseRate", "rr:", (val) => { param.Env.RR = (Byte)val; updateParam(); }); } { WaveTable wt = transform.FindChild("Panel/WaveTable").GetComponent <WaveTable>(); wt.OnUpdateAction = (idx) => { param.WT[idx] = wt.WT[idx]; updateParam(); }; } { Keyboard keyboard = transform.FindChild("Panel/Keyboard").GetComponent <Keyboard>(); keyboard.ChNo = ChNo; keyboard.PortNo = PortNo; } { Transform mmlEditorCanvas = transform.parent.FindChild("MMLPlayerCanvas"); Button button = transform.FindChild("Panel/MMLEditorButton").GetComponent <Button>(); button.onClick.AddListener(() => { mmlBox.Play("Click"); sampleTools.MoveCameraTo(mmlEditorCanvas.localPosition); }); } }
void Awake() { player = GameObject.FindObjectOfType <MyMMLPlayer>(); sampleTools = GameObject.FindObjectOfType <SampleTools>(); mmlBox = sampleTools.GetComponent <MyMMLBox>(); #if false { string mml = "$@(h_close5) = @pm8[4 7 op1[0 0 15 0 7 0 0 0 0 31 0 0 0 0] op2[0 0 0 0 7 0 0 1 0 21 18 5 15 13] op3[0 0 8 0 3 0 0 0 0 31 0 0 0 14] op4[0 0 15 0 3 0 1 1 5 31 17 15 13 9] lfo[0 127 0 0 31 0 0 0 0] ]\nt0=@(h_close5)a32c32"; MyMMLClip clip = new MyMMLClip("Click", mml); clip.GenerateAudioClip = true; mmlBox.Add(clip); } #endif invalid = true; playing = false; ToneEditorCanvas = transform.parent.FindChild("ToneEditorCanvas").gameObject; { Button button = transform.FindChild("Panel/ToneEditorButton").GetComponent <Button>(); button.onClick.AddListener(() => { mmlBox.Play("Click"); sampleTools.MoveCameraTo(ToneEditorCanvas.transform.localPosition); }); } ToneEditorCT8Canvas = transform.parent.FindChild("ToneEditorCT8Canvas").gameObject; { Button button = transform.FindChild("Panel/ToneEditorCT8Button").GetComponent <Button>(); button.onClick.AddListener(() => { mmlBox.Play("Click"); sampleTools.MoveCameraTo(ToneEditorCT8Canvas.transform.localPosition); }); } { Button button = transform.FindChild("Panel/PlayButton").GetComponent <Button>(); cursolPosText = transform.FindChild("Panel/CursolPosText").GetComponent <Text>(); mmlField = transform.FindChild("Panel/MMLField").GetComponent <InputField>(); consoleText = transform.FindChild("Panel/ConsolePanel").GetComponentInChildren <Text>(); instructionText = transform.FindChild("Panel/InstructionPanel").GetComponentInChildren <Text>(); playButtonText = button.GetComponentInChildren <Text>(); mmlField.onValueChanged.AddListener((str) => { invalid = true; if (player.Playing) { player.Stop(); playButtonText.text = "Play"; consoleText.text = ""; playing = false; } else { playButtonText.text = "Play"; } }); button.onClick.AddListener(() => { if (invalid) { if (player.Playing && (player.Clip == mmlClip)) { player.Stop(); playButtonText.text = "Play"; consoleText.text = ""; playing = false; } else { mmlClip.TextB = mmlField.text; player.AppDataEvent = appDataEventFunc; player.PlayingEvent = playingEventFunc; player.Play(mmlClip); resetStb(); invalid = false; consoleText.text = "Playing..."; playButtonText.text = "Pause"; playing = true; } } else { if (player.Playing) { player.Pause(); consoleText.text = ""; playButtonText.text = "Continue"; playing = false; } else { player.Continue(); consoleText.text = "Playing..."; playButtonText.text = "Pause"; playing = true; } } }); } }
void Awake() { syntheStation = GameObject.FindObjectOfType <MySyntheStation>(); sampleTools = GameObject.FindObjectOfType <SampleTools>(); mmlBox = sampleTools.GetComponent <MyMMLBox>(); { Button extend = transform.FindChild("Panel/Extend").GetComponent <Button>(); extend.onClick.AddListener(() => { param.Extended = !param.Extended; loadTone(param); }); } { inputField = transform.FindChild("Panel/InputField").GetComponent <InputField>(); inputField.onEndEdit.AddListener((v) => { if ((v != null) && (v.Length != 0)) { loadTone(new ToneParam(v)); } else { loadTone(new ToneParam(defaultTone)); } }); PresetButton [] presets = GetComponentsInChildren <PresetButton>(); foreach (PresetButton pb in presets) { Button btn = pb.GetComponent <Button>(); ToneParam tp = new ToneParam(pb.ToneData); btn.onClick.AddListener(() => { loadTone(tp); inputField.text = param.ToString(); }); } } { GameObject obj = transform.FindChild("Panel/FM").gameObject; setupSlider(obj, "Algorithm", "al:", (val) => { param.Al = (Byte)val; applyTone(); }); setupSlider(obj, "Feedback", "fb:", (val) => { param.Fb = (Byte)val; applyTone(); }); setupSlider(obj, "WaveForm", "lw:", (val) => { param.Lfo.WS = (Byte)val; applyTone(); }); setupSlider(obj, "Frequency", "lf:", (val) => { param.Lfo.LF = (Byte)val; applyTone(); }); setupSlider(obj, "PMPower", "lp:", (val) => { param.Lfo.LP = (Byte)val; applyTone(); }); setupSlider(obj, "AMPower", "la:", (val) => { param.Lfo.LA = (Byte)val; applyTone(); }); setupSlider(obj, "AttackRate", "ar:", (val) => { if (param.Extended) { param.Lfo.Env.xAR = (Byte)val; } else { param.Lfo.Env.AR = (Byte)val; }; applyTone(); }); setupSlider(obj, "DecayRate", "dr:", (val) => { if (param.Extended) { param.Lfo.Env.xDR = (Byte)val; } else { param.Lfo.Env.DR = (Byte)val; }; applyTone(); }); setupSlider(obj, "SustainLevel", "sl:", (val) => { if (param.Extended) { param.Lfo.Env.xSL = (Byte)val; } else { param.Lfo.Env.SL = (Byte)val; }; applyTone(); }); setupSlider(obj, "SustainRate", "sr:", (val) => { if (param.Extended) { param.Lfo.Env.xSR = (Byte)val; } else { param.Lfo.Env.SR = (Byte)val; }; applyTone(); }); setupSlider(obj, "ReleaseRate", "rr:", (val) => { if (param.Extended) { param.Lfo.Env.xRR = (Byte)val; } else { param.Lfo.Env.RR = (Byte)val; }; applyTone(); }); } for (int i = 0; i < 4; i++) { int n = i; GameObject obj = transform.FindChild("Panel/OP" + (i + 1)).gameObject; setupSlider(obj, "WaveStyle", "ws:", (val) => { param.Op[n].WS = (Byte)val; applyTone(); }); setupSlider(obj, "AMEnable", "ae:", (val) => { param.Op[n].AE = (Byte)val; applyTone(); }); setupSlider(obj, "Multiple", "ml:", (val) => { param.Op[n].Ml = (Byte)val; applyTone(); }); setupSlider(obj, "Detune", "dt:", (val) => { param.Op[n].Dt = (Byte)val; applyTone(); }); setupSlider(obj, "KeyScale", "ks:", (val) => { param.Op[n].Env.KS = (Byte)val; applyTone(); }); setupSlider(obj, "VelocitySense", "vs:", (val) => { param.Op[n].Env.VS = (Byte)val; applyTone(); }); setupSlider(obj, "TotalLevel", "tl:", (val) => { param.Op[n].Env.TL = (Byte)val; applyTone(); }); setupSlider(obj, "AttackRate", "ar:", (val) => { if (param.Extended) { param.Op[n].Env.xAR = (Byte)val; } else { param.Op[n].Env.AR = (Byte)val; }; applyTone(); }); setupSlider(obj, "DecayRate", "dr:", (val) => { if (param.Extended) { param.Op[n].Env.xDR = (Byte)val; } else { param.Op[n].Env.DR = (Byte)val; }; applyTone(); }); setupSlider(obj, "SustainLevel", "sl:", (val) => { if (param.Extended) { param.Op[n].Env.xSL = (Byte)val; } else { param.Op[n].Env.SL = (Byte)val; }; applyTone(); }); setupSlider(obj, "SustainRate", "sr:", (val) => { if (param.Extended) { param.Op[n].Env.xSR = (Byte)val; } else { param.Op[n].Env.SR = (Byte)val; }; applyTone(); }); setupSlider(obj, "ReleaseRate", "rr:", (val) => { if (param.Extended) { param.Op[n].Env.xRR = (Byte)val; } else { param.Op[n].Env.RR = (Byte)val; }; applyTone(); }); } { Keyboard keyboard = transform.FindChild("Panel/Keyboard").GetComponent <Keyboard>(); keyboard.PortNo = PortNo; keyboard.ChNo = ChNo; } { Transform mmlEditorCanvas = transform.parent.FindChild("MMLPlayerCanvas"); Button button = transform.FindChild("Panel/MMLEditorButton").GetComponent <Button>(); button.onClick.AddListener(() => { mmlBox.Play("Click"); sampleTools.MoveCameraTo(mmlEditorCanvas.localPosition); }); } }