March 2007 Real-time binaural sound generation Using TI C6713 DSK board

REAL-TIME BINAURAL SOUND GENERATION USING TI C6713 DSK BOARD

A Thesis

Submitted

To

Electrical Engineering Department

University of Bridgeport, CT, USA

Submitted

By

Vaibhav Bhatnagar

Student ID : 0695161

Academic Advisor

Prof. Navarun Gupta

Table of contents

Title Page

  1. Abstract 3
  2. Introduction 3
  3. Introduction to DSK board 3
  4. Methodology 4
  5. Results 8
  6. Conclusion 8
  7. References 8
  8. Authors biography 8

ABSTRACT

Traditionally 3D sound generation involves the use of multiple speakers that are
strategically placed, and have appropriate lags in the sounds emanating from them. Using Head Related Transfer Functions (HRTFs), a realistic binaural sounds can be generated using a pair of headphones.

This work describes that how a single channel audio can be transformed into binaural (left / right channels) using HRTFs. The implementation has been performed on a C6713 DSK Texas Instrumentation (TI) kit.

Current sound specialization systems use HRTFs, represented by the corresponding impulse response sequences, the Head-Related Impulse Responses (HRIRs). By convolution, a single-channel digital audio signal can be converted in two components (left and right). Whenever, the two channels are delivered to the listener through headphones, the sound seems to emanate from the source location corresponding to the HRIR pair used for the specialization process.

Digital signal processors have become ubiquitous because of their versatility, and low cost. TI C713 is ideally suited for binaural sound synthesis from HRTFs because its high-performance, advanced very-long-instruction-word (VLIW) architecture makes this DSP an excellent choice for multi-channel and multifunction applications. This work associates a real-time demonstration.

INTRODUCTION

In recent years, an interest of binaural sound has increased significantly. There is much work has been found in literature for capturing HRTF coefficients around a humane body that are useful to realize it in practice. The DSP lab of Florida International University facilitates a database contains HRTF and relevant anthropometric data of 15 subjects. The data may be useful in studying or implementing 3D sound specialization / localization and their relation to the geometric features of the head and outer ear of the subjects.

A binaural sound is the sound or speech that give a 3-D effect to the ears of a listener. Moreover, a sound generation A user can feel the movements in any directions around his head.

During this work, we use a single channel HRTF coefficients from DSP lab FIU, which are useful for implementation of an stereo FIR filter on DSK board in order to generate real-time binaural sound. Before going in to detail, an introduction to the hardware is necessary.

INTRODUCTION TO DSK C6713 TI BOARD

