Esempio n. 1
0
        public PianoPlayer(int sampleRate = 44100, int channelCount = 2)
        {
            foreach (string filename in System.IO.Directory.EnumerateFiles("..\\..\\..\\..\\samples"))
            {
                //var components = filename
                var nameComponents = System.IO.Path.GetFileName(filename).Split('.');

                if ((!filename.Contains("-old")) && nameComponents[1] == "pp")
                {
                    var noteInfo = nameComponents[2];
                    var key      = PianoKey.Parse(noteInfo);
                    if (key != null)
                    {
                        key = new PianoKey(key.Octave + 1, key.Note);
                        var ar = new CachedSound(filename);

                        soundDict.Add(key, ar);
                    }
                }
            }

            Console.WriteLine("Loaded sounds.");

            outputDevice    = new DirectSoundOut(60);
            mixer           = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(sampleRate, channelCount));
            mixer.ReadFully = true;
            outputDevice.Init(mixer);
            outputDevice.Play();
        }
Esempio n. 2
0
 public CachedSoundSampleProvider(CachedSound cachedSound)
 {
     this.cachedSound = cachedSound;
 }