public MyMMLClip Play(int port, int channel, float tempoScale, float volume, params string[] mml) { if (sequencer == null) { return(null); } sequencer.Stop(playOutTime); if ((port < 0) || (port >= MyMMLSequence.MaxNumPorts)) { return(null); } if ((channel < 0) || (channel >= MySynthesizer.NumChannels)) { return(null); } if ((mml.Length == 0) || (mml.Length >= MyMMLSequence.MaxNumTracks)) { return(null); } clip = new MyMMLClip(); clip.Name = "Impromptu"; clip.TempoScale = tempoScale; clip.Volume = volume; var sb = MyFountain <System.Text.StringBuilder> .Get(() => new System.Text.StringBuilder()); sb.Length = 0; for (int i = 0; i < mml.Length; i++) { if (mml[i] == null) { continue; } sb.Append("$t" + i.ToString("d2") + "=" + port.ToString() + ":" + channel.ToString() + "\n"); } for (int i = 0; i < mml.Length; i++) { if (mml[i] == null) { continue; } sb.Append("t" + i.ToString("d2") + "=" + mml[i] + "\n"); } clip.TextB = sb.ToString(); sb.Length = 0; MyFountain <System.Text.StringBuilder> .Put(sb); state = PlayState.Prepareing; return(clip); }
public void Wait() { if (IsCompleted) { return; } var mre = MyFountain <System.Threading.ManualResetEvent> .Get(() => new System.Threading.ManualResetEvent(false)); mre.Reset(); complete = mre; if (!IsCompleted) { complete.WaitOne(); } complete = null; MyFountain <System.Threading.ManualResetEvent> .Put(mre); }
private void OnGUI() { if (Disabled) { return; } var style = GUI.skin.GetStyle("label"); var oldFontSize = style.fontSize; style.fontSize = (int)(Screen.height * fontScale); var fh = (int)Mathf.Ceil(style.lineHeight); var h = ((int)(Screen.height * rect.height) - fh + 1) / fh; string str; { var builder = MyFountain <StringBuilder> .Get(() => new StringBuilder()); lock (lines) { var end = lines.Count; var begin = end - h; if (begin < 0) { begin = 0; } for (int i = begin; i < end; i++) { builder.AppendLine(lines[i]); } } str = builder.ToString(); builder.Length = 0; MyFountain <StringBuilder> .Put(builder); } var r = new Rect(Screen.width * rect.xMin, Screen.height * rect.yMin, Screen.width * rect.width, Screen.height * rect.height); var prevColor = GUI.color; GUI.color = color; GUI.Label(r, str); GUI.color = prevColor; style.fontSize = oldFontSize; }
/// <summary> /// write /// </summary> /// <param name="frm"></param> /// <param name="args"></param> public static void Write(string frm, params object[] args) { if (frm == null) { return; } { var builder = MyFountain <StringBuilder> .Get(() => new StringBuilder()); builder.AppendFormat(frm, args); var str = builder.ToString(); builder.Length = 0; MyFountain <StringBuilder> .Put(builder); string[] lines; lock (temporary) { str = temporary + str; lines = str.Split('\n'); temporary = lines[lines.Length - 1]; } outputLines(lines, lines.Length - 1); } }