Digital Signal Processors such as the TMS320(C6x) family of processors that are similar to fast special-purpose microprocessors with a special type of architecture and an instruction set appropriate for a signal processing in real time [1]. The TMS320DSK6713 DSK starter kit plays a great role here. This starter kit is a critical invention of Texas Instruments. The essential properties of DSK6713 starter kit that make it useful for real-time are:

  • DSK board is powerful and inexpensive ($395.
  • C6713 is a floating-point digital signal processor
  • Onboard codec TLV320AIC23 (AIC23) serves for analog to digital converter (ADC) and digital to analog converter (DAC) conversion.
  • 12-MHz system clock.
  • Supports a sampling rate from 8 to 96 KHz.
  • Two 80-pin connectors provide an external peripheral and external memory interface (IMIF) with light-emitting diodes (LEDs) and liquid-crystal displays (LCDs) for spectrum display.
  • 16 MB (megabytes) of synchronous dynamic random access memory (SDRAM) and 256kB (kilobytes) of flash memory.
  • Input/outputs : MIC IN for microphone input, LINE IN for line input, LINE OUT for line output, and HEADPHONE for a headphone output (multiplexed with line output).
  • Four users dip switches on the DSK board for a feedback control interface.
  • Code composer studio (CCS) is a software interface that can include Matlab also.

The DSK hardware is used for stereo FIR implementation, whereas the FIR has designed with the one channel HRTFs in Matlab.

Rest of the paper is organized as: METHODOLOGY describes method used to obtain the results, in RESULTS the hardware outcome has been discussed, CONCLUSION concludes the end of the paper, and REFERENCES give some important papers, taken in to account.

METHODOLOGY

Brown and Duda in [3] proposed an “structural” model for binaural sound synthesis. A customizable functional model developed by Algazi models a listener’s head with only 3 simple anatomical measurements [4]. Like Brown and Duda there are many models available to generate binaural sound and measure HRTF. As mentioned earlier, we use HRTF coefficients provided openly by DSP lab, FIU. In addition, a simple FIR filter can be designed in C language and can lead a further implementation as a Real Time FIR Stereo Filter on a powerful DSK board.

Filtering is one of the most useful signal processing operation. Moreover, TMS320C6x instruction set [1] and architecture makes DSK well suited for such filtering operations. An analog filter operates on continuous signals and is typically realized with discrete components such as operational amplifiers, resistors, and capacitors. However, a digital filter, such as an FIR filter, operates on discrete-time signals and can be implemented with a DSP chip such as the TMS320C6x. This involves use of an ADC to capture an external input signal, process the input samples, and send the output through a DAC. A number of tools are available to design an FIR filter that can be further implemented on hardware. The filter design consists of an approximation of a transfer function with a resulting set of coefficients. Here we use the HRTF coefficients that have taken from FIU (Florida Institute of Technology) available for all directions on a humane head [1].

The convolution of FIR filters can be approximated with a finite number of terms by equation 1.

y (n) = (1)

If the input is a unit impulse x (n) = δ (0), the output impulse response will be y (n) = h (k). If the filter has N coefficients h (0), h (1) …h (N-1), and N input samples x (n), x (n-1)… x (n-(N-1)). Equation (1) shows that an FIR filter can be implemented with knowledge of the input x (n) at time n and of the delayed inputs x (n-k). It is a non-recursive, no feedback, and non-causal filter. Filters with feedback are transversal and tapped-delay filters. Moreover, the Z-transform of equation (1) with zero initial conditions yields

Y (z) = h(0)X(z)+h(1)z-1X(z)+h(2)z-2X(z)+ …+h(N-1)z-(N-1)X(z) (2)

Equation (1) represents a convolution in time domain between the coefficients and the input samples, whereas equation 2 is equivalent to a multiplication in the frequency domain.

Y (z) = H (z) X (z),(3)

where H (z) = ZT [h (k)] is the transfer function, which indicates N -1 poles located at the origin. Hence this FIR filter is inherently stable, with its poles located inside the unit circle. We usually describe an FIR filter as a filter with “no poles”. A very useful feature of an FIR filter is that it can guarantee a linear phase. In speech analysis linear phase feature can avoid the critical phase distortion because due to linear phase, all input sinusoidal components are delayed by the same amount. Otherwise, harmonic distortion can occur. Linear Phase filters are FIR filters; but, not all FIR filters have linear phase.

By using FIR filter we can implement a real time stereo filter. In this project, 24 HRIR as coefficients are used for FIR filter implementation; 12 sound directions and 24 HRIR for both right and left ear. Size of each coefficient file is 256. To generate binaural sound we are using 12 directions.

To understand the all directions we need to understand an spherical co-ordinate system that has two parts (Fig. 1):

1) Azimuth

2) Elevation

Figure 1.

For example, we can consider and HRIR having azimuth +300 and elevation 540. Figure 2 shows the HRIR in time domain and Figure 3 shows the HRTF in frequency domain for the same.

Here with the following C program we can understand what exactly FIR filter doing.

Figure 2.

Figure 2.

//Fir.c FIR filter. Include coefficient file with length N

#include "bs2700.cof" //coefficient file

#include "dsk6713_aic23.h"//codec-dsk support file

Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;//set sampling rate

