예제 #1
0
        public static WavFile Compose(IModulator modulator, SampleRateType sampleRate, BitArray data)
        {
            using MemoryStream ms = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(ms);

            bw.Write(new byte[(int)(0.5 * 2 * (int)sampleRate)]);

            foreach (bool bit in data)
            {
                if (bit)
                {
                    modulator.WriteOne(ms);
                }
                else
                {
                    modulator.WriteZero(ms);
                }
            }

            bw.Write(new byte[(int)(0.5 * 2 * (int)sampleRate)]);

            var wavFile = new WavFile((int)sampleRate, ms.ToArray());

            return(wavFile);
        }
예제 #2
0
 public void SetLFO(Events.LFO lfo, double frequency)
 {
     OscillatorForm mainForm = lfo.Main - 1;
     m_osc2.Form = mainForm;
     m_mod2 = m_osc2.ModulatorFromForm(mainForm);
     m_osc2sign = lfo.Reverse ? -1.0 : 1.0;
     if (mainForm >= OscillatorForm.Max)
         m_osc2connect = false;
     if (mainForm == OscillatorForm.GBWave)
     {
         GBWave gbWave = (GBWave)m_osc2.ModulatorFromForm(OscillatorForm.GBWave);
         gbWave.WaveIndex = (int)lfo.Sub;
     }
     m_lfoDepth = lfo.Depth;
     m_osc2connect = m_lfoDepth == 0 ? false : true;
     m_mod2.Frequency = frequency;
     m_mod2.ResetPhase();
     Noise noise = (Noise)m_osc2.ModulatorFromForm(OscillatorForm.Noise);
     noise.NoiseFrequency = frequency / Sample.RATE;
     m_lfoDelay = lfo.Delay;
     int time = lfo.Time;
     m_lfoEnd = time > 0 ? m_lfoDelay + time : 0;
 }
예제 #3
0
 public Channel()
 {
     m_vco = new Envelope(0.0, 60.0 / VELOCITY_MAX2, 30.0 / VELOCITY_MAX2, 1.0 / VELOCITY_MAX2);
     m_vcf = new Envelope(0.0, 30.0 / VELOCITY_MAX2, 0.0, 1.0);
     m_osc1 = new Oscillator();
     m_mod1 = m_osc1.CurrentModulator;
     m_osc2 = new Oscillator() { Form = OscillatorForm.Sine };
     m_osc2.MakeAsLFO();
     m_mod2 = m_osc2.CurrentModulator;
     m_filter = new Filter();
     m_osc2connect = m_enableFilter = false;
     m_formant = new Formant();
     m_volumeMode = 0;
     m_expression = 0;
     m_onCounter = 0;
     m_lfoDelay = 0;
     m_lfoDepth = 0;
     m_lfoEnd = 0;
     m_lpfAmount = 0;
     m_lpfFrequency = 0;
     m_lpfResonance = 0;
     NoteIndex = 0;
     Detune = 0;
     m_frequencyIndex = 0;
     Pan = 64;
     Expression = 127;
     Velocity = 100;
     Input = new Events.Input() { Sens = 0, Pipe = 0 };
     Output = new Events.Output() { Mode = ChannelOutputMode.Default, Pipe = 0 };
     Ring = new Events.Ring() { Sens = 0, Pipe = 0 };
     Sync = new Events.Sync() { Mode = ChannelOutputMode.Default, Pipe = 0 };
 }