Exemple #1
0
        private void btnAddOscListToChunk_Click(object sender, EventArgs e)
        {
            AudioChunk chunk = GetSelectedChunk();

            if (chunk == null)
            {
                return;
            }

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

            List <WaveType> types = lvWaveForms.GetSelectedForms();

            foreach (var item in types)
            {
                chunk.AddOscillator(item, duration, freq, amp, 2);

                //chunk.AddOscillator(item, duration, freq, -amp, 2);
            }

            chunkTree.RemoveChunk(chunk);
            chunkTree.AddChunk(chunk);
        }
Exemple #2
0
        private void btnTestForm_Click(object sender, EventArgs e)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                WaveStreamWriter streamWriter = new WaveStreamWriter(stream);

                //   streamWriter.WriteSilenceChunk(5);

                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"));

                //foreach (var item in tones)
                //{
                ////streamWriter.WriteOscillator(new Oscillator(WaveType.Sine, (int)numDuration.Value, item.Frequency, (int)numAmplitude.Value, 2));
                //streamWriter.WriteChunk(SampleHelper.MakeChordChunk(duration, freq, amp, 2));
                ////streamWriter.WriteChunk(SampleHelper.MakeChordChunk(duration, freq, -amp, 2));
                //streamWriter.WriteSilenceChunk(10);
                //}


                //foreach (var item in Tones.ToneList())
                //{
                //      streamWriter.WriteOscillator(new Oscillator(WaveType.Sine, 200, item.Frequency, item.Amplitude, 2));
                //      streamWriter.WriteSilenceChunk(100);

                //}
                List <WaveType> types = lvWaveForms.GetSelectedForms();
                AudioChunk      chunk = new AudioChunk();

                foreach (var item in types)
                {
                    chunk.AddOscillator(item, duration, freq, amp, 2);

                    //chunk.AddOscillator(item, duration, freq, -amp, 2);
                }
                ////chunk.AddOscillator(WaveType.Noise, duration, 40, 2000, 2);
                ////chunk.AddOscillator(WaveType.Noise, duration, 20, 1000, 2);

                ////for (int i = 0; i < 15; i++)
                ////{
                ////    chunk.AddOscillator(WaveType.Square, duration, freq - i, amp - (i * 200), 2);
                ////    chunk.AddOscillator(WaveType.Sawtooth, duration, freq - i, amp - (i * 200), 2);
                ////    //chunk.AddOscillator(WaveType.Sine, duration, freq -i, amp - (i * 100), 2);
                ////}

                if (chunk.Oscillators.Count > 0)
                {
                    streamWriter.WriteChunk(chunk);
                    streamWriter.WriteChunk(chunk);
                    streamWriter.WriteChunk(chunk);
                }

                streamWriter.Close();

                PlayStream(stream);
            }
        }