## Saturday, November 30, 2013

### DSP in MATLAB®: Echo and Reverberation Part 2

We observed in the last post how the delays can be set according to the amount of reverberation required. But, what if you wish to alter the characteristics? That would be a tedious job, you cannot go into the software every time to program the delays (totally impractical).

So, lets take a look at the Convolution reverberation algorithm, whose use is widespread in the audio industry.

#### Method 2: The Convolution Reverb

The convolution reverb is a modification of the concept of transfer functions in control system theory.

To take a glance on the same,
A Transfer Function is the ratio of the output of a system to the input of a system, in the Laplace domain considering its initial conditions and equilibrium point to be zero. If we have an input function of X(s), and an output function Y(s), we define the transfer function H(s) to be:

Readers who have read the Circuit Theory book will recognize the transfer function as being the impedance, admittance, impedance ratio of a voltage divider or the admittance ratio of a current divider.

So, now we will consider that our theater, which we were discussing last time, is H(s) (obviously it's larger than the box above ;) ). Now, out input will be sound signal, let's say music played on loudspeaker, and the output is the sound with the reverberation.
Essentially, to duplicate this effect, we can find out the transfer function. How? By using impulse response, i.e. output when the input is an impulse function.
The Impulse Function, denoted with δ(t) is a special function defined piece-wise as follows:

$\delta(t) = \left\{ \begin{matrix} 0, & t < 0 \\ \mbox{undefined}, & t = 0 \\ 0, & t > 0 \end{matrix}\right.$
The impulse function is also known as the delta function because it's denoted with the Greek lower-case letter δ. The delta function is typically graphed as an arrow towards infinity, as shown below:

Thus, it is similar to unit identity among transfer functions. Thus, when an impulse is provided, the output is the system transfer function.

You need not find out the impulse response yourself, the files are available at

and you may use them for your experimentation.

Now, according to the equation of transfer function, after obtaining this impulse response, we will convolve it with the input. Thus, we will get the output which will sound as if the recording was done in the place whose impulse response we used for processing.

So, if you convolve your opera music with the response of the theater, you can enjoy the same at your convenience, no theater and no tickets!

The MATLAB code is discussed here for the same, which mainly depends on the conv function. The important conclusion drawn from above is that frequency domain multiplication is time domain convolution. Thus, we use convolution here.

 d=wavread('cathIR.wav'); %impulse response file, this one is of a cathedral
d=d(:,1); % select any one sound channel, here I chose left
g=g(:,1); % because conv function does not apply to matrix, only vectors
sound(d,44100); %play file to check
sound(g,44100); %the sampling frequency depends on the file you chose, take care both %should be same or the output will not be accurate due to under or over sampling
y=conv(d,g); % you may write conv(g,d) as it is a commutative function
sound(y,44100); % play output file
wavwrite('output.wav',44100); %save output file to your current directory  

Thus, you finally get what you want, the theater effect, or an discotheque effect on your music devices. Generally, Digital Signal Controllers (DSC) are used which perform this process in real time. Also, the impulse responses are stored in the memory, or implemented using gates on an FPGA.

### DSP in MATLAB®: Echo and Reverberation Part 1

Digital Signal Processing (DSP) is an interesting discipline as far as applications are concerned. This is one of the disciplines that came into academics from industry, not vice versa.

I'll discuss about the most common application of digital audio signal processing in the audio domain, i.e. echo generation. This is implemented to give a pleasant sound effect to a very dry sound, e.g. at home, listening to an orchestra would be boring (unless you have a big home!). But, a visit to the theater will always give a more soothing, or rather pleasant sound effect to harmonic instruments rather than at home. This is due to the architectural acoustics of the theater, which creates a calculated amount of reverberation.

We all know about sound effects used in sound card software (e.g. Realtek HD Audio Manager) or media players (e.g. VLC media player) and even sound mixing software (e.g. VirtualDJ). In this post, I will discuss the insides of reverberation used in these software on a basic level.

Please note that some software mention reverberation settings as "spatializer", because it generates a false impression of a room whose parameters are set by the user.

Note: Echo is the reflection of sound which returns after a longer period of time like shouting in the hills. Reverberation is the effect which we look for, to improve music quality ("the orchestra in the theater" stuff). Essentially, a reverberation elongates the perception of the sound. For human ear, this period is well within 1/15th of a second.

#### Method 1: Using delay blocks in Simulink

We know that whether it is an echo or a reverberation, it is essentially a damped delay of the original sound data. Using this fact, we can implement an echo or a reverberation generator using Simulink.

The block diagram can be made as shown below in Simulink using the following blocks:
• From multimedia file
• To output device
• Delay
• Gain
• Unbuffer

Though this is taken from an example from MATLAB, this design shown here is more improvised, as it provides multipath reflection simulation. Also, a switch may be provided to compare the results of the original sound and the processed sound.

The gain block provides negative feedback, and stabilizes the system from unbounded output, which will result into noise. One may also set a parameter in the "Adder" block, which prevents overflow of the output, by saturating it to a certain maximum value.

The model file link is provided here.

One should also take note about the block "From multimedia file". One can select any file from the computer for processing. This block reduces the burden of decoding any file, may it be MP3, WAV, etc., and provides data in a stream form in real time. But, audio files are mostly frame coded, i.e. number of samples are grouped in one frame. These should be unbuffered to process them in Simulink as some blocks are inconsistent with frame based simulation (e.g. To output device).

Also, considering the delay to be set, it should be calculated on the basis of the number of samples that pass through the circuit for that period. e.g. if you need a delay of 0.15 seconds, and the sample rate is 44100Hz, then you should place a delay of 44100*0.15= 6615 samples. The delays can be set to give a harmonic illusion of reflection and gain should be set for the same.

Method 2 will be discussed in my next post. See you there...

## Saturday, November 23, 2013

### C sharp for beginners

I found a C# mini course on Microsoft Faculty Conections Alfred Thompson, but the download link was provided too slow; the fast link is provided to registered faculty only.

This .zip file contains all basic topics for beginners with no knowledge of C#, as well as video lectures and a reference book.

http://ul.to/p86cuq3s

http://www.4shared.com/zip/u-ngOfEC/CSharpCourse.html

Note:- This material is the property of Alfred Thompson. I do not claim any right upon this material, but can be useful for those who want to start off with C# with good examples.

You can also refer to the C# yellow book by Robert Miles as well as C# The Basics by Vijay Mukhi

The CRC checksum is as given below for file verification after download:
Filename          : CSharpCourse.zip
MD5                : 6806faa103656a024f4f411f20971051
SHA1              : 57ef7fee54068a65027fce44022d17d40ea17141
CRC32            : 19320111
SHA-256         : 0a56c55a4fea51b71337c8ce0f9b85d3fc1d68c336f28b3785d646ec2d9fba63
SHA-512         : 3c3291deb2b14f5b3387caee1098b9ebc410d5daf6de7f28103d6241532e42f4f99dd48918cba918cc436aaa55a998b3b328bd7a3cf4ecbde8ace1505c35a81f
SHA-384         : d0140ec7c573868440cb0ba124994c244b51584ec6e99624ac3f27be3cefd39d4f5dd82cd9a3d66a239b83a4ac9556f5

## Thursday, November 21, 2013

### Making hassle-free posters in Microsoft Office Publisher

I once took part in a poster competition (for the first time though) at college. Now, a person like me would obviously not like to take up paints and stuff again, because I am tired of improving upon my drawing skills. But, creative people have their own solutions, and thus I found Microsoft Office Publisher.

Publisher is a DTP (Desktop Publishing) software included in Microsoft Office suite since 2003. It helps you to make posters, banners, cards, websites, envelopes, flyers without any complications. It is similar to making a PowerPoint presentation, just drag and drop, and organize. You are done!

So, let's take a look at the first screen.

But, before moving to posters, lets see what kind of paper sizes are available in the market. I generally prefer the A series of papers as it's easy to find them here. The measurements are given below:

Well, for your reference, I made a poster on Moon-bounce communication (click here for details), which was related to my Electronic Communication subject. Also, I used a few images from Wikipedia, which you'll notice when you read the details. The paper size was A1 in my case (pretty big).

Getting Started

After researching on your topic and finding out relevant photographs for the same, we can start with software. The GIF animation is self explanatory, and the tools indicated are similar to PowerPoint.

Now, let me show you my poster :) This is an original size poster here.

This is the original poster that I presented, for which I got the 2nd prize with the friends (Vivek, Darshan and Rathang) who are listed here in the poster.

### You can find the printer-friendly image of the above poster at:

Please not that prints should be taken from a reliable banner printing firm, so as not to spoil the final appearance of the poster. You can use flex banner prints if the print result is satisfactory and the poster needs to be used for outdoor purposes.

You can see that:
• The two antennas are taken from Wikipedia.
• The wave path is shown by writing too many ")" in a single text box and rotating it.
• using a black background to cover up for the night photograph of the Earth. The actual photo was smaller, so I used a black background to simulate space ;) That was a tweak suggested by a friend who is good at graphics.
• The yellow area is actually made using a rectangle, the 2 warning symbols and text from a Ham radio book. It was all overlapped and grouped. This would prevent the alignment to mess up if page size or the yellow area size has to be changed. E.g.: I was planning to make an A0 poster, but due to costs, it was cut down to A1, and it messed everything up. It took one day extra to align everything up. :P
NOTES:
• The images are taken from Google, and I sincerely regret to the owners of the images that I couldn't put in the credits. I hope you guys will accept my apologies!
I hope you guys will surely come out with newer pieces of art (well, it is art! :) or at least a skill if only you can do it ) with this DTP software. For a slight boost, I would like to take a look at this certificate also, which I designed for a college workshop. The paper used was A4 photo paper. Sorry for the SPECIMEN label, but this certificate needs to be void before displaying it here. Also, the certificate is void till not signed by the respective faculty.

