Wednesday, 3 June 2015

Audio effects.



Abstract.

In this report we are going to emphasis explain what we experienced and tested in the last practical lecture in the lab, where we tried to simulate the block diagrams of both the echo block and multi-echo reverberation system. That is done in order to see the effect of delay on the quality of the input signal taking in to consideration the period of delay in a certain input signal and the amplitude of the attenuation. We used the subjective test (hearing the audio or speech signal by our ears and then decided the quality or what is called in speech processing signal the mean opinion square) to evaluate the quality of the processed signal. In natural environments, sounds we perceive depend on the listening conditions and in particular on the acoustic environment. The same sound signal played in a concert hall; bathroom or a small room will not be “perceived” the same. Since these effects are important for musicians, the digital technology can be used to simulate them.

Objectives.

This experiment aims to many targets and goals among them:
1-to make students able to deal with different types of audio effects such as reverb, chorus, flanging.in addition to delay effect which is the most important one of all.
2- to understand the blocks diagrams and the difference equations which make them of delay, echo, reverberation.
3- togive the students the experience and  the ability to test the output voice or speech using the subjective or perceptual tests.

Equipment and tools:

·        A computer hasing code composal studio and Matlab.
·        A 6713dsk toolkit.
·        A picoscope.
·        Output speaker.
·        Input mice.

Introduction.

1.1       Delay

Delay is the simplest audio effect which holds input signal and then plays it back after a period of time. Delay is used very often by musicians. It is also the main block for other audio effects such as reverb, chorus, and flanging.
The difference equation for the delay operation is  where  is the delay amount. Since the difference equation between the output and the input is specified, it can be directly coded in C language. To implement the delay operation, the best way is defining an array which stores input audio signals. In Figure 1, we demonstrate the delay operation using  length array which should be defined beforehand. To feed the delayed audio signal to output, first we should store the audio signal on the first entry of the array. At each operation cycle, each entry in the array should be shifted towards right, to open space to the new input. This way, an input which is taken at time  will reach to the end of the array  cycles later.
   
Figure 1block diagram illustrating delay.

1.1       Echo

The echo block simply takes an audio signal and plays it after summing with a delayed version of the same signal. The delay time can range from several milliseconds to several seconds. 
     
Figure 2 echo block diagram
The difference equation which describes the echo system is ; where  is the delay mix parameter,  is the delay amount.
In order to generate the echo effect, both the present and the delayed signal are needed. In order to access to the delayed signal, we should store the input audio signal in an array to generate the delayed version of the signal as explained in the previous sub-section. Using this array, generate the echo as illustrated by the echo equation.

1.1       Reverberation

Reverberation is also one of the most heavily used effects in music. The effects of combining an original signal with a very short (<20ms) time-delayed version of itself results is reverberation. In fact, when a signal is delayed for a very short time and then added to the original, the ear perceives a fused sound rather than two separate sounds. If a number of very short delays (that are fed back) are mixed together, a crude form of reverberation can be achieved. The block diagram of a basic reverberation system is given in Figure below.
     
Figure 3The block diagram of a multi-echo reverberation system
The difference equation for this systemis . The value of normally falls between 0 and 1.

1          Experiment procedure(Discussion and results)

In this experiment echo generation and cancelation will be demonstrated by the procedure explained in the next subsections. Reverberation will be considered in section 2.2.

1.1       Echo generation


1     In this part of the experiment you are going to generate an echo signal by reading an audio samples form the LINE IN terminal then delay and process these signals according to the echo equation. Your code may appear as shown below
#include "dsk6713_aic23.h" //codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
short input, output;
short bufferlength = 3000; //buffer size for delay
short buffer[3000]; //create buffer
short i = 0;
short amplitude = 5; //to vary amplitude of echo
interrupt void c_int11() //ISR
{
input = input_sample(); //newest input sample data
output=input + 0.1*amplitude*buffer[i];//newest + oldest samples
output_sample(output); //output sample
buffer[i] = input; //store newest input sample
i++; //increment buffer count
if (i >= bufferlength) i = 0; //if end of buffer reinit
}
main()
{
comm_intr(); //init DSK, codec, McBSP
while(1); //infinite loop
}

