Example #1
0
        /// <summary>
        /// Starts synthesizing the current note.
        /// </summary>
        /// <param name="noteNo">The midi note number.</param>
        public void ProcessNoteOnEvent(byte noteNo)
        {
            _synthBuffer = new StereoBuffer(noteNo);
            if (_player == null)
            {
                _player = new SamplePlayer(_synthBuffer);
                _player.Synthesize();
                _player.isOn = true;
            }
            else
            {
                if (_player.isOn == true)
                {
                    if (_player.SynthBuffer.NoteNo != noteNo)
                    {

                        _player.attackTime = 44100 / 20;
                        _player.SynthBuffer = _synthBuffer;
                        //_player = new SamplePlayer(_synthBuffer);
                        _player.Synthesize();
                    }
                }
                else
                {
                    _player.attackTime = 44100 / 5;
                    _player.SynthBuffer = _synthBuffer;
                    _player.Synthesize();
                    _player.isOn = true;
                }
            }
        }
Example #2
0
 public void CopyFrom(StereoBuffer source)
 {
     Debug.Assert(Capacity == source.Capacity);
     // TODO: might as well rotate the ring buffer so element 0 is the oldest
     // element; would keep us from having to do an extra copy into m_LChannelTempBuffer
     m_iOldestValue = source.m_iOldestValue;
     Array.Copy(source.m_LChannelValues, m_LChannelValues, Capacity);
     Array.Copy(source.m_RChannelValues, m_RChannelValues, Capacity);
 }
Example #3
0
        // Start background threads.
        private void Start()
        {
            m_ffmpegVideoReader = new FfmpegPipe();
            m_ffmpegVideo       = new FfmpegPipe();
            m_ffmpegAudio       = new FfmpegPipe();
            m_audioBuffer       = new StereoBuffer(); // SetFps is called below.

            // we use this to ensure StopCapture() is called on exit, even if this behavior is disabled.
            App.Instance.AppExit += OnGuaranteedAppQuit;
        }
Example #4
0
        void Awake()
        {
            m_State = State.Disabled;
#if !DISABLE_AUDIO_CAPTURE
            int size = VisualizerManager.m_Instance.FFTSize;
            m_HotValues     = new StereoBuffer(size);
            m_OperateValues = new StereoBuffer(size);

            m_LChannelTempBuffer = new float[size];
            m_RChannelTempBuffer = new float[size];
#endif
        }
Example #5
0
        /// <summary>
        /// Returns a Stereobuffer class by input of a file
        /// </summary>
        /// <param name="note">note (nog nodig?)</param>
        /// <param name="file">location of audio file</param>
        /// <returns></returns>
        private StereoBuffer CreateSampleBuffer(int gridItemId, string file)
        {
            var kickbuffer = new StereoBuffer(gridItemId);

            float[] leftList = null;

            using (var reader = new AudioFileReader(file)) {
                leftList = new float[reader.Length];
                reader.ToSampleProvider().Read(leftList, 0, leftList.Length);
            }

            //readWav(file, out leftList, out richtList);
            if (leftList != null)
            {
                kickbuffer.LeftSamples  = leftList.ToList();
                kickbuffer.RightSamples = leftList.ToList();
            }

            return(kickbuffer);
        }
Example #6
0
 public SamplePlayer(GridItem gridItem, StereoBuffer buffer)
 {
     GridItem = gridItem;
     Buffer   = buffer;
 }
Example #7
0
 public SamplePlayer(StereoBuffer synthBuffer)
 {
     SynthBuffer = synthBuffer;
 }
Example #8
0
 public Synth()
 {
     _synthBuffer = new StereoBuffer(0);
 }
Example #9
0
 public SamplePlayer(StereoBuffer buffer)
 {
     Buffer = buffer;
 }
Example #10
0
 public SampleRecorder(byte noteNo)
 {
     Buffer = new StereoBuffer(noteNo);
 }
Example #11
0
        private void Initialize(SampleRate sampleRate, StereoBuffer buffer)
        {
            emptyFMModulator = new EmptyMonoComponent(sampleRate, new MonoBuffer(0));

            slewLimiter = new SlewLimiter(sampleRate, new MonoBuffer(0), "Portamento");
            slewLimiter.SynthesizeReplaceEnabled = true;

            envelope1 = new AdsrEnvelope(sampleRate, new MonoBuffer(0), "Envelope 1");
            envelope1.SynthesizeReplaceEnabled = true;

            envelope2 = new AdsrEnvelope(sampleRate, new MonoBuffer(0), "Envelope 2");
            envelope2.SynthesizeReplaceEnabled = true;

            lfo1 = new Lfo(sampleRate, new MonoBuffer(0), "LFO 1");
            lfo1.SynthesizeReplaceEnabled = true;

            lfo2 = new Lfo(sampleRate, new MonoBuffer(0), "LFO 2");
            lfo2.SynthesizeReplaceEnabled = true;

            Wavetable wave = Wavetable.Load("Sawtooth");

            osc1 = new Oscillator(sampleRate, new MonoBuffer(0), "Oscillator 1", wave, emptyFMModulator, slewLimiter);
            osc1.SynthesizeReplaceEnabled = true;

            osc2 = new Oscillator(sampleRate, new MonoBuffer(0), "Oscillator 2", wave, emptyFMModulator, slewLimiter);
            osc2.SynthesizeReplaceEnabled = true;

            filter = new StateVariableFilter(sampleRate, new MonoBuffer(0), "State Variable Filter", osc1, osc2, envelope2, lfo2, envelope1);
            filter.SynthesizeReplaceEnabled = true;

            converter = new MonoToStereoConverter(sampleRate, buffer, filter);
            converter.SynthesizeReplaceEnabled = false;

            oscWaveProgrammer1 = new OscWaveProgrammer("Oscillator 1", osc1);
            oscWaveProgrammer2 = new OscWaveProgrammer("Oscillator 2", osc2);

            oscFMProgrammer1 = new OscFMProgrammer("Oscillator 1", osc1, emptyFMModulator, envelope1, envelope2, lfo1, lfo2);
            oscFMProgrammer2 = new OscFMProgrammer("Oscillator 2", osc2, emptyFMModulator, envelope1, envelope2, lfo1, lfo2);

            AddComponent(emptyFMModulator);
            AddComponent(slewLimiter);
            AddComponent(osc1);
            AddComponent(osc2);
            AddComponent(envelope1);
            AddComponent(envelope2);
            AddComponent(lfo1);
            AddComponent(lfo2);
            AddComponent(filter);
            AddComponent(converter);

            AddParameters(slewLimiter);
            AddParameters(osc1);
            AddParameters(oscWaveProgrammer1);
            AddParameters(oscFMProgrammer1);
            AddParameters(osc2);
            AddParameters(oscWaveProgrammer2);
            AddParameters(oscFMProgrammer2);
            AddParameters(envelope1);
            AddParameters(envelope2);
            AddParameters(lfo1);
            AddParameters(lfo2);
            AddParameters(filter);

            AddBendable(osc1);
            AddBendable(osc2);

            AddControllable(lfo1);
            AddControllable(lfo2);
        }
Example #12
0
 public SynthVoice(SampleRate sampleRate, StereoBuffer buffer, string name)
     : base(sampleRate, buffer, name)
 {
     Initialize(sampleRate, buffer);
 }
Example #13
0
 public SynthVoice(SampleRate sampleRate, StereoBuffer buffer)
     : base(sampleRate, buffer)
 {
     Initialize(sampleRate, buffer);
 }