## Saturday, November 16, 2013

### Making CAD files for packages not available in your PCB software

Many PCB software come ready with the basic PCB packages which can be used for routing. But, what if you don't find your package?! I faced the same problem when I was designing for the final year project. Let's see how can you do it easy.

Note: You can use any CAD software for making the footprint of the package(e.g. AutoCAD, I used AutoCAD Electrical 2014, though the generic AutoCAD will do). Also, you can use any software other than Proteus if it supports an "Import .DXF file"option.

Using CAD software is important because some software do not provide you with the precision (e.g. I am using Proteus ARES currently) which can lead to a PCB you wouldn't want. Furthermore, it provides you compatibility, between various design softwares, so, no need to find specific packages, just import the file.

Proteus ARES accepts DXF files for importing package footprints, so this tutorial will aim at creating a .DXF file.

Let's take the STGIPL14K60. Its an IPM released a few months ago by STMicroelectronics, but you won't find a CAD files on their website (some corporations do provide a CAD in maybe another format file e.g. Texas Instruments, if you find one just skip to the last step).

You can see that this package would be a hard nut to crack if you don't know where to find the footprint. But there's this option to your rescue! See the animation and you'll know how. But, for your information, this option can have some other name in other software, so, just try to find out yourself (troublesome eh!).

Well I prefer an animated .GIF (made using http://gifmaker.me/) so that people craving for bandwidth wont need to download a Youtube video (I understand you guys, I was the same once :-D )

APPENDIX : MAKING A DXF DRAWING IN AUTOCAD
To understand how to make that DXF in any AutoCAD suite, first remember these commands. I think these would be enough for electronic guys, you needn't be speedy or even experts. Try to use a mouse with the keyboard please! We ain't mechanical designers. Just imagine its like drawing in paint, and keep the datasheet of the package with you, that's all.

• LTSCALE - to change scale to of the whole drawing
• SCALE - to scale selected objects, needs a base point (a reference to perform the math)
• D - change dimensional styles if you need them
• LINE - self explanatory, but you have many good option in AutoCAD to draw a line, e.g. two point, point and slope (just like math equations :) ).
• POLYLINE - similar to line, but to draw a 2D line with many junctions
• CIRCLE - To draw our very own CIRCLE!!!!! But you have options here too, e.g. 2-point, 3-point, tangent, etc.
• MOVE - self explanatory, but needs a base point
• COPY - self explanatory, but needs a base point
• RECTANGLE - self explanatory, also has many methods like 2-point and length-breadth
• MEASUREGEOM - this may be not available in older AutoCAD versions, but you can measure without using DIM category of functions, because you'll have dimension clutter all over the screen (no mess strategy please).
• ARRAYCLASSIC - to create an array of one object e.g. you can draw 10 lines with same parallel distance by drawing a line and then using this command. Arrangement can be in a rectangular array or a polar array (like chairs around a table).
So, however fancy your package is, however smaller too, use CAD and bingo! You can import it for designing your PCB.

