/// <summary> /// Create a new instance of the FluidSys.Note class using the /// specified VoiceProp. /// </summary> public Note(VoiceProp vProp) { UseDefaultVb = true; VoiceProperties = vProp; Location = 0; Length = 1024; Velocity = 100; }
/// <summary> /// Returns the VoiceProp class from OtoReader.voices with a matching /// SampleName property, or a new VoiceProp if none matching. /// </summary> /// <param name="sampleName">The VoiceProp.SampleName property to search for.</param> /// <returns>A VoiceProp class with the matching VoiceProp.SampleName property.</returns> public VoiceProp GetVoicePropFromSampleName(string sampleName) { VoiceProp vp = new VoiceProp(); foreach (var item in voices) { if (item.SampleName == sampleName) { return(item); } else if (item.FileName == sampleName + ".wav") { return(item); } } return(vp); }
/// <summary> /// Opens a voicebank configuration file to use within the OTOMmate.OtoReder class. /// </summary> /// <param name="fileLoc">The location of the voicebank config file.</param> public void OpenFile(string fileLoc) { try { // Used to add to the voices list later VoiceProp vp; int index = 0; // Used for seperating lines int lastIndex = 0; // Also used for seperating lines int run = 0; // Who knows what this does int run2 = 0; // I'm run2 // Read text file sr = new StreamReader(fileLoc); otoText = sr.ReadToEnd(); sr.Close(); // Get lines count lines = Count4(otoText); // Each line from oto.ini string[] otoLines = new string[lines]; // Seperate text file into lines foreach (var item in otoText) { if (item == '\n') { index = otoText.IndexOf(item, lastIndex + 1); otoLines[run] = otoText.Substring(lastIndex, index - lastIndex); lastIndex = index; run++; } } // Generate VoiceProp classes from seperated lines foreach (var item in otoLines) { vp = new VoiceProp(); try { // Get indexes from line int index1 = item.IndexOf('='); int index2 = item.IndexOf(",", index1 + 1); int index3 = item.IndexOf(",", index2 + 1); int index4 = item.IndexOf(",", index3 + 1); int index5 = item.IndexOf(",", index4 + 1); int index6 = item.IndexOf(",", index5 + 1); // Chop up line into individual properties and add them to vp vp.FileName = item.Substring(0, index1); vp.SampleName = item.Substring(index1 + 1, index2 - index1 - 1); vp.StartString = item.Substring(index2 + 1, index3 - index2 - 1); vp.ConsonantString = item.Substring(index3 + 1, index4 - index3 - 1); vp.EndString = item.Substring(index4 + 1, index5 - index4 - 1); vp.PreutteranceString = item.Substring(index5 + 1, index6 - index5 - 1); vp.OverlapString = item.Substring(index6 + 1); vp.FileDir = fileLoc.Substring(0, fileLoc.LastIndexOf("\\")) + "\\"; // Removes /n from FileName property if (vp.FileName.Contains("\n")) vp.FileName = vp.FileName.Substring(1); // Add vp to voices voices.Add(vp); } catch (Exception ex) { break; } run2++; } } catch (Exception ex) { throw; } }
/// <summary> /// Returns the VoiceProp class from OtoReader.voices with a matching /// SampleName property, or a new VoiceProp if none matching. /// </summary> /// <param name="sampleName">The VoiceProp.SampleName property to search for.</param> /// <returns>A VoiceProp class with the matching VoiceProp.SampleName property.</returns> public VoiceProp GetVoicePropFromSampleName(string sampleName) { VoiceProp vp = new VoiceProp(); foreach (var item in voices) { if (item.SampleName == sampleName) return item; else if (item.FileName == sampleName + ".wav") return item; } return vp; }
/// <summary> /// Creates a new instance of the FLuidSys.Note class. /// </summary> public Note() { UseDefaultVb = true; VoiceProperties = new VoiceProp(); Location = 0; Length = 1024; Velocity = 100; }
/// <summary> /// Opens a voicebank configuration file to use within the OTOMmate.OtoReder class. /// </summary> /// <param name="fileLoc">The location of the voicebank config file.</param> public void OpenFile(string fileLoc) { try { // Used to add to the voices list later VoiceProp vp; int index = 0; // Used for seperating lines int lastIndex = 0; // Also used for seperating lines int run = 0; // Who knows what this does int run2 = 0; // '' // Read text file sr = new StreamReader(fileLoc); otoText = sr.ReadToEnd(); sr.Close(); // Get lines count lines = Count4(otoText); // Each line from oto.ini string[] otoLines = new string[lines]; // Seperate text file into lines foreach (var item in otoText) { if (item == '\n') { index = otoText.IndexOf(item, lastIndex + 1); otoLines[run] = otoText.Substring(lastIndex, index - lastIndex); lastIndex = index; run++; } } // Generate VoiceProp classes from seperated lines foreach (var otoItem in otoLines) { vp = new VoiceProp(); // needed because of newline fix string item = otoItem; try { // remove newlines that get left behind for (int chr = 0; chr < item.Length; chr++) { if (item[chr] == '\r' || item[chr] == '\n') { item = item.Remove(chr, 1); } } // Get indexes from line int index1 = item.IndexOf('='); int index2 = item.IndexOf(",", index1 + 1); int index3 = item.IndexOf(",", index2 + 1); int index4 = item.IndexOf(",", index3 + 1); int index5 = item.IndexOf(",", index4 + 1); int index6 = item.IndexOf(",", index5 + 1); // Chop up line into individual properties and add them to vp vp.FileName = item.Substring(0, index1); vp.SampleName = item.Substring(index1 + 1, index2 - index1 - 1); vp.StartString = item.Substring(index2 + 1, index3 - index2 - 1); vp.ConsonantString = item.Substring(index3 + 1, index4 - index3 - 1); vp.EndString = item.Substring(index4 + 1, index5 - index4 - 1); vp.PreutteranceString = item.Substring(index5 + 1, index6 - index5 - 1); vp.OverlapString = item.Substring(index6 + 1); vp.FileDir = fileLoc.Substring(0, fileLoc.LastIndexOf("\\")) + "\\"; // Removes \n from FileName property if (vp.FileName.Contains("\n")) { vp.FileName = vp.FileName.Substring(1); } // Add vp to voices voices.Add(vp); } catch (Exception ex) { break; } run2++; } } catch (Exception ex) { throw; } }