コード例 #1
0
 public Harmonic(CustomSoundProvider provider)
 {
     Sine = new SineWave(provider);
     Square = new SquareWave(provider);
     Triangle = new TriangleWave(provider);
     Sawtooth = new SawtoothWave(provider);
     Amplitude = 0.25f;
 }
コード例 #2
0
        private void MusicDemo_Load(object sender, EventArgs e)
        {
            sensors = new DistanceSensors();
            sensors.DistancesChanged += new DistanceSensors.DistancesChangedHandler(sensors_DistancesChanged);
            sensors.Connect();

            scales = new Dictionary<ScaleType, int[]>();
            scales[ScaleType.Major] = MajorScale;
            scales[ScaleType.Minor] = MinorScale;
            scales[ScaleType.Chromatic] = ChromaticScale;
            scales[ScaleType.Whole] = WholeToneScale;
            scales[ScaleType.Blues] = BluesScale;

            songs = new List<Song>();
            //songs.Add(new Song(Hysteria));
            songs.Add(new Song(SomewhereOverTheRainbow));

            waveForm = new List<float>();

            sound = new CustomSoundProvider();
            sound.SetWaveFormat(16000, 1);
            sound.DataReady += new CustomSoundProvider.DataReadyDelegate(sound_DataReady);
            frequency = 440;
            amplitude = 1.0f;
            SoundChooser.SelectedIndex = 0;

            OrganBar1.Tag = 0;
            OrganBar2.Tag = 1;
            OrganBar3.Tag = 2;
            OrganBar4.Tag = 3;
            OrganBar5.Tag = 4;
            OrganBar6.Tag = 5;
            OrganBar7.Tag = 6;
            OrganBar8.Tag = 7;
            OrganBar9.Tag = 8;
            OrganSettingsPanel.Visible = false;
            for (int i = 0; i < ORGAN_PRESETS.GetLength(0); i++) PresetChooser.Items.Add(ORGAN_PRESETS[i, 0]);
            PresetChooser.SelectedIndex = 0;

            ScaleChooser.SelectedIndex = 0;
            ScaleTypeChooser.SelectedIndex = 0;
            NumOctavesChooser.SelectedIndex = 1;

            waveOut = new NAudio.Wave.WaveOut();
            waveOut.Init(sound);
            waveOut.Play();

            SetTone(frequency, amplitude);
        }