private void CreateSampleModel() { ListLibraySample = new List<LibraySample>(); string directory = Path.Combine(Application.StartupPath, "Samples"); foreach (String subDirectory in Directory.GetDirectories(directory)) { LibraySample libraySample = new LibraySample(Path.GetFileName(subDirectory)); this.ListLibraySample.Add(libraySample); foreach (String file in Directory.GetFiles(Path.Combine(directory, subDirectory))) { Color color = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256)); SampleModel sampleModel = new SampleModel(libraySample, Path.GetFileNameWithoutExtension(file), color, 1, libraySample.ListSampleModel.Count); sampleModel.SoundSource = _soundEngine.AddSoundSourceFromFile( Application.StartupPath + "\\" + "Samples" + "\\" + libraySample.Name + "\\" + sampleModel.Name + ".wav"); libraySample.ListSampleModel.Add(sampleModel); } } }
public Sample(SampleModel sampleModel) { this.SampleModel = sampleModel; }
public void PlaySample(SampleModel sample) { _soundEngine.Play2D(Application.StartupPath + "\\" + "Samples" + "\\" + sample.LibraySample.Name + "\\" + sample.Name + ".wav", false); }