1.     Vary the buffer size from 3000 to 8000 and listen to the played recorded wave. What effect do you observe on heared signal?
Answer (1)-   the period of echo is longer for the largest and biggest buffer size so the echo sound is longer for buffer size which contains 8000 samples.
2.     In your code change the statement buffer[i]=input into buffer[i]=output and listen to the recorded signal. What effect to the signal happens here?
Answer (2)- When we made the mentioned changed in the lab we noticed attenuation happened to the signal so the signal is distorted and the output may be equal zero if the two signals (input and delayed signal) are out of phase. This phenomenon is called fading to the signal. 
3.     Try to implement multi echo by using different buffers with differentbuffer lengths and modify your code as shown below
* File Name :   echogeneration.c

* Target    :   TMS320C6713

* Version   :   3.1

* Description : This Program tells about the Echo generation.
  Input is taken from Mic-in using Mic, n output can be analysed
by using headphone.
**********************************************************************************************/

#include"dsk6713_aic23.h"                        //this file is added to initialize the DSK6713
Uint32 fs = DSK6713_AIC23_FREQ_8KHZ;     // set sampling frequency

short input,output;                                                        // variable initialization
short bufferlength = 4000;                                   // buffer initialization of different length for storage of input analog-signal
short buffer[4000];
short bufferlength1 = 8000;
short buffer1[8000];
short bufferlength2 = 12000;
short buffer2[12000];
short bufferlength3 = 16000;
short buffer3[16000];
short i = 0,j = 0,k = 0,l=0;
short amplitude =1;

interrupt void c_int11()                              // ISR call, At each Interrupt, program execution goes to the interrupt service routine
{
          input = input_sample();                              // input from Mic
          output =input + 0.4*amplitude*buffer[i]+0.3*amplitude*buffer1[j]+ 0.2*amplitude*buffer2[k]+ 0.1*amplitude*buffer3[l];
          output_sample(output);                             // // the value in the buffer sine_table indexed by the variable loop is written on to the codec.
          buffer[i]  = input;
          buffer1[j] = buffer[i];
          buffer2[k] = buffer1[j];
          buffer3[l] = buffer2[k];
          i++;
          j++;
          k++;
          l++;
          if(i >= bufferlength)  i = 0;
          if(j >= bufferlength1) j = 0;
          if(k >= bufferlength2) k = 0;
          if(l >= bufferlength3) l = 0;
}

main()                                               // main routin call
{
          comm_intr();                  // ISR function is called, using the given command
          while(1);                         // program execution halts and it starts listening for the interrupt which occur at every sampling period Ts.
}
Small conclusion:
We noticed different phases and periods of delay this due to using consecutive multi-buffer, it was obvious the clearest one of them (delays) is the one that has largest value of alpha(delay mix parameter). This is proved by changing buffer size and alpha value.  

1.2       Echo with Control for Different Effects

