Пример #1
0
        private void ResetOutput()
        {
            SoundOutput.Dispose();

            SoundMixer = new MixingWaveProvider32(new List <WaveChannel32> {
                PitchSelector.GetWavePlayer(Pitch.Empty, WaveForm).Channel
            });
            SoundOutput = new DirectSoundOut();
            SoundOutput.Init(SoundMixer);
            SoundOutput.Play();
        }
Пример #2
0
        internal List <Pitch> GetFrequenciesPlaying()
        {
            List <Pitch> frequenciesPlaying = new List <Pitch> {
            };

            foreach (Pitch frequency in PitchSelector.EnumeratePitches())
            {
                if (CurrentlyPlayingPitches[(int)frequency])
                {
                    frequenciesPlaying.Add(frequency);
                }
            }
            return(frequenciesPlaying);
        }
Пример #3
0
        /// <summary>
        /// Stop playing given pitch
        /// </summary>
        /// <param name="pitch">Pitch</param>
        public void StopPlayingPitch(Pitch pitch)
        {
            // alert recorder that a change has been made
            UpdateRecorder();

            // do nothing if no tone was released
            if (pitch == Pitch.Empty)
            {
                return;
            }

            WavePlayer inputStream = PitchSelector.GetWavePlayer(pitch, WaveForm);

            SoundMixer.RemoveInputStream(inputStream.Channel);
            CurrentlyPlayingPitches[(int)pitch] = false;
        }
Пример #4
0
        /// <summary>
        /// Starts playing the specified pitch
        /// </summary>
        /// <param name="pitch">Pitch</param>
        public void StartPlayingPitch(Pitch pitch)
        {
            // do nothing if no tone is added
            if (pitch == Pitch.Empty)
            {
                return;
            }

            if (!CurrentlyPlayingPitches[(int)pitch])
            {
                UpdateRecorder();

                WavePlayer inputStream = PitchSelector.GetWavePlayer(pitch, WaveForm);
                SoundMixer.AddInputStream(inputStream.Channel);
                CurrentlyPlayingPitches[(int)pitch] = true;
            }
        }
Пример #5
0
        /// <summary>
        /// Computes the exact tones in the chord
        /// by taking into account its name and scale.
        /// </summary>
        /// <returns>List of Pitches in the chord</returns>
        public List <Pitch> GetChord()
        {
            if (chordName == ChordName.None)
            {
                return new List <Pitch> {
                           Pitch.Empty
                }
            }
            ;

            Dictionary <ChordName, ChordShiftFromBase> chordShifts = scale.Major ? MajChordShifts : MinChordShifts;

            List <Pitch> chord = new List <Pitch> {
            };

            chord.Add(PitchSelector.ShiftPitchBySemitones(scale.Base, chordShifts[chordName].first));
            chord.Add(PitchSelector.ShiftPitchBySemitones(scale.Base, chordShifts[chordName].second));
            chord.Add(PitchSelector.ShiftPitchBySemitones(scale.Base, chordShifts[chordName].third));
            return(chord);
        }
Пример #6
0
 /// <summary>
 /// Returns WavePlayer corresponding to key and wave form.
 /// </summary>
 public static WavePlayer GetWavePlayerFromKey(Keys key, WaveFormEquation waveForm)
 => PitchSelector.GetWavePlayer(GetPitchFromKey(key), waveForm);