Mic input to effectStream Output

Jan 28, 2013 at 8:59 PM

Hello, Now I creating my project about Effect Guitar by DSP. then my project have some problem about MIC input to effectStream. Because I get data form MIC-input by WaveIn and get data into BufferWaveProvider. But I can't to get input data to pass effectStream. Please help me give some a sample code to get data pass effectStream.

        public void Start()
            waveOuts = new WaveOut();
            sourceStream = new WaveIn();
            sourceStream.BufferMilliseconds = 20;
            sourceStream.DeviceNumber = 0;
            sourceStream.WaveFormat = new WaveFormat(44100, 16, 2);
            sourceStream.DataAvailable += new EventHandler<WaveInEventArgs>(sourceStream_DataAvailable);

            waveBuffer = new BufferedWaveProvider(sourceStream.WaveFormat);
            waveBuffer.DiscardOnBufferOverflow = true;


            //effectStream = new EffectStream(effects, waveBuffer);


        private void sourceStream_DataAvailable(object sender, WaveInEventArgs args)
            waveBuffer.AddSamples(args.Buffer, 0, args.BytesRecorded);

How I can get data to pass effectStream for my output. Please help me. Thank you so much.

Ps. Sorry for my English is poor. And I beginner in C#. Sorry very much.

Jan 31, 2013 at 7:01 AM
you need to set up an effect pipeline. You are doing roughly the right thing, its just that EffectStream is expecting a WaveStream. I'd modify EffectStream to simply require an IWaveProvider. It dones't really need a WaveStream. Then you will be able to call waveOuts.Init(effectStream)
Feb 2, 2013 at 8:34 PM
Thank you for answer. But I can't understand about to modify EffectStream to simply require an IWaveProvider. Please show me how to modify this. Thank you very much.
Feb 4, 2013 at 10:05 AM
change the EffectStream code so its constructor takes an IWaveProvider, and so that EffectStream just implements IWaveProvider. Then you can delete its Length and Position properties. Makes life simpler.
Feb 6, 2013 at 4:24 PM
Thank you for advise to modify. Now I can take an IWaveProvider into EffectStream but it have warning about effects have null parameter when I click play Mic input it had show error about effects. Please help me to take effect pass Mic real-time and show me for example to take Mic input pass effectStream. Because I have dead line to present project on 8 Feb but now it have problem. Thank you very much.
public class EffectStream : IWaveProvider
        private EffectChain effects;
        public IWaveProvider sourceIn;
        private object effectLock = new object();
        private object sourceLock = new object();

        public EffectStream(EffectChain effects, IWaveProvider sourceStreamIn)
            this.effects = effects;
            this.sourceIn = sourceStreamIn;
             //effects have null
            foreach (Effect effect in effects)
Feb 11, 2013 at 2:17 PM
Do you actually have any effects in your effects chain?
Feb 24, 2013 at 6:06 PM
Hi, Mark. Please help me. Now I modify EffectStream to simply require an IWaveProvider. But when I call waveOuts.Init(effectStream). It shown clean sound. It sound not process with effect. Please advise me about to get sound to pass effect. Thank you.
Feb 25, 2013 at 3:21 PM
well what effects have you put into your effect chain?