示例#1
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;
        }
示例#2
0
        /// <summary>
        /// Starts playing beat with the specified bpm.
        /// </summary>
        /// <param name="bpm">Beats per minute</param>
        public void StartPlayingBeat(int bpm)
        {
            // generate beat wave
            byte[] beatWave = Wave.ConvertShortWaveToBytes(Wave.GenerateBeatWave(bpm));

            // write the wave into a file
            using (FileStream fs = File.Create(defaultBeatFilePath))
                Wave.WriteToStream(fs, beatWave, beatWave.Length / sizeof(short),
                                   Config.SAMPLE_RATE, Config.BITS_PER_SAMPLE, Config.CHANNELS);

            // play the file
            Beat = new WavePlayer(defaultBeatFilePath);
            SoundMixer.AddInputStream(Beat.Channel);
            BeatPlaying = true;
            CurrentBpm  = bpm;
        }
示例#3
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;
            }
        }