Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #966
    syamkumar
    Member

    Anybody can help me to construct a fm stereo coder in software form (in visual c++)….

    #11501
    Wout
    Member

    Sure, can you post your code.

    #11502
    JesseG
    Member

    better yet, start a project on SF.net if one doesn’t already exist for that. 8)

    #11503
    syamkumar
    Member

    Pseudo code for FM stereo Encoder is as follow:
    Dataout[i] = 0.45*(lval+rval) + 0.091*tone_19kHz + 0.45*(lval-rval)*tone_38kHz
    which repeats 192000 times. Can anybody to implement this code in VC++

    #11504
    Leif
    Keymaster

    Syam, you asked me, and I wrote that pseudo code for you.

    I thought you wanted to make a stereo coder. If I write the pseudo code, and someone else writes the code, then what part are you doing??

    Honestly, if you can’t write the code yourself even with the pseudo code, then perhaps you should start with a simpler programming project before you attempt realtime audio processing. This is not an easy project, and neither is being a programmer! Being a programmer means being able to do it yourself even though it’s difficult. You mentioned this is a postgraduate project — didn’t they teach you how to write programs at school? If not, a programming project may not be the best choice for you.

    ///Leif

    #11505
    Modulator
    Member

    Gotta mention, I wrote an stereo coder in Python.. It’s pretty straight forward imo.. too bad I don’t know anything about filtering so there aren’t any lowpass filters 😉

    #11506
    Vincent
    Member

    This is how I’ve done it:

    You have to create sine tables for both the pilot and 38kHz modulator.

    code :#define SINE_LENGTH 192

    float fPilot[SINE_LENGTH];
    float fMod[SINE_LENGTH];

    for( int i = 0; i < SINE_LENGTH; i++ )
    {
    fPilot[i] = (float)sin(2 * PI * i * 19000.0f/192000.0f);
    fMod[i] = (float)sin(2 * PI * i * 38000.0f/192000.0f);
    }

    Depending on the interface you use, you should do the following in the function that is called when a new block of data is available.

    In my code, a callback function is called directly from the ASIO driver. It has a pointer to both the input and output buffers and the length of the buffer.

    code :static int Callback( const void *inputBuffer, void *outputBuffer,
    unsigned long framesPerBuffer,
    const PaStreamCallbackTimeInfo* timeInfo,
    PaStreamCallbackFlags statusFlags,
    void *userData )
    {

    const float *in = (const float *) inputBuffer;
    float *out = (float *) outputBuffer;

    float fLeft, fRight;
    float fRmL, fRpL;
    float fMpx;

    int iPhase = 0;

    for( int i = 0; i < framesPerBuffer; i++ )
    {

    fLeft = *in++;
    fRight = *in++;

    fRmL = fRight - fLeft;
    fRpL = fRight + fLeft;

    fMpx = (( 0.45 * fRpL ) + (0.090 * fPilot[iPhase])) + ( 0.45 * fRmL * fMod[iPhase] );

    *out++ = fMpx; //left output = MPX
    *out++ = fMpx;//right output = MPX

    if( ++iPhase == SINE_LENGTH )
    {
    iPhase = 0;
    }

    }
    return 0;
    }

    Well, that was easy! Note that this is the stereo encoding part only. You have to add preemphasis, low pass filtering and clipping.

    Low pass filters are easy to implement. There are a lot of programs that calculate the cofs for a IIR filter (including the filter function itself) like Winfilter. Writing the preemphasis is difficult (if you don’t understand the math).

    #11507
    syamkumar
    Member

    Thank u. Actually I am doing a FM quadraphonic coder. I had done this project successfully in hardware form using MC1496 Gilbertcell (a ring modulator) including quadraphonic stereo decoder. Since i have no idea to access sound card in visual c++ i decide to collect the complete source code of fm stereo coder by using that knowledge i can develop the software for FM quadraphonic coder (since software is more flexible than hardware).

    #11508
    JesseG
    Member

    "portaudio" is ok, and cross platform. i use it.

    #11509
    syamkumar
    Member

    which is better Port audio or RtAudio API for starting to write program of MPX Stereo encoder???
    Have a nice day 🙂

    #11510
    JesseG
    Member

    I haven’t used RtAudio but it seems decent.

    #11511
    syamkumar
    Member

    I am using Gigabyte mother board for my computer which supports 7.1 audio output.
    Also I use Virtual Audio Cable (VAC) to interface between Media Player and FM Stereo Encoder.
    FM Stereo Encoder is made using PortAudio API and working fine.
    Many many thanks to Vincent who helped me a lot to make FM Stereo Encoder.
    I made a FM Quadraphonic Encoder also which encode four audio channel. For that project I changed VAC cable settings as follows:
    1. Sampling rate range = 8000 to 384000 samples per second
    2. Number of channels = 4
    3. Number of bits = 16
    I changed both system’s audio settings and Realtek Audio Control panel’s settings to Quadraphonic sound.
    At first the program for FM Quadraphonic Encoder written in C (console application) and it worked fine. After that I changed it to C# to make a GUI and a C# binding API called PortAudioSharp.dll from portaudio website and PortAudio.dll is used for it. But the problem is that when channel count set (for both input and output device) to four, an invalid channel count error is occurred. Port audio input device is set as "Virtual Cable1" and output device is set as "Realtek High Definition output".
    My question is that does port audio supports at least four input channel and four output channel?
    If yes please give a simple four channel program which take data from virtual audio cable (second device) and maps it to Realtek sound card output (ie, a wire program). Thanks in advance. Have a nice day 🙂

Viewing 12 posts - 1 through 12 (of 12 total)
  • The forum ‘Breakaway Professional Products – [discontinued]’ is closed to new topics and replies.