In this part of the experiment you are to generate an echo signal and control the echo parameters using three sliders.
1.     If the echo_type is set by the slider to  1 then fading is selected otherwise normal echo is used
2.     The delay of the echo also can be made variable by using a delay parameter called delay. The delay parameter either increase or decrease the length of the buffer from 1000 to 8000 in steps of 1000
3.     The amplitude parameter  of the delayed version of the input also can be made variable, therefore generating different effects on the echo signal
4.     Type the program shown below and the subsequent gel files to accomplish this task
//Echo_control.cEcho effects with fading
//3 sliders to control effects: buffer size, amplitude, fading
#include "DSK6713_AIC23.h" //codec-DSK file support
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
short input, output;
short buffer[8000]; //max size of buffer
short bufferlength = 1000; //initial buffer size
short i = 0; //buffer index
short delay = 3; //determines size of buffer
short delay_flag = 1; //flag if buffer size changes
short amplitude = 5; //amplitude control by slider
short echo_type = 1; //1 for fading(0 with no fading)
main()
{
short new_count; //count for new buffer
comm_poll(); //init DSK, codec, McBSP
while(1) //infinite loop
{
output=input+0.1*amplitude*buffer[i];//newest + oldest samples
if (echo_type == 1) //if fading is desired
{
new_count = (i-1) % bufferlength; //previous buffer location
buffer[new_count] = output; //to store most recent output
}
output_sample(output); //output delayed sample
input = input_sample(); //newest input sample data
if (delay_flag != delay) //if delay has changed
{ //new buffer size
delay_flag = delay; //reint for future change
bufferlength = 1000*delay; //new buffer length
i = 0; //reinit buffer count
}
buffer[i] = input; //store input sample
i++; //increment buffer index
if (i == bufferlength) i=0; //if @ end of buffer reinit
}
}
Small conclusion:
We noticed that the output speech or audio can be changed by changing one or more of the most important parameters that control the features and characteristics of signal such as delay period which is determined by buffer size value, amplitude of echo and output signal which is determined by alpha which can be called as delay mix parameter and echo type whether it is with fading or normal without fading.

The slider files may appear as shown below
//Echo_control.gelSliders vary time delay,amplitude,and type of echo
menuitem "Echo with Fading"
slider Amplitude(1,8,1,1,amplitude_parameter) /*incr by 1, up to 8*/
{
amplitude = amplitude_parameter; /*vary amplit of echo*/
}
slider Delay(1,8,1,1,delay_parameter) /*incr by 1, up to 8*/
{
delay = delay_parameter; /*vary buffer size*/
}
slider Type(0,1,1,1,echo_typeparameter) /*incr by 1, up to 1*/
{
echo_type = echo_typeparameter; /*echo type for fading*/
}

1.3       Reverberation generation

As mentioned at the beginning of this experiment, reverberation is a kind of echo with delay time less than 20 ms. Reverberation can be implemented by using the following piece of code
#include "dsk6713_aic23.h" //codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
short input, output;
short bufferlength = 1600; //buffer size for delay
short in_buffer[1600]; //create buffer
short i = 0;
short amplitude = 5; //to vary amplitude of e/cho
interrupt void c_int11() //ISR
{
input = input_sample(); //newest input sample data
output=input + 0.20*amplitude*in_buffer[i] + 0.04 * in_buffer[i] + 0.00016* in_buffer[i];//newest + oldest samples

if (out_type==1)
output_sample(input);
else
output_sample(output);
 //output sample
in_buffer[i] = input; //store newest input sample
i++; //increment buffer count
if (i >= bufferlength) i = 0; //if end of buffer reinit
}
main()
{
comm_intr(); //init DSK, codec, McBSP
while(1); //infinite loop
}
1.     Run the program and feed an input signal to LINE IN
2.     Listen to the signal at the output of the DSK6713 kit
3.     Is there any difference between the signal generated in this part of the experiment and the echo generated in the previous step?
Answer – the signal generated in this part (reverberation) is clearer, nicer, and purer than the previous one, therefore, reverberation improves the quality of the signal because of suitable delay echo (less than 20 ms) which is matched with hearing and perceiving of human ear.
Conclusion:
We added a brief conclusion after ending each part of this experiment. Anyhow we can summarize them as following:
1-reverbiration means delay with less than 20ms, improves the quality of signal.
2- the period of echo is longer for the largest and biggest buffer size
3-signal is distorted and the output may be equal zero if the two signals (input and delayed signal)              are out of phase. This phenomenon is called fading to the signal.
4- We noticed different phases and periods of delay this due to using consecutive multi-buffer, it was obvious the clearest one of them (delays) is the one that has largest value of alpha(delay mix parameter). This is proved by changing buffer size and alpha value.
Finally, we was able to deal and understand the main and common effects of audio and speech signal.
 

 

No comments: