Beispiel #1
0
        private void InitSoundEngines()
        {
            // Init sound
            var availableOutputs = new List <SoundSettings.EOutput>();

            availableOutputs.Add(SoundSettings.EOutput.None);
#if USE_MIDI
            try {
                _midiPlayer = new Midi.MidiPlayer(0); //!!! make device index configurable
                availableOutputs.Add(SoundSettings.EOutput.Midi);
            } catch (Exception ex) {
                Console.Error.WriteLine("Can't initialize Midi: {0}", ex.Message);
            }
#endif
#if USE_WAVE
            try {
                var format = new Wave.WaveFormat {
                    bytesPerSample = 2,
                    sampleRate     = 22050,
                    channels       = 1,
                };
                _waveEngine      = new Wave.WaveEngine(format, bufferLengthMs: 60);
                _partialProvider = new Wave.PartialProvider();
                _waveEngine.SetSampleProvider(_partialProvider);
                availableOutputs.Add(SoundSettings.EOutput.Wave);
                availableOutputs.Add(SoundSettings.EOutput.WavePartialsTempered);
            }
            catch (Exception ex) {
                Console.Error.WriteLine("Can't initialize WaveEngine: {0}", ex.Message);
            }
#endif
            _availableSoundOutputs = availableOutputs.ToArray();

            // Find controls
            _comboBoxSoundOutput       = ExpectControl <ComboBox>(this, "comboBoxSoundOutput");
            _comboBoxSoundOutput.Items = _availableSoundOutputs;
            //_textBoxWavePartials = ExpectControl<TextBox2>(this, "textBoxWavePartials");
        }