public static WavEditor Modify(WavInfo wavInfo) { var editor = new WavEditor(); editor.wav = CloneWav(wavInfo); return(editor); }
public static WavInfo GetNote(string note, int pressLevel, double duration) { var settings = PianoSettings.Instance(); return(WavEditor.Modify( WavIO.Load($"D:\\Projects\\PianoGenerator\\PianoGenerator\\bin\\Debug\\Resources\\Notes\\{settings.GetNoteName(note, pressLevel)}") ) .FreezeRegion(0, duration) .MultiplyWith((double x, double i) => Math.Max(0, 1 - settings.GetReleaseKeyK() * i), true) .GetWav()); }
public static WavEditor CreateWav(WavInfo settings) { var editor = new WavEditor(); editor.wav = new WavInfo(); editor.wav.Amplitudes = new double[0]; editor.wav.BitsPerSample = settings.BitsPerSample; editor.wav.BlockAlign = settings.BlockAlign; editor.wav.ByteRate = settings.ByteRate; editor.wav.SampleRate = settings.SampleRate; return(editor); }
static void CutNotes() { var files = Directory.EnumerateFiles(Directory.GetCurrentDirectory() + @"\\Resources\\Notes"); foreach (var filePath in files) { var fileName = Path.GetFileName(filePath); var wav = WavIO.Load(filePath); var nwav = WavEditor.Modify(wav).Cut(val => Math.Abs((int)val) > 20000, val => Math.Abs((int)val) > 20000, 0.3f, 2f); WavIO.Save("D:\\Projects\\PianoGenerator\\PianoGenerator\\bin\\Debug\\Resources\\Notes\\Cut\\" + fileName, nwav.GetWav()); Console.WriteLine($"'{fileName}' done."); } }
public void Generate(string pathToFile) { var parser = new Parser(); parser.Parse(File.ReadAllText(pathToFile)); source = parser.GetSource(); var main = source.FindVariable("main"); if (main == null) { throw new CompilationException("No 'main' variable found"); } mainEditor = WavEditor.CreateWav(GetNote("C4", 3, PianoSettings.NoteDuration.D1)); GenerateVariable(main, 0); }