Пример #1
0
        private void WriteNote(WaveStreamWriter streamWriter, string name, int durationBefore, int duration, int amplitude)
        {
            Tone tone = Tones.Item(name);

            if (durationBefore > 0)
            {
                streamWriter.WriteSilenceChunk(durationBefore);
            }

            streamWriter.WriteChunk(SampleHelper.MakeBassChunk2(duration, tone.Frequency, amplitude, 2));
            //streamWriter.WriteOscillator(new Oscillator(WaveType.Sine, duration, tone.Frequency, amplitude, 2));
        }
Пример #2
0
        private void btnDraftTest_Click(object sender, EventArgs e)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                WaveStreamWriter streamWriter = new WaveStreamWriter(stream);

                streamWriter.WriteSilenceChunk(50);

                int freq     = (int)waveFormControl.Frequency;
                int duration = (int)waveFormControl.Duration;
                int amp      = (int)waveFormControl.Amplitude;

                List <Tone> tones = new List <Tone>();

                tones.Add(Tones.Item("Do3"));
                tones.Add(Tones.Item("Ré3"));
                tones.Add(Tones.Item("Mi3"));
                tones.Add(Tones.Item("Fa3"));
                tones.Add(Tones.Item("Sol3"));
                tones.Add(Tones.Item("La3"));
                tones.Add(Tones.Item("Si3"));
                tones.Add(Tones.Item("Do4"));

                WriteNote(streamWriter, "Ré3", 75, 300, amp);
                WriteNote(streamWriter, "Sol3", 75, 300, amp);
                WriteNote(streamWriter, "La3", 75, 300, amp);
                WriteNote(streamWriter, "Si3", 100, 300, amp);
                WriteNote(streamWriter, "La3", 125, 300, amp);
                WriteNote(streamWriter, "Sol3", 125, 750, amp);

                WriteNote(streamWriter, "Sol3", 325, 150, amp);
                WriteNote(streamWriter, "Sol3", 60, 150, amp);
                WriteNote(streamWriter, "Sol3", 60, 250, amp);

                WriteNote(streamWriter, "La3", 125, 300, amp);

                WriteNote(streamWriter, "Si3", 125, 350, amp);
                WriteNote(streamWriter, "La3", 125, 650, amp);

                //WriteNote(streamWriter, "La3", 50, 150, amp);
                //WriteNote(streamWriter, "La3", 50, 150, amp);
                //WriteNote(streamWriter, "La3", 50, 150, amp);

                //WriteNote(streamWriter, "Si3", 100, 250, amp);
                //WriteNote(streamWriter, "Do3", 100, 150, amp);
                //WriteNote(streamWriter, "Si3", 100, 200, amp);
                //WriteNote(streamWriter, "La3", 100, 300, amp);

                //WriteNote(streamWriter, "La3", 100, 150, amp);
                //WriteNote(streamWriter, "La3", 100, 150, amp);
                //WriteNote(streamWriter, "La3", 100, 150, amp);

                //WriteNote(streamWriter, "Si3", 100, 300, amp);
                //WriteNote(streamWriter, "La3", 100, 250, amp);
                //WriteNote(streamWriter, "Sol3", 100, 400, amp);
                //WriteNote(streamWriter, "La3", 100, 200, amp);

                streamWriter.Close();

                PlayStream(stream);
            }
        }