LabVIEW Embedded

Showing results for 
Search instead for 
Did you mean: 

Blackfin mu-law compression and expansion

Blackfin mu-law compression and expansion

Hi All,

I hope you can help, I did look through the forum and haven't found an answer to my question. What I'm trying to do is use the mu-law compression and expansion VI's provided with LabVIEW Embedded on the Blackfin BF533. Currently I have the Audio talkthrough working properly and also UART write on the same VI. I would like to mu-law compress the audio data and write it to UART, then on another board read from UART and use mu-law expand to play the Audio Data. I'm having trouble understanding the mu-law compression and expansion VI's. If anyone can provide me with either an example VI for the mu-law compression or expansion on the Blackfin that would be great. The 'output' and 'output_out' are confusing me. I'm not entirely sure what to input into 'output' and length. I've used the mu-law functions provided from Analog Devices in Visual DSP++ in 'C' and they are working. Please let me know if anyone can point me in the right direction.

Thank you,

0 Kudos
Message 1 of 8

Re: Blackfin mu-law compression and expansion

Hi Sean,

Try using the A-law Companding example as a foundation for making a Mu-law Companding example.  In NI Example Finder, go to Toolkits and Modules»Blackfin»Analysis Library»Companding.lvproj.

The input named output needs to be an initialized array that is the same size as the input.  The reason why there in an input named output and an output named output_out is because of the way the VDSP++ function is designed and how LabVIEW allocates memory.  If you view the Mu-law compression VI, you'll notice that it calls a DLL, and that the output array is an input to a pointer.  So the input named output's memory will be used by the DLL as memory for output_out.

So the name comes from the fact that the input array output is the same memory used for output_out.

It is absolutely critical that you initialize an array because otherwise you're pointing to a byte in memory that the DLL will then write to bytes after it, which could be used by another by another Blackfin process.

Trey B | Applications Engineering | National Instruments

Message Edited by Trey B on 04-16-2008 01:23 PM
0 Kudos
Message 2 of 8

Re: Blackfin mu-law compression and expansion

Hi Trey,

Excellent, thank you! I have mu_law working properly on one board right now. First I take the audio data into the Blackfin, then mu_law compress it then mu_law expand and send to the output for both right and left channels. Thanks again for your help this is working very nicely.

On the same board I have a string being sent out of UART. From the BF533 EZ Kit I have a bluetooth modem connected to the RX and TX lines and I'm wirelessly transmitting the string back to my laptop (bluetooth device). This is working properly. However, what I really want to do is take the 8 bit data after the mu_law compression and transmit that out of UART. I attempted to use the 'byte array to string' VI to send the output to UART however, the Blackfin tends to halt with this conversion. I then tried going through a For loop with auto indexing from the mu_law compression and write each value to UART. This also didn't work as expected. I'm not sure if I'm having a timing issue with the clock and baud rate or if my conversion methods are wrong. I have the UART transmission set to 115200 bps and I'm taking in 512 samples for the Audio. Does anyone have any ideas on some steps to take in correcting this? I can provide a screenshot of my current VI if that would be helpful.

Thank you!

0 Kudos
Message 3 of 8

Re: Blackfin mu-law compression and expansion

:manvery-happy:Hi every one!
I have a ADSP BF537 EZ kit lite and i would control RF receiver by UART 0. when i program for PC to driver it,  everything is OK. and i have checked TX and RX pulse at pin 2 and pin3 of DB9 connector, these pulses were smooth.
 But when i try driving by ADSP BF537 EZ kit lite using UART 0 with labview embedded for blackfin by using BF UART open VI and BF UART control VI anf BF UART write VI for on/off power only( just send H101) but nothing happened!.
 I have checked TX pin, it has output pulse but these pulse are very distort .
Anybody can help me to solve this problem
thank you very much !:womansad:Smiley Very Happy
0 Kudos
Message 4 of 8

Re: Blackfin mu-law compression and expansion

Hi Seoul,

The UART device has to be enabled after it's opened and configured. There is a VI called "BF Device Enable" in the Blackfin Devices Palette. Use that to enable the device after you use BF UART Open and BF UART Control and before you read/write. Let me know if that helps.

On a side note, in future it would be great if you could create a new forum post for a new topic (like this) and not post in multiple places 1, 2 . This way it would easier to address your specific question and won't get lost in other posts. Thank you.

Message Edited by Nitin T on 05-20-2008 02:41 PM

Message Edited by Nitin T on 05-20-2008 02:43 PM
0 Kudos
Message 5 of 8

Re: Blackfin mu-law compression and expansion


Hi, how are you? You think you could possibly look at my previous thread and let me know if you have any suggestions? I have UART communications working properly between two boards and I also have wireless communications working with the bluetooth devices if I send characters across. I believe my problem is coming from trying to take the output of mu_law compression and sending it to the tx_buffer. I have tried multiple different things to get each 8 bit unsigned character from the output array. In C what I did to send mu_law  compressed data through UART is:

 //buffers for the data that will be compressed
 short mu_buffer[2] = {0,0};
 short tx_exp[2] = {0,0};   
 //storing the data in the buffers
 tx_exp[0] = (short)(iChannel0LeftIn>>8);
 tx_exp[0] /= 4;
 tx_exp[1] = (short)(iChannel0RightIn>>8);
 tx_exp[1] /= 4;
 //mu law compression functions sends the 8 bit data to the transfer buffer
 mu_compress(tx_exp, mu_buffer, 2);
 tx_buffer[0] = (char)mu_buffer[0];
 tx_buffer[1] = (char)mu_buffer[1];

I do have up to the mu_law working in LabVIEW. I can compress, and expand on the same board and still play my audio normally. I want to make the compression happen on one board, then send it over UART to another board and the other board will expand the audio and play it back. I have this working entirely in C, and I really want to get it working in LabVIEW. Then I will attempt the bluetooth after.

Thank you for any suggestions!


0 Kudos
Message 6 of 8

Re: Blackfin mu-law compression and expansion

Hi Nitin T
    I already added BE device enable as your guide, but same result. I would talk you that I have checked pulse in TX and RX pin, those pins have pulse. And right now they are not distort because last time i connected TX( Instrument) to TX( Blackfin board) and RX( Instrument) to RX( Blackfin board) then i changed TX( Instrument) to RX( Blackfin board) and RX( Instrument) to TX( Blackfin board).
   I just want to send H101(string) to open the intrument but still not sucessfully. would you have some more sugguestion to solve my problem?
 here is my code:
and please let me know how to make new post ( sorry because i am new membership)
Thank in advanced
Do Van Lam
0 Kudos
Message 7 of 8

Re: Blackfin mu-law compression and expansion

Hello!I've seen that you said that you managed to make communication via UART work properly betwwen two board.

I am working on a project that involves this step: i am recording a sound and transmitt it to the first blackfin( where i have the compression part of MELP alghoritm) , compress the sound here, and then i have to transmitt via UART the signal compressed to the second blackfin , where i have the decompression part of the MELP algorithm and then share the result obtained from the second blackfin to my headphones.

I have to compare the signal entering the first blackfin, with the result of the decompression returned by the second blackfin.

Unfortunately, I wasn't able to make my communication via UART between the two blackfins work.

I was wondering if you could ,please , send me the code where you did this to take a look.

0 Kudos
Message 8 of 8