using slower sample rate

using slower sample rate

Postby rputra » Thu Apr 10, 2014 10:54 pm

Hi I'm quite new with this codec shield. I'm using maple board from leaflabs to interface with the audio codec shield. For some reason, I want to generate 1kHz sine wave at 2.145kHz sample rate instead of using the default 44.1Khz. But, I could not do it, the output waveform is just a really noisy sine wave which is not even at 1Khz.

This is part of my code:
Code: Select all
#define SAMPLE_RATE 2
//#define SAMPLE_RATE 44

int16 sinewave[] __FLASH__ = {
  #include <>

const uint16 realSamplerate = 2450;
//const uint16 realSamplerate = 44100;
const uint16 sineSize = 1024;
uint16 currentFreqL = 1000;
int16 tempL;
uint16 locationL;

samplesPerSinewaveL = realSamplerate / currentFreqL;
sineIncL = sineSize/ samplesPerSinewaveL;   

tempL = sinewave[locationL];
locationL += sineIncL;
locationL &= 0x03ff;
Posts: 3
Joined: Thu Apr 10, 2014 10:42 pm

Re: using slower sample rate

Postby guest » Fri Apr 11, 2014 12:32 am

i would suggest running the sine_generator test code, and seeing if you can generate a 1khz tone by turning the knob. what im suspecting is happening, is that your increment calculation is turncating, and you are jumping ahead by 512 samples each time. but, if you start at position 0, you jump to 512, and then to 0, etc. the values at 0 and 512 are identical, and therefore no output is produced.
Site Admin
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: using slower sample rate

Postby rputra » Mon May 12, 2014 5:43 pm

Thanks, that is exactly what happened. I tried to generate a little bit higher frequency (i.e. at 1.25 kHz), and it worked.
Posts: 3
Joined: Thu Apr 10, 2014 10:42 pm

Return to Audio Codec Shield

Who is online

Users browsing this forum: Bing [Bot] and 0 guests