filoe / cscore

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
Other
2.15k stars 451 forks source link

Request for some help, want to create an audio base Radio IF Signal Processor [IF SDR] #250

Open pa3akp opened 7 years ago

pa3akp commented 7 years ago

Let me first comment that CSCore is an amazing project, the first one I have ever seen with such details.

What do I want to create. I am an HAM radio operator and want to create in C#, with the help of CSCore, a universal Audio IF (IF = Intermediate Frequency) signal processor to built a IF SDR (software defined Radio). The signal processing is meant to demodulate radio signals converted from the 455kHz IF of my receiver into a 12kHz IF. The modulation types can be AM, FM, USB, LSB,.... whatever.

Next to the IF processing, I would like to create Audio Based signal processing of of signals like SSTV(Slow Scan Television, WEFAX (Weather Fax Maps), APT(Automatic Picture Transmission from weather satelllites), RTTY ( Radio TeleType) etc etc.

Also custom filtering DSP must be one of the features (Low Pass, High Pass etc)

As a first step for help:

At the moment I already can sample the incoming Audio, using one of the samples in CScore, and place them info a buffer with a programmable size. Making use of Zedgraph I can display the sampled time domain and using AlgLib and Zedgraph to create a spectral plot.

In the code below, I store each sample of the single block read in a buffer of 2^n samples. When the buffer has all the points I show time domain or (after FFT) show freq domain.

QUESTION: how can I replay the contents of this (unprocessed) data back again to the audio output of the soundcard?

Thanks Onno de Meijer

private void SingleBlockNotificationStreamOnSingleBlockRead(object sender, SingleBlockReadEventArgs e)
        {
            // Filling of FFT-list to 'totSamples' points
            if (fftBufferPointer < totSamples - 1)         //This statement was < is now !=

            {
                // Array without the Window function for the Scope, no windowing
                fftBufferL.Add(Convert.ToDouble(e.Left));
                fftBufferR.Add(Convert.ToDouble(e.Right));

                // if the form SpectrumAnalyserForm is open, then work on the FFT data points.

                switch (fftWindow)
                // Depending on the sampling winwdow type, fill the Array 'windowedBuffer(L)(R)' with windowed sample points
                {
                case "hamming":
                    windowedBufferL.Add(Convert.ToDouble(e.Left) * (0.54 - 0.46 * Math.Cos((2 * Math.PI * fftBufferPointer) / (totSamples - 1))));
                    break;
                case "hanning":
                    windowedBufferL.Add(Convert.ToDouble(e.Left) * 0.5 * (1 - Math.Cos((2 * Math.PI * fftBufferPointer) / (totSamples - 1))));
                    break;
                case "blackman-harris":
                    windowedBufferL.Add(Convert.ToDouble(e.Left) * (0.35875 - 0.48829 * Math.Cos((2 * Math.PI * fftBufferPointer) / (totSamples - 1)) + 0.14128 * Math.Cos((4 * Math.PI * fftBufferPointer) / (totSamples - 1)) - 0.01168 * Math.Cos((6 * Math.PI * fftBufferPointer) / (totSamples - 1))));
                    break;
                }

                // Increment the fftBufferPointer
                fftBufferPointer++;

            }
            else
            {
                //Debug.Print(windowedBufferL.Count.ToString());

                fftBufferPointer++;

                // Is the ScopeForm loaded?
                Form fc = Application.OpenForms["ScopeForm"];
                if (fc != null)
                {
                    // Call the scope display with the list converted to an array
                    audioToScope(fftBufferL.ToArray());
                }

                // Is the SpecAnForm loaded?
                fc = Application.OpenForms["SpectrumAnalyserForm"];
                if (fc != null)
                {
                    // Call the specan display with the list converted to an array
                    audioToSpecAn(windowedBufferL.ToArray());
                }

                // Clear the audio time-span buffers and the pointer
                fftBufferL.Clear();
                fftBufferR.Clear();

                windowedBufferL.Clear();
                windowedBufferR.Clear();

                fftBufferPointer = 0;
            }
        }
pa3akp commented 7 years ago

To make it more clear : the data which resides in the buffer fftBufferL and/or fftBufferR

Onno

filoe commented 7 years ago

As far as I understood you correct, you would like to do a IFFT on the fftBufferL and fftBufferR, store the samples in a buffer again and play them?

pa3akp commented 7 years ago

Thanks for coming back Florian!

I will compose a good explanation of my needs and come back to you!

Best regards,

Onno de Meijer

From: Florian Rosmann [mailto:notifications@github.com] Sent: Sunday, July 02, 2017 5:49 PM To: filoe/cscore Cc: Onno de Meijer; Author Subject: Re: [filoe/cscore] Request for some help, want to create an audio base Radio IF Signal Processor [IF SDR] (#250)

As far as I understood you correct, you would like to do a IFFT on the fftBufferL and fftBufferR, store the samples in a buffer again and play them?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/filoe/cscore/issues/250#issuecomment-312499626 , or mute the thread https://github.com/notifications/unsubscribe-auth/AbM8mT_g-u28XS5U0FSxoe9hSZbTQ89Aks5sJ7v4gaJpZM4OEiSs . https://github.com/notifications/beacon/AbM8mfKNze_QyObTSCsqhzkX633_QX20ks5sJ7v4gaJpZM4OEiSs.gif

filoe commented 6 years ago

Any news on that?

pa3akp commented 6 years ago

Hi Florian,

Thanks for the mail!

Not yet unfortunately, sorry for this.

I am working on a large project in Russia at present for work, and free time is a problem, and away from home often.

I will come back on this, but appreciate your reminder!

Best regards,

Onno

From: Florian Rosmann [mailto:notifications@github.com] Sent: Saturday, October 21, 2017 10:34 PM To: filoe/cscore Cc: Onno de Meijer; Author Subject: Re: [filoe/cscore] Request for some help, want to create an audio base Radio IF Signal Processor [IF SDR] (#250)

Any news on that?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/filoe/cscore/issues/250#issuecomment-338430516 , or mute the thread https://github.com/notifications/unsubscribe-auth/AbM8mbDu-JlBio3dCOoTtX6nF4kcmDkWks5sulU3gaJpZM4OEiSs . https://github.com/notifications/beacon/AbM8mcdZEkkuxF8SR5ftlyqjCBLjTaUmks5sulU3gaJpZM4OEiSs.gif