Hi, All
I have FM sample file(binary) with sample rate of 500k samples per second
containing I/Q samples, downloaded from internet.
I have demodulated earlier AM sample file (wav) with sample rate of 44100
samples per second. i had no problem in demodulating and playing file as
the sample rate was compatible with sound card.
Now in FM case file is binary and sample rate is 500k. I have performed
demodulation without decimation but for decimation to 44100 i am not
getting which factor i use because 500000/44100 =11.33 (not integer), even
if i decimate by this. I am only able to hear only distortion.
My code is
j=0;
for(int a=0; a<samples_count/2;)//a++)
{
i = fptr[a++];
q = fptr[a++];
final[j++]= 83 * (atan(i/q)-atan(tempi/tempq));
tempi=i; tempq=q;
}
j=0;
for(int b=0; b<samples_count/2; b+=12)
{
final[j++]=final[b];
}
err= Pa_WriteStream( g_PAStream, final, j);
_____________________________
Posted through www.DSPRelated.com
RF File Sample Rate Conversion
Started by ●June 23, 2014
Reply by ●June 23, 20142014-06-23
On Mon, 23 Jun 2014 12:51:48 -0500, engrmasood2002 wrote:> Hi, All I have FM sample file(binary) with sample rate of 500k samples > per second containing I/Q samples, downloaded from internet. > I have demodulated earlier AM sample file (wav) with sample rate of > 44100 samples per second. i had no problem in demodulating and playing > file as the sample rate was compatible with sound card. > Now in FM case file is binary and sample rate is 500k. I have performed > demodulation without decimation but for decimation to 44100 i am not > getting which factor i use because 500000/44100 =11.33 (not integer), > even if i decimate by this. I am only able to hear only distortion. > My code isCode snipped, because "free" isn't nearly enough pay to read uncommented code. Divide and conquer: If you just decimate by 11 then the result will be slowed down a bit, but should otherwise sound fine. If all you hear is distortion, then you know that your problem is in the demodulation, not the downsampling. If it sounds fine (other than being a bit slow and flat) then you know that your demodulation is fine and you need to work on the downsampling. Once you've verified the demodulation with the wrong decimation rate, then do a web search on "polyphase filtering" to find out how to do the downsampling. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by ●June 23, 20142014-06-23
>On Mon, 23 Jun 2014 12:51:48 -0500, engrmasood2002 wrote: > >> Hi, All I have FM sample file(binary) with sample rate of 500k samples >> per second containing I/Q samples, downloaded from internet. >> I have demodulated earlier AM sample file (wav) with sample rate of >> 44100 samples per second. i had no problem in demodulating and playing >> file as the sample rate was compatible with sound card. >> Now in FM case file is binary and sample rate is 500k. I have performed >> demodulation without decimation but for decimation to 44100 i am not >> getting which factor i use because 500000/44100 =11.33 (not integer), >> even if i decimate by this. I am only able to hear only distortion. >> My code is > >Code snipped, because "free" isn't nearly enough pay to read uncommented >code. > >Divide and conquer: > >If you just decimate by 11 then the result will be slowed down a bit, but>should otherwise sound fine. If all you hear is distortion, then you >know that your problem is in the demodulation, not the downsampling. If >it sounds fine (other than being a bit slow and flat) then you know that >your demodulation is fine and you need to work on the downsampling. > >Once you've verified the demodulation with the wrong decimation rate, >then do a web search on "polyphase filtering" to find out how to do the >downsampling. > >-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com > >Thanks for the reply, For Audio playback i am decimating by 16 to get 31250 sample rate (500k/16), which falls under 44100 sound card sample rate but i am not sure whether sound card can play at 31250 audio rate other then 22050 and 44100 which are standard. Now only problem is demodulation, with sample rate of 500k i am using following formula i got from gnu radio but no luck. i think its either due sound card audio rate set by me to 31250 or problem in the formula. std::complex <float> tempconj; std::complex <float> current; for(int a=0; a<samples_count;)//a++) { // I*dQ/dt - Q*dI/dt i = fptr[a++]; q = fptr[a++]; current.real(i); current.imag(q); std::complex <float> product = current * std::conj (tempconj); final[j++]= 20 * (atan2f(product.imag(),product.real() )); tempconj.real(i); tempconj.imag(q); } int len=j; j=0; for(int b=0; b<len; b+=16) //decimation factor=16 for audio play { final[j++]=final[b]; } err= Pa_WriteStream( g_PAStream, final, j); please reply soon. Thanks _____________________________ Posted through www.DSPRelated.com
Reply by ●June 23, 20142014-06-23
On 24.06.14 00.08, engrmasood2002 wrote:> Thanks for the reply, > For Audio playback i am decimating by 16 to get 31250 sample rate > (500k/16), which falls under 44100 sound card sample rate but i am not sure > whether sound card can play at 31250 audio rate other then 22050 and 44100 > which are standard.Almost no sound card can play at 31250. But almost all can play 32000. Marcel
Reply by ●June 23, 20142014-06-23
On Mon, 23 Jun 2014 17:08:34 -0500, engrmasood2002 wrote:>>On Mon, 23 Jun 2014 12:51:48 -0500, engrmasood2002 wrote: >> >>> Hi, All I have FM sample file(binary) with sample rate of 500k samples >>> per second containing I/Q samples, downloaded from internet. >>> I have demodulated earlier AM sample file (wav) with sample rate of >>> 44100 samples per second. i had no problem in demodulating and playing >>> file as the sample rate was compatible with sound card. >>> Now in FM case file is binary and sample rate is 500k. I have >>> performed demodulation without decimation but for decimation to 44100 >>> i am not getting which factor i use because 500000/44100 =11.33 (not >>> integer), even if i decimate by this. I am only able to hear only >>> distortion. My code is >> >>Code snipped, because "free" isn't nearly enough pay to read uncommented >>code. >> >>Divide and conquer: >> >>If you just decimate by 11 then the result will be slowed down a bit, >>but > >>should otherwise sound fine. If all you hear is distortion, then you >>know that your problem is in the demodulation, not the downsampling. If >>it sounds fine (other than being a bit slow and flat) then you know that >>your demodulation is fine and you need to work on the downsampling. >> >>Once you've verified the demodulation with the wrong decimation rate, >>then do a web search on "polyphase filtering" to find out how to do the >>downsampling. >> >>-- >> >>Tim Wescott Wescott Design Services http://www.wescottdesign.com >> >> >> > Thanks for the reply, > For Audio playback i am decimating by 16 to get 31250 sample rate > (500k/16), which falls under 44100 sound card sample rate but i am not > sure whether sound card can play at 31250 audio rate other then 22050 > and 44100 which are standard. > > Now only problem is demodulation, with sample rate of 500k i am using > following formula i got from gnu radio but no luck. i think its either > due sound card audio rate set by me to 31250 or problem in the formula.<< insert exasperated emoticon here >> First: publish the algorithm, not the code. If you can't reverse- engineer the algorithm out of the code, then figure it out. Second: I suggest that you break this down into easy bits, and you come back and tell me that you've added a THIRD unknown. Why???? Do you want to fail, and waste time to boot? If you're going to try things at an oddball sampling rate, and you don't know if that'll work with your card, then for gods sake, either don't do that, or make a known test signal and feed it through the card at that rate. This is what I meant by divide and conquer. This is elementary engineering (not to mention science). If you can't bring yourself to do it, you need to find a career in management or literary criticism, or politics, or some other place where you can produce no real value and still get paid. Always, _always_, ALWAYS do the following. If you're stuck, do it again with whatever bit you're stuck on: * Break the problem into easy bits. * Solve each bit separately. * Verify each solved bit before proceeding. Not doing this is like going into a room, not bothering to turn on the light, and then posting the question "how can I avoid stubbing my toe?" Note that this technique does demand that you understand what you're doing -- see my first suggestion, and re-read the comment about career paths if you can't. Third: Re-read my first and second suggestions, and take them. When you get stuck on something SMALLER than the original problem, rather than BIGGER, then someone may feel motivated to help you. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by ●June 24, 20142014-06-24
On 06/24/2014 06:35 AM, Marcel M�ller wrote:> On 24.06.14 00.08, engrmasood2002 wrote: >> Thanks for the reply, >> For Audio playback i am decimating by 16 to get 31250 sample rate >> (500k/16), which falls under 44100 sound card sample rate but i am not >> sure >> whether sound card can play at 31250 audio rate other then 22050 and >> 44100 >> which are standard. > > Almost no sound card can play at 31250. But almost all can play 32000. > > > MarcelVery few modern sound cards can play at anything other than 48k samples/second. All other rates are achieved by resampling. High end cards can do 96k, 192k, and sometimes 44.1k and 88.2k. Regards, Steve
Reply by ●June 24, 20142014-06-24
Steve Underwood <steveu@dis.org> writes:> On 06/24/2014 06:35 AM, Marcel Müller wrote: >> On 24.06.14 00.08, engrmasood2002 wrote: >>> Thanks for the reply, >>> For Audio playback i am decimating by 16 to get 31250 sample rate >>> (500k/16), which falls under 44100 sound card sample rate but i am not >>> sure >>> whether sound card can play at 31250 audio rate other then 22050 and >>> 44100 >>> which are standard. >> >> Almost no sound card can play at 31250. But almost all can play 32000. >> >> >> Marcel > > Very few modern sound cards can play at anything other than 48k > samples/second. All other rates are achieved by resampling. High end > cards can do 96k, 192k, and sometimes 44.1k and 88.2k. > > Regards, > SteveI recently wrote a Qt application that used the QAudioInput class, exposed the sample rates reported by QAudioDeviceInfo, and found the following sample rates for the following devices: Internal sound: 8000, 11025, 22050, 44100, 48000 USB Webcam/mic: 8000, 11025, 22050, 44100, 48000 Plantronics USB headset: 8000, 22050, 44100, 48000 Sabrent USB-SBCV: 8000, 11025, 22050, 44100, 48000 In no case did I find 32 kHz. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
Reply by ●June 24, 20142014-06-24
>Steve Underwood <steveu@dis.org> writes: > >> On 06/24/2014 06:35 AM, Marcel Müller wrote: >>> On 24.06.14 00.08, engrmasood2002 wrote: >>>> Thanks for the reply, >>>> For Audio playback i am decimating by 16 to get 31250 sample rate >>>> (500k/16), which falls under 44100 sound card sample rate but i amnot>>>> sure >>>> whether sound card can play at 31250 audio rate other then 22050 and >>>> 44100 >>>> which are standard. >>> >>> Almost no sound card can play at 31250. But almost all can play 32000. >>> >>> >>> Marcel >> >> Very few modern sound cards can play at anything other than 48k >> samples/second. All other rates are achieved by resampling. High end >> cards can do 96k, 192k, and sometimes 44.1k and 88.2k. >> >> Regards, >> Steve > >I recently wrote a Qt application that used the QAudioInput class, >exposed the sample rates reported by QAudioDeviceInfo, and found the >following sample rates for the following devices: > > Internal sound: 8000, 11025, 22050, 44100, 48000 > USB Webcam/mic: 8000, 11025, 22050, 44100, 48000 > Plantronics USB headset: 8000, 22050, 44100, 48000 > Sabrent USB-SBCV: 8000, 11025, 22050, 44100, 48000 > >In no case did I find 32 kHz. >-- >Randy Yates >Digital Signal Labs >http://www.digitalsignallabs.com >I think some guys have misunderstood me, i love DSP and have also designed AM and FM radios (hardware) and now i want to do the same in software. I have studied SDR and have built AM radio now my next aim is to complete FM receiver. As many people are doing, i am doing DSP for fun but dont want to reinvent the wheel, so my questions may seem insane as i am not a dsp guru but trying to learn and experimenting with existing dsp techniques and algorithms and code available. In doing so when i hang on something i then try to ask expert guys like you for quick reply and suggestion, it does not mean one should change his career or so and one should also not think that if he had been lucky enough doing everything right means insulting the weaker ,if he thinks that way about the other persons asking questions. Any ways i am sorry as if it seems to be hurting any one. _____________________________ Posted through www.DSPRelated.com
Reply by ●June 24, 20142014-06-24
On Tuesday, June 24, 2014 5:51:48 AM UTC+12, engrmasood2002 wrote:> Hi, All > > I have FM sample file(binary) with sample rate of 500k samples per second > > containing I/Q samples, downloaded from internet. > > I have demodulated earlier AM sample file (wav) with sample rate of 44100 > > samples per second. i had no problem in demodulating and playing file as > > the sample rate was compatible with sound card. > > Now in FM case file is binary and sample rate is 500k. I have performed > > demodulation without decimation but for decimation to 44100 i am not > > getting which factor i use because 500000/44100 =11.33 (not integer), even > > if i decimate by this. I am only able to hear only distortion. > > My code is > > > > j=0; > > for(int a=0; a<samples_count/2;)//a++) > > { > > i = fptr[a++]; > > q = fptr[a++]; > > final[j++]= 83 * (atan(i/q)-atan(tempi/tempq)); > > tempi=i; tempq=q; > > > > } > > j=0; > > for(int b=0; b<samples_count/2; b+=12) > > { > > final[j++]=final[b]; > > } > > > > err= Pa_WriteStream( g_PAStream, final, j); > > > > _____________________________ > > Posted through www.DSPRelated.comI see you are doing phase demodulation. You don't need the atan. What an FM receiver receives is teh rate of change of phase ie d/dt of the ATAN you have. This will remove the ATAN and give you better results.
Reply by ●June 24, 20142014-06-24
>On Tuesday, June 24, 2014 5:51:48 AM UTC+12, engrmasood2002 wrote: >> Hi, All >> >> I have FM sample file(binary) with sample rate of 500k samples persecond>> >> containing I/Q samples, downloaded from internet. >> >> I have demodulated earlier AM sample file (wav) with sample rate of44100>> >> samples per second. i had no problem in demodulating and playing fileas>> >> the sample rate was compatible with sound card. >> >> Now in FM case file is binary and sample rate is 500k. I have performed >> >> demodulation without decimation but for decimation to 44100 i am not >> >> getting which factor i use because 500000/44100 =11.33 (not integer),even>> >> if i decimate by this. I am only able to hear only distortion. >> >> My code is >> >> >> >> j=0; >> >> for(int a=0; a<samples_count/2;)//a++) >> >> { >> >> i = fptr[a++]; >> >> q = fptr[a++]; >> >> final[j++]= 83 * (atan(i/q)-atan(tempi/tempq)); >> >> tempi=i; tempq=q; >> >> >> >> } >> >> j=0; >> >> for(int b=0; b<samples_count/2; b+=12) >> >> { >> >> final[j++]=final[b]; >> >> } >> >> >> >> err= Pa_WriteStream( g_PAStream, final, j); >> >> >> >> _____________________________ >> >> Posted through www.DSPRelated.com > >I see you are doing phase demodulation. You don't need the atan. What anFM receiver receives is teh rate of change of phase ie d/dt of the ATAN you have. This will remove the ATAN and give you better results.>I am doing whole process this way: 1. Reading File as binary for FM I/Q Data. File is philly_93.3MHz_500ksps.32fc downloaded from http://www.trondeau.com/gr-tutorial/ This file was captured using a USRP N210 with a WBX board in Philadelphia on FM channel 93.3 MHz 2. Reading I/Q data in arrays and performing demodulation like this samples_count=fread( (void*) fptr,4,1024,fp); //fptr now contains data 3. Then after seperating I and Q i do demodulation as suggested by applying formula to get rate of change of phase. i also decimate by 16 for audio playback through sound card (32k) and apply LPF for 16 Khz after demodulation and only hear distortion and negligible sound for(int a=0; a<samples_count;)//a++)// /8 { // I*dQ/dt - Q*dI/dt i = fptr[a++]; q = fptr[a++]; current.real(i); current.imag(q); std::complex <float> product = current * std::conj (tempconj); float img=tempconj.imag(); float rel=tempconj.real(); final[j++]= 103*(i*(atan2f(q,i))-q*(atan2f(tempq,tempi)) ) ; tempconj.real(i); tempconj.imag(q); tempi=i; tempq=q; } //Decimation by 16, i.e 500k/16 approx 32k for sound card play back int len=j; j=0; for(int b=0; b<len; b+=16) { final[j++]=final[b]; } FIRFilter(final,j); err= Pa_WriteStream( g_PAStream, final, j); _____________________________ Posted through www.DSPRelated.com






