DSPRelated.com
Forums

Re: Re: query regarding interfacing of ADC/DAC for speech i/p and o/p

Started by Jeff Brower October 20, 2006
Umer-

> Jeff-
> Actually when i run this code a shrill sound is heard from headphones and
> then every thing stops. And then sometimes nothing comes out (nothing happens).

C'mon Umer, you have to debug -- that's the nature of engineering. Now you're
finding out that engineering is 20% fun (design) and 80% hard work (debug, test,
documentation, etc). Hope you're ready for that.

If you take out the middle four lines inside the loop, then the code is just like
what you said works previously. So first, double-check that. Does that still work?
If you put back those 4 lines, then try a reduced value for BUFLEN, maybe 1024. Does
it work then?

When code completely breaks and won't run, then one likely issue is memory map /
allocation.

-Jeff
> When i use software delay loop like:
>
> Uint32 delay;
> DSK5510_AIC23_CodecHandle hCodec;
> Int16 i,sample,left,right;
> DSK5510_init();
> hCodec = DSK5510_AIC23_openCodec(0, &config);
> while(true)
> {
> /*Read a sample from the left input channel */
>
> while(!DSK5510_AIC23_read16(hCodec, &left));
>
> for(delay=0; delay000000;delay++
> {
> }
>
> /* Send a sample to the left channel */
>
> while(!DSK5510_AIC23_write16(hCodec, left));
> }
> In this way it doesn't work and simply nothing happens or no sound. Actually I used that loop from another example of CCS (LED example).In that example it was used to introduce a delay in blinking of LEDs. Is this approach valid? Or I have to go through shifting in arrays only.No other way.
> Umer-
> >
> >> Sorry I was out of town so didn't respond you timely
> >> No it is not working....even after outptr=1.....now what to do. Ok just
> >> ell me is there any other way..or how can we improve it..
> >
> >Please explain "not working". What happens?
> >
> >> .what is the purpose of software delay loop...can't we use it?
> >
> >I thought that's what you wanted, a long delay between output and input.
> >
> >-Jeff
> >
> >> > It was pointed out to me that outptr should be initialized to 1 to get the
> >> > full 4 sec delay:
> >> >
> >> > inptr = 0;
> >> > outptr = 1;
> >> >
> >> > Let me know if it works, or at least gets you closer.
> >> >
> >> > -Jeff
> >> >
> >> > ---------------------------- Original Message ----------------------------
> >> > Subject: Re: [c55x] Re: Re: query regarding interfacing of ADC/DAC for
> >> > speech i/p and o/p From: "Jeff Brower"
> >> > Date: Thu, October 12, 2006 7:18 pm
> >> > To: "Umer Khan"
> >> > Cc: c...
> >> > --
> >> >
> >> > Umer-
> >> > > I couldn't get your second hint related to single circular ....I/O
> >> > pointer shifted tio each others.So far as your point of not debugging my
> >> > assignment is concerned, let me tell you that after this preliminay set
> >> > up (just to verify the correct working of DSK's CODEC) I have to undergo
> >> > a detailed course of DSP alongwith DSK training. So plz change your mind
> >> > that i am getting my assignment done from you. If you dont help me I
> >> > will do it after 6 months. I just want to show it to my advisor.
> >> > Otherwise i will just show him the loopback working. I was trying to
> >> > show him a good piece of work by looping it back after some seconds.
> >> > Also I have the Java experiance not for C.So I would be happy if you
> >> > help me getting it done. Otherwise no prob.,,,
> >> >
> >> > Ok ok... something like the code example below. For a sampling rate of 8
> >> > kHz, output will be delayed from input by 4 sec. I only stored left
> >> > channel. I didn't test the code.
> >> >
> >> > -Jeff
> >> > define #BUFLEN 16384 /* must be power of 2 */
> >> > short left, right, inptr, outptr;
> >> > short buf[BUFLEN];
> >> >
> >> > inptr = 0;
> >> > outptr = BUFLEN-1;
> >> >
> >> > while (TRUE) {
> >> >
> >> > while (!DSK5510_AIC23_read16(hCodec, &left));
> >> > while (!DSK5510_AIC23_read16(hCodec, &right));
> >> >
> >> > buf[inptr++] = left;
> >> > inptr &= BUFLEN-1;
> >> >
> >> > left = buf[outptr++];
> >> > outptr &= BUFLEN-1;
> >> >
> >> > while(!DSK5510_AIC23_write16(hCodec, left));
> >> > while(!DSK5510_AIC23_write16(hCodec, right));
> >> > }
> >> >
> >> > > Jeff Brower wrote:
> >> > >
> >> > > Umer-
> >> > >
> >> > > > Thanks for ur reply. The code snippet that u have mentioned (i.e.
> >> > loopback) is already working and i hav already tried it out. But
> >> > I just
> >> > >
> >> > > > want to store the audio input in some buffer array or any thing
> >> > else.
> >> > > And
> >> > > > then I want to loop it back after sometime (in seconds just like
> >> > after introducing some delay). Please look in to my code to
> >> > understand wht i am trying to do. This is my first assignment to
> >> > configure DSK and a preliminary demo (abt which my question is).
> >> > After that i will start learning DSP concepts and tutorials and
> >> > manuals of CCS. So kindly help me to get this first step.
> >> > >
> >> > > I know what you're trying to do, and I know what's wrong with your
> >> > code. But I'm not
> >> > > going to debug your assignment for you.
> >> > >
> >> > > The point of my reply is to show that you are assuming too many
> >> > steps between the
> >> > > initial working code, and your objective -- which is a typical
> >> > student error. If you
> >> > > go carefully, step-by-step, then you can figure it out. I'll give
> >> > you 2 hints: a)
> >> > > don't make separate for-loops, and b) use a single, circular buffer
> >> > with input and
> >> > > output pointers shifted from each other.
> >> > >
> >> > > Good luck!
> >> > >
> >> > > -Jeff
> >> > >
> >> > > > Umer-
> >> > > > >
> >> > > > > > So did u find answer to your query? I am really a new comer in
> >> > DSP domain and unknown to working C5510 in detail. I want to
> >> > read audio input from mic and store it.Then i want to play it
> >> > back to headphone.
> >> > > > > >
> >> > > > > > This is my main():
> >> > > > >
> >> > > > > First I would try something very simple to verify your DSK
> >> > board, tool
> >> > >
> >> > > > > set-up, build options, memory map, and other basic factors are Ok:
> >> > > > >
> >> > > > > void main() {
> >> > > > >
> >> > > > > DSK5510_AIC23_CodecHandle hCodec;
> >> > > > > Int16 left,right;
> >> > > > >
> >> > > > > /* Initialize the board support library, must be called first
> >> > */ DSK5510_init();
> >> > > > >
> >> > > > > /* Start the codec */
> >> > > > > hCodec = DSK5510_AIC23_openCodec(0, &config);
> >> > > > >
> >> > > > > /* Audio loopback */
> >> > > > > while (TRUE) {
> >> > > > >
> >> > > > > while (!DSK5510_AIC23_read16(hCodec, &left));
> >> > > > > while (!DSK5510_AIC23_read16(hCodec, &right));
> >> > > > >
> >> > > > > while(!DSK5510_AIC23_write16(hCodec, left));
> >> > > > > while(!DSK5510_AIC23_write16(hCodec, right));
> >> > > > > }
> >> > > > >
> >> > > > > DSK5510_AIC23_closeCodec(hCodec);
> >> > > > > }
> >> > > > >
> >> > > > > This should enable audio loopback -- you should hear whatever is on
> >> > > the
> >> > > > > inputs. Does that much work? If so, then you can go step-by-step to
> >> > > add
> >> > > > > the functionality you need, testing each step carefully.
> >> > > > >
> >> > > > > Also, here is a nice page for generating a sine wave with DSK 5510:
> >> > > > >
> >> > > > > http://www.tkt.cs.tut.fi/kurssit/3516/exercises/fall05/test_audioIO.c
> >> > >
> >> > > > >
> >> > > > > -Jeff
> >> > > > > > void main()
> >> > > > > > {
> >> > > > > >
> >> > > > > > DSK5510_AIC23_CodecHandle hCodec;
> >> > > > > > Int16 i,j,k,left,right;
> >> > > > > > Int16 input1[8000];
> >> > > > > > Int16 input2[8000];
> >> > > > > > /* Initialize the board support library, must be called first
> >> > */ DSK5510_init();
> >> > > > > >
> >> > > > > > /* Start the codec */
> >> > > > > > hCodec = DSK5510_AIC23_openCodec(0, &config);
> >> > > > > >
> >> > > > > > /* Generate a 1KHz sine wave for 5 seconds */
> >> > > > > > for (i = 0; i < 10; i++)
> >> > > > > > {
> >> > > > > > for (j = 0; j < 8000; j++)
> >> > > > > > {
> >> > > > > > /* Read a sample from left channel */
> >> > > > > > while (!DSK5510_AIC23_read16(hCodec, &left));
> >> > > > > > input1[j]=left;
> >> > > > > >
> >> > > > > > /* Read a sample from right channel */
> >> > > > > > while (!DSK5510_AIC23_read16(hCodec, &right));
> >> > > > > > input2[j]= right;
> >> > > > > > }
> >> > > > > >
> >> > > > > > }
> >> > > > > > for (i = 0; i < 10; i++)
> >> > > > > > {
> >> > > > > > for(k=0; k {
> >> > > > > > while(!DSK5510_AIC23_write16(hCodec, input1[k]));
> >> > > > > > /* Send a sample to the right channel */
> >> > > > > > while(!DSK5510_AIC23_write16(hCodec, input2[k]));
> >> > > > > > }
> >> > > > > > }
> >> > > > > > /* Close the codec */
> >> > > > > > DSK5510_AIC23_closeCodec(hCodec);
> >> > > > > > }
> >> > > > > >
> >> > > > > > But it is not giving any output. What to do?
> >> > > > > > kindly help me where i am going wrong. I will be waiting for ur
> >> > > reply
> >> > > > > >
> >> > > > > > regards,
> >> > > > > > Umer
> >> > > > > > >
> >> > > > > > > hello everybody
> >> > > > > > > i m an student doing project "Real time
> >> > > > > > > implementation of G.723.1 on TMS320VC5510"
> >> > > > > > > right now i am ready with optimised code which is
> >> > > > > > > running in CCS simulator by taking i/p from file and putting
> >> > o/p in2 file
> >> > > > > > > but now my next step is to run it in to DSK board for that i
> >> > have to take i/p from mike and taken o/p from headphone
> >> > > > > > > and for that i have to interface adc/dac of that
> >> > > > > > > particular board which uses AIC23 as a codec.
> >> > > > > > > i tried 2 get some idea from audio project available in TI
> >> > but not getting the flow as i don't aquant with DSP-BIOS
> >> > also
> >> > > > > > > please any1 sugest me how to proceed or else can
> >> > > > > > > anybody send me programme to interface codec withought using
> >> > DSP-BIOS
> >> > > > > > >
> >> > > > > > > sorry for long mail
> >> > > > > > > waiting for early reply as i have to submit my project bbye
> >> > > > > > > Alpana
> >> > > > > > > M.E.(GCOEP)
> >> > > > > > > Pune
> >> > >
> >> >