public static void Main(string[] args) { String DefaultConsoleTitle = Console.Title; Int32 Position = 0; Byte CurrentOctave = 4; Boolean Uninterrupted = true; Boolean Harmonic = false; Boolean Square = false; List <TactUnit> Tacts = new List <TactUnit>(); Queue <Char> InitialEntries = new Queue <Char>(); ConsoleColor DefaultTextColor = Console.ForegroundColor; ConsoleColor DefaultBackgroundColor = Console.BackgroundColor; Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; if (args.Length >= 1) { foreach (Char i in args[0]) { InitialEntries.Enqueue(i); } } for (int i = 0; i < 12; i++) { if (i == 1 || i == 3 || i == 6 || i == 8 || i == 10) { Console.BackgroundColor = DefaultBackgroundColor; Console.ForegroundColor = DefaultTextColor; } else { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; } Console.Write(Notes.StringForm((Note)i)); Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; Console.Write(" "); } Console.Write("\n"); List <Char> InputStack = new List <Char>(); TactUnit Last = new TactUnit(0.0); Console.BackgroundColor = DefaultBackgroundColor; Console.ForegroundColor = DefaultTextColor; while (Uninterrupted) { UpdateConsoleTitle(CurrentOctave, Position, Harmonic, Square); Char cki = (InitialEntries.Count > 0 ? InitialEntries.Dequeue() : Console.ReadKey(true).KeyChar); if (cki == ' ' || cki == '1' || cki == '2' || cki == '3' || cki == '4' || cki == '5' || cki == '6' || cki == '7' || cki == '8' || cki == '9' || cki == '0' || cki == '-' || cki == '=' || cki == ',' || cki == '.' || cki == '`' || cki == 'v' || cki == 'q') { InputStack.Add(cki); } switch (cki) { case ' ': Console.Write("____"); Console.Write(" "); Tacts.Add(new TactUnit(0.125)); break; case 'z': Uninterrupted = false; Console.Write("\n"); break; case ' ': { Sequencer sq = new Sequencer(1, 44100); foreach (TactUnit i in Tacts) { sq.Push(i); } if (sq.Length != 0) { SoundPlayer sp = new SoundPlayer(); sp.Stream = sq.SnapshotStream; sp.Load(); sp.PlaySync(); } break; } case ',': { if (CurrentOctave > 4) { CurrentOctave--; } break; } case '.': { if (CurrentOctave < 9) { CurrentOctave++; } break; } case '\r': case '\n': { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Save wave file to needed location..."; sfd.Filter = "WAV file (*.wav)|*.wav"; DialogResult dr = sfd.ShowDialog(); if (dr == DialogResult.OK) { FileStream fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write); Sequencer sq = new Sequencer(1, 44100); foreach (TactUnit i in Tacts) { sq.Push(i); } WaveFormatter.WriteSequenceToFile(sq, fs); fs.Close(); } break; } case 'r': { if (Position > 0) { List <TactUnit> tu = new List <TactUnit>(); for (int i = 0; i < Position - 1; i++) { tu.Add(Tacts[i]); } Tacts.Clear(); foreach (TactUnit x in tu) { Tacts.Add(x); } Int32 CharsEnlisted = InputStack.Count; Int32 CutHere = CharsEnlisted; while (CutHere > 0) { Char last = InputStack[CutHere - 1]; Boolean pop = false; switch (last) { case ',': if (CurrentOctave < 9) { CurrentOctave++; } CutHere--; break; case '.': if (CurrentOctave > 4) { CurrentOctave--; } CutHere--; break; case '~': Harmonic = false; CutHere--; break; case 'v': Harmonic = true; CutHere--; break; case 'q': Square = !Square; CutHere--; break; default: pop = true; CutHere--; break; } if (pop) { break; } } if (CharsEnlisted > 0) { List <Char> cl = new List <char>(); for (int i = 0; i < CutHere; i++) { cl.Add(InputStack[i]); } InputStack.Clear(); foreach (Char i in cl) { InputStack.Add(i); } } if (Console.CursorLeft == 0) { Console.CursorTop -= 1; Console.CursorLeft = 75; } else { Console.CursorLeft -= 5; } Console.Write(" "); Console.CursorLeft -= 5; } break; } case '`': { Harmonic = true; break; } case 'v': { Harmonic = false; break; } case 'q': { Square = !Square; break; } default: { Int32 x = GetNoteFromChar(cki); if (x != -1) { Note a = (Note)x; Console.Write("{0}{1}", (Harmonic ? (Square ? "+" : "~") : "-"), Notes.StringForm(a, CurrentOctave)); TactUnit tact = new TactUnit(new AmplifiedWave(Phonemes.Get((Harmonic ? (Square ? "__" : "AH") : "/R"), a, CurrentOctave, 64, 44100), 0.75), 0.125); if (Position > 1) { if (Tacts[Position - 1].Frequency == tact.Frequency) { tact.BeginningOffset = Tacts[Position - 1].BeginningOffset + 0.125; } } Tacts.Add(tact); // QuickPlay(tact); Console.Write(" "); } break; } } Position = Tacts.Count; if ((Console.CursorLeft != 0) && (Position % 16 == 0)) { Console.Write("\n"); } } Console.Title = DefaultConsoleTitle; foreach (Char i in InputStack) { Console.Write(i); } Console.WriteLine(); Console.ReadLine(); }
public void TestCompute() { var syllabifier = new Syllabifier(); var phonemes = "stʁil.bjuʁ.goz.dʁɥi.fwastχ"; var input = string.Join("", phonemes.Split('.')).ToCharArray().Select(c => Phonemes.BySymbol(c.ToString())).ToArray(); var expected = new[] { new Syllable( onset: new [] { Phonemes.s, Phonemes.t, Phonemes.R, }, nucleus: Phonemes.i, coda: new [] { Phonemes.l, }), new Syllable( onset: new [] { Phonemes.b, Phonemes.j, }, nucleus: Phonemes.u, coda: new [] { Phonemes.R, }), new Syllable( onset: new [] { Phonemes.g, }, nucleus: Phonemes.o, coda: new [] { Phonemes.z, }), new Syllable( onset: new [] { Phonemes.d, Phonemes.R, Phonemes.Y, }, nucleus: Phonemes.i, coda: new Phoneme[0]), new Syllable( onset: new [] { Phonemes.f, Phonemes.w, }, nucleus: Phonemes.a, coda: new [] { Phonemes.s, Phonemes.t, Phonemes.X, }), }; var result = syllabifier.Compute(input).ToArray(); Assert.Equal(expected.Length, result.Length); }
public bool HasVowel() { return(Phonemes.Any(phoneme => phoneme.Letters.HasVowel())); }
private static Neighborhood <Phoneme> Of(string center, params string[][] circles) => new Neighborhood <Phoneme>( Phonemes.BySymbol(center), circles.Select(ps => ps.Select(p => Phonemes.BySymbol(p)).ToArray()).ToArray());
public bool HasPhonemeConsonant() { return(Phonemes.Any(phoneme => phoneme.ArticulationManner != ArticulationManners.Vowel)); }
public int CountPhonemeVowels() { return(Phonemes.Count(phoneme => phoneme.ArticulationManner == ArticulationManners.Vowel)); }
public bool HasPhonemeArticulationManner(ArticulationManners manner) { return(Phonemes.Any(phoneme => phoneme.ArticulationManner == manner)); }
public bool HasPhoneme(Func <Phoneme, bool> predicate) { return(Phonemes.Any(predicate)); }
public IEnumerable <Phoneme> FromNucleus() { return(Phonemes.SkipWhile(each => !each.IsVowel())); }
public SylInW(PhonWord inW, int inBeg, int inEnd, Phonemes inP) : base(inW, inBeg, inEnd, inP) { }
public static void DrawGraph(Phonemes phonemes, ref float time, Callback repaint, CallbackIndex onDrawItem) { //Get area space Rect rect = GUILayoutUtility.GetRect(Screen.width, 300).Shrink(10); GUI.Box(rect, "", Styles.whiteFrame); rect = rect.Shrink(2); Event e = Event.current; Styles.Load(); //Draw top rect Rect topRect = new Rect(rect.x, rect.y, rect.width, 18); EditorGUI.DrawRect(topRect, graphBgColor); //Draw background rect = rect.Offset(0, 20, 0, -20); EditorGUI.DrawRect(rect, graphBgColor); //Handle setTime events if ((e.type == EventType.MouseDown || e.type == EventType.MouseDrag) && rect.Contains(e.mousePosition)) { time = Rect.PointToNormalized(rect, e.mousePosition).x; repaint.Invoke(); } //Draw cursor Rect cursorRect = new Rect(rect.x + rect.width * time, rect.y, 2, rect.height); EditorGUI.DrawRect(cursorRect, Color.white); //Draw curves and fields bool haveCustomItem = onDrawItem != null; float width = Screen.width - EditorGUIUtility.labelWidth - (haveCustomItem ? 180 : 50); float maxValue = 0.0f; string maxValueName = ""; Color maxValueColor = Color.white; for (int i = 0; i < phonemes.curves.Length; i++) { Color curveColor = Color.HSVToRGB((i * 0.13f) % 1.0f, 0.8f, 1.0f); EditorGUIUtility.DrawCurveSwatch(rect, phonemes.curves[i].curve, null, curveColor, transparent, new Rect(0, 0, 1, 1)); GUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.Label(phonemes.curves[i].name, GUILayout.Width(EditorGUIUtility.labelWidth)); Rect barRect = GUILayoutUtility.GetRect(width, 16); barRect.x -= 10; barRect.width = width; GUI.Box(barRect, "", Styles.whiteFrame); float value = phonemes.curves[i].curve.Evaluate(time); Rect fillRect = barRect; fillRect.width *= Mathf.Clamp01(value); if (value > maxValue) { maxValue = value; maxValueName = phonemes.curves[i].name; maxValueColor = curveColor; } fillRect = fillRect.Shrink(1); EditorGUI.DrawRect(fillRect, curveColor); if (haveCustomItem) { barRect.Set(barRect.x + barRect.width + 10, barRect.y, 120, barRect.height); onDrawItem.Invoke(barRect, i); } GUILayout.EndHorizontal(); GUILayout.Space(3); } //Draw maxValue top label if (maxValue > 0.0001f) { topRect.x = cursorRect.x - 10; Color guiColor = GUI.color; GUI.color = maxValueColor; GUI.Label(topRect, maxValueName, Styles.whiteLabel); GUI.color = guiColor; } }