Home › Forums › Breakaway Professional Products – [discontinued] › fm stereo coder
- This topic has 11 replies, 6 voices, and was last updated 12 years, 7 months ago by syamkumar.
-
AuthorPosts
-
October 11, 2010 at 8:29 am #966syamkumarMember
Anybody can help me to construct a fm stereo coder in software form (in visual c++)….
October 11, 2010 at 11:21 am #11501WoutMemberSure, can you post your code.
October 13, 2010 at 4:32 am #11502JesseGMemberbetter yet, start a project on SF.net if one doesn’t already exist for that. 8)
June 20, 2011 at 5:57 am #11503syamkumarMemberPseudo 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++June 20, 2011 at 12:37 pm #11504LeifKeymasterSyam, 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
June 20, 2011 at 3:15 pm #11505ModulatorMemberGotta 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 😉
June 27, 2011 at 8:48 pm #11506VincentMemberThis 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 = MPXif( ++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).
March 17, 2012 at 8:19 am #11507syamkumarMemberThank 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).
March 17, 2012 at 8:47 pm #11508JesseGMember"portaudio" is ok, and cross platform. i use it.
March 28, 2012 at 8:44 am #11509syamkumarMemberwhich is better Port audio or RtAudio API for starting to write program of MPX Stereo encoder???
Have a nice day 🙂March 28, 2012 at 5:39 pm #11510JesseGMemberI haven’t used RtAudio but it seems decent.
April 17, 2012 at 5:15 am #11511syamkumarMemberI 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 🙂 -
AuthorPosts
- The forum ‘Breakaway Professional Products – [discontinued]’ is closed to new topics and replies.