Now, complete your design, and save it as a .DXF file. I'll just put the image of the complete package, you can refer to the help from AutoCAD for further details.

You can find my .DXF files on this link

P.S. This blog does not endorse any of the companies or software mentioned above. The blog aims to ease a problem which people may face, and can be easily solved using the information provided above. AutoCAD, Texas Instruments, STMicroelectronics, are  trade names, trademarks and/or registered trademarks of the respective owners with which they are associated

Internet speed test

## Saturday, November 2, 2013

### Proteus simulation for 8051: Codes from Mazidi

8051 microcontroller is the basic controller taught in electronics and electrical engineering. And, Mazidi's is the Bible of 8051!

Below are some of my codes and simulations adapted from Mazidi to help the beginners :)

All codes are made in Keil uVision and in embedded C. This is to help the beginners who find C language uncomfortable.

Below are the link for files for Proteus ISIS and few C file examples.

Instructions:
2. Open the .DSN files in Proteus ISIS.
3. Make a new project in KEil uVision, and select either Intel 8051 or Atmel AT89C51. Now, include the C file (only one of them) in the project; compile and run.
4. In Keil, set the crystal frequency accordingly ("e.g." you should select 11.0592MHz for serial comms, else to your needs).
5. Also, the 8051's crystal frequency should be changed in the .DSN file.
6. Now, in Keil, compile the project and generate a HEX file.
7. Load this HEX file via properties of 8051 in the .DSN file by Right Click-> Edit properties.
8. Run simulation by pressing Play button in ISIS.

Hope this helps you guys a lot! These are actually my lab experiments when I was in 3rd year of BE(EC) at GCET under NHD [many thanks for his guidance :) ].