int yn = 0; //initialize filter's output

short dly[N]; //delay samples

interrupt void c_int11() //ISR

{

short i;

Figure 3.

dly[0]=input_sample(); //input newest sample

yn = 0; //initialize filter's output

for (i = 0; i< N; i++)

yn += (h[i] * dly[i]); //y(n) += h(i)* x(n-i)

for (i = N-1; i > 0; i--) //starting @ end of buffer

dly[i] = dly[i-1]; //update delays with data move

output_sample(yn > 15); //scale output filter sample

return;

}

void main()

{

comm_intr(); //init DSK, codec, McBSP

while(1); //infinite loop

}

A buffer dly [N] is created for the delay samples. The newest input sample, x (n), is acquired through dly [0] and stored at the beginning of the buffer. The coefficients are stored in another buffer, h [N], with h [0] at the beginning of the coefficients’ buffer. The samples and coefficients are then arranged in their respective buffer.

Two for loops are used within the interrupt service routing (we will also implement an FIR filter using one loop). The first loop implements the convolution equation with N coefficients and N delay samples for a specific time n. At time n the output is

y(n) = h(0)x(n) + h(1)x(n-1) + … + h(N-1)x(n-(N-1)) (4)

The delay samples are then updated within the second loop to be used for calculating y (n) at time n+1, or y (n+1). The newly acquired input sample always resides at the beginning of the samples buffer (in this example). The memory location that contained the sample x (n) now contains the newly acquired sample x (n + 1). The output y (n + 1) at time n+1 is then calculated. This scheme uses a data move to update the delayed samples.

In the final program we use 2 dimensional filter coefficients files. The looping is same as above but result generates the binaural sound with the help of 24 HRIR files of 12 directions.

RESULTS

There are no physical results to show. Anybody can feel the generated sound by using the single pair of headphones. Normally, the sound moves around the head. This effect shows that sound is binaural. In practical life to generate the binaural sound we need to place lot of sound sources around the listener so that he can feel the mono sound in a binaural fashionnonetheless with the help of HRIR files we could perform it in a real-time. According to our personnel experience with the result, this is effective way of producing 3-D sound. And the best effect we realize in the azimuth +900 to -900 mainly back of head.

CONCLUSION

With the help of available HRTF coefficients, an stereo FIR filter has been designed, implemented, and validated on a DSK C6713 TI board. However, the sound quality is not clear but a person can still realize a sound motion. A clear sound can be achieved by replacing HRTF coefficients with HRIR coefficients. Moreover, we need to optimize the program for higher sampling rate and more directions that should be included to attain a perfect 3-D sound.

REFERENCES

[1] Digital Signal Processing and Applications with the C6713 and C6416 DSK, Rulph Chassaing, Wiley Interscience (2005). ISBN 0-471-69007-4.

[2] “Decomposition of Head Related Impulse Responses by Selection of Conjugate Pole Pairs, Kenneth John Faller II1, Armando Barreto1, Navarun Gupta2 and Naphatali Rishe3.

[3] C. P. Brown and R. O. Duda, “A structural model for binaural sound sysnthesis, “Ieee Transactions on speech and Audio Processing, vol. 6, pp. 476-448, 1998.

[4] V.R. Algazi, C. Avendano, and R.O. Duda, “Estimation of a spherical-head model from anthropometry,” Journal of the Audio Engineering Society, vol. 49, pp. 472-479, 2001.

AUTHOR(S) BIOGRAPHY

Vaibhav Bhatnagar is Graduate Assistant in Electrical Engineering at the University of Bridgeport, Bridgeport, CT. He did his undergraduate in Electronics and Communications at the UttarPradeshTechnicalUniversity, Lucknow in 2004. He is pursuing his Masters of Science, Electrical Engineering at the University of Bridgeport, CT. He graduates in May 2007.

1

Master Thesis Vaibhav Bhatnagar 0695161